1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/builtins/builtins.h"
#include "src/api/api-inl.h"
#include "src/builtins/builtins-descriptors.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/callable.h"
#include "src/codegen/macro-assembler-inl.h"
#include "src/codegen/macro-assembler.h"
#include "src/diagnostics/code-tracer.h"
#include "src/execution/isolate.h"
#include "src/interpreter/bytecodes.h"
#include "src/logging/code-events.h" // For CodeCreateEvent.
#include "src/logging/log.h" // For Logger.
#include "src/objects/fixed-array.h"
#include "src/objects/objects-inl.h"
#include "src/objects/visitors.h"
#include "src/snapshot/embedded/embedded-data.h"
#include "src/utils/ostreams.h"
namespace v8 {
namespace internal {
// Forward declarations for C++ builtins.
#define FORWARD_DECLARE(Name) \
Address Builtin_##Name(int argc, Address* args, Isolate* isolate);
BUILTIN_LIST_C(FORWARD_DECLARE)
#undef FORWARD_DECLARE
namespace {
// TODO(jgruber): Pack in CallDescriptors::Key.
struct BuiltinMetadata {
const char* name;
Builtins::Kind kind;
struct BytecodeAndScale {
interpreter::Bytecode bytecode : 8;
interpreter::OperandScale scale : 8;
};
STATIC_ASSERT(sizeof(interpreter::Bytecode) == 1);
STATIC_ASSERT(sizeof(interpreter::OperandScale) == 1);
STATIC_ASSERT(sizeof(BytecodeAndScale) <= sizeof(Address));
// The `data` field has kind-specific contents.
union KindSpecificData {
// TODO(jgruber): Union constructors are needed since C++11 does not support
// designated initializers (e.g.: {.parameter_count = count}). Update once
// we're at C++20 :)
// The constructors are marked constexpr to avoid the need for a static
// initializer for builtins.cc (see check-static-initializers.sh).
constexpr KindSpecificData() : cpp_entry(kNullAddress) {}
constexpr KindSpecificData(Address cpp_entry) : cpp_entry(cpp_entry) {}
constexpr KindSpecificData(int parameter_count,
int /* To disambiguate from above */)
: parameter_count(static_cast<int16_t>(parameter_count)) {}
constexpr KindSpecificData(interpreter::Bytecode bytecode,
interpreter::OperandScale scale)
: bytecode_and_scale{bytecode, scale} {}
Address cpp_entry; // For CPP builtins.
int16_t parameter_count; // For TFJ builtins.
BytecodeAndScale bytecode_and_scale; // For BCH builtins.
} data;
};
#define DECL_CPP(Name, ...) \
{#Name, Builtins::CPP, {FUNCTION_ADDR(Builtin_##Name)}},
#define DECL_TFJ(Name, Count, ...) {#Name, Builtins::TFJ, {Count, 0}},
#define DECL_TFC(Name, ...) {#Name, Builtins::TFC, {}},
#define DECL_TFS(Name, ...) {#Name, Builtins::TFS, {}},
#define DECL_TFH(Name, ...) {#Name, Builtins::TFH, {}},
#define DECL_BCH(Name, OperandScale, Bytecode) \
{#Name, Builtins::BCH, {Bytecode, OperandScale}},
#define DECL_ASM(Name, ...) {#Name, Builtins::ASM, {}},
const BuiltinMetadata builtin_metadata[] = {BUILTIN_LIST(
DECL_CPP, DECL_TFJ, DECL_TFC, DECL_TFS, DECL_TFH, DECL_BCH, DECL_ASM)};
#undef DECL_CPP
#undef DECL_TFJ
#undef DECL_TFC
#undef DECL_TFS
#undef DECL_TFH
#undef DECL_BCH
#undef DECL_ASM
} // namespace
BytecodeOffset Builtins::GetContinuationBytecodeOffset(Builtin builtin) {
DCHECK(Builtins::KindOf(builtin) == TFJ || Builtins::KindOf(builtin) == TFC ||
Builtins::KindOf(builtin) == TFS);
return BytecodeOffset(BytecodeOffset::kFirstBuiltinContinuationId +
ToInt(builtin));
}
Builtin Builtins::GetBuiltinFromBytecodeOffset(BytecodeOffset id) {
Builtin builtin = Builtins::FromInt(
id.ToInt() - BytecodeOffset::kFirstBuiltinContinuationId);
DCHECK(Builtins::KindOf(builtin) == TFJ || Builtins::KindOf(builtin) == TFC ||
Builtins::KindOf(builtin) == TFS);
return builtin;
}
void Builtins::TearDown() { initialized_ = false; }
const char* Builtins::Lookup(Address pc) {
// Off-heap pc's can be looked up through binary search.
Builtin builtin = OffHeapInstructionStream::TryLookupCode(isolate_, pc);
if (Builtins::IsBuiltinId(builtin)) return name(builtin);
// May be called during initialization (disassembler).
if (!initialized_) return nullptr;
for (Builtin builtin_ix = Builtins::kFirst; builtin_ix <= Builtins::kLast;
++builtin_ix) {
if (code(builtin_ix).contains(isolate_, pc)) return name(builtin_ix);
}
return nullptr;
}
Handle<Code> Builtins::CallFunction(ConvertReceiverMode mode) {
switch (mode) {
case ConvertReceiverMode::kNullOrUndefined:
return code_handle(Builtin::kCallFunction_ReceiverIsNullOrUndefined);
case ConvertReceiverMode::kNotNullOrUndefined:
return code_handle(Builtin::kCallFunction_ReceiverIsNotNullOrUndefined);
case ConvertReceiverMode::kAny:
return code_handle(Builtin::kCallFunction_ReceiverIsAny);
}
UNREACHABLE();
}
Handle<Code> Builtins::Call(ConvertReceiverMode mode) {
switch (mode) {
case ConvertReceiverMode::kNullOrUndefined:
return code_handle(Builtin::kCall_ReceiverIsNullOrUndefined);
case ConvertReceiverMode::kNotNullOrUndefined:
return code_handle(Builtin::kCall_ReceiverIsNotNullOrUndefined);
case ConvertReceiverMode::kAny:
return code_handle(Builtin::kCall_ReceiverIsAny);
}
UNREACHABLE();
}
Handle<Code> Builtins::NonPrimitiveToPrimitive(ToPrimitiveHint hint) {
switch (hint) {
case ToPrimitiveHint::kDefault:
return code_handle(Builtin::kNonPrimitiveToPrimitive_Default);
case ToPrimitiveHint::kNumber:
return code_handle(Builtin::kNonPrimitiveToPrimitive_Number);
case ToPrimitiveHint::kString:
return code_handle(Builtin::kNonPrimitiveToPrimitive_String);
}
UNREACHABLE();
}
Handle<Code> Builtins::OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint) {
switch (hint) {
case OrdinaryToPrimitiveHint::kNumber:
return code_handle(Builtin::kOrdinaryToPrimitive_Number);
case OrdinaryToPrimitiveHint::kString:
return code_handle(Builtin::kOrdinaryToPrimitive_String);
}
UNREACHABLE();
}
FullObjectSlot Builtins::builtin_slot(Builtin builtin) {
Address* location = &isolate_->builtin_table()[Builtins::ToInt(builtin)];
return FullObjectSlot(location);
}
FullObjectSlot Builtins::builtin_tier0_slot(Builtin builtin) {
DCHECK(IsTier0(builtin));
Address* location =
&isolate_->builtin_tier0_table()[Builtins::ToInt(builtin)];
return FullObjectSlot(location);
}
void Builtins::set_code(Builtin builtin, Code code) {
DCHECK_EQ(builtin, code.builtin_id());
DCHECK(Internals::HasHeapObjectTag(code.ptr()));
// The given builtin may be uninitialized thus we cannot check its type here.
isolate_->builtin_table()[Builtins::ToInt(builtin)] = code.ptr();
}
Code Builtins::code(Builtin builtin) {
Address ptr = isolate_->builtin_table()[Builtins::ToInt(builtin)];
return Code::cast(Object(ptr));
}
Handle<Code> Builtins::code_handle(Builtin builtin) {
Address* location = &isolate_->builtin_table()[Builtins::ToInt(builtin)];
return Handle<Code>(location);
}
FullObjectSlot Builtins::builtin_code_data_container_slot(Builtin builtin) {
CHECK(V8_EXTERNAL_CODE_SPACE_BOOL);
Address* location =
&isolate_->builtin_code_data_container_table()[Builtins::ToInt(builtin)];
return FullObjectSlot(location);
}
void Builtins::set_codet(Builtin builtin, CodeT code) {
CHECK(V8_EXTERNAL_CODE_SPACE_BOOL);
// TODO(v8:11880): add DCHECK_EQ(builtin, code.builtin_id()); once CodeT
// has respective field.
DCHECK(Internals::HasHeapObjectTag(code.ptr()));
// The given builtin may be uninitialized thus we cannot check its type here.
isolate_->builtin_code_data_container_table()[Builtins::ToInt(builtin)] =
code.ptr();
}
CodeT Builtins::codet(Builtin builtin) {
Address* table = V8_EXTERNAL_CODE_SPACE_BOOL
? isolate_->builtin_code_data_container_table()
: isolate_->builtin_table();
Address ptr = table[Builtins::ToInt(builtin)];
return CodeT::cast(Object(ptr));
}
Handle<CodeT> Builtins::codet_handle(Builtin builtin) {
Address* table = V8_EXTERNAL_CODE_SPACE_BOOL
? isolate_->builtin_code_data_container_table()
: isolate_->builtin_table();
Address* location = &table[Builtins::ToInt(builtin)];
return Handle<CodeT>(location);
}
// static
int Builtins::GetStackParameterCount(Builtin builtin) {
DCHECK(Builtins::KindOf(builtin) == TFJ);
return builtin_metadata[ToInt(builtin)].data.parameter_count;
}
// static
CallInterfaceDescriptor Builtins::CallInterfaceDescriptorFor(Builtin builtin) {
CallDescriptors::Key key;
switch (builtin) {
// This macro is deliberately crafted so as to emit very little code,
// in order to keep binary size of this function under control.
#define CASE_OTHER(Name, ...) \
case Builtin::k##Name: { \
key = Builtin_##Name##_InterfaceDescriptor::key(); \
break; \
}
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, CASE_OTHER, CASE_OTHER,
CASE_OTHER, IGNORE_BUILTIN, CASE_OTHER)
#undef CASE_OTHER
default:
Builtins::Kind kind = Builtins::KindOf(builtin);
DCHECK_NE(BCH, kind);
if (kind == TFJ || kind == CPP) {
return JSTrampolineDescriptor{};
}
UNREACHABLE();
}
return CallInterfaceDescriptor{key};
}
// static
Callable Builtins::CallableFor(Isolate* isolate, Builtin builtin) {
Handle<Code> code = isolate->builtins()->code_handle(builtin);
return Callable{code, CallInterfaceDescriptorFor(builtin)};
}
// static
bool Builtins::HasJSLinkage(Builtin builtin) {
DCHECK_NE(BCH, Builtins::KindOf(builtin));
return CallInterfaceDescriptorFor(builtin) == JSTrampolineDescriptor{};
}
// static
const char* Builtins::name(Builtin builtin) {
int index = ToInt(builtin);
DCHECK(IsBuiltinId(index));
return builtin_metadata[index].name;
}
void Builtins::PrintBuiltinCode() {
DCHECK(FLAG_print_builtin_code);
#ifdef ENABLE_DISASSEMBLER
for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast;
++builtin) {
const char* builtin_name = name(builtin);
Handle<Code> code = code_handle(builtin);
if (PassesFilter(base::CStrVector(builtin_name),
base::CStrVector(FLAG_print_builtin_code_filter))) {
CodeTracer::Scope trace_scope(isolate_->GetCodeTracer());
OFStream os(trace_scope.file());
code->Disassemble(builtin_name, os, isolate_);
os << "\n";
}
}
#endif
}
void Builtins::PrintBuiltinSize() {
DCHECK(FLAG_print_builtin_size);
for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast;
++builtin) {
const char* builtin_name = name(builtin);
const char* kind = KindNameOf(builtin);
Code code = Builtins::code(builtin);
PrintF(stdout, "%s Builtin, %s, %d\n", kind, builtin_name,
code.InstructionSize());
}
}
// static
Address Builtins::CppEntryOf(Builtin builtin) {
DCHECK(Builtins::IsCpp(builtin));
return builtin_metadata[ToInt(builtin)].data.cpp_entry;
}
// static
bool Builtins::IsBuiltin(const Code code) {
return Builtins::IsBuiltinId(code.builtin_id());
}
bool Builtins::IsBuiltinHandle(Handle<HeapObject> maybe_code,
Builtin* builtin) const {
Address* handle_location = maybe_code.location();
Address* builtins_table = isolate_->builtin_table();
if (handle_location < builtins_table) return false;
Address* builtins_table_end = &builtins_table[Builtins::kBuiltinCount];
if (handle_location >= builtins_table_end) return false;
*builtin = FromInt(static_cast<int>(handle_location - builtins_table));
return true;
}
bool Builtins::IsBuiltinCodeDataContainerHandle(Handle<HeapObject> maybe_code,
Builtin* builtin) const {
Address* handle_location = maybe_code.location();
Address* builtins_table = isolate_->builtin_code_data_container_table();
if (handle_location < builtins_table) return false;
Address* builtins_table_end = &builtins_table[Builtins::kBuiltinCount];
if (handle_location >= builtins_table_end) return false;
*builtin = FromInt(static_cast<int>(handle_location - builtins_table));
return true;
}
// static
bool Builtins::IsIsolateIndependentBuiltin(const Code code) {
const Builtin builtin = code.builtin_id();
return Builtins::IsBuiltinId(builtin) &&
Builtins::IsIsolateIndependent(builtin);
}
// static
void Builtins::InitializeIsolateDataTables(Isolate* isolate) {
EmbeddedData embedded_data = EmbeddedData::FromBlob(isolate);
IsolateData* isolate_data = isolate->isolate_data();
// The entry table.
for (Builtin i = Builtins::kFirst; i <= Builtins::kLast; ++i) {
DCHECK(Builtins::IsBuiltinId(isolate->builtins()->code(i).builtin_id()));
DCHECK(isolate->builtins()->code(i).is_off_heap_trampoline());
isolate_data->builtin_entry_table()[ToInt(i)] =
embedded_data.InstructionStartOfBuiltin(i);
}
// T0 tables.
for (Builtin i = Builtins::kFirst; i <= Builtins::kLastTier0; ++i) {
const int ii = ToInt(i);
isolate_data->builtin_tier0_entry_table()[ii] =
isolate_data->builtin_entry_table()[ii];
isolate_data->builtin_tier0_table()[ii] = isolate_data->builtin_table()[ii];
}
}
// static
void Builtins::EmitCodeCreateEvents(Isolate* isolate) {
if (!isolate->logger()->is_listening_to_code_events() &&
!isolate->is_profiling()) {
return; // No need to iterate the entire table in this case.
}
Address* builtins = isolate->builtin_table();
int i = 0;
HandleScope scope(isolate);
for (; i < ToInt(Builtin::kFirstBytecodeHandler); i++) {
Handle<AbstractCode> code(AbstractCode::cast(Object(builtins[i])), isolate);
PROFILE(isolate, CodeCreateEvent(CodeEventListener::BUILTIN_TAG, code,
Builtins::name(FromInt(i))));
}
STATIC_ASSERT(kLastBytecodeHandlerPlusOne == kBuiltinCount);
for (; i < kBuiltinCount; i++) {
Handle<AbstractCode> code(AbstractCode::cast(Object(builtins[i])), isolate);
interpreter::Bytecode bytecode =
builtin_metadata[i].data.bytecode_and_scale.bytecode;
interpreter::OperandScale scale =
builtin_metadata[i].data.bytecode_and_scale.scale;
PROFILE(isolate,
CodeCreateEvent(
CodeEventListener::BYTECODE_HANDLER_TAG, code,
interpreter::Bytecodes::ToString(bytecode, scale).c_str()));
}
}
namespace {
enum TrampolineType { kAbort, kJump };
class OffHeapTrampolineGenerator {
public:
explicit OffHeapTrampolineGenerator(Isolate* isolate)
: isolate_(isolate),
masm_(isolate, AssemblerOptions::DefaultForOffHeapTrampoline(isolate),
CodeObjectRequired::kYes,
ExternalAssemblerBuffer(buffer_, kBufferSize)) {}
CodeDesc Generate(Address off_heap_entry, TrampolineType type) {
// Generate replacement code that simply tail-calls the off-heap code.
DCHECK(!masm_.has_frame());
{
FrameScope scope(&masm_, StackFrame::NO_FRAME_TYPE);
if (type == TrampolineType::kJump) {
masm_.CodeEntry();
masm_.JumpToOffHeapInstructionStream(off_heap_entry);
} else {
DCHECK_EQ(type, TrampolineType::kAbort);
masm_.Trap();
}
}
CodeDesc desc;
masm_.GetCode(isolate_, &desc);
return desc;
}
Handle<HeapObject> CodeObject() { return masm_.CodeObject(); }
private:
Isolate* isolate_;
// Enough to fit the single jmp.
static constexpr int kBufferSize = 256;
byte buffer_[kBufferSize];
MacroAssembler masm_;
};
constexpr int OffHeapTrampolineGenerator::kBufferSize;
} // namespace
// static
Handle<Code> Builtins::GenerateOffHeapTrampolineFor(
Isolate* isolate, Address off_heap_entry, int32_t kind_specfic_flags,
bool generate_jump_to_instruction_stream) {
DCHECK_NOT_NULL(isolate->embedded_blob_code());
DCHECK_NE(0, isolate->embedded_blob_code_size());
OffHeapTrampolineGenerator generator(isolate);
CodeDesc desc =
generator.Generate(off_heap_entry, generate_jump_to_instruction_stream
? TrampolineType::kJump
: TrampolineType::kAbort);
return Factory::CodeBuilder(isolate, desc, CodeKind::BUILTIN)
.set_kind_specific_flags(kind_specfic_flags)
.set_read_only_data_container(!V8_EXTERNAL_CODE_SPACE_BOOL)
.set_self_reference(generator.CodeObject())
.set_is_executable(generate_jump_to_instruction_stream)
.Build();
}
// static
Handle<ByteArray> Builtins::GenerateOffHeapTrampolineRelocInfo(
Isolate* isolate) {
OffHeapTrampolineGenerator generator(isolate);
// Generate a jump to a dummy address as we're not actually interested in the
// generated instruction stream.
CodeDesc desc = generator.Generate(kNullAddress, TrampolineType::kJump);
Handle<ByteArray> reloc_info = isolate->factory()->NewByteArray(
desc.reloc_size, AllocationType::kReadOnly);
Code::CopyRelocInfoToByteArray(*reloc_info, desc);
return reloc_info;
}
Builtins::Kind Builtins::KindOf(Builtin builtin) {
DCHECK(IsBuiltinId(builtin));
return builtin_metadata[ToInt(builtin)].kind;
}
// static
const char* Builtins::KindNameOf(Builtin builtin) {
Kind kind = Builtins::KindOf(builtin);
// clang-format off
switch (kind) {
case CPP: return "CPP";
case TFJ: return "TFJ";
case TFC: return "TFC";
case TFS: return "TFS";
case TFH: return "TFH";
case BCH: return "BCH";
case ASM: return "ASM";
}
// clang-format on
UNREACHABLE();
}
// static
bool Builtins::IsCpp(Builtin builtin) {
return Builtins::KindOf(builtin) == CPP;
}
// static
bool Builtins::AllowDynamicFunction(Isolate* isolate, Handle<JSFunction> target,
Handle<JSObject> target_global_proxy) {
if (FLAG_allow_unsafe_function_constructor) return true;
HandleScopeImplementer* impl = isolate->handle_scope_implementer();
Handle<Context> responsible_context = impl->LastEnteredOrMicrotaskContext();
// TODO(jochen): Remove this.
if (responsible_context.is_null()) {
return true;
}
if (*responsible_context == target->context()) return true;
return isolate->MayAccess(responsible_context, target_global_proxy);
}
// static
bool Builtins::CodeObjectIsExecutable(Builtin builtin) {
// If the runtime/optimized code always knows when executing a given builtin
// that it is a builtin, then that builtin does not need an executable Code
// object. Such Code objects can go in read_only_space (and can even be
// smaller with no branch instruction), thus saving memory.
// Builtins with JS linkage will always have executable Code objects since
// they can be called directly from jitted code with no way of determining
// that they are builtins at generation time. E.g.
// f = Array.of;
// f(1, 2, 3);
// TODO(delphick): This is probably too loose but for now Wasm can call any JS
// linkage builtin via its Code object. Once Wasm is fixed this can either be
// tighted or removed completely.
if (Builtins::KindOf(builtin) != BCH && HasJSLinkage(builtin)) {
return true;
}
// There are some other non-TF builtins that also have JS linkage like
// InterpreterEntryTrampoline which are explicitly allow-listed below.
// TODO(delphick): Some of these builtins do not fit with the above, but
// currently cause problems if they're not executable. This list should be
// pared down as much as possible.
switch (builtin) {
case Builtin::kInterpreterEntryTrampoline:
case Builtin::kCompileLazy:
case Builtin::kCompileLazyDeoptimizedCode:
case Builtin::kCallFunction_ReceiverIsNullOrUndefined:
case Builtin::kCallFunction_ReceiverIsNotNullOrUndefined:
case Builtin::kCallFunction_ReceiverIsAny:
case Builtin::kCallBoundFunction:
case Builtin::kCall_ReceiverIsNullOrUndefined:
case Builtin::kCall_ReceiverIsNotNullOrUndefined:
case Builtin::kCall_ReceiverIsAny:
case Builtin::kHandleApiCall:
case Builtin::kInstantiateAsmJs:
#if V8_ENABLE_WEBASSEMBLY
case Builtin::kGenericJSToWasmWrapper:
#endif // V8_ENABLE_WEBASSEMBLY
// TODO(delphick): Remove this when calls to it have the trampoline inlined
// or are converted to use kCallBuiltinPointer.
case Builtin::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit:
return true;
default:
#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
// TODO(Loongson): Move non-JS linkage builtins code objects into RO_SPACE
// caused MIPS platform to crash, and we need some time to handle it. Now
// disable this change temporarily on MIPS platform.
return true;
#else
return false;
#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
}
}
Builtin ExampleBuiltinForTorqueFunctionPointerType(
size_t function_pointer_type_id) {
switch (function_pointer_type_id) {
#define FUNCTION_POINTER_ID_CASE(id, name) \
case id: \
return Builtin::k##name;
TORQUE_FUNCTION_POINTER_TYPE_TO_BUILTIN_MAP(FUNCTION_POINTER_ID_CASE)
#undef FUNCTION_POINTER_ID_CASE
default:
UNREACHABLE();
}
}
} // namespace internal
} // namespace v8
|