Add premonomorphic store ICs

BUG=
R=jkummerow@chromium.org

Review URL: https://chromiumcodereview.appspot.com/23442016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16509 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2013-09-03 13:33:54 +00:00
parent c1a35b4e24
commit 56d554588f
4 changed files with 68 additions and 14 deletions

View File

@ -1461,6 +1461,16 @@ static void Generate_StoreIC_Initialize_Strict(MacroAssembler* masm) {
}
static void Generate_StoreIC_PreMonomorphic(MacroAssembler* masm) {
StoreIC::GeneratePreMonomorphic(masm);
}
static void Generate_StoreIC_PreMonomorphic_Strict(MacroAssembler* masm) {
StoreIC::GeneratePreMonomorphic(masm);
}
static void Generate_StoreIC_Miss(MacroAssembler* masm) {
StoreIC::GenerateMiss(masm);
}
@ -1546,6 +1556,16 @@ static void Generate_KeyedStoreIC_Initialize_Strict(MacroAssembler* masm) {
}
static void Generate_KeyedStoreIC_PreMonomorphic(MacroAssembler* masm) {
KeyedStoreIC::GeneratePreMonomorphic(masm);
}
static void Generate_KeyedStoreIC_PreMonomorphic_Strict(MacroAssembler* masm) {
KeyedStoreIC::GeneratePreMonomorphic(masm);
}
static void Generate_KeyedStoreIC_NonStrictArguments(MacroAssembler* masm) {
KeyedStoreIC::GenerateNonStrictArguments(masm);
}

View File

@ -162,6 +162,8 @@ enum BuiltinExtraArguments {
\
V(StoreIC_Initialize, STORE_IC, UNINITIALIZED, \
Code::kNoExtraICState) \
V(StoreIC_PreMonomorphic, STORE_IC, PREMONOMORPHIC, \
Code::kNoExtraICState) \
V(StoreIC_Normal, STORE_IC, MONOMORPHIC, \
Code::kNoExtraICState) \
V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, \
@ -174,6 +176,8 @@ enum BuiltinExtraArguments {
Code::kNoExtraICState) \
V(StoreIC_Initialize_Strict, STORE_IC, UNINITIALIZED, \
kStrictMode) \
V(StoreIC_PreMonomorphic_Strict, STORE_IC, PREMONOMORPHIC, \
kStrictMode) \
V(StoreIC_Normal_Strict, STORE_IC, MONOMORPHIC, \
kStrictMode) \
V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \
@ -185,11 +189,15 @@ enum BuiltinExtraArguments {
\
V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, \
Code::kNoExtraICState) \
V(KeyedStoreIC_PreMonomorphic, KEYED_STORE_IC, PREMONOMORPHIC, \
Code::kNoExtraICState) \
V(KeyedStoreIC_Generic, KEYED_STORE_IC, GENERIC, \
Code::kNoExtraICState) \
\
V(KeyedStoreIC_Initialize_Strict, KEYED_STORE_IC, UNINITIALIZED, \
kStrictMode) \
V(KeyedStoreIC_PreMonomorphic_Strict, KEYED_STORE_IC, PREMONOMORPHIC, \
kStrictMode) \
V(KeyedStoreIC_Generic_Strict, KEYED_STORE_IC, GENERIC, \
kStrictMode) \
V(KeyedStoreIC_NonStrictArguments, KEYED_STORE_IC, MONOMORPHIC, \

View File

@ -1711,22 +1711,30 @@ MaybeObject* StoreIC::Store(State state,
}
LookupResult lookup(isolate());
if (LookupForWrite(receiver, name, value, &lookup, &state)) {
if (FLAG_use_ic) {
UpdateCaches(&lookup, state, strict_mode, receiver, name, value);
}
} else if (strict_mode == kStrictMode &&
!(lookup.IsProperty() && lookup.IsReadOnly()) &&
IsUndeclaredGlobal(object)) {
bool can_store = LookupForWrite(receiver, name, value, &lookup, &state);
if (!can_store &&
strict_mode == kStrictMode &&
!(lookup.IsProperty() && lookup.IsReadOnly()) &&
IsUndeclaredGlobal(object)) {
// Strict mode doesn't allow setting non-existent global property.
return ReferenceError("not_defined", name);
} else if (FLAG_use_ic &&
(!name->IsCacheable(isolate()) ||
lookup.IsNormal() ||
(lookup.IsField() && lookup.CanHoldValue(value)))) {
Handle<Code> stub = strict_mode == kStrictMode
? generic_stub_strict() : generic_stub();
set_target(*stub);
}
if (FLAG_use_ic) {
if (state == UNINITIALIZED) {
Handle<Code> stub = (strict_mode == kStrictMode)
? pre_monomorphic_stub_strict()
: pre_monomorphic_stub();
set_target(*stub);
TRACE_IC("StoreIC", name, state, *stub);
} else if (can_store) {
UpdateCaches(&lookup, state, strict_mode, receiver, name, value);
} else if (!name->IsCacheable(isolate()) ||
lookup.IsNormal() ||
(lookup.IsField() && lookup.CanHoldValue(value))) {
Handle<Code> stub = (strict_mode == kStrictMode) ? generic_stub_strict()
: generic_stub();
set_target(*stub);
}
}
// Set the property.

View File

@ -527,6 +527,9 @@ class StoreIC: public IC {
// Code generators for stub routines. Only called once at startup.
static void GenerateSlow(MacroAssembler* masm);
static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
static void GeneratePreMonomorphic(MacroAssembler* masm) {
GenerateMiss(masm);
}
static void GenerateMiss(MacroAssembler* masm);
static void GenerateMegamorphic(MacroAssembler* masm,
StrictModeFlag strict_mode);
@ -558,6 +561,12 @@ class StoreIC: public IC {
virtual Handle<Code> generic_stub_strict() const {
return isolate()->builtins()->StoreIC_Generic_Strict();
}
virtual Handle<Code> pre_monomorphic_stub() const {
return isolate()->builtins()->StoreIC_PreMonomorphic();
}
virtual Handle<Code> pre_monomorphic_stub_strict() const {
return isolate()->builtins()->StoreIC_PreMonomorphic_Strict();
}
virtual Handle<Code> global_proxy_stub() {
return isolate()->builtins()->StoreIC_GlobalProxy();
}
@ -643,6 +652,9 @@ class KeyedStoreIC: public StoreIC {
static void GenerateInitialize(MacroAssembler* masm) {
GenerateMiss(masm, MISS);
}
static void GeneratePreMonomorphic(MacroAssembler* masm) {
GenerateMiss(masm, MISS);
}
static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic);
static void GenerateSlow(MacroAssembler* masm);
static void GenerateRuntimeSetProperty(MacroAssembler* masm,
@ -660,6 +672,12 @@ class KeyedStoreIC: public StoreIC {
Handle<Object> value);
virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { }
virtual Handle<Code> pre_monomorphic_stub() const {
return isolate()->builtins()->KeyedStoreIC_PreMonomorphic();
}
virtual Handle<Code> pre_monomorphic_stub_strict() const {
return isolate()->builtins()->KeyedStoreIC_PreMonomorphic_Strict();
}
virtual Handle<Code> megamorphic_stub() {
return isolate()->builtins()->KeyedStoreIC_Generic();
}