Commit 8f2245bf authored by ishell's avatar ishell Committed by Commit bot

[ic] Fix StoreIC_SlowSloppy/Strict builtins.

... by using KeyedStoreIC_Slow builtin instead. The issue with hard-coded
language mode is that the stub can be re-used through megamorphic stub cache for
an IC with incompatible language mode. KeyedStoreIC_Slow already does the
right thing - it decodes the language mode from the IC slot kind.

This CL also fixes the code kinds of the slow IC handlers. The code kind of
IC handlers is used only for checking that the handler was added to the right
megamorphic stub cache, which expect the handlers' code kinds to be either
Code::LOAD_IC or Code::STORE_IC.

And the megamorphic builtins are just helper code stubs that are called from
IC dispatchers, therefore they should have BUILTIN code kind. Same applies to
the other stubs which are neither IC dispatchers nor handlers.

BUG=v8:5917

Review-Url: https://codereview.chromium.org/2677603004
Cr-Commit-Position: refs/heads/master@{#42958}
parent 01c2b455
......@@ -212,35 +212,5 @@ void Builtins::Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) {
NamedStoreHandlerCompiler::GenerateStoreViaSetterForDeopt(masm);
}
namespace {
void Generate_StoreIC_Slow(compiler::CodeAssemblerState* state,
LanguageMode language_mode) {
typedef compiler::Node Node;
typedef StoreWithVectorDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* receiver = assembler.Parameter(Descriptor::kReceiver);
Node* name = assembler.Parameter(Descriptor::kName);
Node* value = assembler.Parameter(Descriptor::kValue);
Node* context = assembler.Parameter(Descriptor::kContext);
Node* lang_mode = assembler.SmiConstant(Smi::FromInt(language_mode));
// The slow case calls into the runtime to complete the store without causing
// an IC miss that would otherwise cause a transition to the generic stub.
assembler.TailCallRuntime(Runtime::kSetProperty, context, receiver, name,
value, lang_mode);
}
} // anonymous namespace
void Builtins::Generate_StoreIC_SlowSloppy(
compiler::CodeAssemblerState* state) {
Generate_StoreIC_Slow(state, SLOPPY);
}
void Builtins::Generate_StoreIC_SlowStrict(
compiler::CodeAssemblerState* state) {
Generate_StoreIC_Slow(state, STRICT);
}
} // namespace internal
} // namespace v8
......@@ -224,30 +224,27 @@ class Isolate;
TFS(GetSuperConstructor, BUILTIN, kNoExtraICState, TypeConversion) \
\
/* Handlers */ \
TFS(LoadICProtoArray, HANDLER, Code::LOAD_IC, LoadICProtoArray) \
TFS(LoadICProtoArrayThrowIfNonexistent, HANDLER, Code::LOAD_IC, \
TFS(LoadICProtoArray, BUILTIN, kNoExtraICState, LoadICProtoArray) \
TFS(LoadICProtoArrayThrowIfNonexistent, BUILTIN, kNoExtraICState, \
LoadICProtoArray) \
TFS(KeyedLoadIC_Megamorphic, KEYED_LOAD_IC, kNoExtraICState, LoadWithVector) \
TFS(KeyedLoadIC_Megamorphic, BUILTIN, kNoExtraICState, LoadWithVector) \
TFS(KeyedLoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
TFS(KeyedLoadIC_Slow, HANDLER, Code::KEYED_LOAD_IC, LoadWithVector) \
TFS(KeyedStoreIC_Megamorphic, KEYED_STORE_IC, kNoExtraICState, \
StoreWithVector) \
TFS(KeyedStoreIC_Megamorphic_Strict, KEYED_STORE_IC, kNoExtraICState, \
TFS(KeyedLoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector) \
TFS(KeyedStoreIC_Megamorphic, BUILTIN, kNoExtraICState, StoreWithVector) \
TFS(KeyedStoreIC_Megamorphic_Strict, BUILTIN, kNoExtraICState, \
StoreWithVector) \
TFS(KeyedStoreIC_Miss, BUILTIN, kNoExtraICState, StoreWithVector) \
TFS(KeyedStoreIC_Slow, HANDLER, Code::KEYED_STORE_IC, StoreWithVector) \
TFS(KeyedStoreIC_Slow, HANDLER, Code::STORE_IC, StoreWithVector) \
TFS(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector) \
TFS(LoadGlobalIC_Slow, HANDLER, Code::LOAD_GLOBAL_IC, LoadGlobalWithVector) \
TFS(LoadField, HANDLER, Code::LOAD_IC, LoadField) \
ASH(LoadIC_Getter_ForDeopt, LOAD_IC, kNoExtraICState) \
TFS(LoadField, BUILTIN, kNoExtraICState, LoadField) \
ASH(LoadIC_Getter_ForDeopt, BUILTIN, kNoExtraICState) \
TFS(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
TFS(LoadIC_Normal, HANDLER, Code::LOAD_IC, LoadWithVector) \
TFS(LoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector) \
TFS(StoreIC_Miss, BUILTIN, kNoExtraICState, StoreWithVector) \
TFS(StoreIC_Normal, HANDLER, Code::STORE_IC, StoreWithVector) \
ASH(StoreIC_Setter_ForDeopt, STORE_IC, kNoExtraICState) \
TFS(StoreIC_SlowSloppy, HANDLER, Code::STORE_IC, StoreWithVector) \
TFS(StoreIC_SlowStrict, HANDLER, Code::STORE_IC, StoreWithVector) \
ASH(StoreIC_Setter_ForDeopt, BUILTIN, kNoExtraICState) \
\
/* Built-in functions for Javascript */ \
/* Special internal builtins */ \
......
......@@ -2632,7 +2632,6 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) {
}
}
// Used from ic-<arch>.cc.
RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) {
HandleScope scope(isolate);
......
......@@ -380,19 +380,8 @@ class StoreIC : public IC {
protected:
// Stub accessors.
Handle<Code> slow_stub() const {
// TODO(ishell): don't hard-code language mode into the handler because
// this handler can be re-used through megamorphic stub cache for wrong
// language mode.
// The slow stub must decode the language mode from the IC kind.
switch (language_mode()) {
case SLOPPY:
return isolate()->builtins()->StoreIC_SlowSloppy();
case STRICT:
return isolate()->builtins()->StoreIC_SlowStrict();
default:
UNREACHABLE();
return Handle<Code>();
}
// StoreIC and KeyedStoreIC share the same slow stub.
return isolate()->builtins()->KeyedStoreIC_Slow();
}
// Update the inline cache and the global stub cache based on the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment