Commit 5abc73a1 authored by yangguo's avatar yangguo Committed by Commit bot

[builtins] unify builtins list.

Now builtins are sorted by use, not implementation.

R=bmeurer@chromium.org
BUG=v8:5197

Review-Url: https://codereview.chromium.org/2145413002
Cr-Commit-Position: refs/heads/master@{#37761}
parent 63449d21
...@@ -6314,7 +6314,7 @@ Builtins::Builtins() : initialized_(false) { ...@@ -6314,7 +6314,7 @@ Builtins::Builtins() : initialized_(false) {
Builtins::~Builtins() {} Builtins::~Builtins() {}
#define DEF_ENUM_C(name, ignore) FUNCTION_ADDR(Builtin_##name), #define DEF_ENUM_C(name) FUNCTION_ADDR(Builtin_##name),
Address const Builtins::c_functions_[cfunction_count] = { Address const Builtins::c_functions_[cfunction_count] = {
BUILTIN_LIST_C(DEF_ENUM_C)}; BUILTIN_LIST_C(DEF_ENUM_C)};
#undef DEF_ENUM_C #undef DEF_ENUM_C
...@@ -6437,73 +6437,80 @@ void Builtins::InitBuiltinFunctionTable() { ...@@ -6437,73 +6437,80 @@ void Builtins::InitBuiltinFunctionTable() {
functions[builtin_count].exit_frame_type = EXIT; functions[builtin_count].exit_frame_type = EXIT;
functions[builtin_count].argc = 0; functions[builtin_count].argc = 0;
#define DEF_FUNCTION_PTR_C(aname, aexit_frame_type) \ #define DEF_CPP(Name) \
functions->builder = &MacroAssemblerBuilder; \ functions->builder = &MacroAssemblerBuilder; \
functions->generator = FUNCTION_ADDR(Generate_Adaptor); \ functions->generator = FUNCTION_ADDR(Generate_Adaptor); \
functions->c_code = FUNCTION_ADDR(Builtin_##aname); \ functions->c_code = FUNCTION_ADDR(Builtin_##Name); \
functions->s_name = #aname; \ functions->s_name = #Name; \
functions->name = c_##aname; \ functions->name = c_##Name; \
functions->flags = Code::ComputeFlags(Code::BUILTIN); \ functions->flags = Code::ComputeFlags(Code::BUILTIN); \
functions->exit_frame_type = aexit_frame_type; \ functions->exit_frame_type = BUILTIN_EXIT; \
functions->argc = 0; \ functions->argc = 0; \
++functions; ++functions;
#define DEF_FUNCTION_PTR_A(aname, kind, extra) \ #define DEF_API(Name) \
functions->builder = &MacroAssemblerBuilder; \ functions->builder = &MacroAssemblerBuilder; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \ functions->generator = FUNCTION_ADDR(Generate_Adaptor); \
functions->c_code = NULL; \ functions->c_code = FUNCTION_ADDR(Builtin_##Name); \
functions->s_name = #aname; \ functions->s_name = #Name; \
functions->name = k##aname; \ functions->name = c_##Name; \
functions->flags = Code::ComputeFlags(Code::kind, extra); \
functions->exit_frame_type = EXIT; \
functions->argc = 0; \
++functions;
#define DEF_FUNCTION_PTR_T(aname, aargc) \
functions->builder = &CodeStubAssemblerBuilderJS; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \
functions->c_code = NULL; \
functions->s_name = #aname; \
functions->name = k##aname; \
functions->flags = Code::ComputeFlags(Code::BUILTIN); \ functions->flags = Code::ComputeFlags(Code::BUILTIN); \
functions->exit_frame_type = EXIT; \ functions->exit_frame_type = EXIT; \
functions->argc = aargc; \ functions->argc = 0; \
++functions; ++functions;
#define DEF_FUNCTION_PTR_S(aname, kind, extra, interface_descriptor) \ #define DEF_TFJ(Name, Argc) \
functions->builder = &CodeStubAssemblerBuilderCS; \ functions->builder = &CodeStubAssemblerBuilderJS; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \ functions->generator = FUNCTION_ADDR(Generate_##Name); \
functions->c_code = NULL; \ functions->c_code = NULL; \
functions->s_name = #aname; \ functions->s_name = #Name; \
functions->name = k##aname; \ functions->name = k##Name; \
functions->flags = Code::ComputeFlags(Code::kind, extra); \ functions->flags = Code::ComputeFlags(Code::BUILTIN); \
functions->exit_frame_type = EXIT; \ functions->exit_frame_type = EXIT; \
functions->argc = CallDescriptors::interface_descriptor; \ functions->argc = Argc; \
++functions; ++functions;
#define DEF_FUNCTION_PTR_H(aname, kind) \ #define DEF_TFS(Name, Kind, Extra, InterfaceDescriptor) \
functions->builder = &CodeStubAssemblerBuilderCS; \
functions->generator = FUNCTION_ADDR(Generate_##Name); \
functions->c_code = NULL; \
functions->s_name = #Name; \
functions->name = k##Name; \
functions->flags = Code::ComputeFlags(Code::Kind, Extra); \
functions->exit_frame_type = EXIT; \
functions->argc = CallDescriptors::InterfaceDescriptor; \
++functions;
#define DEF_ASM(Name) \
functions->builder = &MacroAssemblerBuilder; \
functions->generator = FUNCTION_ADDR(Generate_##Name); \
functions->c_code = NULL; \
functions->s_name = #Name; \
functions->name = k##Name; \
functions->flags = Code::ComputeFlags(Code::BUILTIN); \
functions->exit_frame_type = EXIT; \
functions->argc = 0; \
++functions;
#define DEF_ASH(Name, Kind, Extra) \
functions->builder = &MacroAssemblerBuilder; \ functions->builder = &MacroAssemblerBuilder; \
functions->generator = FUNCTION_ADDR(Generate_##aname); \ functions->generator = FUNCTION_ADDR(Generate_##Name); \
functions->c_code = NULL; \ functions->c_code = NULL; \
functions->s_name = #aname; \ functions->s_name = #Name; \
functions->name = k##aname; \ functions->name = k##Name; \
functions->flags = Code::ComputeHandlerFlags(Code::kind); \ functions->flags = Code::ComputeFlags(Code::Kind, Extra); \
functions->exit_frame_type = EXIT; \ functions->exit_frame_type = EXIT; \
functions->argc = 0; \ functions->argc = 0; \
++functions; ++functions;
BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) BUILTIN_LIST(DEF_CPP, DEF_API, DEF_TFJ, DEF_TFS, DEF_ASM, DEF_ASH, DEF_ASM)
BUILTIN_LIST_A(DEF_FUNCTION_PTR_A)
BUILTIN_LIST_T(DEF_FUNCTION_PTR_T)
BUILTIN_LIST_S(DEF_FUNCTION_PTR_S)
BUILTIN_LIST_H(DEF_FUNCTION_PTR_H)
BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A)
#undef DEF_FUNCTION_PTR_C #undef DEF_CPP
#undef DEF_FUNCTION_PTR_A #undef DEF_API
#undef DEF_FUNCTION_PTR_T #undef DEF_TFJ
#undef DEF_FUNCTION_PTR_S #undef DEF_TFS
#undef DEF_FUNCTION_PTR_H #undef DEF_ASM
#undef DEF_ASH
} }
void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
...@@ -6514,7 +6521,7 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) { ...@@ -6514,7 +6521,7 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
#define INITIALIZE_CALL_DESCRIPTOR(name, kind, extra, interface_descriptor) \ #define INITIALIZE_CALL_DESCRIPTOR(name, kind, extra, interface_descriptor) \
{ interface_descriptor##Descriptor descriptor(isolate); } { interface_descriptor##Descriptor descriptor(isolate); }
BUILTIN_LIST_S(INITIALIZE_CALL_DESCRIPTOR) BUILTIN_LIST_TFS(INITIALIZE_CALL_DESCRIPTOR)
#undef INITIALIZE_CALL_DESCRIPTOR #undef INITIALIZE_CALL_DESCRIPTOR
const BuiltinDesc* functions = builtin_function_table.functions(); const BuiltinDesc* functions = builtin_function_table.functions();
...@@ -6814,42 +6821,13 @@ void Builtins::Generate_AtomicsStore(CodeStubAssembler* a) { ...@@ -6814,42 +6821,13 @@ void Builtins::Generate_AtomicsStore(CodeStubAssembler* a) {
a->Return(a->Int32Constant(0)); a->Return(a->Int32Constant(0));
} }
#define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ #define DEFINE_BUILTIN_ACCESSOR(Name, ...) \
Handle<Code> Builtins::name() { \ 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); \
}
#define DEFINE_BUILTIN_ACCESSOR_A(name, kind, extra) \
Handle<Code> Builtins::name() { \
Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
return Handle<Code>(code_address); \
}
#define DEFINE_BUILTIN_ACCESSOR_T(name, argc) \
Handle<Code> Builtins::name() { \
Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
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) \
Handle<Code> Builtins::name() { \
Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \
return Handle<Code>(code_address); \ return Handle<Code>(code_address); \
} }
BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) BUILTIN_LIST_ALL(DEFINE_BUILTIN_ACCESSOR)
BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) #undef DEFINE_BUILTIN_ACCESSOR
BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
BUILTIN_LIST_S(DEFINE_BUILTIN_ACCESSOR_S)
BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
#undef DEFINE_BUILTIN_ACCESSOR_C
#undef DEFINE_BUILTIN_ACCESSOR_A
#undef DEFINE_BUILTIN_ACCESSOR_T
#undef DEFINE_BUILTIN_ACCESSOR_S
#undef DEFINE_BUILTIN_ACCESSOR_H
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
This diff is collapsed.
...@@ -318,7 +318,7 @@ void RuntimeCallStats::Print(std::ostream& os) { ...@@ -318,7 +318,7 @@ void RuntimeCallStats::Print(std::ostream& os) {
FOR_EACH_INTRINSIC(PRINT_COUNTER) FOR_EACH_INTRINSIC(PRINT_COUNTER)
#undef PRINT_COUNTER #undef PRINT_COUNTER
#define PRINT_COUNTER(name, ignore) entries.Add(&this->Builtin_##name); #define PRINT_COUNTER(name) entries.Add(&this->Builtin_##name);
BUILTIN_LIST_C(PRINT_COUNTER) BUILTIN_LIST_C(PRINT_COUNTER)
#undef PRINT_COUNTER #undef PRINT_COUNTER
...@@ -343,7 +343,7 @@ void RuntimeCallStats::Reset() { ...@@ -343,7 +343,7 @@ void RuntimeCallStats::Reset() {
FOR_EACH_INTRINSIC(RESET_COUNTER) FOR_EACH_INTRINSIC(RESET_COUNTER)
#undef RESET_COUNTER #undef RESET_COUNTER
#define RESET_COUNTER(name, ignore) this->Builtin_##name.Reset(); #define RESET_COUNTER(name) this->Builtin_##name.Reset();
BUILTIN_LIST_C(RESET_COUNTER) BUILTIN_LIST_C(RESET_COUNTER)
#undef RESET_COUNTER #undef RESET_COUNTER
......
...@@ -748,7 +748,7 @@ class RuntimeCallStats { ...@@ -748,7 +748,7 @@ class RuntimeCallStats {
RuntimeCallCounter Runtime_##name = RuntimeCallCounter(#name); RuntimeCallCounter Runtime_##name = RuntimeCallCounter(#name);
FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER) FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER)
#undef CALL_RUNTIME_COUNTER #undef CALL_RUNTIME_COUNTER
#define CALL_BUILTIN_COUNTER(name, ignore) \ #define CALL_BUILTIN_COUNTER(name) \
RuntimeCallCounter Builtin_##name = RuntimeCallCounter(#name); RuntimeCallCounter Builtin_##name = RuntimeCallCounter(#name);
BUILTIN_LIST_C(CALL_BUILTIN_COUNTER) BUILTIN_LIST_C(CALL_BUILTIN_COUNTER)
#undef CALL_BUILTIN_COUNTER #undef CALL_BUILTIN_COUNTER
......
...@@ -248,9 +248,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -248,9 +248,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
}; };
static const RefTableEntry c_builtins[] = { static const RefTableEntry c_builtins[] = {
#define DEF_ENTRY_C(name, ignore) {Builtins::c_##name, "Builtins::" #name}, #define DEF_ENTRY(name) {Builtins::c_##name, "Builtins::" #name},
BUILTIN_LIST_C(DEF_ENTRY_C) BUILTIN_LIST_C(DEF_ENTRY)
#undef DEF_ENTRY_C #undef DEF_ENTRY
}; };
for (unsigned i = 0; i < arraysize(c_builtins); ++i) { for (unsigned i = 0; i < arraysize(c_builtins); ++i) {
...@@ -260,12 +260,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -260,12 +260,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
} }
static const RefTableEntry builtins[] = { static const RefTableEntry builtins[] = {
#define DEF_ENTRY_C(name, ignore) {Builtins::k##name, "Builtins::" #name}, #define DEF_ENTRY(name, ...) {Builtins::k##name, "Builtins::" #name},
#define DEF_ENTRY_A(name, i1, i2) {Builtins::k##name, "Builtins::" #name}, BUILTIN_LIST_C(DEF_ENTRY) BUILTIN_LIST_A(DEF_ENTRY)
BUILTIN_LIST_C(DEF_ENTRY_C) BUILTIN_LIST_A(DEF_ENTRY_A) #undef DEF_ENTRY
BUILTIN_LIST_DEBUG_A(DEF_ENTRY_A)
#undef DEF_ENTRY_C
#undef DEF_ENTRY_A
}; };
for (unsigned i = 0; i < arraysize(builtins); ++i) { for (unsigned i = 0; i < arraysize(builtins); ++i) {
......
...@@ -5172,8 +5172,8 @@ bool Code::is_inline_cache_stub() { ...@@ -5172,8 +5172,8 @@ bool Code::is_inline_cache_stub() {
bool Code::is_debug_stub() { bool Code::is_debug_stub() {
if (kind() != BUILTIN) return false; if (kind() != BUILTIN) return false;
switch (builtin_index()) { switch (builtin_index()) {
#define CASE_DEBUG_BUILTIN(name, kind, extra) case Builtins::k##name: #define CASE_DEBUG_BUILTIN(name) case Builtins::k##name:
BUILTIN_LIST_DEBUG_A(CASE_DEBUG_BUILTIN) BUILTIN_LIST_DBG(CASE_DEBUG_BUILTIN)
#undef CASE_DEBUG_BUILTIN #undef CASE_DEBUG_BUILTIN
return true; return true;
default: default:
......
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