Commit 2ef6862e authored by ishell's avatar ishell Committed by Commit bot

[builtins] Turn LoadIC_Miss and LoadIC_Slow builtins to TurboFan code stubs.

Review-Url: https://codereview.chromium.org/2033423002
Cr-Commit-Position: refs/heads/master@{#36915}
parent 7ceed92a
...@@ -5334,106 +5334,108 @@ BUILTIN(HandleApiCallAsConstructor) { ...@@ -5334,106 +5334,108 @@ BUILTIN(HandleApiCallAsConstructor) {
return HandleApiCallAsFunctionOrConstructor(isolate, true, args); return HandleApiCallAsFunctionOrConstructor(isolate, true, args);
} }
namespace {
static void Generate_LoadIC_Miss(MacroAssembler* masm) { void Generate_LoadIC_Miss(CodeStubAssembler* assembler) {
LoadIC::GenerateMiss(masm); typedef compiler::Node Node;
}
Node* receiver = assembler->Parameter(0);
Node* name = assembler->Parameter(1);
Node* slot = assembler->Parameter(2);
Node* vector = assembler->Parameter(3);
Node* context = assembler->Parameter(4);
static void Generate_LoadIC_Normal(MacroAssembler* masm) { assembler->TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name,
LoadIC::GenerateNormal(masm); slot, vector);
} }
void Generate_LoadIC_Normal(MacroAssembler* masm) {
LoadIC::GenerateNormal(masm);
}
static void Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) { void Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) {
NamedLoadHandlerCompiler::GenerateLoadViaGetterForDeopt(masm); NamedLoadHandlerCompiler::GenerateLoadViaGetterForDeopt(masm);
} }
void Generate_LoadIC_Slow(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
static void Generate_LoadIC_Slow(MacroAssembler* masm) { Node* receiver = assembler->Parameter(0);
LoadIC::GenerateRuntimeGetProperty(masm); Node* name = assembler->Parameter(1);
} // Node* slot = assembler->Parameter(2);
// Node* vector = assembler->Parameter(3);
Node* context = assembler->Parameter(4);
assembler->TailCallRuntime(Runtime::kGetProperty, context, receiver, name);
}
static void Generate_KeyedLoadIC_Slow(MacroAssembler* masm) { void Generate_KeyedLoadIC_Slow(MacroAssembler* masm) {
KeyedLoadIC::GenerateRuntimeGetProperty(masm); KeyedLoadIC::GenerateRuntimeGetProperty(masm);
} }
void Generate_KeyedLoadIC_Miss(MacroAssembler* masm) {
static void Generate_KeyedLoadIC_Miss(MacroAssembler* masm) {
KeyedLoadIC::GenerateMiss(masm); KeyedLoadIC::GenerateMiss(masm);
} }
void Generate_KeyedLoadIC_Megamorphic(MacroAssembler* masm) {
static void Generate_KeyedLoadIC_Megamorphic(MacroAssembler* masm) {
KeyedLoadIC::GenerateMegamorphic(masm); KeyedLoadIC::GenerateMegamorphic(masm);
} }
void Generate_StoreIC_Miss(MacroAssembler* masm) {
static void Generate_StoreIC_Miss(MacroAssembler* masm) {
StoreIC::GenerateMiss(masm); StoreIC::GenerateMiss(masm);
} }
void Generate_StoreIC_Normal(MacroAssembler* masm) {
static void Generate_StoreIC_Normal(MacroAssembler* masm) {
StoreIC::GenerateNormal(masm); StoreIC::GenerateNormal(masm);
} }
void Generate_StoreIC_Slow(MacroAssembler* masm) {
static void Generate_StoreIC_Slow(MacroAssembler* masm) {
NamedStoreHandlerCompiler::GenerateSlow(masm); NamedStoreHandlerCompiler::GenerateSlow(masm);
} }
void Generate_KeyedStoreIC_Slow(MacroAssembler* masm) {
static void Generate_KeyedStoreIC_Slow(MacroAssembler* masm) {
ElementHandlerCompiler::GenerateStoreSlow(masm); ElementHandlerCompiler::GenerateStoreSlow(masm);
} }
void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) {
static void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) {
NamedStoreHandlerCompiler::GenerateStoreViaSetterForDeopt(masm); NamedStoreHandlerCompiler::GenerateStoreViaSetterForDeopt(masm);
} }
static void Generate_StoreIC_Megamorphic(MacroAssembler* masm) { void Generate_StoreIC_Megamorphic(MacroAssembler* masm) {
StoreIC::GenerateMegamorphic(masm); StoreIC::GenerateMegamorphic(masm);
} }
static void Generate_StoreIC_Megamorphic_Strict(MacroAssembler* masm) { void Generate_StoreIC_Megamorphic_Strict(MacroAssembler* masm) {
StoreIC::GenerateMegamorphic(masm); StoreIC::GenerateMegamorphic(masm);
} }
void Generate_KeyedStoreIC_Megamorphic(MacroAssembler* masm) {
static void Generate_KeyedStoreIC_Megamorphic(MacroAssembler* masm) {
KeyedStoreIC::GenerateMegamorphic(masm, SLOPPY); KeyedStoreIC::GenerateMegamorphic(masm, SLOPPY);
} }
void Generate_KeyedStoreIC_Megamorphic_Strict(MacroAssembler* masm) {
static void Generate_KeyedStoreIC_Megamorphic_Strict(MacroAssembler* masm) {
KeyedStoreIC::GenerateMegamorphic(masm, STRICT); KeyedStoreIC::GenerateMegamorphic(masm, STRICT);
} }
void Generate_KeyedStoreIC_Miss(MacroAssembler* masm) {
static void Generate_KeyedStoreIC_Miss(MacroAssembler* masm) {
KeyedStoreIC::GenerateMiss(masm); KeyedStoreIC::GenerateMiss(masm);
} }
void Generate_Return_DebugBreak(MacroAssembler* masm) {
static void Generate_Return_DebugBreak(MacroAssembler* masm) {
DebugCodegen::GenerateDebugBreakStub(masm, DebugCodegen::GenerateDebugBreakStub(masm,
DebugCodegen::SAVE_RESULT_REGISTER); DebugCodegen::SAVE_RESULT_REGISTER);
} }
void Generate_Slot_DebugBreak(MacroAssembler* masm) {
static void Generate_Slot_DebugBreak(MacroAssembler* masm) {
DebugCodegen::GenerateDebugBreakStub(masm, DebugCodegen::GenerateDebugBreakStub(masm,
DebugCodegen::IGNORE_RESULT_REGISTER); DebugCodegen::IGNORE_RESULT_REGISTER);
} }
void Generate_FrameDropper_LiveEdit(MacroAssembler* masm) {
static void Generate_FrameDropper_LiveEdit(MacroAssembler* masm) {
DebugCodegen::GenerateFrameDropperLiveEdit(masm); DebugCodegen::GenerateFrameDropperLiveEdit(masm);
} }
} // namespace
Builtins::Builtins() : initialized_(false) { Builtins::Builtins() : initialized_(false) {
memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count);
...@@ -5518,7 +5520,8 @@ Handle<Code> MacroAssemblerBuilder(Isolate* isolate, ...@@ -5518,7 +5520,8 @@ Handle<Code> MacroAssemblerBuilder(Isolate* isolate,
return isolate->factory()->NewCode(desc, flags, masm.CodeObject()); return isolate->factory()->NewCode(desc, flags, masm.CodeObject());
} }
Handle<Code> CodeStubAssemblerBuilder(Isolate* isolate, // Builder for builtins implemented in TurboFan with JS linkage.
Handle<Code> CodeStubAssemblerBuilderJS(Isolate* isolate,
BuiltinDesc const* builtin_desc) { BuiltinDesc const* builtin_desc) {
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
CodeStubAssembler assembler(isolate, &zone, builtin_desc->argc, CodeStubAssembler assembler(isolate, &zone, builtin_desc->argc,
...@@ -5530,6 +5533,25 @@ Handle<Code> CodeStubAssemblerBuilder(Isolate* isolate, ...@@ -5530,6 +5533,25 @@ Handle<Code> CodeStubAssemblerBuilder(Isolate* isolate,
return assembler.GenerateCode(); return assembler.GenerateCode();
} }
// Builder for builtins implemented in TurboFan with CallStub linkage.
Handle<Code> CodeStubAssemblerBuilderCS(Isolate* isolate,
BuiltinDesc const* builtin_desc) {
Zone zone(isolate->allocator());
// The interface descriptor with given key must be initialized at this point
// and this construction just queries the details from the descriptors table.
CallInterfaceDescriptor descriptor(
isolate, static_cast<CallDescriptors::Key>(builtin_desc->argc));
// Ensure descriptor is already initialized.
DCHECK_NOT_NULL(descriptor.GetFunctionType());
CodeStubAssembler assembler(isolate, &zone, descriptor, builtin_desc->flags,
builtin_desc->s_name);
// Generate the code/adaptor.
typedef void (*Generator)(CodeStubAssembler*);
Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator);
g(&assembler);
return assembler.GenerateCode();
}
} // namespace } // namespace
// Define array of pointers to generators and C builtin functions. // Define array of pointers to generators and C builtin functions.
...@@ -5570,7 +5592,7 @@ void Builtins::InitBuiltinFunctionTable() { ...@@ -5570,7 +5592,7 @@ void Builtins::InitBuiltinFunctionTable() {
++functions; ++functions;
#define DEF_FUNCTION_PTR_T(aname, aargc) \ #define DEF_FUNCTION_PTR_T(aname, aargc) \
functions->builder = &CodeStubAssemblerBuilder; \ functions->builder = &CodeStubAssemblerBuilderJS; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \ functions->generator = FUNCTION_ADDR(Generate_##aname); \
functions->c_code = NULL; \ functions->c_code = NULL; \
functions->s_name = #aname; \ functions->s_name = #aname; \
...@@ -5580,6 +5602,17 @@ void Builtins::InitBuiltinFunctionTable() { ...@@ -5580,6 +5602,17 @@ void Builtins::InitBuiltinFunctionTable() {
functions->argc = aargc; \ functions->argc = aargc; \
++functions; ++functions;
#define DEF_FUNCTION_PTR_S(aname, kind, extra, interface_descriptor) \
functions->builder = &CodeStubAssemblerBuilderCS; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \
functions->c_code = NULL; \
functions->s_name = #aname; \
functions->name = k##aname; \
functions->flags = Code::ComputeFlags(Code::kind, extra); \
functions->extra_args = BuiltinExtraArguments::kNone; \
functions->argc = CallDescriptors::interface_descriptor; \
++functions;
#define DEF_FUNCTION_PTR_H(aname, kind) \ #define DEF_FUNCTION_PTR_H(aname, kind) \
functions->builder = &MacroAssemblerBuilder; \ functions->builder = &MacroAssemblerBuilder; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \ functions->generator = FUNCTION_ADDR(Generate_##aname); \
...@@ -5594,13 +5627,15 @@ void Builtins::InitBuiltinFunctionTable() { ...@@ -5594,13 +5627,15 @@ void Builtins::InitBuiltinFunctionTable() {
BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) BUILTIN_LIST_C(DEF_FUNCTION_PTR_C)
BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) BUILTIN_LIST_A(DEF_FUNCTION_PTR_A)
BUILTIN_LIST_T(DEF_FUNCTION_PTR_T) BUILTIN_LIST_T(DEF_FUNCTION_PTR_T)
BUILTIN_LIST_S(DEF_FUNCTION_PTR_S)
BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) BUILTIN_LIST_H(DEF_FUNCTION_PTR_H)
BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A)
#undef DEF_FUNCTION_PTR_C #undef DEF_FUNCTION_PTR_C
#undef DEF_FUNCTION_PTR_A #undef DEF_FUNCTION_PTR_A
#undef DEF_FUNCTION_PTR_H
#undef DEF_FUNCTION_PTR_T #undef DEF_FUNCTION_PTR_T
#undef DEF_FUNCTION_PTR_S
#undef DEF_FUNCTION_PTR_H
} }
...@@ -5610,6 +5645,11 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { ...@@ -5610,6 +5645,11 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
// Create a scope for the handles in the builtins. // Create a scope for the handles in the builtins.
HandleScope scope(isolate); HandleScope scope(isolate);
#define INITIALIZE_CALL_DESCRIPTOR(name, kind, extra, interface_descriptor) \
{ interface_descriptor##Descriptor descriptor(isolate); }
BUILTIN_LIST_S(INITIALIZE_CALL_DESCRIPTOR)
#undef INITIALIZE_CALL_DESCRIPTOR
const BuiltinDesc* functions = builtin_function_table.functions(); const BuiltinDesc* functions = builtin_function_table.functions();
// Traverse the list of builtins and generate an adaptor in a // Traverse the list of builtins and generate an adaptor in a
...@@ -5930,6 +5970,11 @@ Handle<Code> Builtins::name() { \ ...@@ -5930,6 +5970,11 @@ Handle<Code> Builtins::name() { \
Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
return Handle<Code>(code_address); \ return Handle<Code>(code_address); \
} }
#define DEFINE_BUILTIN_ACCESSOR_S(name, kind, extra, interface_descriptor) \
Handle<Code> Builtins::name() { \
Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
return Handle<Code>(code_address); \
}
#define DEFINE_BUILTIN_ACCESSOR_H(name, kind) \ #define DEFINE_BUILTIN_ACCESSOR_H(name, kind) \
Handle<Code> Builtins::name() { \ Handle<Code> Builtins::name() { \
Code** code_address = \ Code** code_address = \
...@@ -5939,11 +5984,13 @@ Handle<Code> Builtins::name() { \ ...@@ -5939,11 +5984,13 @@ Handle<Code> Builtins::name() { \
BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
BUILTIN_LIST_S(DEFINE_BUILTIN_ACCESSOR_S)
BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
#undef DEFINE_BUILTIN_ACCESSOR_C #undef DEFINE_BUILTIN_ACCESSOR_C
#undef DEFINE_BUILTIN_ACCESSOR_A #undef DEFINE_BUILTIN_ACCESSOR_A
#undef DEFINE_BUILTIN_ACCESSOR_T #undef DEFINE_BUILTIN_ACCESSOR_T
#undef DEFINE_BUILTIN_ACCESSOR_S
#undef DEFINE_BUILTIN_ACCESSOR_H #undef DEFINE_BUILTIN_ACCESSOR_H
} // namespace internal } // namespace internal
......
...@@ -253,7 +253,6 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) { ...@@ -253,7 +253,6 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
V(InterpreterPushArgsAndConstruct, BUILTIN, kNoExtraICState) \ V(InterpreterPushArgsAndConstruct, BUILTIN, kNoExtraICState) \
V(InterpreterEnterBytecodeDispatch, BUILTIN, kNoExtraICState) \ V(InterpreterEnterBytecodeDispatch, BUILTIN, kNoExtraICState) \
\ \
V(LoadIC_Miss, BUILTIN, kNoExtraICState) \
V(KeyedLoadIC_Miss, BUILTIN, kNoExtraICState) \ V(KeyedLoadIC_Miss, BUILTIN, kNoExtraICState) \
V(StoreIC_Miss, BUILTIN, kNoExtraICState) \ V(StoreIC_Miss, BUILTIN, kNoExtraICState) \
V(KeyedStoreIC_Miss, BUILTIN, kNoExtraICState) \ V(KeyedStoreIC_Miss, BUILTIN, kNoExtraICState) \
...@@ -340,9 +339,13 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) { ...@@ -340,9 +339,13 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
V(AtomicsLoad, 3) \ V(AtomicsLoad, 3) \
V(AtomicsStore, 4) V(AtomicsStore, 4)
// Define list of builtins implemented in TurboFan (with CallStub linkage).
#define BUILTIN_LIST_S(V) \
V(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
V(LoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector)
// Define list of builtin handlers implemented in assembly. // Define list of builtin handlers implemented in assembly.
#define BUILTIN_LIST_H(V) \ #define BUILTIN_LIST_H(V) \
V(LoadIC_Slow, LOAD_IC) \
V(KeyedLoadIC_Slow, KEYED_LOAD_IC) \ V(KeyedLoadIC_Slow, KEYED_LOAD_IC) \
V(StoreIC_Slow, STORE_IC) \ V(StoreIC_Slow, STORE_IC) \
V(KeyedStoreIC_Slow, KEYED_STORE_IC) \ V(KeyedStoreIC_Slow, KEYED_STORE_IC) \
...@@ -378,13 +381,15 @@ class Builtins { ...@@ -378,13 +381,15 @@ class Builtins {
#define DEF_ENUM_C(name, ignore) k##name, #define DEF_ENUM_C(name, ignore) k##name,
#define DEF_ENUM_A(name, kind, extra) k##name, #define DEF_ENUM_A(name, kind, extra) k##name,
#define DEF_ENUM_T(name, argc) k##name, #define DEF_ENUM_T(name, argc) k##name,
#define DEF_ENUM_S(name, kind, extra, interface_descriptor) k##name,
#define DEF_ENUM_H(name, kind) k##name, #define DEF_ENUM_H(name, kind) k##name,
BUILTIN_LIST_C(DEF_ENUM_C) BUILTIN_LIST_A(DEF_ENUM_A) BUILTIN_LIST_C(DEF_ENUM_C) BUILTIN_LIST_A(DEF_ENUM_A)
BUILTIN_LIST_T(DEF_ENUM_T) BUILTIN_LIST_H(DEF_ENUM_H) BUILTIN_LIST_T(DEF_ENUM_T) BUILTIN_LIST_S(DEF_ENUM_S)
BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) BUILTIN_LIST_H(DEF_ENUM_H) BUILTIN_LIST_DEBUG_A(DEF_ENUM_A)
#undef DEF_ENUM_C #undef DEF_ENUM_C
#undef DEF_ENUM_A #undef DEF_ENUM_A
#undef DEF_ENUM_T #undef DEF_ENUM_T
#undef DEF_ENUM_S
#undef DEF_ENUM_H #undef DEF_ENUM_H
builtin_count builtin_count
}; };
...@@ -399,15 +404,19 @@ class Builtins { ...@@ -399,15 +404,19 @@ class Builtins {
#define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name();
#define DECLARE_BUILTIN_ACCESSOR_A(name, kind, extra) Handle<Code> name(); #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, extra) Handle<Code> name();
#define DECLARE_BUILTIN_ACCESSOR_T(name, argc) Handle<Code> name(); #define DECLARE_BUILTIN_ACCESSOR_T(name, argc) Handle<Code> name();
#define DECLARE_BUILTIN_ACCESSOR_S(name, kind, extra, interface_descriptor) \
Handle<Code> name();
#define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name(); #define DECLARE_BUILTIN_ACCESSOR_H(name, kind) Handle<Code> name();
BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C)
BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A)
BUILTIN_LIST_T(DECLARE_BUILTIN_ACCESSOR_T) BUILTIN_LIST_T(DECLARE_BUILTIN_ACCESSOR_T)
BUILTIN_LIST_S(DECLARE_BUILTIN_ACCESSOR_S)
BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H) BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H)
BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A) BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A)
#undef DECLARE_BUILTIN_ACCESSOR_C #undef DECLARE_BUILTIN_ACCESSOR_C
#undef DECLARE_BUILTIN_ACCESSOR_A #undef DECLARE_BUILTIN_ACCESSOR_A
#undef DECLARE_BUILTIN_ACCESSOR_T #undef DECLARE_BUILTIN_ACCESSOR_T
#undef DECLARE_BUILTIN_ACCESSOR_S
#undef DECLARE_BUILTIN_ACCESSOR_H #undef DECLARE_BUILTIN_ACCESSOR_H
// Convenience wrappers. // Convenience wrappers.
......
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