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
This commit is contained in:
parent
5a33ffd7e8
commit
beb0bbe3a9
@ -425,9 +425,9 @@ void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm,
|
|||||||
// may be clobbered. Upon branch to miss_label, the receiver and name
|
// may be clobbered. Upon branch to miss_label, the receiver and name
|
||||||
// registers have their original values.
|
// registers have their original values.
|
||||||
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
||||||
JSObject* object,
|
Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
Register receiver_reg,
|
Register receiver_reg,
|
||||||
Register name_reg,
|
Register name_reg,
|
||||||
Register scratch,
|
Register scratch,
|
||||||
@ -453,11 +453,11 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
|||||||
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
|
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
|
||||||
|
|
||||||
// Perform map transition for the receiver if necessary.
|
// 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.
|
// The properties must be extended before we can store the value.
|
||||||
// We jump to a runtime call that extends the properties array.
|
// We jump to a runtime call that extends the properties array.
|
||||||
__ push(receiver_reg);
|
__ push(receiver_reg);
|
||||||
__ mov(r2, Operand(Handle<Map>(transition)));
|
__ mov(r2, Operand(transition));
|
||||||
__ Push(r2, r0);
|
__ Push(r2, r0);
|
||||||
__ TailCallExternalReference(
|
__ TailCallExternalReference(
|
||||||
ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage),
|
ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage),
|
||||||
@ -467,10 +467,10 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transition != NULL) {
|
if (!transition.is_null()) {
|
||||||
// Update the map of the object; no write barrier updating is
|
// Update the map of the object; no write barrier updating is
|
||||||
// needed because the map is never in new space.
|
// needed because the map is never in new space.
|
||||||
__ mov(ip, Operand(Handle<Map>(transition)));
|
__ mov(ip, Operand(transition));
|
||||||
__ str(ip, FieldMemOperand(receiver_reg, HeapObject::kMapOffset));
|
__ str(ip, FieldMemOperand(receiver_reg, HeapObject::kMapOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2821,10 +2821,10 @@ MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
|
Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
String* name) {
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- r0 : value
|
// -- r0 : value
|
||||||
// -- r1 : receiver
|
// -- r1 : receiver
|
||||||
@ -2833,18 +2833,13 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
Label miss;
|
Label miss;
|
||||||
|
|
||||||
GenerateStoreField(masm(),
|
GenerateStoreField(masm(), object, index, transition, r1, r2, r3, &miss);
|
||||||
object,
|
|
||||||
index,
|
|
||||||
transition,
|
|
||||||
r1, r2, r3,
|
|
||||||
&miss);
|
|
||||||
__ bind(&miss);
|
__ bind(&miss);
|
||||||
Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
|
Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
|
||||||
__ Jump(ic, RelocInfo::CODE_TARGET);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(INTERCEPTOR, name);
|
return TryGetCode(INTERCEPTOR, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
|
Handle<Code> StoreStubCompiler::CompileStoreGlobal(
|
||||||
JSGlobalPropertyCell* cell,
|
Handle<GlobalObject> object,
|
||||||
String* name) {
|
Handle<JSGlobalPropertyCell> cell,
|
||||||
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- r0 : value
|
// -- r0 : value
|
||||||
// -- r1 : receiver
|
// -- r1 : receiver
|
||||||
@ -2964,7 +2960,7 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
|
|||||||
// cell could have been deleted and reintroducing the global needs
|
// cell could have been deleted and reintroducing the global needs
|
||||||
// to update the property details in the property dictionary of the
|
// to update the property details in the property dictionary of the
|
||||||
// global object. We bail out to the runtime system to do that.
|
// global object. We bail out to the runtime system to do that.
|
||||||
__ mov(r4, Operand(Handle<JSGlobalPropertyCell>(cell)));
|
__ mov(r4, Operand(cell));
|
||||||
__ LoadRoot(r5, Heap::kTheHoleValueRootIndex);
|
__ LoadRoot(r5, Heap::kTheHoleValueRootIndex);
|
||||||
__ ldr(r6, FieldMemOperand(r4, JSGlobalPropertyCell::kValueOffset));
|
__ ldr(r6, FieldMemOperand(r4, JSGlobalPropertyCell::kValueOffset));
|
||||||
__ cmp(r5, r6);
|
__ cmp(r5, r6);
|
||||||
@ -3407,10 +3403,10 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
String* name) {
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- r0 : value
|
// -- r0 : value
|
||||||
// -- r1 : name
|
// -- r1 : name
|
||||||
@ -3423,17 +3419,12 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ IncrementCounter(counters->keyed_store_field(), 1, r3, r4);
|
__ IncrementCounter(counters->keyed_store_field(), 1, r3, r4);
|
||||||
|
|
||||||
// Check that the name has not changed.
|
// Check that the name has not changed.
|
||||||
__ cmp(r1, Operand(Handle<String>(name)));
|
__ cmp(r1, Operand(name));
|
||||||
__ b(ne, &miss);
|
__ b(ne, &miss);
|
||||||
|
|
||||||
// r3 is used as scratch register. r1 and r2 keep their values if a jump to
|
// r3 is used as scratch register. r1 and r2 keep their values if a jump to
|
||||||
// the miss label is generated.
|
// the miss label is generated.
|
||||||
GenerateStoreField(masm(),
|
GenerateStoreField(masm(), object, index, transition, r2, r1, r3, &miss);
|
||||||
object,
|
|
||||||
index,
|
|
||||||
transition,
|
|
||||||
r2, r1, r3,
|
|
||||||
&miss);
|
|
||||||
__ bind(&miss);
|
__ bind(&miss);
|
||||||
|
|
||||||
__ DecrementCounter(counters->keyed_store_field(), 1, r3, r4);
|
__ DecrementCounter(counters->keyed_store_field(), 1, r3, r4);
|
||||||
@ -3441,11 +3432,12 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ Jump(ic, RelocInfo::CODE_TARGET);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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<Code> KeyedStoreStubCompiler::CompileStoreElement(
|
||||||
|
Handle<Map> receiver_map) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- r0 : value
|
// -- r0 : value
|
||||||
// -- r1 : key
|
// -- r1 : key
|
||||||
@ -3453,30 +3445,25 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreElement(Map* receiver_map) {
|
|||||||
// -- lr : return address
|
// -- lr : return address
|
||||||
// -- r3 : scratch
|
// -- r3 : scratch
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
Code* stub;
|
|
||||||
ElementsKind elements_kind = receiver_map->elements_kind();
|
ElementsKind elements_kind = receiver_map->elements_kind();
|
||||||
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
||||||
MaybeObject* maybe_stub =
|
Handle<Code> stub =
|
||||||
KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode();
|
KeyedStoreElementStub(is_js_array, elements_kind).GetCode();
|
||||||
if (!maybe_stub->To(&stub)) return maybe_stub;
|
|
||||||
__ DispatchMap(r2,
|
__ DispatchMap(r2, r3, receiver_map, stub, DO_SMI_CHECK);
|
||||||
r3,
|
|
||||||
Handle<Map>(receiver_map),
|
|
||||||
Handle<Code>(stub),
|
|
||||||
DO_SMI_CHECK);
|
|
||||||
|
|
||||||
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
|
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
|
||||||
__ Jump(ic, RelocInfo::CODE_TARGET);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(NORMAL, NULL);
|
return GetCode(NORMAL, factory()->empty_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
|
||||||
MapList* receiver_maps,
|
MapHandleList* receiver_maps,
|
||||||
CodeList* handler_stubs,
|
CodeHandleList* handler_stubs,
|
||||||
MapList* transitioned_maps) {
|
MapHandleList* transitioned_maps) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- r0 : value
|
// -- r0 : value
|
||||||
// -- r1 : key
|
// -- r1 : key
|
||||||
@ -3490,17 +3477,15 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
|||||||
int receiver_count = receiver_maps->length();
|
int receiver_count = receiver_maps->length();
|
||||||
__ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
|
__ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
|
||||||
for (int i = 0; i < receiver_count; ++i) {
|
for (int i = 0; i < receiver_count; ++i) {
|
||||||
Handle<Map> map(receiver_maps->at(i));
|
__ mov(ip, Operand(receiver_maps->at(i)));
|
||||||
Handle<Code> code(handler_stubs->at(i));
|
|
||||||
__ mov(ip, Operand(map));
|
|
||||||
__ cmp(r3, ip);
|
__ cmp(r3, ip);
|
||||||
if (transitioned_maps->at(i) == NULL) {
|
if (transitioned_maps->at(i).is_null()) {
|
||||||
__ Jump(code, RelocInfo::CODE_TARGET, eq);
|
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq);
|
||||||
} else {
|
} else {
|
||||||
Label next_map;
|
Label next_map;
|
||||||
__ b(ne, &next_map);
|
__ b(ne, &next_map);
|
||||||
__ mov(r3, Operand(Handle<Map>(transitioned_maps->at(i))));
|
__ mov(r3, Operand(transitioned_maps->at(i)));
|
||||||
__ Jump(code, RelocInfo::CODE_TARGET, al);
|
__ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al);
|
||||||
__ bind(&next_map);
|
__ bind(&next_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3510,7 +3495,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
|||||||
__ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
|
__ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(NORMAL, NULL, MEGAMORPHIC);
|
return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -772,9 +772,9 @@ void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) {
|
|||||||
// Both name_reg and receiver_reg are preserved on jumps to miss_label,
|
// Both name_reg and receiver_reg are preserved on jumps to miss_label,
|
||||||
// but may be destroyed if store is successful.
|
// but may be destroyed if store is successful.
|
||||||
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
||||||
JSObject* object,
|
Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
Register receiver_reg,
|
Register receiver_reg,
|
||||||
Register name_reg,
|
Register name_reg,
|
||||||
Register scratch,
|
Register scratch,
|
||||||
@ -797,12 +797,12 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
|||||||
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
|
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
|
||||||
|
|
||||||
// Perform map transition for the receiver if necessary.
|
// 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.
|
// The properties must be extended before we can store the value.
|
||||||
// We jump to a runtime call that extends the properties array.
|
// We jump to a runtime call that extends the properties array.
|
||||||
__ pop(scratch); // Return address.
|
__ pop(scratch); // Return address.
|
||||||
__ push(receiver_reg);
|
__ push(receiver_reg);
|
||||||
__ push(Immediate(Handle<Map>(transition)));
|
__ push(Immediate(transition));
|
||||||
__ push(eax);
|
__ push(eax);
|
||||||
__ push(scratch);
|
__ push(scratch);
|
||||||
__ TailCallExternalReference(
|
__ TailCallExternalReference(
|
||||||
@ -813,11 +813,11 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transition != NULL) {
|
if (!transition.is_null()) {
|
||||||
// Update the map of the object; no write barrier updating is
|
// Update the map of the object; no write barrier updating is
|
||||||
// needed because the map is never in new space.
|
// needed because the map is never in new space.
|
||||||
__ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset),
|
__ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset),
|
||||||
Immediate(Handle<Map>(transition)));
|
Immediate(transition));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust for the number of properties stored in the object. Even in the
|
// 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<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
String* name) {
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : value
|
// -- eax : value
|
||||||
// -- ecx : name
|
// -- ecx : name
|
||||||
@ -2712,21 +2712,16 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
Label miss;
|
Label miss;
|
||||||
|
|
||||||
// Generate store field code. Trashes the name register.
|
// Generate store field code. Trashes the name register.
|
||||||
GenerateStoreField(masm(),
|
GenerateStoreField(masm(), object, index, transition, edx, ecx, ebx, &miss);
|
||||||
object,
|
|
||||||
index,
|
|
||||||
transition,
|
|
||||||
edx, ecx, ebx,
|
|
||||||
&miss);
|
|
||||||
|
|
||||||
// Handle store cache miss.
|
// Handle store cache miss.
|
||||||
__ bind(&miss);
|
__ bind(&miss);
|
||||||
__ mov(ecx, Immediate(Handle<String>(name))); // restore name
|
__ mov(ecx, Immediate(name)); // restore name
|
||||||
Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
|
Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
|
||||||
__ jmp(ic, RelocInfo::CODE_TARGET);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(INTERCEPTOR, name);
|
return TryGetCode(INTERCEPTOR, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
|
Handle<Code> StoreStubCompiler::CompileStoreGlobal(
|
||||||
JSGlobalPropertyCell* cell,
|
Handle<GlobalObject> object,
|
||||||
String* name) {
|
Handle<JSGlobalPropertyCell> cell,
|
||||||
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : value
|
// -- eax : value
|
||||||
// -- ecx : name
|
// -- ecx : name
|
||||||
@ -2846,7 +2842,7 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
|
|||||||
__ j(not_equal, &miss);
|
__ j(not_equal, &miss);
|
||||||
|
|
||||||
// Compute the cell operand to use.
|
// Compute the cell operand to use.
|
||||||
__ mov(ebx, Immediate(Handle<JSGlobalPropertyCell>(cell)));
|
__ mov(ebx, Immediate(cell));
|
||||||
Operand cell_operand = FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset);
|
Operand cell_operand = FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset);
|
||||||
|
|
||||||
// Check that the value in the cell is not the hole. If it is, this
|
// 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<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
String* name) {
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : value
|
// -- eax : value
|
||||||
// -- ecx : key
|
// -- ecx : key
|
||||||
@ -2906,16 +2902,11 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ IncrementCounter(counters->keyed_store_field(), 1);
|
__ IncrementCounter(counters->keyed_store_field(), 1);
|
||||||
|
|
||||||
// Check that the name has not changed.
|
// Check that the name has not changed.
|
||||||
__ cmp(ecx, Immediate(Handle<String>(name)));
|
__ cmp(ecx, Immediate(name));
|
||||||
__ j(not_equal, &miss);
|
__ j(not_equal, &miss);
|
||||||
|
|
||||||
// Generate store field code. Trashes the name register.
|
// Generate store field code. Trashes the name register.
|
||||||
GenerateStoreField(masm(),
|
GenerateStoreField(masm(), object, index, transition, edx, ecx, ebx, &miss);
|
||||||
object,
|
|
||||||
index,
|
|
||||||
transition,
|
|
||||||
edx, ecx, ebx,
|
|
||||||
&miss);
|
|
||||||
|
|
||||||
// Handle store cache miss.
|
// Handle store cache miss.
|
||||||
__ bind(&miss);
|
__ bind(&miss);
|
||||||
@ -2924,40 +2915,37 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ jmp(ic, RelocInfo::CODE_TARGET);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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<Code> KeyedStoreStubCompiler::CompileStoreElement(
|
||||||
|
Handle<Map> receiver_map) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : value
|
// -- eax : value
|
||||||
// -- ecx : key
|
// -- ecx : key
|
||||||
// -- edx : receiver
|
// -- edx : receiver
|
||||||
// -- esp[0] : return address
|
// -- esp[0] : return address
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
Code* stub;
|
|
||||||
ElementsKind elements_kind = receiver_map->elements_kind();
|
ElementsKind elements_kind = receiver_map->elements_kind();
|
||||||
bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
||||||
MaybeObject* maybe_stub =
|
Handle<Code> stub =
|
||||||
KeyedStoreElementStub(is_jsarray, elements_kind).TryGetCode();
|
KeyedStoreElementStub(is_jsarray, elements_kind).GetCode();
|
||||||
if (!maybe_stub->To(&stub)) return maybe_stub;
|
|
||||||
__ DispatchMap(edx,
|
__ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
|
||||||
Handle<Map>(receiver_map),
|
|
||||||
Handle<Code>(stub),
|
|
||||||
DO_SMI_CHECK);
|
|
||||||
|
|
||||||
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
|
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
|
||||||
__ jmp(ic, RelocInfo::CODE_TARGET);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(NORMAL, NULL);
|
return GetCode(NORMAL, factory()->empty_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
|
||||||
MapList* receiver_maps,
|
MapHandleList* receiver_maps,
|
||||||
CodeList* handler_stubs,
|
CodeHandleList* handler_stubs,
|
||||||
MapList* transitioned_maps) {
|
MapHandleList* transitioned_maps) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- eax : value
|
// -- eax : value
|
||||||
// -- ecx : key
|
// -- ecx : key
|
||||||
@ -2969,15 +2957,14 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
|||||||
__ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
|
__ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
|
||||||
// ebx: receiver->map().
|
// ebx: receiver->map().
|
||||||
for (int i = 0; i < receiver_maps->length(); ++i) {
|
for (int i = 0; i < receiver_maps->length(); ++i) {
|
||||||
Handle<Map> map(receiver_maps->at(i));
|
__ cmp(edi, receiver_maps->at(i));
|
||||||
__ cmp(edi, map);
|
if (transitioned_maps->at(i).is_null()) {
|
||||||
if (transitioned_maps->at(i) == NULL) {
|
__ j(equal, handler_stubs->at(i));
|
||||||
__ j(equal, Handle<Code>(handler_stubs->at(i)));
|
|
||||||
} else {
|
} else {
|
||||||
Label next_map;
|
Label next_map;
|
||||||
__ j(not_equal, &next_map, Label::kNear);
|
__ j(not_equal, &next_map, Label::kNear);
|
||||||
__ mov(ebx, Immediate(Handle<Map>(transitioned_maps->at(i))));
|
__ mov(ebx, Immediate(transitioned_maps->at(i)));
|
||||||
__ jmp(Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET);
|
__ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
|
||||||
__ bind(&next_map);
|
__ bind(&next_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2986,7 +2973,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
|||||||
__ jmp(miss_ic, RelocInfo::CODE_TARGET);
|
__ jmp(miss_ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(NORMAL, NULL, MEGAMORPHIC);
|
return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,18 +237,6 @@ int SortedListBSearch(const List<T>& list, T elem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
List<T*>* UnwrapHandleList(List<T*>* destination, List<Handle<T> >* source) {
|
|
||||||
ASSERT(destination->is_empty());
|
|
||||||
int length = source->length();
|
|
||||||
for (int i = 0; i < length; ++i) {
|
|
||||||
Handle<T> handle = source->at(i);
|
|
||||||
destination->Add(handle.is_null() ? NULL : *handle);
|
|
||||||
}
|
|
||||||
return destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace v8::internal
|
} } // namespace v8::internal
|
||||||
|
|
||||||
#endif // V8_LIST_INL_H_
|
#endif // V8_LIST_INL_H_
|
||||||
|
@ -179,14 +179,6 @@ int SortedListBSearch(
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
int SortedListBSearch(const List<T>& list, T elem);
|
int SortedListBSearch(const List<T>& 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 <class T>
|
|
||||||
List<T*>* UnwrapHandleList(List<T*>* destination, List<Handle<T> >* source);
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace v8::internal
|
} } // namespace v8::internal
|
||||||
|
|
||||||
|
@ -417,20 +417,6 @@ Handle<Code> StubCache::ComputeKeyedLoadFunctionPrototype(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
|
||||||
int index,
|
|
||||||
Handle<Map> transition,
|
|
||||||
Handle<String> name) {
|
|
||||||
CALL_HEAP_FUNCTION(
|
|
||||||
isolate(),
|
|
||||||
(set_failure(NULL),
|
|
||||||
CompileStoreField(*object, index,
|
|
||||||
transition.is_null() ? NULL : *transition,
|
|
||||||
*name)),
|
|
||||||
Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> StubCache::ComputeStoreField(Handle<String> name,
|
Handle<Code> StubCache::ComputeStoreField(Handle<String> name,
|
||||||
Handle<JSObject> receiver,
|
Handle<JSObject> receiver,
|
||||||
int field_index,
|
int field_index,
|
||||||
@ -452,14 +438,6 @@ Handle<Code> StubCache::ComputeStoreField(Handle<String> name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(Handle<Map> map) {
|
|
||||||
CALL_HEAP_FUNCTION(isolate(),
|
|
||||||
(set_failure(NULL),
|
|
||||||
CompileStoreElement(*map)),
|
|
||||||
Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement(
|
Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement(
|
||||||
Handle<JSObject> receiver,
|
Handle<JSObject> receiver,
|
||||||
KeyedIC::StubKind stub_kind,
|
KeyedIC::StubKind stub_kind,
|
||||||
@ -515,29 +493,6 @@ Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> 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<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) {
|
Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) {
|
||||||
return (strict_mode == kStrictMode)
|
return (strict_mode == kStrictMode)
|
||||||
? isolate_->builtins()->Builtins::StoreIC_Normal_Strict()
|
? isolate_->builtins()->Builtins::StoreIC_Normal_Strict()
|
||||||
@ -545,17 +500,6 @@ Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> StoreStubCompiler::CompileStoreGlobal(
|
|
||||||
Handle<GlobalObject> object,
|
|
||||||
Handle<JSGlobalPropertyCell> holder,
|
|
||||||
Handle<String> name) {
|
|
||||||
CALL_HEAP_FUNCTION(isolate(),
|
|
||||||
(set_failure(NULL),
|
|
||||||
CompileStoreGlobal(*object, *holder, *name)),
|
|
||||||
Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name,
|
Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name,
|
||||||
Handle<GlobalObject> receiver,
|
Handle<GlobalObject> receiver,
|
||||||
Handle<JSGlobalPropertyCell> cell,
|
Handle<JSGlobalPropertyCell> cell,
|
||||||
@ -629,19 +573,6 @@ Handle<Code> StubCache::ComputeStoreInterceptor(Handle<String> name,
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
|
||||||
int index,
|
|
||||||
Handle<Map> transition,
|
|
||||||
Handle<String> name) {
|
|
||||||
CALL_HEAP_FUNCTION(
|
|
||||||
isolate(),
|
|
||||||
(set_failure(NULL),
|
|
||||||
CompileStoreField(*object, index,
|
|
||||||
transition.is_null() ? NULL : *transition,
|
|
||||||
*name)),
|
|
||||||
Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name,
|
Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name,
|
||||||
Handle<JSObject> receiver,
|
Handle<JSObject> receiver,
|
||||||
int field_index,
|
int field_index,
|
||||||
@ -1616,7 +1547,20 @@ MaybeObject* KeyedLoadStubCompiler::TryGetCode(PropertyType type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
|
Handle<Code> StoreStubCompiler::GetCode(PropertyType type,
|
||||||
|
Handle<String> name) {
|
||||||
|
Code::Flags flags =
|
||||||
|
Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
|
||||||
|
Handle<Code> 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::Flags flags =
|
||||||
Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
|
Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
|
||||||
MaybeObject* result = TryGetCodeWithFlags(flags, name);
|
MaybeObject* result = TryGetCodeWithFlags(flags, name);
|
||||||
@ -1633,22 +1577,15 @@ MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type,
|
Handle<Code> KeyedStoreStubCompiler::GetCode(PropertyType type,
|
||||||
String* name,
|
Handle<String> name,
|
||||||
InlineCacheState state) {
|
InlineCacheState state) {
|
||||||
Code::Flags flags =
|
Code::Flags flags =
|
||||||
Code::ComputeFlags(Code::KEYED_STORE_IC, state, strict_mode_, type);
|
Code::ComputeFlags(Code::KEYED_STORE_IC, state, strict_mode_, type);
|
||||||
MaybeObject* result = TryGetCodeWithFlags(flags, name);
|
Handle<Code> code = GetCodeWithFlags(flags, name);
|
||||||
if (!result->IsFailure()) {
|
PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, *name));
|
||||||
PROFILE(isolate(),
|
GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code));
|
||||||
CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
|
return code;
|
||||||
Code::cast(result->ToObjectUnchecked()),
|
|
||||||
name));
|
|
||||||
GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC,
|
|
||||||
name,
|
|
||||||
Code::cast(result->ToObjectUnchecked())));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,9 +440,9 @@ class StubCompiler BASE_EMBEDDED {
|
|||||||
Label* miss_label);
|
Label* miss_label);
|
||||||
|
|
||||||
static void GenerateStoreField(MacroAssembler* masm,
|
static void GenerateStoreField(MacroAssembler* masm,
|
||||||
JSObject* object,
|
Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
Register receiver_reg,
|
Register receiver_reg,
|
||||||
Register name_reg,
|
Register name_reg,
|
||||||
Register scratch,
|
Register scratch,
|
||||||
@ -708,11 +708,6 @@ class StoreStubCompiler: public StubCompiler {
|
|||||||
Handle<Map> transition,
|
Handle<Map> transition,
|
||||||
Handle<String> name);
|
Handle<String> name);
|
||||||
|
|
||||||
MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
|
|
||||||
int index,
|
|
||||||
Map* transition,
|
|
||||||
String* name);
|
|
||||||
|
|
||||||
Handle<Code> CompileStoreCallback(Handle<JSObject> object,
|
Handle<Code> CompileStoreCallback(Handle<JSObject> object,
|
||||||
Handle<AccessorInfo> callback,
|
Handle<AccessorInfo> callback,
|
||||||
Handle<String> name);
|
Handle<String> name);
|
||||||
@ -730,13 +725,10 @@ class StoreStubCompiler: public StubCompiler {
|
|||||||
Handle<JSGlobalPropertyCell> holder,
|
Handle<JSGlobalPropertyCell> holder,
|
||||||
Handle<String> name);
|
Handle<String> name);
|
||||||
|
|
||||||
MUST_USE_RESULT MaybeObject* CompileStoreGlobal(GlobalObject* object,
|
|
||||||
JSGlobalPropertyCell* holder,
|
|
||||||
String* name);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeObject* GetCode(PropertyType type, String* name);
|
MaybeObject* TryGetCode(PropertyType type, String* name);
|
||||||
|
|
||||||
|
Handle<Code> GetCode(PropertyType type, Handle<String> name);
|
||||||
|
|
||||||
StrictModeFlag strict_mode_;
|
StrictModeFlag strict_mode_;
|
||||||
};
|
};
|
||||||
@ -752,24 +744,12 @@ class KeyedStoreStubCompiler: public StubCompiler {
|
|||||||
Handle<Map> transition,
|
Handle<Map> transition,
|
||||||
Handle<String> name);
|
Handle<String> name);
|
||||||
|
|
||||||
MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
|
|
||||||
int index,
|
|
||||||
Map* transition,
|
|
||||||
String* name);
|
|
||||||
|
|
||||||
Handle<Code> CompileStoreElement(Handle<Map> receiver_map);
|
Handle<Code> CompileStoreElement(Handle<Map> receiver_map);
|
||||||
|
|
||||||
MUST_USE_RESULT MaybeObject* CompileStoreElement(Map* receiver_map);
|
|
||||||
|
|
||||||
Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps,
|
Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps,
|
||||||
CodeHandleList* handler_stubs,
|
CodeHandleList* handler_stubs,
|
||||||
MapHandleList* transitioned_maps);
|
MapHandleList* transitioned_maps);
|
||||||
|
|
||||||
MUST_USE_RESULT MaybeObject* CompileStorePolymorphic(
|
|
||||||
MapList* receiver_maps,
|
|
||||||
CodeList* handler_stubs,
|
|
||||||
MapList* transitioned_maps);
|
|
||||||
|
|
||||||
static void GenerateStoreFastElement(MacroAssembler* masm,
|
static void GenerateStoreFastElement(MacroAssembler* masm,
|
||||||
bool is_js_array,
|
bool is_js_array,
|
||||||
ElementsKind element_kind);
|
ElementsKind element_kind);
|
||||||
@ -783,8 +763,8 @@ class KeyedStoreStubCompiler: public StubCompiler {
|
|||||||
static void GenerateStoreDictionaryElement(MacroAssembler* masm);
|
static void GenerateStoreDictionaryElement(MacroAssembler* masm);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeObject* GetCode(PropertyType type,
|
Handle<Code> GetCode(PropertyType type,
|
||||||
String* name,
|
Handle<String> name,
|
||||||
InlineCacheState state = MONOMORPHIC);
|
InlineCacheState state = MONOMORPHIC);
|
||||||
|
|
||||||
StrictModeFlag strict_mode_;
|
StrictModeFlag strict_mode_;
|
||||||
|
@ -768,9 +768,9 @@ void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) {
|
|||||||
// Both name_reg and receiver_reg are preserved on jumps to miss_label,
|
// Both name_reg and receiver_reg are preserved on jumps to miss_label,
|
||||||
// but may be destroyed if store is successful.
|
// but may be destroyed if store is successful.
|
||||||
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
||||||
JSObject* object,
|
Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
Register receiver_reg,
|
Register receiver_reg,
|
||||||
Register name_reg,
|
Register name_reg,
|
||||||
Register scratch,
|
Register scratch,
|
||||||
@ -793,12 +793,12 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
|||||||
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
|
ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
|
||||||
|
|
||||||
// Perform map transition for the receiver if necessary.
|
// 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.
|
// The properties must be extended before we can store the value.
|
||||||
// We jump to a runtime call that extends the properties array.
|
// We jump to a runtime call that extends the properties array.
|
||||||
__ pop(scratch); // Return address.
|
__ pop(scratch); // Return address.
|
||||||
__ push(receiver_reg);
|
__ push(receiver_reg);
|
||||||
__ Push(Handle<Map>(transition));
|
__ Push(transition);
|
||||||
__ push(rax);
|
__ push(rax);
|
||||||
__ push(scratch);
|
__ push(scratch);
|
||||||
__ TailCallExternalReference(
|
__ TailCallExternalReference(
|
||||||
@ -809,11 +809,10 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transition != NULL) {
|
if (!transition.is_null()) {
|
||||||
// Update the map of the object; no write barrier updating is
|
// Update the map of the object; no write barrier updating is
|
||||||
// needed because the map is never in new space.
|
// needed because the map is never in new space.
|
||||||
__ Move(FieldOperand(receiver_reg, HeapObject::kMapOffset),
|
__ Move(FieldOperand(receiver_reg, HeapObject::kMapOffset), transition);
|
||||||
Handle<Map>(transition));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust for the number of properties stored in the object. Even in the
|
// 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<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
String* name) {
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- rax : value
|
// -- rax : value
|
||||||
// -- rcx : name
|
// -- rcx : name
|
||||||
@ -2582,12 +2581,7 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
Label miss;
|
Label miss;
|
||||||
|
|
||||||
// Generate store field code. Preserves receiver and name on jump to miss.
|
// Generate store field code. Preserves receiver and name on jump to miss.
|
||||||
GenerateStoreField(masm(),
|
GenerateStoreField(masm(), object, index, transition, rdx, rcx, rbx, &miss);
|
||||||
object,
|
|
||||||
index,
|
|
||||||
transition,
|
|
||||||
rdx, rcx, rbx,
|
|
||||||
&miss);
|
|
||||||
|
|
||||||
// Handle store cache miss.
|
// Handle store cache miss.
|
||||||
__ bind(&miss);
|
__ bind(&miss);
|
||||||
@ -2595,7 +2589,7 @@ MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ Jump(ic, RelocInfo::CODE_TARGET);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(INTERCEPTOR, name);
|
return TryGetCode(INTERCEPTOR, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
|
Handle<Code> StoreStubCompiler::CompileStoreGlobal(
|
||||||
JSGlobalPropertyCell* cell,
|
Handle<GlobalObject> object,
|
||||||
String* name) {
|
Handle<JSGlobalPropertyCell> cell,
|
||||||
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- rax : value
|
// -- rax : value
|
||||||
// -- rcx : name
|
// -- rcx : name
|
||||||
@ -2715,7 +2710,7 @@ MaybeObject* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
|
|||||||
__ j(not_equal, &miss);
|
__ j(not_equal, &miss);
|
||||||
|
|
||||||
// Compute the cell operand to use.
|
// Compute the cell operand to use.
|
||||||
__ Move(rbx, Handle<JSGlobalPropertyCell>(cell));
|
__ Move(rbx, cell);
|
||||||
Operand cell_operand = FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset);
|
Operand cell_operand = FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset);
|
||||||
|
|
||||||
// Check that the value in the cell is not the hole. If it is, this
|
// 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<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
|
||||||
int index,
|
int index,
|
||||||
Map* transition,
|
Handle<Map> transition,
|
||||||
String* name) {
|
Handle<String> name) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- rax : value
|
// -- rax : value
|
||||||
// -- rcx : key
|
// -- rcx : key
|
||||||
@ -2775,16 +2770,11 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ IncrementCounter(counters->keyed_store_field(), 1);
|
__ IncrementCounter(counters->keyed_store_field(), 1);
|
||||||
|
|
||||||
// Check that the name has not changed.
|
// Check that the name has not changed.
|
||||||
__ Cmp(rcx, Handle<String>(name));
|
__ Cmp(rcx, name);
|
||||||
__ j(not_equal, &miss);
|
__ j(not_equal, &miss);
|
||||||
|
|
||||||
// Generate store field code. Preserves receiver and name on jump to miss.
|
// Generate store field code. Preserves receiver and name on jump to miss.
|
||||||
GenerateStoreField(masm(),
|
GenerateStoreField(masm(), object, index, transition, rdx, rcx, rbx, &miss);
|
||||||
object,
|
|
||||||
index,
|
|
||||||
transition,
|
|
||||||
rdx, rcx, rbx,
|
|
||||||
&miss);
|
|
||||||
|
|
||||||
// Handle store cache miss.
|
// Handle store cache miss.
|
||||||
__ bind(&miss);
|
__ bind(&miss);
|
||||||
@ -2793,40 +2783,38 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
|
|||||||
__ Jump(ic, RelocInfo::CODE_TARGET);
|
__ Jump(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// 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<Code> KeyedStoreStubCompiler::CompileStoreElement(
|
||||||
|
Handle<Map> receiver_map) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- rax : value
|
// -- rax : value
|
||||||
// -- rcx : key
|
// -- rcx : key
|
||||||
// -- rdx : receiver
|
// -- rdx : receiver
|
||||||
// -- rsp[0] : return address
|
// -- rsp[0] : return address
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
Code* stub;
|
|
||||||
ElementsKind elements_kind = receiver_map->elements_kind();
|
ElementsKind elements_kind = receiver_map->elements_kind();
|
||||||
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
|
||||||
MaybeObject* maybe_stub =
|
Handle<Code> stub =
|
||||||
KeyedStoreElementStub(is_js_array, elements_kind).TryGetCode();
|
KeyedStoreElementStub(is_js_array, elements_kind).GetCode();
|
||||||
if (!maybe_stub->To(&stub)) return maybe_stub;
|
|
||||||
__ DispatchMap(rdx,
|
__ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
|
||||||
Handle<Map>(receiver_map),
|
|
||||||
Handle<Code>(stub),
|
|
||||||
DO_SMI_CHECK);
|
|
||||||
|
|
||||||
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
|
Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
|
||||||
__ jmp(ic, RelocInfo::CODE_TARGET);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(NORMAL, NULL);
|
return GetCode(NORMAL, factory()->empty_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
|
||||||
MapList* receiver_maps,
|
MapHandleList* receiver_maps,
|
||||||
CodeList* handler_stubs,
|
CodeHandleList* handler_stubs,
|
||||||
MapList* transitioned_maps) {
|
MapHandleList* transitioned_maps) {
|
||||||
// ----------- S t a t e -------------
|
// ----------- S t a t e -------------
|
||||||
// -- rax : value
|
// -- rax : value
|
||||||
// -- rcx : key
|
// -- rcx : key
|
||||||
@ -2840,17 +2828,14 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
|||||||
int receiver_count = receiver_maps->length();
|
int receiver_count = receiver_maps->length();
|
||||||
for (int i = 0; i < receiver_count; ++i) {
|
for (int i = 0; i < receiver_count; ++i) {
|
||||||
// Check map and tail call if there's a match
|
// Check map and tail call if there's a match
|
||||||
Handle<Map> map(receiver_maps->at(i));
|
__ Cmp(rdi, receiver_maps->at(i));
|
||||||
__ Cmp(rdi, map);
|
if (transitioned_maps->at(i).is_null()) {
|
||||||
if (transitioned_maps->at(i) == NULL) {
|
__ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET);
|
||||||
__ j(equal, Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET);
|
|
||||||
} else {
|
} else {
|
||||||
Label next_map;
|
Label next_map;
|
||||||
__ j(not_equal, &next_map, Label::kNear);
|
__ j(not_equal, &next_map, Label::kNear);
|
||||||
__ movq(rbx,
|
__ movq(rbx, transitioned_maps->at(i), RelocInfo::EMBEDDED_OBJECT);
|
||||||
Handle<Map>(transitioned_maps->at(i)),
|
__ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
|
||||||
RelocInfo::EMBEDDED_OBJECT);
|
|
||||||
__ jmp(Handle<Code>(handler_stubs->at(i)), RelocInfo::CODE_TARGET);
|
|
||||||
__ bind(&next_map);
|
__ bind(&next_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2860,7 +2845,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStorePolymorphic(
|
|||||||
__ jmp(ic, RelocInfo::CODE_TARGET);
|
__ jmp(ic, RelocInfo::CODE_TARGET);
|
||||||
|
|
||||||
// Return the generated code.
|
// Return the generated code.
|
||||||
return GetCode(NORMAL, NULL, MEGAMORPHIC);
|
return GetCode(NORMAL, factory()->empty_string(), MEGAMORPHIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user