v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
code-factory.cc
Go to the documentation of this file.
1// Copyright 2014 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
6
9#include "src/ic/ic.h"
13
14namespace v8 {
15namespace internal {
16
17// static
19 bool switch_to_central_stack) {
20 return CodeFactory::CEntry(isolate, result_size, ArgvMode::kStack, false,
21 switch_to_central_stack);
22}
23
24// static
25Handle<Code> CodeFactory::CEntry(Isolate* isolate, int result_size,
26 ArgvMode argv_mode, bool builtin_exit_frame,
27 bool switch_to_central_stack) {
28 Builtin builtin = Builtins::CEntry(result_size, argv_mode, builtin_exit_frame,
29 switch_to_central_stack);
30 return isolate->builtins()->code_handle(builtin);
31}
32
33// static
35 return Builtins::CallableFor(isolate, Builtins::LoadGlobalIC(typeof_mode));
36}
37
38// static
44
46 return Builtins::CallableFor(isolate, Builtin::kDefineNamedOwnICTrampoline);
47}
48
50 return Builtins::CallableFor(isolate, Builtin::kDefineNamedOwnIC);
51}
52
53// static
57
58// static
60 ScopeType scope_type) {
61 switch (scope_type) {
63 return Builtins::CallableFor(isolate,
64 Builtin::kFastNewFunctionContextEval);
66 return Builtins::CallableFor(isolate,
67 Builtin::kFastNewFunctionContextFunction);
68 default:
70 }
71}
72
73// static
77
78// static
81 switch (mode) {
84 isolate, Builtin::kCall_ReceiverIsNullOrUndefined_WithFeedback);
87 isolate, Builtin::kCall_ReceiverIsNotNullOrUndefined_WithFeedback);
89 return Builtins::CallableFor(isolate,
90 Builtin::kCall_ReceiverIsAny_WithFeedback);
91 }
93}
94
95// static
97 return Builtins::CallableFor(isolate, Builtin::kCallWithArrayLike);
98}
99
100// static
102 return Builtins::CallableFor(isolate, Builtin::kCallWithSpread);
103}
104
105// static
109
110// static
112 return Builtins::CallableFor(isolate, Builtin::kCallForwardVarargs);
113}
114
115// static
117 return Builtins::CallableFor(isolate, Builtin::kCallFunctionForwardVarargs);
118}
119
120// static
122 return Builtins::CallableFor(isolate, Builtin::kConstruct);
123}
124
125// static
127 return Builtins::CallableFor(isolate, Builtin::kConstructWithSpread);
128}
129
130// static
132 return Builtins::CallableFor(isolate, Builtin::kConstructForwardVarargs);
133}
134
135// static
137 return Builtins::CallableFor(isolate,
138 Builtin::kConstructFunctionForwardVarargs);
139}
140
141// static
143 Isolate* isolate, ElementsKind kind,
144 AllocationSiteOverrideMode override_mode) {
145#define CASE(kind_caps, kind_camel, mode_camel) \
146 case kind_caps: \
147 return Builtins::CallableFor( \
148 isolate, \
149 Builtin::kArrayNoArgumentConstructor_##kind_camel##_##mode_camel);
150 if (override_mode == DONT_OVERRIDE && AllocationSite::ShouldTrack(kind)) {
152 switch (kind) {
155 default:
156 UNREACHABLE();
157 }
158 } else {
159 DCHECK(override_mode == DISABLE_ALLOCATION_SITES ||
161 switch (kind) {
168 default:
169 UNREACHABLE();
170 }
171 }
172#undef CASE
173}
174
175// static
177 Isolate* isolate, ElementsKind kind,
178 AllocationSiteOverrideMode override_mode) {
179#define CASE(kind_caps, kind_camel, mode_camel) \
180 case kind_caps: \
181 return Builtins::CallableFor( \
182 isolate, \
183 Builtin::kArraySingleArgumentConstructor_##kind_camel##_##mode_camel)
184 if (override_mode == DONT_OVERRIDE && AllocationSite::ShouldTrack(kind)) {
186 switch (kind) {
189 default:
190 UNREACHABLE();
191 }
192 } else {
193 DCHECK(override_mode == DISABLE_ALLOCATION_SITES ||
195 switch (kind) {
202 default:
203 UNREACHABLE();
204 }
205 }
206#undef CASE
207}
208
209#ifdef V8_IS_TSAN
210// static
211Builtin CodeFactory::GetTSANStoreStub(SaveFPRegsMode fp_mode, int size,
212 std::memory_order order) {
213 if (order == std::memory_order_relaxed) {
214 if (size == kInt8Size) {
215 return fp_mode == SaveFPRegsMode::kIgnore
216 ? Builtin::kTSANRelaxedStore8IgnoreFP
217 : Builtin::kTSANRelaxedStore8SaveFP;
218 } else if (size == kInt16Size) {
219 return fp_mode == SaveFPRegsMode::kIgnore
220 ? Builtin::kTSANRelaxedStore16IgnoreFP
221 : Builtin::kTSANRelaxedStore16SaveFP;
222 } else if (size == kInt32Size) {
223 return fp_mode == SaveFPRegsMode::kIgnore
224 ? Builtin::kTSANRelaxedStore32IgnoreFP
225 : Builtin::kTSANRelaxedStore32SaveFP;
226 } else {
227 CHECK_EQ(size, kInt64Size);
228 return fp_mode == SaveFPRegsMode::kIgnore
229 ? Builtin::kTSANRelaxedStore64IgnoreFP
230 : Builtin::kTSANRelaxedStore64SaveFP;
231 }
232 } else {
233 DCHECK_EQ(order, std::memory_order_seq_cst);
234 if (size == kInt8Size) {
235 return fp_mode == SaveFPRegsMode::kIgnore
236 ? Builtin::kTSANSeqCstStore8IgnoreFP
237 : Builtin::kTSANSeqCstStore8SaveFP;
238 } else if (size == kInt16Size) {
239 return fp_mode == SaveFPRegsMode::kIgnore
240 ? Builtin::kTSANSeqCstStore16IgnoreFP
241 : Builtin::kTSANSeqCstStore16SaveFP;
242 } else if (size == kInt32Size) {
243 return fp_mode == SaveFPRegsMode::kIgnore
244 ? Builtin::kTSANSeqCstStore32IgnoreFP
245 : Builtin::kTSANSeqCstStore32SaveFP;
246 } else {
247 CHECK_EQ(size, kInt64Size);
248 return fp_mode == SaveFPRegsMode::kIgnore
249 ? Builtin::kTSANSeqCstStore64IgnoreFP
250 : Builtin::kTSANSeqCstStore64SaveFP;
251 }
252 }
253}
254
255// static
256Builtin CodeFactory::GetTSANRelaxedLoadStub(SaveFPRegsMode fp_mode, int size) {
257 if (size == kInt32Size) {
258 return fp_mode == SaveFPRegsMode::kIgnore
259 ? Builtin::kTSANRelaxedLoad32IgnoreFP
260 : Builtin::kTSANRelaxedLoad32SaveFP;
261 } else {
262 CHECK_EQ(size, kInt64Size);
263 return fp_mode == SaveFPRegsMode::kIgnore
264 ? Builtin::kTSANRelaxedLoad64IgnoreFP
265 : Builtin::kTSANRelaxedLoad64SaveFP;
266 }
267}
268#endif // V8_IS_TSAN
269
270} // namespace internal
271} // namespace v8
Builtins::Kind kind
Definition builtins.cc:40
static bool ShouldTrack(ElementsKind boilerplate_elements_kind)
static constexpr Builtin CallFunction(ConvertReceiverMode=ConvertReceiverMode::kAny)
static constexpr Builtin LoadGlobalICInOptimizedCode(TypeofMode typeof_mode)
static constexpr Builtin Call(ConvertReceiverMode=ConvertReceiverMode::kAny)
static constexpr Builtin StringAdd(StringAddFlags flags=STRING_ADD_CHECK_NONE)
static constexpr Builtin CEntry(int result_size, ArgvMode argv_mode, bool builtin_exit_frame=false, bool switch_to_central_stack=false)
static constexpr Builtin LoadGlobalIC(TypeofMode typeof_mode)
static V8_EXPORT_PRIVATE Callable CallableFor(Isolate *isolate, Builtin builtin)
Definition builtins.cc:214
static Callable ConstructFunctionForwardVarargs(Isolate *isolate)
static Callable ConstructWithSpread(Isolate *isolate)
static Callable ArrayNoArgumentConstructor(Isolate *isolate, ElementsKind kind, AllocationSiteOverrideMode override_mode)
static DirectHandle< Code > RuntimeCEntry(Isolate *isolate, int result_size=1, bool switch_to_central_stack=false)
static Callable StringAdd(Isolate *isolate, StringAddFlags flags=STRING_ADD_CHECK_NONE)
static Callable Construct(Isolate *isolate)
static Handle< Code > CEntry(Isolate *isolate, int result_size=1, ArgvMode argv_mode=ArgvMode::kStack, bool builtin_exit_frame=false, bool switch_to_central_stack=false)
static Callable DefineNamedOwnIC(Isolate *isolate)
static Callable LoadGlobalICInOptimizedCode(Isolate *isolate, TypeofMode typeof_mode)
static Callable LoadGlobalIC(Isolate *isolate, TypeofMode typeof_mode)
static Callable CallWithArrayLike(Isolate *isolate)
static Callable Call_WithFeedback(Isolate *isolate, ConvertReceiverMode mode)
static Callable CallWithSpread(Isolate *isolate)
static Callable DefineNamedOwnICInOptimizedCode(Isolate *isolate)
static Callable Call(Isolate *isolate, ConvertReceiverMode mode=ConvertReceiverMode::kAny)
static Callable CallFunctionForwardVarargs(Isolate *isolate)
static Callable CallFunction(Isolate *isolate, ConvertReceiverMode mode=ConvertReceiverMode::kAny)
static Callable CallForwardVarargs(Isolate *isolate)
static Callable FastNewFunctionContext(Isolate *isolate, ScopeType scope_type)
static Callable ConstructForwardVarargs(Isolate *isolate)
static Callable ArraySingleArgumentConstructor(Isolate *isolate, ElementsKind kind, AllocationSiteOverrideMode override_mode)
constexpr int kInt64Size
Definition globals.h:402
constexpr int kInt16Size
Definition globals.h:398
DONT_OVERRIDE DISABLE_ALLOCATION_SITES Holey
constexpr bool IsSmiElementsKind(ElementsKind kind)
DONT_OVERRIDE DISABLE_ALLOCATION_SITES DISABLE_ALLOCATION_SITES HoleyDouble
@ DISABLE_ALLOCATION_SITES
DONT_OVERRIDE DISABLE_ALLOCATION_SITES HOLEY_ELEMENTS
constexpr int kInt32Size
Definition globals.h:401
DONT_OVERRIDE DISABLE_ALLOCATION_SITES DISABLE_ALLOCATION_SITES HOLEY_DOUBLE_ELEMENTS
constexpr int kInt8Size
Definition globals.h:393
DONT_OVERRIDE DisableAllocationSites
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485