v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
external-reference-table.h
Go to the documentation of this file.
1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_CODEGEN_EXTERNAL_REFERENCE_TABLE_H_
6#define V8_CODEGEN_EXTERNAL_REFERENCE_TABLE_H_
7
13
14namespace v8 {
15namespace internal {
16
17class Isolate;
18
19// ExternalReferenceTable is a helper class that defines the relationship
20// between external references and their encodings. It is used to build
21// hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder.
23 public:
24 // For the nullptr ref, see the constructor.
25 static constexpr int kSpecialReferenceCount = 1;
30 static constexpr int kBuiltinsReferenceCount =
31#define COUNT_C_BUILTIN(...) +1
33#undef COUNT_C_BUILTIN
34 static constexpr int kRuntimeReferenceCount =
35 Runtime::kNumFunctions -
36 Runtime::kNumInlineFunctions; // Don't count dupe kInline... functions.
38 static constexpr int kAccessorReferenceCount =
39 Accessors::kAccessorInfoCount + Accessors::kAccessorGetterCount +
41 // The number of stub cache external references, see AddStubCache.
42 static constexpr int kStubCacheReferenceCount = 6 * 3; // 3 stub caches
43 static constexpr int kStatsCountersReferenceCount =
44#define SC(...) +1
46#undef SC
47 static constexpr int kSizeIsolateIndependent =
51 static constexpr int kSize =
55 static constexpr uint32_t kEntrySize =
56 static_cast<uint32_t>(kSystemPointerSize);
57 static constexpr uint32_t kSizeInBytes = kSize * kEntrySize + 2 * kUInt32Size;
58
59 Address address(uint32_t i) const { return ref_addr_[i]; }
60 const char* name(uint32_t i) const { return ref_name_[i]; }
61
62 bool is_initialized() const { return is_initialized_ == kInitialized; }
63
64 static const char* ResolveSymbol(void* address);
65
66 static constexpr uint32_t OffsetOfEntry(uint32_t i) {
67 // Used in CodeAssembler::LookupExternalReference.
68 return i * kEntrySize;
69 }
70
72 MemorySpan<Address> shared_external_references);
73 static const char* NameOfIsolateIndependentAddress(
74 Address address, MemorySpan<Address> shared_external_references);
75
76 const char* NameFromOffset(uint32_t offset) {
79 int index = offset / kEntrySize;
80 return name(index);
81 }
82
86
88 MemorySpan<Address> shared_external_references); // Step 1.
89
90 void Init(Isolate* isolate); // Step 2.
91
92 private:
93 static void AddIsolateIndependent(
94 Address address, int* index,
95 MemorySpan<Address> shared_external_references);
96
98 int* index, MemorySpan<Address> shared_external_references);
99 static void AddBuiltins(int* index,
100 MemorySpan<Address> shared_external_references);
101 static void AddRuntimeFunctions(
102 int* index, MemorySpan<Address> shared_external_references);
103 static void AddAccessors(int* index,
104 MemorySpan<Address> shared_external_references);
105
106 void Add(Address address, int* index);
107
109 int* index, MemorySpan<Address> shared_external_references);
110 void AddIsolateDependentReferences(Isolate* isolate, int* index);
111 void AddIsolateAddresses(Isolate* isolate, int* index);
112 void AddStubCache(Isolate* isolate, int* index);
113
115 void AddNativeCodeStatsCounters(Isolate* isolate, int* index);
116
117 static_assert(sizeof(Address) == kEntrySize);
118#ifdef DEBUG
120#else
122#endif // DEBUG
123 static const char* const ref_name_[kSize];
124
131
132 // Redirect disabled stats counters to this field. This is done to make sure
133 // we can have a snapshot that includes native counters even when the embedder
134 // isn't collecting them.
135 // This field is uint32_t since the MacroAssembler and CodeStubAssembler
136 // accesses this field as a uint32_t.
138};
139
141 sizeof(ExternalReferenceTable));
142
143} // namespace internal
144} // namespace v8
145#endif // V8_CODEGEN_EXTERNAL_REFERENCE_TABLE_H_
#define BUILTIN_LIST_C(V)
static constexpr int kAccessorSetterCount
Definition accessors.h:101
static constexpr int kAccessorCallbackCount
Definition accessors.h:104
static constexpr int kAccessorGetterCount
Definition accessors.h:98
static constexpr int kExternalReferenceCountIsolateDependent
static void AddIsolateIndependent(Address address, int *index, MemorySpan< Address > shared_external_references)
Address GetStatsCounterAddress(StatsCounter *counter)
const char * NameFromOffset(uint32_t offset)
ExternalReferenceTable & operator=(const ExternalReferenceTable &)=delete
static void AddRuntimeFunctions(int *index, MemorySpan< Address > shared_external_references)
static void InitializeOncePerIsolateGroup(MemorySpan< Address > shared_external_references)
static void AddBuiltins(int *index, MemorySpan< Address > shared_external_references)
void AddStubCache(Isolate *isolate, int *index)
void Add(Address address, int *index)
static constexpr int kExternalReferenceCountIsolateIndependent
void InitIsolateIndependent(MemorySpan< Address > shared_external_references)
void AddIsolateDependentReferences(Isolate *isolate, int *index)
static const char * ResolveSymbol(void *address)
static void AddIsolateIndependentReferences(int *index, MemorySpan< Address > shared_external_references)
ExternalReferenceTable(const ExternalReferenceTable &)=delete
static void AddAccessors(int *index, MemorySpan< Address > shared_external_references)
static const char *const ref_name_[kSize]
static const char * NameOfIsolateIndependentAddress(Address address, MemorySpan< Address > shared_external_references)
void AddNativeCodeStatsCounters(Isolate *isolate, int *index)
void AddIsolateAddresses(Isolate *isolate, int *index)
static constexpr uint32_t OffsetOfEntry(uint32_t i)
void CopyIsolateIndependentReferences(int *index, MemorySpan< Address > shared_external_references)
static constexpr int kExternalReferenceCountIsolateIndependent
static constexpr int kExternalReferenceCountIsolateDependent
static constexpr int kNumInlineFunctions
Definition runtime.h:909
#define STATS_COUNTER_NATIVE_CODE_LIST(SC)
#define COUNT_C_BUILTIN(...)
int32_t offset
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
Definition flags.cc:2086
constexpr int kSystemPointerSize
Definition globals.h:410
@ kIsolateAddressCount
Definition globals.h:2646
constexpr int kUInt32Size
Definition globals.h:403
constexpr Opcode SC
static constexpr Address kNullAddress
Definition v8-internal.h:53
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485