Commit c06ad086 authored by yangguo's avatar yangguo Committed by Commit bot

[builtins] remove redundant builtins lists.

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

Review-Url: https://codereview.chromium.org/2155633002
Cr-Commit-Position: refs/heads/master@{#37820}
parent f4234422
...@@ -896,10 +896,8 @@ void ExternalReference::SetUp() { ...@@ -896,10 +896,8 @@ void ExternalReference::SetUp() {
static_cast<double>(static_cast<uint32_t>(0xFFFFFFFF)) + 1; static_cast<double>(static_cast<uint32_t>(0xFFFFFFFF)) + 1;
} }
ExternalReference::ExternalReference(Address address, Isolate* isolate)
ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate) : address_(Redirect(isolate, address)) {}
: address_(Redirect(isolate, Builtins::c_function_address(id))) {}
ExternalReference::ExternalReference( ExternalReference::ExternalReference(
ApiFunction* fun, ApiFunction* fun,
......
...@@ -859,7 +859,7 @@ class ExternalReference BASE_EMBEDDED { ...@@ -859,7 +859,7 @@ class ExternalReference BASE_EMBEDDED {
ExternalReference() : address_(NULL) {} ExternalReference() : address_(NULL) {}
ExternalReference(Builtins::CFunctionId id, Isolate* isolate); ExternalReference(Address address, Isolate* isolate);
ExternalReference(ApiFunction* ptr, Type type, Isolate* isolate); ExternalReference(ApiFunction* ptr, Type type, Isolate* isolate);
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r0 : number of arguments excluding receiver // -- r0 : number of arguments excluding receiver
...@@ -44,7 +44,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -44,7 +44,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(r0, r1, r3); __ Push(r0, r1, r3);
__ SmiUntag(r0); __ SmiUntag(r0);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
...@@ -29,7 +29,7 @@ static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, ...@@ -29,7 +29,7 @@ static void GenerateLoadInternalArrayFunction(MacroAssembler* masm,
__ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result);
} }
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- x0 : number of arguments excluding receiver // -- x0 : number of arguments excluding receiver
...@@ -58,7 +58,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -58,7 +58,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(x0, x1, x3); __ Push(x0, x1, x3);
__ SmiUntag(x0); __ SmiUntag(x0);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
This diff is collapsed.
...@@ -392,17 +392,12 @@ namespace internal { ...@@ -392,17 +392,12 @@ namespace internal {
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \
V, V, V) V, V, V)
#define BUILTIN_LIST_TFS(V) \
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, V, \
IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN)
#define BUILTIN_LIST_DBG(V) \ #define BUILTIN_LIST_DBG(V) \
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \
IGNORE_BUILTIN, IGNORE_BUILTIN, V) IGNORE_BUILTIN, IGNORE_BUILTIN, V)
// Forward declarations. // Forward declarations.
class CodeStubAssembler; class CodeStubAssembler;
class BuiltinFunctionTable;
class ObjectVisitor; class ObjectVisitor;
class Builtins { class Builtins {
...@@ -421,20 +416,13 @@ class Builtins { ...@@ -421,20 +416,13 @@ class Builtins {
const char* Lookup(byte* pc); const char* Lookup(byte* pc);
enum Name { enum Name {
#define DEF_ENUM(name, ...) k##name, #define DEF_ENUM(Name, ...) k##Name,
BUILTIN_LIST_ALL(DEF_ENUM) BUILTIN_LIST_ALL(DEF_ENUM)
#undef DEF_ENUM #undef DEF_ENUM
builtin_count builtin_count
}; };
enum CFunctionId { #define DECLARE_BUILTIN_ACCESSOR(Name, ...) Handle<Code> Name();
#define DEF_ENUM(name) c_##name,
BUILTIN_LIST_C(DEF_ENUM)
#undef DEF_ENUM
cfunction_count
};
#define DECLARE_BUILTIN_ACCESSOR(name, ...) Handle<Code> name();
BUILTIN_LIST_ALL(DECLARE_BUILTIN_ACCESSOR) BUILTIN_LIST_ALL(DECLARE_BUILTIN_ACCESSOR)
#undef DECLARE_BUILTIN_ACCESSOR #undef DECLARE_BUILTIN_ACCESSOR
...@@ -462,13 +450,7 @@ class Builtins { ...@@ -462,13 +450,7 @@ class Builtins {
return reinterpret_cast<Address>(&builtins_[name]); return reinterpret_cast<Address>(&builtins_[name]);
} }
static Address c_function_address(CFunctionId id) { return c_functions_[id]; } const char* name(int index);
const char* name(int index) {
DCHECK(index >= 0);
DCHECK(index < builtin_count);
return names_[index];
}
bool is_initialized() const { return initialized_; } bool is_initialized() const { return initialized_; }
...@@ -478,20 +460,12 @@ class Builtins { ...@@ -478,20 +460,12 @@ class Builtins {
enum ExitFrameType { EXIT, BUILTIN_EXIT }; enum ExitFrameType { EXIT, BUILTIN_EXIT };
static void Generate_Adaptor(MacroAssembler* masm, Address builtin_address,
ExitFrameType exit_frame_type);
private: private:
Builtins(); Builtins();
// The external C++ functions called from the code.
static Address const c_functions_[cfunction_count];
// Note: These are always Code objects, but to conform with
// IterateBuiltins() above which assumes Object**'s for the callback
// function f, we use an Object* array here.
Object* builtins_[builtin_count];
const char* names_[builtin_count];
static void Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
ExitFrameType exit_frame_type);
static void Generate_AllocateInNewSpace(MacroAssembler* masm); static void Generate_AllocateInNewSpace(MacroAssembler* masm);
static void Generate_AllocateInOldSpace(MacroAssembler* masm); static void Generate_AllocateInOldSpace(MacroAssembler* masm);
static void Generate_ConstructedNonConstructable(MacroAssembler* masm); static void Generate_ConstructedNonConstructable(MacroAssembler* masm);
...@@ -823,11 +797,12 @@ class Builtins { ...@@ -823,11 +797,12 @@ class Builtins {
static void Generate_AtomicsLoad(CodeStubAssembler* assembler); static void Generate_AtomicsLoad(CodeStubAssembler* assembler);
static void Generate_AtomicsStore(CodeStubAssembler* assembler); static void Generate_AtomicsStore(CodeStubAssembler* assembler);
static void InitBuiltinFunctionTable(); // Note: These are always Code objects, but to conform with
// IterateBuiltins() above which assumes Object**'s for the callback
// function f, we use an Object* array here.
Object* builtins_[builtin_count];
bool initialized_; bool initialized_;
friend class BuiltinFunctionTable;
friend class Isolate; friend class Isolate;
DISALLOW_COPY_AND_ASSIGN(Builtins); DISALLOW_COPY_AND_ASSIGN(Builtins);
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : number of arguments excluding receiver // -- eax : number of arguments excluding receiver
...@@ -49,7 +49,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -49,7 +49,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(edx); __ Push(edx);
__ PushReturnAddressFrom(ecx); __ PushReturnAddressFrom(ecx);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver // -- a0 : number of arguments excluding receiver
...@@ -44,8 +44,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -44,8 +44,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(a0, a1, a3); __ Push(a0, a1, a3);
__ SmiUntag(a0); __ SmiUntag(a0);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), PROTECT, __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); PROTECT, exit_frame_type == BUILTIN_EXIT);
} }
// Load the built-in InternalArray function from the current context. // Load the built-in InternalArray function from the current context.
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0 : number of arguments excluding receiver // -- a0 : number of arguments excluding receiver
...@@ -44,8 +44,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -44,8 +44,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(a0, a1, a3); __ Push(a0, a1, a3);
__ SmiUntag(a0); __ SmiUntag(a0);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), PROTECT, __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); PROTECT, exit_frame_type == BUILTIN_EXIT);
} }
// Load the built-in InternalArray function from the current context. // Load the built-in InternalArray function from the current context.
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r3 : number of arguments excluding receiver // -- r3 : number of arguments excluding receiver
...@@ -44,7 +44,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -44,7 +44,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(r3, r4, r6); __ Push(r3, r4, r6);
__ SmiUntag(r3); __ SmiUntag(r3);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r2 : number of arguments excluding receiver // -- r2 : number of arguments excluding receiver
...@@ -44,7 +44,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -44,7 +44,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(r2, r3, r5); __ Push(r2, r3, r5);
__ SmiUntag(r2); __ SmiUntag(r2);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
...@@ -14,7 +14,7 @@ namespace internal { ...@@ -14,7 +14,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- rax : number of arguments excluding receiver // -- rax : number of arguments excluding receiver
...@@ -49,7 +49,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -49,7 +49,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(rdx); __ Push(rdx);
__ PushReturnAddressFrom(kScratchRegister); __ PushReturnAddressFrom(kScratchRegister);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
...@@ -15,7 +15,7 @@ namespace internal { ...@@ -15,7 +15,7 @@ namespace internal {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address,
ExitFrameType exit_frame_type) { ExitFrameType exit_frame_type) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : number of arguments excluding receiver // -- eax : number of arguments excluding receiver
...@@ -49,7 +49,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, ...@@ -49,7 +49,7 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
__ Push(edx); __ Push(edx);
__ PushReturnAddressFrom(ecx); __ PushReturnAddressFrom(ecx);
__ JumpToExternalReference(ExternalReference(id, masm->isolate()), __ JumpToExternalReference(ExternalReference(address, masm->isolate()),
exit_frame_type == BUILTIN_EXIT); exit_frame_type == BUILTIN_EXIT);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "src/accessors.h" #include "src/accessors.h"
#include "src/assembler.h" #include "src/assembler.h"
#include "src/builtins/builtins.h"
#include "src/counters.h" #include "src/counters.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/ic/stub-cache.h" #include "src/ic/stub-cache.h"
...@@ -13,6 +14,12 @@ ...@@ -13,6 +14,12 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// Forward declarations for C++ builtins.
#define FORWARD_DECLARE(Name) \
Object* Builtin_##Name(int argc, Object** args, Isolate* isolate);
BUILTIN_LIST_C(FORWARD_DECLARE)
#undef FORWARD_DECLARE
ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) { ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) {
ExternalReferenceTable* external_reference_table = ExternalReferenceTable* external_reference_table =
isolate->external_reference_table(); isolate->external_reference_table();
...@@ -24,6 +31,18 @@ ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) { ...@@ -24,6 +31,18 @@ ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) {
} }
ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
AddReferences(isolate);
AddBuiltins(isolate);
AddRuntimeFunctions(isolate);
AddStatCounters(isolate);
AddIsolateAddresses(isolate);
AddAccessors(isolate);
AddStubCache(isolate);
AddDeoptEntries(isolate);
AddApiReferences(isolate);
}
void ExternalReferenceTable::AddReferences(Isolate* isolate) {
// Miscellaneous // Miscellaneous
Add(ExternalReference::roots_array_start(isolate).address(), Add(ExternalReference::roots_array_start(isolate).address(),
"Heap::roots_array_start()"); "Heap::roots_array_start()");
...@@ -234,54 +253,68 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -234,54 +253,68 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
"OffsetsVector::static_offsets_vector"); "OffsetsVector::static_offsets_vector");
#endif // V8_INTERPRETED_REGEXP #endif // V8_INTERPRETED_REGEXP
// The following populates all of the different type of external references // Runtime entries
// into the ExternalReferenceTable. Add(ExternalReference::delete_handle_scope_extensions(isolate).address(),
// "HandleScope::DeleteExtensions");
// NOTE: This function was originally 100k of code. It has since been Add(ExternalReference::incremental_marking_record_write_function(isolate)
// rewritten to be mostly table driven, as the callback macro style tends to .address(),
// very easily cause code bloat. Please be careful in the future when adding "IncrementalMarking::RecordWrite");
// new references. Add(ExternalReference::incremental_marking_record_write_code_entry_function(
isolate)
.address(),
"IncrementalMarking::RecordWriteOfCodeEntryFromCode");
Add(ExternalReference::store_buffer_overflow_function(isolate).address(),
"StoreBuffer::StoreBufferOverflow");
}
struct RefTableEntry { void ExternalReferenceTable::AddBuiltins(Isolate* isolate) {
uint16_t id; struct CBuiltinEntry {
Address address;
const char* name; const char* name;
}; };
static const CBuiltinEntry c_builtins[] = {
static const RefTableEntry c_builtins[] = { #define DEF_ENTRY(Name, ...) {FUNCTION_ADDR(&Builtin_##Name), "Builtin_" #Name},
#define DEF_ENTRY(name) {Builtins::c_##name, "Builtins::" #name},
BUILTIN_LIST_C(DEF_ENTRY) BUILTIN_LIST_C(DEF_ENTRY)
#undef DEF_ENTRY #undef DEF_ENTRY
}; };
for (unsigned i = 0; i < arraysize(c_builtins); ++i) { for (unsigned i = 0; i < arraysize(c_builtins); ++i) {
ExternalReference ref(static_cast<Builtins::CFunctionId>(c_builtins[i].id), Add(ExternalReference(c_builtins[i].address, isolate).address(),
isolate); c_builtins[i].name);
Add(ref.address(), c_builtins[i].name);
} }
static const RefTableEntry builtins[] = { struct BuiltinEntry {
#define DEF_ENTRY(name, ...) {Builtins::k##name, "Builtins::" #name}, Builtins::Name id;
const char* name;
};
static const BuiltinEntry builtins[] = {
#define DEF_ENTRY(Name, ...) {Builtins::k##Name, "Builtin_" #Name},
BUILTIN_LIST_C(DEF_ENTRY) BUILTIN_LIST_A(DEF_ENTRY) BUILTIN_LIST_C(DEF_ENTRY) BUILTIN_LIST_A(DEF_ENTRY)
#undef DEF_ENTRY #undef DEF_ENTRY
}; };
for (unsigned i = 0; i < arraysize(builtins); ++i) { for (unsigned i = 0; i < arraysize(builtins); ++i) {
ExternalReference ref(static_cast<Builtins::Name>(builtins[i].id), isolate); Add(isolate->builtins()->builtin_address(builtins[i].id), builtins[i].name);
Add(ref.address(), builtins[i].name);
} }
}
static const RefTableEntry runtime_functions[] = { void ExternalReferenceTable::AddRuntimeFunctions(Isolate* isolate) {
struct RuntimeEntry {
Runtime::FunctionId id;
const char* name;
};
static const RuntimeEntry runtime_functions[] = {
#define RUNTIME_ENTRY(name, i1, i2) {Runtime::k##name, "Runtime::" #name}, #define RUNTIME_ENTRY(name, i1, i2) {Runtime::k##name, "Runtime::" #name},
FOR_EACH_INTRINSIC(RUNTIME_ENTRY) FOR_EACH_INTRINSIC(RUNTIME_ENTRY)
#undef RUNTIME_ENTRY #undef RUNTIME_ENTRY
}; };
for (unsigned i = 0; i < arraysize(runtime_functions); ++i) { for (unsigned i = 0; i < arraysize(runtime_functions); ++i) {
ExternalReference ref( ExternalReference ref(runtime_functions[i].id, isolate);
static_cast<Runtime::FunctionId>(runtime_functions[i].id), isolate);
Add(ref.address(), runtime_functions[i].name); Add(ref.address(), runtime_functions[i].name);
} }
}
void ExternalReferenceTable::AddStatCounters(Isolate* isolate) {
// Stat counters // Stat counters
struct StatsRefTableEntry { struct StatsRefTableEntry {
StatsCounter* (Counters::*counter)(); StatsCounter* (Counters::*counter)();
...@@ -305,7 +338,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -305,7 +338,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
} }
Add(address, stats_ref_table[i].name); Add(address, stats_ref_table[i].name);
} }
}
void ExternalReferenceTable::AddIsolateAddresses(Isolate* isolate) {
// Top addresses // Top addresses
static const char* address_names[] = { static const char* address_names[] = {
#define BUILD_NAME_LITERAL(Name, name) "Isolate::" #name "_address", #define BUILD_NAME_LITERAL(Name, name) "Isolate::" #name "_address",
...@@ -317,7 +352,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -317,7 +352,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
Add(isolate->get_address_from_id(static_cast<Isolate::AddressId>(i)), Add(isolate->get_address_from_id(static_cast<Isolate::AddressId>(i)),
address_names[i]); address_names[i]);
} }
}
void ExternalReferenceTable::AddAccessors(Isolate* isolate) {
// Accessors // Accessors
struct AccessorRefTable { struct AccessorRefTable {
Address address; Address address;
...@@ -346,7 +383,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -346,7 +383,9 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
for (unsigned i = 0; i < arraysize(setters); ++i) { for (unsigned i = 0; i < arraysize(setters); ++i) {
Add(setters[i].address, setters[i].name); Add(setters[i].address, setters[i].name);
} }
}
void ExternalReferenceTable::AddStubCache(Isolate* isolate) {
StubCache* load_stub_cache = isolate->load_stub_cache(); StubCache* load_stub_cache = isolate->load_stub_cache();
// Stub cache tables // Stub cache tables
...@@ -378,21 +417,11 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -378,21 +417,11 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
"Store StubCache::secondary_->value"); "Store StubCache::secondary_->value");
Add(store_stub_cache->map_reference(StubCache::kSecondary).address(), Add(store_stub_cache->map_reference(StubCache::kSecondary).address(),
"Store StubCache::secondary_->map"); "Store StubCache::secondary_->map");
}
// Runtime entries void ExternalReferenceTable::AddDeoptEntries(Isolate* isolate) {
Add(ExternalReference::delete_handle_scope_extensions(isolate).address(), // Add a small set of deopt entry addresses to encoder without generating
"HandleScope::DeleteExtensions"); // the
Add(ExternalReference::incremental_marking_record_write_function(isolate)
.address(),
"IncrementalMarking::RecordWrite");
Add(ExternalReference::incremental_marking_record_write_code_entry_function(
isolate)
.address(),
"IncrementalMarking::RecordWriteOfCodeEntryFromCode");
Add(ExternalReference::store_buffer_overflow_function(isolate).address(),
"StoreBuffer::StoreBufferOverflow");
// Add a small set of deopt entry addresses to encoder without generating the
// deopt table code, which isn't possible at deserialization time. // deopt table code, which isn't possible at deserialization time.
HandleScope scope(isolate); HandleScope scope(isolate);
for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) { for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) {
...@@ -401,8 +430,11 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -401,8 +430,11 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
Deoptimizer::CALCULATE_ENTRY_ADDRESS); Deoptimizer::CALCULATE_ENTRY_ADDRESS);
Add(address, "lazy_deopt"); Add(address, "lazy_deopt");
} }
}
// Add external references provided by the embedder (a null-terminated array). void ExternalReferenceTable::AddApiReferences(Isolate* isolate) {
// Add external references provided by the embedder (a null-terminated
// array).
intptr_t* api_external_references = isolate->api_external_references(); intptr_t* api_external_references = isolate->api_external_references();
if (api_external_references != nullptr) { if (api_external_references != nullptr) {
while (*api_external_references != 0) { while (*api_external_references != 0) {
......
...@@ -40,6 +40,16 @@ class ExternalReferenceTable { ...@@ -40,6 +40,16 @@ class ExternalReferenceTable {
refs_.Add(entry); refs_.Add(entry);
} }
void AddReferences(Isolate* isolate);
void AddBuiltins(Isolate* isolate);
void AddRuntimeFunctions(Isolate* isolate);
void AddStatCounters(Isolate* isolate);
void AddIsolateAddresses(Isolate* isolate);
void AddAccessors(Isolate* isolate);
void AddStubCache(Isolate* isolate);
void AddDeoptEntries(Isolate* isolate);
void AddApiReferences(Isolate* isolate);
List<ExternalReferenceEntry> refs_; List<ExternalReferenceEntry> refs_;
DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable);
......
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