diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index ca82ba1b05..215de73ec4 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -2895,9 +2895,9 @@ Handle StoreStubCompiler::CompileStoreGlobal( Handle LoadStubCompiler::CompileLoadNonexistent( - Handle name, Handle object, Handle last, + Handle name, Handle global) { // ----------- S t a t e ------------- // -- r0 : receiver @@ -2941,44 +2941,25 @@ Handle LoadStubCompiler::CompileLoadNonexistent( } -Handle LoadStubCompiler::CompileLoadField(Handle object, - Handle holder, - PropertyIndex index, - Handle name) { - // ----------- S t a t e ------------- - // -- r0 : receiver - // -- r2 : name - // -- lr : return address - // ----------------------------------- - Label miss; - - GenerateLoadField(object, holder, r0, r3, r1, r4, index, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::FIELD, name); +Register* LoadStubCompiler::registers() { + // receiver, name, scratch1, scratch2, scratch3, scratch4. + static Register registers[] = { r0, r2, r3, r1, r4, r5 }; + return registers; } -Handle LoadStubCompiler::CompileLoadCallback( - Handle name, - Handle object, - Handle holder, - Handle callback) { - // ----------- S t a t e ------------- - // -- r0 : receiver - // -- r2 : name - // -- lr : return address - // ----------------------------------- - Label miss; - GenerateLoadCallback(object, holder, r0, r2, r3, r1, r4, r5, callback, name, - &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); +Register* KeyedLoadStubCompiler::registers() { + // receiver, name, scratch1, scratch2, scratch3, scratch4. + static Register registers[] = { r1, r0, r2, r3, r4, r5 }; + return registers; +} - // Return the generated code. - return GetCode(Code::CALLBACKS, name); + +void KeyedLoadStubCompiler::GenerateNameCheck(Handle name, + Register name_reg, + Label* miss) { + __ cmp(name_reg, Operand(name)); + __ b(ne, miss); } @@ -3020,9 +3001,9 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, Handle LoadStubCompiler::CompileLoadViaGetter( - Handle name, Handle receiver, Handle holder, + Handle name, Handle getter) { // ----------- S t a t e ------------- // -- r0 : receiver @@ -3045,48 +3026,6 @@ Handle LoadStubCompiler::CompileLoadViaGetter( } -Handle LoadStubCompiler::CompileLoadConstant(Handle object, - Handle holder, - Handle value, - Handle name) { - // ----------- S t a t e ------------- - // -- r0 : receiver - // -- r2 : name - // -- lr : return address - // ----------------------------------- - Label miss; - - GenerateLoadConstant(object, holder, r0, r3, r1, r4, value, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::CONSTANT_FUNCTION, name); -} - - -Handle LoadStubCompiler::CompileLoadInterceptor(Handle object, - Handle holder, - Handle name) { - // ----------- S t a t e ------------- - // -- r0 : receiver - // -- r2 : name - // -- lr : return address - // ----------------------------------- - Label miss; - - LookupResult lookup(isolate()); - LookupPostInterceptor(holder, name, &lookup); - GenerateLoadInterceptor(object, holder, &lookup, r0, r2, r3, r1, r4, name, - &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::INTERCEPTOR, name); -} - - Handle LoadStubCompiler::CompileLoadGlobal( Handle object, Handle holder, @@ -3129,105 +3068,6 @@ Handle LoadStubCompiler::CompileLoadGlobal( } -Handle KeyedLoadStubCompiler::CompileLoadField(Handle name, - Handle receiver, - Handle holder, - PropertyIndex index) { - // ----------- S t a t e ------------- - // -- lr : return address - // -- r0 : key - // -- r1 : receiver - // ----------------------------------- - Label miss; - - // Check the key is the cached one. - __ cmp(r0, Operand(name)); - __ b(ne, &miss); - - GenerateLoadField(receiver, holder, r1, r2, r3, r4, index, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - return GetCode(Code::FIELD, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadCallback( - Handle name, - Handle receiver, - Handle holder, - Handle callback) { - // ----------- S t a t e ------------- - // -- lr : return address - // -- r0 : key - // -- r1 : receiver - // ----------------------------------- - Label miss; - - // Check the key is the cached one. - __ cmp(r0, Operand(name)); - __ b(ne, &miss); - - GenerateLoadCallback(receiver, holder, r1, r0, r2, r3, r4, r5, callback, name, - &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - return GetCode(Code::CALLBACKS, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadConstant( - Handle name, - Handle receiver, - Handle holder, - Handle value) { - // ----------- S t a t e ------------- - // -- lr : return address - // -- r0 : key - // -- r1 : receiver - // ----------------------------------- - Label miss; - - // Check the key is the cached one. - __ cmp(r0, Operand(name)); - __ b(ne, &miss); - - GenerateLoadConstant(receiver, holder, r1, r2, r3, r4, value, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::CONSTANT_FUNCTION, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadInterceptor( - Handle receiver, - Handle holder, - Handle name) { - // ----------- S t a t e ------------- - // -- lr : return address - // -- r0 : key - // -- r1 : receiver - // ----------------------------------- - Label miss; - - // Check the key is the cached one. - __ cmp(r0, Operand(name)); - __ b(ne, &miss); - - LookupResult lookup(isolate()); - LookupPostInterceptor(holder, name, &lookup); - GenerateLoadInterceptor(receiver, holder, &lookup, r1, r0, r2, r3, r4, name, - &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - return GetCode(Code::INTERCEPTOR, name); -} - - Handle KeyedLoadStubCompiler::CompileLoadElement( Handle receiver_map) { // ----------- S t a t e ------------- diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index 89f606d598..704f8de205 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -2965,9 +2965,9 @@ Handle KeyedStoreStubCompiler::CompileStorePolymorphic( Handle LoadStubCompiler::CompileLoadNonexistent( - Handle name, Handle object, Handle last, + Handle name, Handle global) { // ----------- S t a t e ------------- // -- ecx : name @@ -3013,45 +3013,25 @@ Handle LoadStubCompiler::CompileLoadNonexistent( } -Handle LoadStubCompiler::CompileLoadField(Handle object, - Handle holder, - PropertyIndex index, - Handle name) { - // ----------- S t a t e ------------- - // -- ecx : name - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - GenerateLoadField(object, holder, edx, ebx, eax, edi, index, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::FIELD, name); +Register* LoadStubCompiler::registers() { + // receiver, name, scratch1, scratch2, scratch3, scratch4. + static Register registers[] = { edx, ecx, ebx, eax, edi, no_reg }; + return registers; } -Handle LoadStubCompiler::CompileLoadCallback( - Handle name, - Handle object, - Handle holder, - Handle callback) { - // ----------- S t a t e ------------- - // -- ecx : name - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; +Register* KeyedLoadStubCompiler::registers() { + // receiver, name, scratch1, scratch2, scratch3, scratch4. + static Register registers[] = { edx, ecx, ebx, eax, edi, no_reg }; + return registers; +} - GenerateLoadCallback(object, holder, edx, ecx, ebx, eax, edi, no_reg, - callback, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - // Return the generated code. - return GetCode(Code::CALLBACKS, name); +void KeyedLoadStubCompiler::GenerateNameCheck(Handle name, + Register name_reg, + Label* miss) { + __ cmp(name_reg, Immediate(name)); + __ j(not_equal, miss); } @@ -3093,9 +3073,9 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, Handle LoadStubCompiler::CompileLoadViaGetter( - Handle name, Handle receiver, Handle holder, + Handle name, Handle getter) { // ----------- S t a t e ------------- // -- ecx : name @@ -3118,52 +3098,6 @@ Handle LoadStubCompiler::CompileLoadViaGetter( } -Handle LoadStubCompiler::CompileLoadConstant(Handle object, - Handle holder, - Handle value, - Handle name) { - // ----------- S t a t e ------------- - // -- ecx : name - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - GenerateLoadConstant(object, holder, edx, ebx, eax, edi, value, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::CONSTANT_FUNCTION, name); -} - - -Handle LoadStubCompiler::CompileLoadInterceptor(Handle receiver, - Handle holder, - Handle name) { - // ----------- S t a t e ------------- - // -- ecx : name - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - LookupResult lookup(isolate()); - LookupPostInterceptor(holder, name, &lookup); - - // TODO(368): Compile in the whole chain: all the interceptors in - // prototypes and ultimate answer. - GenerateLoadInterceptor(receiver, holder, &lookup, edx, ecx, eax, ebx, edi, - name, &miss); - - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::INTERCEPTOR, name); -} - - Handle LoadStubCompiler::CompileLoadGlobal( Handle object, Handle holder, @@ -3212,127 +3146,6 @@ Handle LoadStubCompiler::CompileLoadGlobal( } -Handle KeyedLoadStubCompiler::CompileLoadField(Handle name, - Handle receiver, - Handle holder, - PropertyIndex index) { - // ----------- S t a t e ------------- - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_field(), 1); - - // Check that the name has not changed. - __ cmp(ecx, Immediate(name)); - __ j(not_equal, &miss); - - GenerateLoadField(receiver, holder, edx, ebx, eax, edi, index, name, &miss); - - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_field(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::FIELD, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadCallback( - Handle name, - Handle receiver, - Handle holder, - Handle callback) { - // ----------- S t a t e ------------- - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_callback(), 1); - - // Check that the name has not changed. - __ cmp(ecx, Immediate(name)); - __ j(not_equal, &miss); - - GenerateLoadCallback(receiver, holder, edx, ecx, ebx, eax, edi, no_reg, - callback, name, &miss); - - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_callback(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::CALLBACKS, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadConstant( - Handle name, - Handle receiver, - Handle holder, - Handle value) { - // ----------- S t a t e ------------- - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_constant_function(), 1); - - // Check that the name has not changed. - __ cmp(ecx, Immediate(name)); - __ j(not_equal, &miss); - - GenerateLoadConstant( - receiver, holder, edx, ebx, eax, edi, value, name, &miss); - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_constant_function(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::CONSTANT_FUNCTION, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadInterceptor( - Handle receiver, - Handle holder, - Handle name) { - // ----------- S t a t e ------------- - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- - Label miss; - - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_interceptor(), 1); - - // Check that the name has not changed. - __ cmp(ecx, Immediate(name)); - __ j(not_equal, &miss); - - LookupResult lookup(isolate()); - LookupPostInterceptor(holder, name, &lookup); - GenerateLoadInterceptor(receiver, holder, &lookup, edx, ecx, eax, ebx, edi, - name, &miss); - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_interceptor(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::INTERCEPTOR, name); -} - - Handle KeyedLoadStubCompiler::CompileLoadElement( Handle receiver_map) { // ----------- S t a t e ------------- diff --git a/src/stub-cache.cc b/src/stub-cache.cc index 16420a5db6..08ca3f6882 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -133,7 +133,7 @@ Handle StubCache::ComputeLoadNonexistent(Handle name, LoadStubCompiler compiler(isolate_); Handle code = - compiler.CompileLoadNonexistent(cache_name, receiver, current, global); + compiler.CompileLoadNonexistent(receiver, current, cache_name, global); PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *cache_name)); GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *cache_name, *code)); JSObject::UpdateMapCodeCache(receiver, cache_name, code); @@ -144,7 +144,7 @@ Handle StubCache::ComputeLoadNonexistent(Handle name, Handle StubCache::ComputeLoadField(Handle name, Handle receiver, Handle holder, - PropertyIndex field_index) { + PropertyIndex field) { InlineCacheHolderFlag cache_holder = IC::GetCodeCacheForObject(*receiver, *holder); Handle map_holder(IC::GetCodeCacheHolder(*receiver, cache_holder)); @@ -154,8 +154,7 @@ Handle StubCache::ComputeLoadField(Handle name, if (probe->IsCode()) return Handle::cast(probe); LoadStubCompiler compiler(isolate_); - Handle code = - compiler.CompileLoadField(receiver, holder, field_index, name); + Handle code = compiler.CompileLoadField(receiver, holder, name, field); PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -179,7 +178,7 @@ Handle StubCache::ComputeLoadCallback(Handle name, LoadStubCompiler compiler(isolate_); Handle code = - compiler.CompileLoadCallback(name, receiver, holder, callback); + compiler.CompileLoadCallback(receiver, holder, name, callback); PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -202,7 +201,7 @@ Handle StubCache::ComputeLoadViaGetter(Handle name, LoadStubCompiler compiler(isolate_); Handle code = - compiler.CompileLoadViaGetter(name, receiver, holder, getter); + compiler.CompileLoadViaGetter(receiver, holder, name, getter); PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -225,7 +224,7 @@ Handle StubCache::ComputeLoadConstant(Handle name, LoadStubCompiler compiler(isolate_); Handle code = - compiler.CompileLoadConstant(receiver, holder, value, name); + compiler.CompileLoadConstant(receiver, holder, name, value); PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -287,7 +286,7 @@ Handle StubCache::ComputeLoadGlobal(Handle name, Handle StubCache::ComputeKeyedLoadField(Handle name, Handle receiver, Handle holder, - PropertyIndex field_index) { + PropertyIndex field) { InlineCacheHolderFlag cache_holder = IC::GetCodeCacheForObject(*receiver, *holder); Handle map_holder(IC::GetCodeCacheHolder(*receiver, cache_holder)); @@ -298,8 +297,7 @@ Handle StubCache::ComputeKeyedLoadField(Handle name, if (probe->IsCode()) return Handle::cast(probe); KeyedLoadStubCompiler compiler(isolate_); - Handle code = - compiler.CompileLoadField(name, receiver, holder, field_index); + Handle code = compiler.CompileLoadField(receiver, holder, name, field); PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -322,7 +320,7 @@ Handle StubCache::ComputeKeyedLoadConstant(Handle name, KeyedLoadStubCompiler compiler(isolate_); Handle code = - compiler.CompileLoadConstant(name, receiver, holder, value); + compiler.CompileLoadConstant(receiver, holder, name, value); PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -367,7 +365,7 @@ Handle StubCache::ComputeKeyedLoadCallback( KeyedLoadStubCompiler compiler(isolate_); Handle code = - compiler.CompileLoadCallback(name, receiver, holder, callback); + compiler.CompileLoadCallback(receiver, holder, name, callback); PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); JSObject::UpdateMapCodeCache(map_holder, name, code); @@ -1384,8 +1382,95 @@ void StubCompiler::LookupPostInterceptor(Handle holder, } +#define __ ACCESS_MASM(masm()) + + +Handle BaseLoadStubCompiler::CompileLoadField(Handle object, + Handle holder, + Handle name, + PropertyIndex index) { + Label miss; + + GenerateNameCheck(name, this->name(), &miss); + GenerateLoadField(object, holder, receiver(), + scratch1(), scratch2(), scratch3(), + index, name, &miss); + __ bind(&miss); + GenerateLoadMiss(masm(), kind()); + + // Return the generated code. + return GetCode(Code::FIELD, name); +} + + +Handle BaseLoadStubCompiler::CompileLoadCallback( + Handle object, + Handle holder, + Handle name, + Handle callback) { + Label miss; + + GenerateNameCheck(name, this->name(), &miss); + GenerateLoadCallback(object, holder, receiver(), this->name(), + scratch1(), scratch2(), scratch3(), scratch4(), + callback, name, &miss); + __ bind(&miss); + GenerateLoadMiss(masm(), kind()); + + // Return the generated code. + return GetCode(Code::CALLBACKS, name); +} + + +Handle BaseLoadStubCompiler::CompileLoadConstant( + Handle object, + Handle holder, + Handle name, + Handle value) { + Label miss; + + GenerateNameCheck(name, this->name(), &miss); + GenerateLoadConstant(object, holder, receiver(), + scratch1(), scratch2(), scratch3(), + value, name, &miss); + __ bind(&miss); + GenerateLoadMiss(masm(), kind()); + + // Return the generated code. + return GetCode(Code::CONSTANT_FUNCTION, name); +} + + +Handle BaseLoadStubCompiler::CompileLoadInterceptor( + Handle object, + Handle holder, + Handle name) { + Label miss; + + LookupResult lookup(isolate()); + LookupPostInterceptor(holder, name, &lookup); + + GenerateNameCheck(name, this->name(), &miss); + // TODO(368): Compile in the whole chain: all the interceptors in + // prototypes and ultimate answer. + GenerateLoadInterceptor(object, holder, &lookup, receiver(), this->name(), + scratch1(), scratch2(), scratch3(), + name, &miss); + + __ bind(&miss); + GenerateLoadMiss(masm(), kind()); + + // Return the generated code. + return GetCode(Code::INTERCEPTOR, name); +} + + +#undef __ + + Handle LoadStubCompiler::GetCode(Code::StubType type, - Handle name) { + Handle name, + InlineCacheState state) { Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); Handle code = GetCodeWithFlags(flags, name); PROFILE(isolate(), CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); diff --git a/src/stub-cache.h b/src/stub-cache.h index 451af319df..3a98f544c7 100644 --- a/src/stub-cache.h +++ b/src/stub-cache.h @@ -78,36 +78,36 @@ class StubCache { // Computes the right stub matching. Inserts the result in the // cache before returning. This might compile a stub if needed. Handle ComputeLoadNonexistent(Handle name, - Handle receiver); + Handle object); Handle ComputeLoadField(Handle name, - Handle receiver, + Handle object, Handle holder, PropertyIndex field_index); Handle ComputeLoadCallback(Handle name, - Handle receiver, + Handle object, Handle holder, Handle callback); Handle ComputeLoadViaGetter(Handle name, - Handle receiver, + Handle object, Handle holder, Handle getter); Handle ComputeLoadConstant(Handle name, - Handle receiver, + Handle object, Handle holder, Handle value); Handle ComputeLoadInterceptor(Handle name, - Handle receiver, + Handle object, Handle holder); Handle ComputeLoadNormal(); Handle ComputeLoadGlobal(Handle name, - Handle receiver, + Handle object, Handle holder, Handle cell, bool is_dont_delete); @@ -115,28 +115,28 @@ class StubCache { // --- Handle ComputeKeyedLoadField(Handle name, - Handle receiver, + Handle object, Handle holder, PropertyIndex field_index); Handle ComputeKeyedLoadCallback(Handle name, - Handle receiver, + Handle object, Handle holder, Handle callback); Handle ComputeKeyedLoadConstant(Handle name, - Handle receiver, + Handle object, Handle holder, Handle value); Handle ComputeKeyedLoadInterceptor(Handle name, - Handle receiver, + Handle object, Handle holder); // --- Handle ComputeStoreField(Handle name, - Handle receiver, + Handle object, int field_index, Handle transition, StrictModeFlag strict_mode); @@ -144,30 +144,30 @@ class StubCache { Handle ComputeStoreNormal(StrictModeFlag strict_mode); Handle ComputeStoreGlobal(Handle name, - Handle receiver, + Handle object, Handle cell, StrictModeFlag strict_mode); Handle ComputeStoreCallback(Handle name, - Handle receiver, + Handle object, Handle holder, Handle callback, StrictModeFlag strict_mode); Handle ComputeStoreViaSetter(Handle name, - Handle receiver, + Handle object, Handle holder, Handle setter, StrictModeFlag strict_mode); Handle ComputeStoreInterceptor(Handle name, - Handle receiver, + Handle object, StrictModeFlag strict_mode); // --- Handle ComputeKeyedStoreField(Handle name, - Handle receiver, + Handle object, int field_index, Handle transition, StrictModeFlag strict_mode); @@ -208,7 +208,7 @@ class StubCache { Code::Kind, Code::ExtraICState extra_state, Handle name, - Handle receiver, + Handle object, Handle holder, Handle cell, Handle function); @@ -602,42 +602,69 @@ class StubCompiler BASE_EMBEDDED { }; -class LoadStubCompiler: public StubCompiler { +class BaseLoadStubCompiler: public StubCompiler { public: - explicit LoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } - - Handle CompileLoadNonexistent(Handle name, - Handle object, - Handle last, - Handle global); + BaseLoadStubCompiler(Isolate* isolate, Register* registers) + : StubCompiler(isolate), registers_(registers) { } + virtual ~BaseLoadStubCompiler() { } Handle CompileLoadField(Handle object, Handle holder, - PropertyIndex index, - Handle name); + Handle name, + PropertyIndex index); - Handle CompileLoadCallback(Handle name, - Handle object, + Handle CompileLoadCallback(Handle object, Handle holder, + Handle name, Handle callback); - static void GenerateLoadViaGetter(MacroAssembler* masm, - Handle getter); - - Handle CompileLoadViaGetter(Handle name, - Handle receiver, - Handle holder, - Handle getter); - Handle CompileLoadConstant(Handle object, Handle holder, - Handle value, - Handle name); + Handle name, + Handle value); Handle CompileLoadInterceptor(Handle object, Handle holder, Handle name); + protected: + Register receiver() { return registers_[0]; } + Register name() { return registers_[1]; } + Register scratch1() { return registers_[2]; } + Register scratch2() { return registers_[3]; } + Register scratch3() { return registers_[4]; } + Register scratch4() { return registers_[5]; } + + private: + virtual Code::Kind kind() = 0; + virtual void GenerateNameCheck(Handle name, + Register name_reg, + Label* miss) { } + virtual Handle GetCode(Code::StubType type, + Handle name, + InlineCacheState state = MONOMORPHIC) = 0; + Register* registers_; +}; + + +class LoadStubCompiler: public BaseLoadStubCompiler { + public: + explicit LoadStubCompiler(Isolate* isolate) + : BaseLoadStubCompiler(isolate, registers()) { } + + Handle CompileLoadNonexistent(Handle object, + Handle last, + Handle name, + Handle global); + + static void GenerateLoadViaGetter(MacroAssembler* masm, + Handle getter); + + Handle CompileLoadViaGetter(Handle object, + Handle holder, + Handle name, + Handle getter); + Handle CompileLoadGlobal(Handle object, Handle holder, Handle cell, @@ -645,32 +672,18 @@ class LoadStubCompiler: public StubCompiler { bool is_dont_delete); private: - Handle GetCode(Code::StubType type, Handle name); + Register* registers(); + virtual Code::Kind kind() { return Code::LOAD_IC; } + virtual Handle GetCode(Code::StubType type, + Handle name, + InlineCacheState state = MONOMORPHIC); }; -class KeyedLoadStubCompiler: public StubCompiler { +class KeyedLoadStubCompiler: public BaseLoadStubCompiler { public: - explicit KeyedLoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } - - Handle CompileLoadField(Handle name, - Handle object, - Handle holder, - PropertyIndex index); - - Handle CompileLoadCallback(Handle name, - Handle object, - Handle holder, - Handle callback); - - Handle CompileLoadConstant(Handle name, - Handle object, - Handle holder, - Handle value); - - Handle CompileLoadInterceptor(Handle object, - Handle holder, - Handle name); + explicit KeyedLoadStubCompiler(Isolate* isolate) + : BaseLoadStubCompiler(isolate, registers()) { } Handle CompileLoadElement(Handle receiver_map); @@ -682,9 +695,14 @@ class KeyedLoadStubCompiler: public StubCompiler { static void GenerateLoadDictionaryElement(MacroAssembler* masm); private: - Handle GetCode(Code::StubType type, - Handle name, - InlineCacheState state = MONOMORPHIC); + Register* registers(); + virtual Code::Kind kind() { return Code::KEYED_LOAD_IC; } + virtual Handle GetCode(Code::StubType type, + Handle name, + InlineCacheState state = MONOMORPHIC); + virtual void GenerateNameCheck(Handle name, + Register name_reg, + Label* miss); }; @@ -700,7 +718,7 @@ class StoreStubCompiler: public StubCompiler { Handle name); Handle CompileStoreCallback(Handle name, - Handle receiver, + Handle object, Handle holder, Handle callback); @@ -708,7 +726,7 @@ class StoreStubCompiler: public StubCompiler { Handle setter); Handle CompileStoreViaSetter(Handle name, - Handle receiver, + Handle object, Handle holder, Handle setter); diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 5fdc2a1a72..5ab1347ad0 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -2790,9 +2790,9 @@ Handle KeyedStoreStubCompiler::CompileStorePolymorphic( Handle LoadStubCompiler::CompileLoadNonexistent( - Handle name, Handle object, Handle last, + Handle name, Handle global) { // ----------- S t a t e ------------- // -- rax : receiver @@ -2837,44 +2837,25 @@ Handle LoadStubCompiler::CompileLoadNonexistent( } -Handle LoadStubCompiler::CompileLoadField(Handle object, - Handle holder, - PropertyIndex index, - Handle name) { - // ----------- S t a t e ------------- - // -- rax : receiver - // -- rcx : name - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - - GenerateLoadField(object, holder, rax, rbx, rdx, rdi, index, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::FIELD, name); +Register* LoadStubCompiler::registers() { + // receiver, name, scratch1, scratch2, scratch3, scratch4. + static Register registers[] = { rax, rcx, rbx, rdx, rdi, r8 }; + return registers; } -Handle LoadStubCompiler::CompileLoadCallback( - Handle name, - Handle object, - Handle holder, - Handle callback) { - // ----------- S t a t e ------------- - // -- rax : receiver - // -- rcx : name - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - GenerateLoadCallback(object, holder, rax, rcx, rdx, rbx, rdi, r8, callback, - name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); +Register* KeyedLoadStubCompiler::registers() { + // receiver, name, scratch1, scratch2, scratch3, scratch4. + static Register registers[] = { rdx, rax, rbx, rcx, rdi, r8 }; + return registers; +} - // Return the generated code. - return GetCode(Code::CALLBACKS, name); + +void KeyedLoadStubCompiler::GenerateNameCheck(Handle name, + Register name_reg, + Label* miss) { + __ Cmp(name_reg, name); + __ j(not_equal, miss); } @@ -2916,9 +2897,9 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, Handle LoadStubCompiler::CompileLoadViaGetter( - Handle name, Handle receiver, Handle holder, + Handle name, Handle getter) { // ----------- S t a t e ------------- // -- rax : receiver @@ -2941,50 +2922,6 @@ Handle LoadStubCompiler::CompileLoadViaGetter( } -Handle LoadStubCompiler::CompileLoadConstant(Handle object, - Handle holder, - Handle value, - Handle name) { - // ----------- S t a t e ------------- - // -- rax : receiver - // -- rcx : name - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - - GenerateLoadConstant(object, holder, rax, rbx, rdx, rdi, value, name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::CONSTANT_FUNCTION, name); -} - - -Handle LoadStubCompiler::CompileLoadInterceptor(Handle receiver, - Handle holder, - Handle name) { - // ----------- S t a t e ------------- - // -- rax : receiver - // -- rcx : name - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - LookupResult lookup(isolate()); - LookupPostInterceptor(holder, name, &lookup); - - // TODO(368): Compile in the whole chain: all the interceptors in - // prototypes and ultimate answer. - GenerateLoadInterceptor(receiver, holder, &lookup, rax, rcx, rdx, rbx, rdi, - name, &miss); - __ bind(&miss); - GenerateLoadMiss(masm(), Code::LOAD_IC); - - // Return the generated code. - return GetCode(Code::INTERCEPTOR, name); -} - - Handle LoadStubCompiler::CompileLoadGlobal( Handle object, Handle holder, @@ -3029,124 +2966,6 @@ Handle LoadStubCompiler::CompileLoadGlobal( } -Handle KeyedLoadStubCompiler::CompileLoadField(Handle name, - Handle receiver, - Handle holder, - PropertyIndex index) { - // ----------- S t a t e ------------- - // -- rax : key - // -- rdx : receiver - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_field(), 1); - - // Check that the name has not changed. - __ Cmp(rax, name); - __ j(not_equal, &miss); - - GenerateLoadField(receiver, holder, rdx, rbx, rcx, rdi, index, name, &miss); - - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_field(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::FIELD, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadCallback( - Handle name, - Handle receiver, - Handle holder, - Handle callback) { - // ----------- S t a t e ------------- - // -- rax : key - // -- rdx : receiver - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_callback(), 1); - - // Check that the name has not changed. - __ Cmp(rax, name); - __ j(not_equal, &miss); - - GenerateLoadCallback(receiver, holder, rdx, rax, rbx, rcx, rdi, r8, callback, - name, &miss); - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_callback(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::CALLBACKS, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadConstant( - Handle name, - Handle receiver, - Handle holder, - Handle value) { - // ----------- S t a t e ------------- - // -- rax : key - // -- rdx : receiver - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_constant_function(), 1); - - // Check that the name has not changed. - __ Cmp(rax, name); - __ j(not_equal, &miss); - - GenerateLoadConstant(receiver, holder, rdx, rbx, rcx, rdi, - value, name, &miss); - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_constant_function(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::CONSTANT_FUNCTION, name); -} - - -Handle KeyedLoadStubCompiler::CompileLoadInterceptor( - Handle receiver, - Handle holder, - Handle name) { - // ----------- S t a t e ------------- - // -- rax : key - // -- rdx : receiver - // -- rsp[0] : return address - // ----------------------------------- - Label miss; - Counters* counters = isolate()->counters(); - __ IncrementCounter(counters->keyed_load_interceptor(), 1); - - // Check that the name has not changed. - __ Cmp(rax, name); - __ j(not_equal, &miss); - - LookupResult lookup(isolate()); - LookupPostInterceptor(holder, name, &lookup); - GenerateLoadInterceptor(receiver, holder, &lookup, rdx, rax, rcx, rbx, rdi, - name, &miss); - __ bind(&miss); - __ DecrementCounter(counters->keyed_load_interceptor(), 1); - GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); - - // Return the generated code. - return GetCode(Code::INTERCEPTOR, name); -} - - Handle KeyedLoadStubCompiler::CompileLoadElement( Handle receiver_map) { // ----------- S t a t e -------------