Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: src/ia32/stub-cache-ia32.cc

Issue 12781004: Refactoring Store ICs. A first step towards polymorphic store ICs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: space nits Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/log.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/stub-cache-ia32.cc
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index d0b7881496ef0f3c80b78be9f7e41dab1b97163a..710b232c6fb7ee0dd2bc4609a97e6cf79456e391 100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -369,19 +369,6 @@ void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm,
}
-// Load a fast property out of a holder object (src). In-object properties
-// are loaded directly otherwise the property is loaded from the properties
-// fixed array.
-void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
- Register dst,
- Register src,
- Handle<JSObject> holder,
- PropertyIndex index) {
- DoGenerateFastPropertyLoad(
- masm, dst, src, index.is_inobject(holder), index.translate(holder));
-}
-
-
void StubCompiler::DoGenerateFastPropertyLoad(MacroAssembler* masm,
Register dst,
Register src,
@@ -729,28 +716,13 @@ class CallInterceptorCompiler BASE_EMBEDDED {
};
-void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
- ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
- Handle<Code> code = (kind == Code::LOAD_IC)
- ? masm->isolate()->builtins()->LoadIC_Miss()
- : masm->isolate()->builtins()->KeyedLoadIC_Miss();
- __ jmp(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind) {
- ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
- Handle<Code> code = (kind == Code::STORE_IC)
- ? masm->isolate()->builtins()->StoreIC_Miss()
- : masm->isolate()->builtins()->KeyedStoreIC_Miss();
- __ jmp(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) {
- Handle<Code> code =
- masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
- __ jmp(code, RelocInfo::CODE_TARGET);
+void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
+ Label* label,
+ Handle<Name> name) {
+ if (!label->is_unused()) {
+ __ bind(label);
+ __ mov(this->name(), Immediate(name));
+ }
}
@@ -763,9 +735,11 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
Handle<Name> name,
Register receiver_reg,
Register name_reg,
+ Register value_reg,
Register scratch1,
Register scratch2,
- Label* miss_label) {
+ Label* miss_label,
+ Label* miss_restore_name) {
LookupResult lookup(masm->isolate());
object->Lookup(*name, &lookup);
if (lookup.IsFound() && (lookup.IsReadOnly() || !lookup.IsCacheable())) {
@@ -800,16 +774,8 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
} while (holder->GetPrototype()->IsJSObject());
}
// We need an extra register, push
- __ push(name_reg);
- Label miss_pop, done_check;
CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg,
- scratch1, scratch2, name, &miss_pop);
- __ jmp(&done_check);
- __ bind(&miss_pop);
- __ pop(name_reg);
- __ jmp(miss_label);
- __ bind(&done_check);
- __ pop(name_reg);
+ scratch1, scratch2, name, miss_restore_name);
}
// Stub never generated for non-global objects that require access
@@ -857,11 +823,11 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
if (index < 0) {
// Set the property straight into the object.
int offset = object->map()->instance_size() + (index * kPointerSize);
- __ mov(FieldOperand(receiver_reg, offset), eax);
+ __ mov(FieldOperand(receiver_reg, offset), value_reg);
// Update the write barrier for the array address.
// Pass the value being stored in the now unused name_reg.
- __ mov(name_reg, eax);
+ __ mov(name_reg, value_reg);
__ RecordWriteField(receiver_reg,
offset,
name_reg,
@@ -876,7 +842,7 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
// Update the write barrier for the array address.
// Pass the value being stored in the now unused name_reg.
- __ mov(name_reg, eax);
+ __ mov(name_reg, value_reg);
__ RecordWriteField(scratch1,
offset,
name_reg,
@@ -885,6 +851,7 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
}
// Return the value (register eax).
+ ASSERT(value_reg.is(eax));
__ ret(0);
}
@@ -933,15 +900,16 @@ static void GenerateCheckPropertyCells(MacroAssembler* masm,
}
}
-#undef __
-#define __ ACCESS_MASM(masm())
-
-void StubCompiler::GenerateTailCall(Handle<Code> code) {
+void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
__ jmp(code, RelocInfo::CODE_TARGET);
}
+#undef __
+#define __ ACCESS_MASM(masm())
+
+
Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
Register object_reg,
Handle<JSObject> holder,
@@ -1062,7 +1030,7 @@ void BaseLoadStubCompiler::HandlerFrontendFooter(Label* success,
if (!miss->is_unused()) {
__ jmp(success);
__ bind(miss);
- GenerateLoadMiss(masm(), kind());
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
}
}
@@ -2581,39 +2549,6 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
}
-Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
- int index,
- Handle<Map> transition,
- Handle<Name> name) {
- // ----------- S t a t e -------------
- // -- eax : value
- // -- ecx : name
- // -- edx : receiver
- // -- esp[0] : return address
- // -----------------------------------
- Label miss;
-
- // Generate store field code. Trashes the name register.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- name,
- edx, ecx, ebx, edi,
- &miss);
- // Handle store cache miss.
- __ bind(&miss);
- __ mov(ecx, Immediate(name)); // restore name
- Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
-
- // Return the generated code.
- return GetCode(transition.is_null()
- ? Code::FIELD
- : Code::MAP_TRANSITION, name);
-}
-
-
Handle<Code> StoreStubCompiler::CompileStoreCallback(
Handle<Name> name,
Handle<JSObject> receiver,
@@ -2650,11 +2585,10 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback(
// Handle store cache miss.
__ bind(&miss);
__ pop(eax);
- Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
- return GetCode(Code::CALLBACKS, name);
+ return GetICCode(kind(), Code::CALLBACKS, name);
}
@@ -2727,11 +2661,10 @@ Handle<Code> StoreStubCompiler::CompileStoreViaSetter(
__ bind(&miss);
__ pop(ecx);
- Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
- return GetCode(Code::CALLBACKS, name);
+ return GetICCode(kind(), Code::CALLBACKS, name);
}
@@ -2763,7 +2696,7 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
__ push(edx); // receiver
__ push(ecx); // name
__ push(eax); // value
- __ push(Immediate(Smi::FromInt(strict_mode_)));
+ __ push(Immediate(Smi::FromInt(strict_mode())));
__ push(ebx); // restore return address
// Do tail-call to the runtime system.
@@ -2773,11 +2706,10 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
// Handle store cache miss.
__ bind(&miss);
- Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
- return GetCode(Code::INTERCEPTOR, name);
+ return GetICCode(kind(), Code::INTERCEPTOR, name);
}
@@ -2821,52 +2753,10 @@ Handle<Code> StoreStubCompiler::CompileStoreGlobal(
// Handle store cache miss.
__ bind(&miss);
__ IncrementCounter(counters->named_store_global_inline_miss(), 1);
- Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
- return GetCode(Code::NORMAL, name);
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
- int index,
- Handle<Map> transition,
- Handle<Name> name) {
- // ----------- S t a t e -------------
- // -- eax : value
- // -- ecx : key
- // -- edx : receiver
- // -- esp[0] : return address
- // -----------------------------------
- Label miss;
-
- Counters* counters = isolate()->counters();
- __ IncrementCounter(counters->keyed_store_field(), 1);
-
- // Check that the name has not changed.
- __ cmp(ecx, Immediate(name));
- __ j(not_equal, &miss);
-
- // Generate store field code. Trashes the name register.
- GenerateStoreField(masm(),
- object,
- index,
- transition,
- name,
- edx, ecx, ebx, edi,
- &miss);
-
- // Handle store cache miss.
- __ bind(&miss);
- __ DecrementCounter(counters->keyed_store_field(), 1);
- Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
-
- // Return the generated code.
- return GetCode(transition.is_null()
- ? Code::FIELD
- : Code::MAP_TRANSITION, name);
+ return GetICCode(kind(), Code::NORMAL, name);
}
@@ -2887,11 +2777,10 @@ Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
__ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
- Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
- __ jmp(ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string());
+ return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
}
@@ -2922,11 +2811,11 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
}
}
__ bind(&miss);
- Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss();
- __ jmp(miss_ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
+ return GetICCode(
+ kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
@@ -2964,6 +2853,20 @@ Register* KeyedLoadStubCompiler::registers() {
}
+Register* StoreStubCompiler::registers() {
+ // receiver, name, value, scratch1, scratch2, scratch3.
+ static Register registers[] = { edx, ecx, eax, ebx, edi, no_reg };
+ return registers;
+}
+
+
+Register* KeyedStoreStubCompiler::registers() {
+ // receiver, name, value, scratch1, scratch2, scratch3.
+ static Register registers[] = { edx, ecx, eax, ebx, edi, no_reg };
+ return registers;
+}
+
+
void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name,
Register name_reg,
Label* miss) {
@@ -2972,6 +2875,14 @@ void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name,
}
+void KeyedStoreStubCompiler::GenerateNameCheck(Handle<Name> name,
+ Register name_reg,
+ Label* miss) {
+ __ cmp(name_reg, Immediate(name));
+ __ j(not_equal, miss);
+}
+
+
#undef __
#define __ ACCESS_MASM(masm)
@@ -3071,7 +2982,7 @@ Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
__ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
}
- GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
+ TailCallBuiltin(masm(), Builtins::kKeyedLoadIC_Miss);
// Return the generated code.
return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
@@ -3100,7 +3011,7 @@ Handle<Code> BaseLoadStubCompiler::CompilePolymorphicIC(
}
__ bind(&miss);
- GenerateLoadMiss(masm(), kind());
+ TailCallBuiltin(masm(), MissBuiltin(kind()));
// Return the generated code.
InlineCacheState state =
@@ -3284,10 +3195,7 @@ void KeyedLoadStubCompiler::GenerateLoadDictionaryElement(
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
-
- Handle<Code> slow_ic =
- masm->isolate()->builtins()->KeyedLoadIC_Slow();
- __ jmp(slow_ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow);
__ bind(&miss_force_generic);
// ----------- S t a t e -------------
@@ -3295,10 +3203,7 @@ void KeyedLoadStubCompiler::GenerateLoadDictionaryElement(
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
-
- Handle<Code> miss_force_generic_ic =
- masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
- __ jmp(miss_force_generic_ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
}
@@ -3516,9 +3421,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray(
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
-
- Handle<Code> ic = masm->isolate()->builtins()->KeyedStoreIC_Slow();
- __ jmp(ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
// ----------- S t a t e -------------
// -- eax : value
@@ -3528,9 +3431,7 @@ void KeyedStoreStubCompiler::GenerateStoreExternalArray(
// -----------------------------------
__ bind(&miss_force_generic);
- Handle<Code> miss_ic =
- masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
- __ jmp(miss_ic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
}
@@ -3606,14 +3507,11 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement(
// Handle store cache miss, replacing the ic with the generic stub.
__ bind(&miss_force_generic);
- Handle<Code> ic_force_generic =
- masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
- __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
// Handle transition to other elements kinds without using the generic stub.
__ bind(&transition_elements_kind);
- Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
- __ jmp(ic_miss, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
if (is_js_array && IsGrowStoreMode(store_mode)) {
// Handle transition requiring the array to grow.
@@ -3684,8 +3582,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement(
__ mov(ecx, Immediate(0));
__ bind(&slow);
- Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
- __ jmp(ic_slow, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
}
}
@@ -3734,14 +3631,11 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
// Handle store cache miss, replacing the ic with the generic stub.
__ bind(&miss_force_generic);
- Handle<Code> ic_force_generic =
- masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
- __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
// Handle transition to other elements kinds without using the generic stub.
__ bind(&transition_elements_kind);
- Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
- __ jmp(ic_miss, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
if (is_js_array && IsGrowStoreMode(store_mode)) {
// Handle transition requiring the array to grow.
@@ -3822,8 +3716,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
__ mov(ecx, Immediate(0));
__ bind(&slow);
- Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
- __ jmp(ic_slow, RelocInfo::CODE_TARGET);
+ TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
}
}
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698