From: ulan@chromium.org Date: Wed, 26 Oct 2011 10:45:24 +0000 (+0000) Subject: Handlify simple functions of [keyed] store stub compiler. X-Git-Tag: upstream/4.7.83~18072 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=beb0bbe3a947603f73a6345fa8fdacc5465e7e7a;p=platform%2Fupstream%2Fv8.git Handlify simple functions of [keyed] store stub compiler. Handlified functions: CompileStoreField, CompileStoreGlobal, CompileStoreElement, CompileStorePolymorphic. Based on 8375053. R=kmillikin@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/8393003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9791 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index 43440ac..ff2873d 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -425,9 +425,9 @@ void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, // may be clobbered. Upon branch to miss_label, the receiver and name // registers have their original values. void StubCompiler::GenerateStoreField(MacroAssembler* masm, - JSObject* object, + Handle object, int index, - Map* transition, + Handle transition, Register receiver_reg, Register name_reg, Register scratch, @@ -453,11 +453,11 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); // Perform map transition for the receiver if necessary. - if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) { + if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) { // The properties must be extended before we can store the value. // We jump to a runtime call that extends the properties array. __ push(receiver_reg); - __ mov(r2, Operand(Handle(transition))); + __ mov(r2, Operand(transition)); __ Push(r2, r0); __ TailCallExternalReference( ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), @@ -467,10 +467,10 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, return; } - if (transition != NULL) { + if (!transition.is_null()) { // Update the map of the object; no write barrier updating is // needed because the map is never in new space. - __ mov(ip, Operand(Handle(transition))); + __ mov(ip, Operand(transition)); __ str(ip, FieldMemOperand(receiver_reg, HeapObject::kMapOffset)); } @@ -2821,10 +2821,10 @@ MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object, } -MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, +Handle StoreStubCompiler::CompileStoreField(Handle object, int index, - Map* transition, - String* name) { + Handle transition, + Handle name) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : receiver @@ -2833,18 +2833,13 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, // ----------------------------------- Label miss; - GenerateStoreField(masm(), - object, - index, - transition, - r1, r2, r3, - &miss); + GenerateStoreField(masm(), object, index, transition, r1, r2, r3, &miss); __ bind(&miss); Handle ic = masm()->isolate()->builtins()->StoreIC_Miss(); __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); + return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); } @@ -2892,7 +2887,7 @@ MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CALLBACKS, name); + return TryGetCode(CALLBACKS, name); } @@ -2940,13 +2935,14 @@ MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR, name); + return TryGetCode(INTERCEPTOR, name); } -MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, - JSGlobalPropertyCell* cell, - String* name) { +Handle StoreStubCompiler::CompileStoreGlobal( + Handle object, + Handle cell, + Handle name) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : receiver @@ -2964,7 +2960,7 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, // cell could have been deleted and reintroducing the global needs // to update the property details in the property dictionary of the // global object. We bail out to the runtime system to do that. - __ mov(r4, Operand(Handle(cell))); + __ mov(r4, Operand(cell)); __ LoadRoot(r5, Heap::kTheHoleValueRootIndex); __ ldr(r6, FieldMemOperand(r4, JSGlobalPropertyCell::kValueOffset)); __ cmp(r5, r6); @@ -3407,10 +3403,10 @@ Handle KeyedLoadStubCompiler::CompileLoadPolymorphic( } -MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, +Handle KeyedStoreStubCompiler::CompileStoreField(Handle object, int index, - Map* transition, - String* name) { + Handle transition, + Handle name) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : name @@ -3423,17 +3419,12 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ IncrementCounter(counters->keyed_store_field(), 1, r3, r4); // Check that the name has not changed. - __ cmp(r1, Operand(Handle(name))); + __ cmp(r1, Operand(name)); __ b(ne, &miss); // r3 is used as scratch register. r1 and r2 keep their values if a jump to // the miss label is generated. - GenerateStoreField(masm(), - object, - index, - transition, - r2, r1, r3, - &miss); + GenerateStoreField(masm(), object, index, transition, r2, r1, r3, &miss); __ bind(&miss); __ DecrementCounter(counters->keyed_store_field(), 1, r3, r4); @@ -3441,11 +3432,12 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); + return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); } -MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { +Handle KeyedStoreStubCompiler::CompileStoreElement( + Handle receiver_map) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : key @@ -3453,30 +3445,25 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { // -- lr : return address // -- r3 : scratch // ----------------------------------- - Code* stub; ElementsKind elements_kind = receiver_map->elements_kind(); bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; - MaybeObject* maybe_stub = - KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); - if (!maybe_stub->To(&stub)) return maybe_stub; - __ DispatchMap(r2, - r3, - Handle(receiver_map), - Handle(stub), - DO_SMI_CHECK); + Handle stub = + KeyedStoreElementStub(is_js_array, elements_kind).GetCode(); + + __ DispatchMap(r2, r3, receiver_map, stub, DO_SMI_CHECK); Handle ic = isolate()->builtins()->KeyedStoreIC_Miss(); __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(NORMAL, NULL); + return GetCode(NORMAL, factory()->empty_string()); } -MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( - MapList* receiver_maps, - CodeList* handler_stubs, - MapList* transitioned_maps) { +Handle KeyedStoreStubCompiler::CompileStorePolymorphic( + MapHandleList* receiver_maps, + CodeHandleList* handler_stubs, + MapHandleList* transitioned_maps) { // ----------- S t a t e ------------- // -- r0 : value // -- r1 : key @@ -3490,17 +3477,15 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( int receiver_count = receiver_maps->length(); __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); for (int i = 0; i < receiver_count; ++i) { - Handle map(receiver_maps->at(i)); - Handle code(handler_stubs->at(i)); - __ mov(ip, Operand(map)); + __ mov(ip, Operand(receiver_maps->at(i))); __ cmp(r3, ip); - if (transitioned_maps->at(i) == NULL) { - __ Jump(code, RelocInfo::CODE_TARGET, eq); + if (transitioned_maps->at(i).is_null()) { + __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq); } else { Label next_map; __ b(ne, &next_map); - __ mov(r3, Operand(Handle(transitioned_maps->at(i)))); - __ Jump(code, RelocInfo::CODE_TARGET, al); + __ mov(r3, Operand(transitioned_maps->at(i))); + __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al); __ bind(&next_map); } } @@ -3510,7 +3495,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( __ Jump(miss_ic, RelocInfo::CODE_TARGET, al); // Return the generated code. - return GetCode(NORMAL, NULL, MEGAMORPHIC); + return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); } diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index ed6cf0d..4b43aa9 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -772,9 +772,9 @@ void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) { // Both name_reg and receiver_reg are preserved on jumps to miss_label, // but may be destroyed if store is successful. void StubCompiler::GenerateStoreField(MacroAssembler* masm, - JSObject* object, + Handle object, int index, - Map* transition, + Handle transition, Register receiver_reg, Register name_reg, Register scratch, @@ -797,12 +797,12 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); // Perform map transition for the receiver if necessary. - if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) { + if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) { // The properties must be extended before we can store the value. // We jump to a runtime call that extends the properties array. __ pop(scratch); // Return address. __ push(receiver_reg); - __ push(Immediate(Handle(transition))); + __ push(Immediate(transition)); __ push(eax); __ push(scratch); __ TailCallExternalReference( @@ -813,11 +813,11 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, return; } - if (transition != NULL) { + if (!transition.is_null()) { // Update the map of the object; no write barrier updating is // needed because the map is never in new space. __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), - Immediate(Handle(transition))); + Immediate(transition)); } // Adjust for the number of properties stored in the object. Even in the @@ -2699,10 +2699,10 @@ MaybeObject* CallStubCompiler::CompileCallGlobal( } -MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, +Handle StoreStubCompiler::CompileStoreField(Handle object, int index, - Map* transition, - String* name) { + Handle transition, + Handle name) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : name @@ -2712,21 +2712,16 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, Label miss; // Generate store field code. Trashes the name register. - GenerateStoreField(masm(), - object, - index, - transition, - edx, ecx, ebx, - &miss); + GenerateStoreField(masm(), object, index, transition, edx, ecx, ebx, &miss); // Handle store cache miss. __ bind(&miss); - __ mov(ecx, Immediate(Handle(name))); // restore name + __ mov(ecx, Immediate(name)); // restore name Handle ic = isolate()->builtins()->StoreIC_Miss(); __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); + return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); } @@ -2776,7 +2771,7 @@ MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CALLBACKS, name); + return TryGetCode(CALLBACKS, name); } @@ -2825,13 +2820,14 @@ MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR, name); + return TryGetCode(INTERCEPTOR, name); } -MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, - JSGlobalPropertyCell* cell, - String* name) { +Handle StoreStubCompiler::CompileStoreGlobal( + Handle object, + Handle cell, + Handle name) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : name @@ -2846,7 +2842,7 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, __ j(not_equal, &miss); // Compute the cell operand to use. - __ mov(ebx, Immediate(Handle(cell))); + __ mov(ebx, Immediate(cell)); Operand cell_operand = FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset); // Check that the value in the cell is not the hole. If it is, this @@ -2890,10 +2886,10 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, } -MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, +Handle KeyedStoreStubCompiler::CompileStoreField(Handle object, int index, - Map* transition, - String* name) { + Handle transition, + Handle name) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : key @@ -2906,16 +2902,11 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ IncrementCounter(counters->keyed_store_field(), 1); // Check that the name has not changed. - __ cmp(ecx, Immediate(Handle(name))); + __ cmp(ecx, Immediate(name)); __ j(not_equal, &miss); // Generate store field code. Trashes the name register. - GenerateStoreField(masm(), - object, - index, - transition, - edx, ecx, ebx, - &miss); + GenerateStoreField(masm(), object, index, transition, edx, ecx, ebx, &miss); // Handle store cache miss. __ bind(&miss); @@ -2924,40 +2915,37 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); + return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); } -MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { +Handle KeyedStoreStubCompiler::CompileStoreElement( + Handle receiver_map) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : key // -- edx : receiver // -- esp[0] : return address // ----------------------------------- - Code* stub; ElementsKind elements_kind = receiver_map->elements_kind(); bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; - MaybeObject* maybe_stub = - KeyedStoreElementStub(is_jsarray, elements_kind).TryGetCode(); - if (!maybe_stub->To(&stub)) return maybe_stub; - __ DispatchMap(edx, - Handle(receiver_map), - Handle(stub), - DO_SMI_CHECK); + Handle stub = + KeyedStoreElementStub(is_jsarray, elements_kind).GetCode(); + + __ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK); Handle ic = isolate()->builtins()->KeyedStoreIC_Miss(); __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(NORMAL, NULL); + return GetCode(NORMAL, factory()->empty_string()); } -MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( - MapList* receiver_maps, - CodeList* handler_stubs, - MapList* transitioned_maps) { +Handle KeyedStoreStubCompiler::CompileStorePolymorphic( + MapHandleList* receiver_maps, + CodeHandleList* handler_stubs, + MapHandleList* transitioned_maps) { // ----------- S t a t e ------------- // -- eax : value // -- ecx : key @@ -2969,15 +2957,14 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); // ebx: receiver->map(). for (int i = 0; i < receiver_maps->length(); ++i) { - Handle map(receiver_maps->at(i)); - __ cmp(edi, map); - if (transitioned_maps->at(i) == NULL) { - __ j(equal, Handle(handler_stubs->at(i))); + __ cmp(edi, receiver_maps->at(i)); + if (transitioned_maps->at(i).is_null()) { + __ j(equal, handler_stubs->at(i)); } else { Label next_map; __ j(not_equal, &next_map, Label::kNear); - __ mov(ebx, Immediate(Handle(transitioned_maps->at(i)))); - __ jmp(Handle(handler_stubs->at(i)), RelocInfo::CODE_TARGET); + __ mov(ebx, Immediate(transitioned_maps->at(i))); + __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET); __ bind(&next_map); } } @@ -2986,7 +2973,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( __ jmp(miss_ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(NORMAL, NULL, MEGAMORPHIC); + return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); } diff --git a/src/list-inl.h b/src/list-inl.h index 34fa027..e2c358c 100644 --- a/src/list-inl.h +++ b/src/list-inl.h @@ -237,18 +237,6 @@ int SortedListBSearch(const List& list, T elem) { } -template -List* UnwrapHandleList(List* destination, List >* source) { - ASSERT(destination->is_empty()); - int length = source->length(); - for (int i = 0; i < length; ++i) { - Handle handle = source->at(i); - destination->Add(handle.is_null() ? NULL : *handle); - } - return destination; -} - - } } // namespace v8::internal #endif // V8_LIST_INL_H_ diff --git a/src/list.h b/src/list.h index 0b605e9..57504e0 100644 --- a/src/list.h +++ b/src/list.h @@ -179,14 +179,6 @@ int SortedListBSearch( template int SortedListBSearch(const List& list, T elem); -// Unwraps each handle in the source list to a pointer at -// the corresponding position in the destination list. -// Returns the destination list. -// Both list must have the same length. - -template -List* UnwrapHandleList(List* destination, List >* source); - } } // namespace v8::internal diff --git a/src/stub-cache.cc b/src/stub-cache.cc index 4c99c30..ad7a684 100644 --- a/src/stub-cache.cc +++ b/src/stub-cache.cc @@ -417,20 +417,6 @@ Handle StubCache::ComputeKeyedLoadFunctionPrototype( } -Handle StoreStubCompiler::CompileStoreField(Handle object, - int index, - Handle transition, - Handle name) { - CALL_HEAP_FUNCTION( - isolate(), - (set_failure(NULL), - CompileStoreField(*object, index, - transition.is_null() ? NULL : *transition, - *name)), - Code); -} - - Handle StubCache::ComputeStoreField(Handle name, Handle receiver, int field_index, @@ -452,14 +438,6 @@ Handle StubCache::ComputeStoreField(Handle name, } -Handle KeyedStoreStubCompiler::CompileStoreElement(Handle map) { - CALL_HEAP_FUNCTION(isolate(), - (set_failure(NULL), - CompileStoreElement(*map)), - Code); -} - - Handle StubCache::ComputeKeyedLoadOrStoreElement( Handle receiver, KeyedIC::StubKind stub_kind, @@ -515,29 +493,6 @@ Handle StubCache::ComputeKeyedLoadOrStoreElement( } -Handle KeyedStoreStubCompiler::CompileStorePolymorphic( - MapHandleList* receiver_maps, - CodeHandleList* handler_stubs, - MapHandleList* transitioned_maps) { - MapList raw_receiver_maps(receiver_maps->length()); - CodeList raw_handler_stubs(handler_stubs->length()); - MapList raw_transitioned_maps(transitioned_maps->length()); - CALL_HEAP_FUNCTION( - isolate(), - (set_failure(NULL), - raw_receiver_maps.Clear(), - raw_handler_stubs.Clear(), - raw_transitioned_maps.Clear(), - CompileStorePolymorphic(UnwrapHandleList(&raw_receiver_maps, - receiver_maps), - UnwrapHandleList(&raw_handler_stubs, - handler_stubs), - UnwrapHandleList(&raw_transitioned_maps, - transitioned_maps))), - Code); -} - - Handle StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { return (strict_mode == kStrictMode) ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() @@ -545,17 +500,6 @@ Handle StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { } -Handle StoreStubCompiler::CompileStoreGlobal( - Handle object, - Handle holder, - Handle name) { - CALL_HEAP_FUNCTION(isolate(), - (set_failure(NULL), - CompileStoreGlobal(*object, *holder, *name)), - Code); -} - - Handle StubCache::ComputeStoreGlobal(Handle name, Handle receiver, Handle cell, @@ -629,19 +573,6 @@ Handle StubCache::ComputeStoreInterceptor(Handle name, return code; } -Handle KeyedStoreStubCompiler::CompileStoreField(Handle object, - int index, - Handle transition, - Handle name) { - CALL_HEAP_FUNCTION( - isolate(), - (set_failure(NULL), - CompileStoreField(*object, index, - transition.is_null() ? NULL : *transition, - *name)), - Code); -} - Handle StubCache::ComputeKeyedStoreField(Handle name, Handle receiver, int field_index, @@ -1616,7 +1547,20 @@ MaybeObject* KeyedLoadStubCompiler::TryGetCode(PropertyType type, } -MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { +Handle StoreStubCompiler::GetCode(PropertyType type, + Handle name) { + Code::Flags flags = + Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_); + Handle code = GetCodeWithFlags(flags, name); + PROFILE(isolate(), CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); + GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); + return code; +} + + +// TODO(ulan): Eliminate this function when the stub cache is fully +// handlified. +MaybeObject* StoreStubCompiler::TryGetCode(PropertyType type, String* name) { Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_); MaybeObject* result = TryGetCodeWithFlags(flags, name); @@ -1633,22 +1577,15 @@ MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { } -MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, - String* name, +Handle KeyedStoreStubCompiler::GetCode(PropertyType type, + Handle name, InlineCacheState state) { Code::Flags flags = Code::ComputeFlags(Code::KEYED_STORE_IC, state, strict_mode_, type); - MaybeObject* result = TryGetCodeWithFlags(flags, name); - if (!result->IsFailure()) { - PROFILE(isolate(), - CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, - Code::cast(result->ToObjectUnchecked()), - name)); - GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, - name, - Code::cast(result->ToObjectUnchecked()))); - } - return result; + Handle code = GetCodeWithFlags(flags, name); + PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, *name)); + GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); + return code; } diff --git a/src/stub-cache.h b/src/stub-cache.h index ccc3a4d..0edbb4e 100644 --- a/src/stub-cache.h +++ b/src/stub-cache.h @@ -440,9 +440,9 @@ class StubCompiler BASE_EMBEDDED { Label* miss_label); static void GenerateStoreField(MacroAssembler* masm, - JSObject* object, + Handle object, int index, - Map* transition, + Handle transition, Register receiver_reg, Register name_reg, Register scratch, @@ -688,8 +688,8 @@ class KeyedLoadStubCompiler: public StubCompiler { private: MaybeObject* TryGetCode(PropertyType type, - String* name, - InlineCacheState state = MONOMORPHIC); + String* name, + InlineCacheState state = MONOMORPHIC); Handle GetCode(PropertyType type, Handle name, @@ -708,11 +708,6 @@ class StoreStubCompiler: public StubCompiler { Handle transition, Handle name); - MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, - int index, - Map* transition, - String* name); - Handle CompileStoreCallback(Handle object, Handle callback, Handle name); @@ -730,13 +725,10 @@ class StoreStubCompiler: public StubCompiler { Handle holder, Handle name); - MUST_USE_RESULT MaybeObject* CompileStoreGlobal(GlobalObject* object, - JSGlobalPropertyCell* holder, - String* name); - - private: - MaybeObject* GetCode(PropertyType type, String* name); + MaybeObject* TryGetCode(PropertyType type, String* name); + + Handle GetCode(PropertyType type, Handle name); StrictModeFlag strict_mode_; }; @@ -752,24 +744,12 @@ class KeyedStoreStubCompiler: public StubCompiler { Handle transition, Handle name); - MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object, - int index, - Map* transition, - String* name); - Handle CompileStoreElement(Handle receiver_map); - MUST_USE_RESULT MaybeObject* CompileStoreElement(Map* receiver_map); - Handle CompileStorePolymorphic(MapHandleList* receiver_maps, CodeHandleList* handler_stubs, MapHandleList* transitioned_maps); - MUST_USE_RESULT MaybeObject* CompileStorePolymorphic( - MapList* receiver_maps, - CodeList* handler_stubs, - MapList* transitioned_maps); - static void GenerateStoreFastElement(MacroAssembler* masm, bool is_js_array, ElementsKind element_kind); @@ -783,8 +763,8 @@ class KeyedStoreStubCompiler: public StubCompiler { static void GenerateStoreDictionaryElement(MacroAssembler* masm); private: - MaybeObject* GetCode(PropertyType type, - String* name, + Handle GetCode(PropertyType type, + Handle name, InlineCacheState state = MONOMORPHIC); StrictModeFlag strict_mode_; diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 6b7045d..6ddfbd9 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -768,9 +768,9 @@ void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) { // Both name_reg and receiver_reg are preserved on jumps to miss_label, // but may be destroyed if store is successful. void StubCompiler::GenerateStoreField(MacroAssembler* masm, - JSObject* object, + Handle object, int index, - Map* transition, + Handle transition, Register receiver_reg, Register name_reg, Register scratch, @@ -793,12 +793,12 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); // Perform map transition for the receiver if necessary. - if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) { + if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) { // The properties must be extended before we can store the value. // We jump to a runtime call that extends the properties array. __ pop(scratch); // Return address. __ push(receiver_reg); - __ Push(Handle(transition)); + __ Push(transition); __ push(rax); __ push(scratch); __ TailCallExternalReference( @@ -809,11 +809,10 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm, return; } - if (transition != NULL) { + if (!transition.is_null()) { // Update the map of the object; no write barrier updating is // needed because the map is never in new space. - __ Move(FieldOperand(receiver_reg, HeapObject::kMapOffset), - Handle(transition)); + __ Move(FieldOperand(receiver_reg, HeapObject::kMapOffset), transition); } // Adjust for the number of properties stored in the object. Even in the @@ -2569,10 +2568,10 @@ MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object, } -MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, +Handle StoreStubCompiler::CompileStoreField(Handle object, int index, - Map* transition, - String* name) { + Handle transition, + Handle name) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : name @@ -2582,12 +2581,7 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, Label miss; // Generate store field code. Preserves receiver and name on jump to miss. - GenerateStoreField(masm(), - object, - index, - transition, - rdx, rcx, rbx, - &miss); + GenerateStoreField(masm(), object, index, transition, rdx, rcx, rbx, &miss); // Handle store cache miss. __ bind(&miss); @@ -2595,7 +2589,7 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); + return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); } @@ -2645,7 +2639,7 @@ MaybeObject* StoreStubCompiler::CompileStoreCallback(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(CALLBACKS, name); + return TryGetCode(CALLBACKS, name); } @@ -2694,13 +2688,14 @@ MaybeObject* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(INTERCEPTOR, name); + return TryGetCode(INTERCEPTOR, name); } -MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, - JSGlobalPropertyCell* cell, - String* name) { +Handle StoreStubCompiler::CompileStoreGlobal( + Handle object, + Handle cell, + Handle name) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : name @@ -2715,7 +2710,7 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, __ j(not_equal, &miss); // Compute the cell operand to use. - __ Move(rbx, Handle(cell)); + __ Move(rbx, cell); Operand cell_operand = FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset); // Check that the value in the cell is not the hole. If it is, this @@ -2759,10 +2754,10 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object, } -MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, +Handle KeyedStoreStubCompiler::CompileStoreField(Handle object, int index, - Map* transition, - String* name) { + Handle transition, + Handle name) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : key @@ -2775,16 +2770,11 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ IncrementCounter(counters->keyed_store_field(), 1); // Check that the name has not changed. - __ Cmp(rcx, Handle(name)); + __ Cmp(rcx, name); __ j(not_equal, &miss); // Generate store field code. Preserves receiver and name on jump to miss. - GenerateStoreField(masm(), - object, - index, - transition, - rdx, rcx, rbx, - &miss); + GenerateStoreField(masm(), object, index, transition, rdx, rcx, rbx, &miss); // Handle store cache miss. __ bind(&miss); @@ -2793,40 +2783,38 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, __ Jump(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); + return GetCode(transition.is_null() ? FIELD : MAP_TRANSITION, name); } -MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) { +Handle KeyedStoreStubCompiler::CompileStoreElement( + Handle receiver_map) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : key // -- rdx : receiver // -- rsp[0] : return address // ----------------------------------- - Code* stub; + ElementsKind elements_kind = receiver_map->elements_kind(); bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; - MaybeObject* maybe_stub = - KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode(); - if (!maybe_stub->To(&stub)) return maybe_stub; - __ DispatchMap(rdx, - Handle(receiver_map), - Handle(stub), - DO_SMI_CHECK); + Handle stub = + KeyedStoreElementStub(is_js_array, elements_kind).GetCode(); + + __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK); Handle ic = isolate()->builtins()->KeyedStoreIC_Miss(); __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(NORMAL, NULL); + return GetCode(NORMAL, factory()->empty_string()); } -MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( - MapList* receiver_maps, - CodeList* handler_stubs, - MapList* transitioned_maps) { +Handle KeyedStoreStubCompiler::CompileStorePolymorphic( + MapHandleList* receiver_maps, + CodeHandleList* handler_stubs, + MapHandleList* transitioned_maps) { // ----------- S t a t e ------------- // -- rax : value // -- rcx : key @@ -2840,17 +2828,14 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( int receiver_count = receiver_maps->length(); for (int i = 0; i < receiver_count; ++i) { // Check map and tail call if there's a match - Handle map(receiver_maps->at(i)); - __ Cmp(rdi, map); - if (transitioned_maps->at(i) == NULL) { - __ j(equal, Handle(handler_stubs->at(i)), RelocInfo::CODE_TARGET); + __ Cmp(rdi, receiver_maps->at(i)); + if (transitioned_maps->at(i).is_null()) { + __ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET); } else { Label next_map; __ j(not_equal, &next_map, Label::kNear); - __ movq(rbx, - Handle(transitioned_maps->at(i)), - RelocInfo::EMBEDDED_OBJECT); - __ jmp(Handle(handler_stubs->at(i)), RelocInfo::CODE_TARGET); + __ movq(rbx, transitioned_maps->at(i), RelocInfo::EMBEDDED_OBJECT); + __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET); __ bind(&next_map); } } @@ -2860,7 +2845,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic( __ jmp(ic, RelocInfo::CODE_TARGET); // Return the generated code. - return GetCode(NORMAL, NULL, MEGAMORPHIC); + return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC); }