Line data Source code
1 : // Copyright 2018 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 : #include "src/external-reference.h"
6 :
7 : #include "src/api.h"
8 : #include "src/base/ieee754.h"
9 : #include "src/compiler/code-assembler.h"
10 : #include "src/counters.h"
11 : #include "src/cpu-features.h"
12 : #include "src/date.h"
13 : #include "src/debug/debug.h"
14 : #include "src/deoptimizer.h"
15 : #include "src/elements.h"
16 : #include "src/hash-seed-inl.h"
17 : #include "src/heap/heap.h"
18 : // For IncrementalMarking::RecordWriteFromCode. TODO(jkummerow): Drop.
19 : #include "src/heap/heap-inl.h"
20 : #include "src/ic/stub-cache.h"
21 : #include "src/interpreter/interpreter.h"
22 : #include "src/isolate.h"
23 : #include "src/log.h"
24 : #include "src/math-random.h"
25 : #include "src/microtask-queue.h"
26 : #include "src/objects-inl.h"
27 : #include "src/regexp/regexp-stack.h"
28 : #include "src/simulator-base.h"
29 : #include "src/string-search.h"
30 : #include "src/wasm/wasm-external-refs.h"
31 :
32 : // Include native regexp-macro-assembler.
33 : #if V8_TARGET_ARCH_IA32
34 : #include "src/regexp/ia32/regexp-macro-assembler-ia32.h" // NOLINT
35 : #elif V8_TARGET_ARCH_X64
36 : #include "src/regexp/x64/regexp-macro-assembler-x64.h" // NOLINT
37 : #elif V8_TARGET_ARCH_ARM64
38 : #include "src/regexp/arm64/regexp-macro-assembler-arm64.h" // NOLINT
39 : #elif V8_TARGET_ARCH_ARM
40 : #include "src/regexp/arm/regexp-macro-assembler-arm.h" // NOLINT
41 : #elif V8_TARGET_ARCH_PPC
42 : #include "src/regexp/ppc/regexp-macro-assembler-ppc.h" // NOLINT
43 : #elif V8_TARGET_ARCH_MIPS
44 : #include "src/regexp/mips/regexp-macro-assembler-mips.h" // NOLINT
45 : #elif V8_TARGET_ARCH_MIPS64
46 : #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" // NOLINT
47 : #elif V8_TARGET_ARCH_S390
48 : #include "src/regexp/s390/regexp-macro-assembler-s390.h" // NOLINT
49 : #else // Unknown architecture.
50 : #error "Unknown architecture."
51 : #endif // Target architecture.
52 :
53 : #ifdef V8_INTL_SUPPORT
54 : #include "src/objects/intl-objects.h"
55 : #endif // V8_INTL_SUPPORT
56 :
57 : namespace v8 {
58 : namespace internal {
59 :
60 : // -----------------------------------------------------------------------------
61 : // Common double constants.
62 :
63 : constexpr double double_min_int_constant = kMinInt;
64 : constexpr double double_one_half_constant = 0.5;
65 : constexpr uint64_t double_the_hole_nan_constant = kHoleNanInt64;
66 : constexpr double double_uint32_bias_constant =
67 : static_cast<double>(kMaxUInt32) + 1;
68 :
69 : constexpr struct alignas(16) {
70 : uint32_t a;
71 : uint32_t b;
72 : uint32_t c;
73 : uint32_t d;
74 : } float_absolute_constant = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
75 :
76 : constexpr struct alignas(16) {
77 : uint32_t a;
78 : uint32_t b;
79 : uint32_t c;
80 : uint32_t d;
81 : } float_negate_constant = {0x80000000, 0x80000000, 0x80000000, 0x80000000};
82 :
83 : constexpr struct alignas(16) {
84 : uint64_t a;
85 : uint64_t b;
86 : } double_absolute_constant = {uint64_t{0x7FFFFFFFFFFFFFFF},
87 : uint64_t{0x7FFFFFFFFFFFFFFF}};
88 :
89 : constexpr struct alignas(16) {
90 : uint64_t a;
91 : uint64_t b;
92 : } double_negate_constant = {uint64_t{0x8000000000000000},
93 : uint64_t{0x8000000000000000}};
94 :
95 : // Implementation of ExternalReference
96 :
97 : static ExternalReference::Type BuiltinCallTypeForResultSize(int result_size) {
98 29645806 : switch (result_size) {
99 : case 1:
100 : return ExternalReference::BUILTIN_CALL;
101 : case 2:
102 : return ExternalReference::BUILTIN_CALL_PAIR;
103 : }
104 0 : UNREACHABLE();
105 : }
106 :
107 : // static
108 3579784 : ExternalReference ExternalReference::Create(
109 : ApiFunction* fun, Type type = ExternalReference::BUILTIN_CALL) {
110 3579784 : return ExternalReference(Redirect(fun->address(), type));
111 : }
112 :
113 : // static
114 29643764 : ExternalReference ExternalReference::Create(Runtime::FunctionId id) {
115 59287534 : return Create(Runtime::FunctionForId(id));
116 : }
117 :
118 : // static
119 2036 : ExternalReference ExternalReference::Create(const Runtime::Function* f) {
120 : return ExternalReference(
121 59291612 : Redirect(f->entry, BuiltinCallTypeForResultSize(f->result_size)));
122 : }
123 :
124 : // static
125 17000832 : ExternalReference ExternalReference::Create(Address address) {
126 17000832 : return ExternalReference(Redirect(address));
127 : }
128 :
129 238241 : ExternalReference ExternalReference::isolate_address(Isolate* isolate) {
130 238241 : return ExternalReference(isolate);
131 : }
132 :
133 63898 : ExternalReference ExternalReference::builtins_address(Isolate* isolate) {
134 63898 : return ExternalReference(isolate->heap()->builtin_address(0));
135 : }
136 :
137 62206 : ExternalReference ExternalReference::handle_scope_implementer_address(
138 : Isolate* isolate) {
139 62206 : return ExternalReference(isolate->handle_scope_implementer_address());
140 : }
141 :
142 63214 : ExternalReference ExternalReference::interpreter_dispatch_table_address(
143 : Isolate* isolate) {
144 63214 : return ExternalReference(isolate->interpreter()->dispatch_table_address());
145 : }
146 :
147 61534 : ExternalReference ExternalReference::interpreter_dispatch_counters(
148 : Isolate* isolate) {
149 : return ExternalReference(
150 61534 : isolate->interpreter()->bytecode_dispatch_counters_table());
151 : }
152 :
153 : ExternalReference
154 61646 : ExternalReference::address_of_interpreter_entry_trampoline_instruction_start(
155 : Isolate* isolate) {
156 : return ExternalReference(
157 : isolate->interpreter()
158 61646 : ->address_of_interpreter_entry_trampoline_instruction_start());
159 : }
160 :
161 61650 : ExternalReference ExternalReference::bytecode_size_table_address() {
162 : return ExternalReference(
163 61650 : interpreter::Bytecodes::bytecode_size_table_address());
164 : }
165 :
166 : // static
167 0 : ExternalReference ExternalReference::Create(StatsCounter* counter) {
168 : return ExternalReference(
169 0 : reinterpret_cast<Address>(counter->GetInternalPointer()));
170 : }
171 :
172 : // static
173 51420 : ExternalReference ExternalReference::Create(IsolateAddressId id,
174 : Isolate* isolate) {
175 51420 : return ExternalReference(isolate->get_address_from_id(id));
176 : }
177 :
178 : // static
179 568 : ExternalReference ExternalReference::Create(const SCTableReference& table_ref) {
180 568 : return ExternalReference(table_ref.address());
181 : }
182 :
183 : namespace {
184 :
185 : // Helper function to verify that all types in a list of types are scalar.
186 : // This includes primitive types (int, Address) and pointer types. We also
187 : // allow void.
188 : template <typename T>
189 : constexpr bool AllScalar() {
190 : return std::is_scalar<T>::value || std::is_void<T>::value;
191 : }
192 :
193 : template <typename T1, typename T2, typename... Rest>
194 : constexpr bool AllScalar() {
195 : return AllScalar<T1>() && AllScalar<T2, Rest...>();
196 : }
197 :
198 : // Checks a function pointer's type for compatibility with the
199 : // ExternalReference calling mechanism. Specifically, all arguments
200 : // as well as the result type must pass the AllScalar check above,
201 : // because we expect each item to fit into one register or stack slot.
202 : template <typename T>
203 : struct IsValidExternalReferenceType;
204 :
205 : template <typename Result, typename... Args>
206 : struct IsValidExternalReferenceType<Result (*)(Args...)> {
207 : static const bool value = AllScalar<Result, Args...>();
208 : };
209 :
210 : template <typename Result, typename Class, typename... Args>
211 : struct IsValidExternalReferenceType<Result (Class::*)(Args...)> {
212 : static const bool value = AllScalar<Result, Args...>();
213 : };
214 :
215 : } // namespace
216 :
217 : #define FUNCTION_REFERENCE(Name, Target) \
218 : ExternalReference ExternalReference::Name() { \
219 : STATIC_ASSERT(IsValidExternalReferenceType<decltype(&Target)>::value); \
220 : return ExternalReference(Redirect(FUNCTION_ADDR(Target))); \
221 : }
222 :
223 : #define FUNCTION_REFERENCE_WITH_ISOLATE(Name, Target) \
224 : ExternalReference ExternalReference::Name(Isolate* isolate) { \
225 : STATIC_ASSERT(IsValidExternalReferenceType<decltype(&Target)>::value); \
226 : return ExternalReference(Redirect(FUNCTION_ADDR(Target))); \
227 : }
228 :
229 : #define FUNCTION_REFERENCE_WITH_TYPE(Name, Target, Type) \
230 : ExternalReference ExternalReference::Name() { \
231 : STATIC_ASSERT(IsValidExternalReferenceType<decltype(&Target)>::value); \
232 : return ExternalReference(Redirect(FUNCTION_ADDR(Target), Type)); \
233 : }
234 :
235 61594 : FUNCTION_REFERENCE(incremental_marking_record_write_function,
236 : IncrementalMarking::RecordWriteFromCode)
237 :
238 61650 : ExternalReference ExternalReference::store_buffer_overflow_function() {
239 : return ExternalReference(
240 61650 : Redirect(Heap::store_buffer_overflow_function_address()));
241 : }
242 :
243 61650 : FUNCTION_REFERENCE(delete_handle_scope_extensions,
244 : HandleScope::DeleteExtensions)
245 :
246 62490 : FUNCTION_REFERENCE(get_date_field_function, JSDate::GetField)
247 :
248 61926 : ExternalReference ExternalReference::date_cache_stamp(Isolate* isolate) {
249 61926 : return ExternalReference(isolate->date_cache()->stamp_address());
250 : }
251 :
252 : // static
253 : ExternalReference
254 6 : ExternalReference::runtime_function_table_address_for_unittests(
255 : Isolate* isolate) {
256 6 : return runtime_function_table_address(isolate);
257 : }
258 :
259 : // static
260 0 : Address ExternalReference::Redirect(Address address, Type type) {
261 : #ifdef USE_SIMULATOR
262 : return SimulatorBase::RedirectExternalReference(address, type);
263 : #else
264 0 : return address;
265 : #endif
266 : }
267 :
268 61822 : ExternalReference ExternalReference::stress_deopt_count(Isolate* isolate) {
269 61822 : return ExternalReference(isolate->stress_deopt_count_address());
270 : }
271 :
272 61534 : ExternalReference ExternalReference::force_slow_path(Isolate* isolate) {
273 61534 : return ExternalReference(isolate->force_slow_path_address());
274 : }
275 :
276 105565 : FUNCTION_REFERENCE(new_deoptimizer_function, Deoptimizer::New)
277 :
278 105566 : FUNCTION_REFERENCE(compute_output_frames_function,
279 : Deoptimizer::ComputeOutputFrames)
280 :
281 61542 : FUNCTION_REFERENCE(wasm_f32_trunc, wasm::f32_trunc_wrapper)
282 61542 : FUNCTION_REFERENCE(wasm_f32_floor, wasm::f32_floor_wrapper)
283 61542 : FUNCTION_REFERENCE(wasm_f32_ceil, wasm::f32_ceil_wrapper)
284 61542 : FUNCTION_REFERENCE(wasm_f32_nearest_int, wasm::f32_nearest_int_wrapper)
285 61542 : FUNCTION_REFERENCE(wasm_f64_trunc, wasm::f64_trunc_wrapper)
286 61542 : FUNCTION_REFERENCE(wasm_f64_floor, wasm::f64_floor_wrapper)
287 61542 : FUNCTION_REFERENCE(wasm_f64_ceil, wasm::f64_ceil_wrapper)
288 61542 : FUNCTION_REFERENCE(wasm_f64_nearest_int, wasm::f64_nearest_int_wrapper)
289 61542 : FUNCTION_REFERENCE(wasm_int64_to_float32, wasm::int64_to_float32_wrapper)
290 61542 : FUNCTION_REFERENCE(wasm_uint64_to_float32, wasm::uint64_to_float32_wrapper)
291 61542 : FUNCTION_REFERENCE(wasm_int64_to_float64, wasm::int64_to_float64_wrapper)
292 61542 : FUNCTION_REFERENCE(wasm_uint64_to_float64, wasm::uint64_to_float64_wrapper)
293 61542 : FUNCTION_REFERENCE(wasm_float32_to_int64, wasm::float32_to_int64_wrapper)
294 61542 : FUNCTION_REFERENCE(wasm_float32_to_uint64, wasm::float32_to_uint64_wrapper)
295 61542 : FUNCTION_REFERENCE(wasm_float64_to_int64, wasm::float64_to_int64_wrapper)
296 61542 : FUNCTION_REFERENCE(wasm_float64_to_uint64, wasm::float64_to_uint64_wrapper)
297 61542 : FUNCTION_REFERENCE(wasm_int64_div, wasm::int64_div_wrapper)
298 61542 : FUNCTION_REFERENCE(wasm_int64_mod, wasm::int64_mod_wrapper)
299 61542 : FUNCTION_REFERENCE(wasm_uint64_div, wasm::uint64_div_wrapper)
300 61542 : FUNCTION_REFERENCE(wasm_uint64_mod, wasm::uint64_mod_wrapper)
301 61542 : FUNCTION_REFERENCE(wasm_word32_ctz, wasm::word32_ctz_wrapper)
302 61542 : FUNCTION_REFERENCE(wasm_word64_ctz, wasm::word64_ctz_wrapper)
303 61542 : FUNCTION_REFERENCE(wasm_word32_popcnt, wasm::word32_popcnt_wrapper)
304 61542 : FUNCTION_REFERENCE(wasm_word64_popcnt, wasm::word64_popcnt_wrapper)
305 75022 : FUNCTION_REFERENCE(wasm_word32_rol, wasm::word32_rol_wrapper)
306 75006 : FUNCTION_REFERENCE(wasm_word32_ror, wasm::word32_ror_wrapper)
307 61626 : FUNCTION_REFERENCE(wasm_memory_copy, wasm::memory_copy_wrapper)
308 61578 : FUNCTION_REFERENCE(wasm_memory_fill, wasm::memory_fill_wrapper)
309 :
310 4328 : static void f64_acos_wrapper(Address data) {
311 : double input = ReadUnalignedValue<double>(data);
312 4328 : WriteUnalignedValue(data, base::ieee754::acos(input));
313 4328 : }
314 :
315 61559 : FUNCTION_REFERENCE(f64_acos_wrapper_function, f64_acos_wrapper)
316 :
317 4328 : static void f64_asin_wrapper(Address data) {
318 : double input = ReadUnalignedValue<double>(data);
319 4328 : WriteUnalignedValue<double>(data, base::ieee754::asin(input));
320 4328 : }
321 :
322 61559 : FUNCTION_REFERENCE(f64_asin_wrapper_function, f64_asin_wrapper)
323 :
324 61551 : FUNCTION_REFERENCE(wasm_float64_pow, wasm::float64_pow_wrapper)
325 :
326 32 : static void f64_mod_wrapper(Address data) {
327 : double dividend = ReadUnalignedValue<double>(data);
328 32 : double divisor = ReadUnalignedValue<double>(data + sizeof(dividend));
329 : WriteUnalignedValue<double>(data, Modulo(dividend, divisor));
330 32 : }
331 :
332 61558 : FUNCTION_REFERENCE(f64_mod_wrapper_function, f64_mod_wrapper)
333 :
334 432790 : FUNCTION_REFERENCE(wasm_call_trap_callback_for_testing,
335 : wasm::call_trap_callback_for_testing)
336 :
337 61538 : FUNCTION_REFERENCE(log_enter_external_function, Logger::EnterExternal)
338 61538 : FUNCTION_REFERENCE(log_leave_external_function, Logger::LeaveExternal)
339 :
340 950593 : ExternalReference ExternalReference::isolate_root(Isolate* isolate) {
341 950593 : return ExternalReference(isolate->isolate_root());
342 : }
343 :
344 61926 : ExternalReference ExternalReference::allocation_sites_list_address(
345 : Isolate* isolate) {
346 61926 : return ExternalReference(isolate->heap()->allocation_sites_list_address());
347 : }
348 :
349 1454848 : ExternalReference ExternalReference::address_of_stack_limit(Isolate* isolate) {
350 1454848 : return ExternalReference(isolate->stack_guard()->address_of_jslimit());
351 : }
352 :
353 61534 : ExternalReference ExternalReference::address_of_real_stack_limit(
354 : Isolate* isolate) {
355 61534 : return ExternalReference(isolate->stack_guard()->address_of_real_jslimit());
356 : }
357 :
358 61646 : ExternalReference ExternalReference::store_buffer_top(Isolate* isolate) {
359 123292 : return ExternalReference(isolate->heap()->store_buffer_top_address());
360 : }
361 :
362 61590 : ExternalReference ExternalReference::heap_is_marking_flag_address(
363 : Isolate* isolate) {
364 61590 : return ExternalReference(isolate->heap()->IsMarkingFlagAddress());
365 : }
366 :
367 331644 : ExternalReference ExternalReference::new_space_allocation_top_address(
368 : Isolate* isolate) {
369 331644 : return ExternalReference(isolate->heap()->NewSpaceAllocationTopAddress());
370 : }
371 :
372 321366 : ExternalReference ExternalReference::new_space_allocation_limit_address(
373 : Isolate* isolate) {
374 321366 : return ExternalReference(isolate->heap()->NewSpaceAllocationLimitAddress());
375 : }
376 :
377 62144 : ExternalReference ExternalReference::old_space_allocation_top_address(
378 : Isolate* isolate) {
379 62144 : return ExternalReference(isolate->heap()->OldSpaceAllocationTopAddress());
380 : }
381 :
382 62144 : ExternalReference ExternalReference::old_space_allocation_limit_address(
383 : Isolate* isolate) {
384 62144 : return ExternalReference(isolate->heap()->OldSpaceAllocationLimitAddress());
385 : }
386 :
387 61646 : ExternalReference ExternalReference::handle_scope_level_address(
388 : Isolate* isolate) {
389 61646 : return ExternalReference(HandleScope::current_level_address(isolate));
390 : }
391 :
392 61646 : ExternalReference ExternalReference::handle_scope_next_address(
393 : Isolate* isolate) {
394 61646 : return ExternalReference(HandleScope::current_next_address(isolate));
395 : }
396 :
397 61646 : ExternalReference ExternalReference::handle_scope_limit_address(
398 : Isolate* isolate) {
399 61646 : return ExternalReference(HandleScope::current_limit_address(isolate));
400 : }
401 :
402 61646 : ExternalReference ExternalReference::scheduled_exception_address(
403 : Isolate* isolate) {
404 61646 : return ExternalReference(isolate->scheduled_exception_address());
405 : }
406 :
407 118814 : ExternalReference ExternalReference::address_of_pending_message_obj(
408 : Isolate* isolate) {
409 118814 : return ExternalReference(isolate->pending_message_obj_address());
410 : }
411 :
412 61548 : FUNCTION_REFERENCE(abort_with_reason, i::abort_with_reason)
413 :
414 : ExternalReference
415 61874 : ExternalReference::address_of_harmony_await_optimization_flag() {
416 61874 : return ExternalReference(&FLAG_harmony_await_optimization);
417 : }
418 :
419 61558 : ExternalReference ExternalReference::address_of_min_int() {
420 61558 : return ExternalReference(reinterpret_cast<Address>(&double_min_int_constant));
421 : }
422 :
423 : ExternalReference
424 61538 : ExternalReference::address_of_mock_arraybuffer_allocator_flag() {
425 61538 : return ExternalReference(&FLAG_mock_arraybuffer_allocator);
426 : }
427 :
428 64114 : ExternalReference ExternalReference::address_of_runtime_stats_flag() {
429 64114 : return ExternalReference(&TracingFlags::runtime_stats);
430 : }
431 :
432 61558 : ExternalReference ExternalReference::address_of_one_half() {
433 : return ExternalReference(
434 61558 : reinterpret_cast<Address>(&double_one_half_constant));
435 : }
436 :
437 61543 : ExternalReference ExternalReference::address_of_the_hole_nan() {
438 : return ExternalReference(
439 61543 : reinterpret_cast<Address>(&double_the_hole_nan_constant));
440 : }
441 :
442 61538 : ExternalReference ExternalReference::address_of_uint32_bias() {
443 : return ExternalReference(
444 61538 : reinterpret_cast<Address>(&double_uint32_bias_constant));
445 : }
446 :
447 61543 : ExternalReference ExternalReference::address_of_float_abs_constant() {
448 61543 : return ExternalReference(reinterpret_cast<Address>(&float_absolute_constant));
449 : }
450 :
451 61543 : ExternalReference ExternalReference::address_of_float_neg_constant() {
452 61543 : return ExternalReference(reinterpret_cast<Address>(&float_negate_constant));
453 : }
454 :
455 61543 : ExternalReference ExternalReference::address_of_double_abs_constant() {
456 : return ExternalReference(
457 61543 : reinterpret_cast<Address>(&double_absolute_constant));
458 : }
459 :
460 61543 : ExternalReference ExternalReference::address_of_double_neg_constant() {
461 61543 : return ExternalReference(reinterpret_cast<Address>(&double_negate_constant));
462 : }
463 :
464 61646 : ExternalReference ExternalReference::is_profiling_address(Isolate* isolate) {
465 61646 : return ExternalReference(isolate->is_profiling_address());
466 : }
467 :
468 61594 : ExternalReference ExternalReference::invoke_function_callback() {
469 61594 : Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
470 : ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL;
471 : ApiFunction thunk_fun(thunk_address);
472 61594 : return ExternalReference::Create(&thunk_fun, thunk_type);
473 : }
474 :
475 61594 : ExternalReference ExternalReference::invoke_accessor_getter_callback() {
476 61594 : Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback);
477 : ExternalReference::Type thunk_type = ExternalReference::PROFILING_GETTER_CALL;
478 : ApiFunction thunk_fun(thunk_address);
479 61594 : return ExternalReference::Create(&thunk_fun, thunk_type);
480 : }
481 :
482 : #if V8_TARGET_ARCH_X64
483 : #define re_stack_check_func RegExpMacroAssemblerX64::CheckStackGuardState
484 : #elif V8_TARGET_ARCH_IA32
485 : #define re_stack_check_func RegExpMacroAssemblerIA32::CheckStackGuardState
486 : #elif V8_TARGET_ARCH_ARM64
487 : #define re_stack_check_func RegExpMacroAssemblerARM64::CheckStackGuardState
488 : #elif V8_TARGET_ARCH_ARM
489 : #define re_stack_check_func RegExpMacroAssemblerARM::CheckStackGuardState
490 : #elif V8_TARGET_ARCH_PPC
491 : #define re_stack_check_func RegExpMacroAssemblerPPC::CheckStackGuardState
492 : #elif V8_TARGET_ARCH_MIPS
493 : #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState
494 : #elif V8_TARGET_ARCH_MIPS64
495 : #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState
496 : #elif V8_TARGET_ARCH_S390
497 : #define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState
498 : #else
499 : UNREACHABLE();
500 : #endif
501 :
502 225704 : FUNCTION_REFERENCE_WITH_ISOLATE(re_check_stack_guard_state, re_stack_check_func)
503 : #undef re_stack_check_func
504 :
505 143609 : FUNCTION_REFERENCE_WITH_ISOLATE(re_grow_stack,
506 : NativeRegExpMacroAssembler::GrowStack)
507 :
508 61731 : FUNCTION_REFERENCE_WITH_ISOLATE(
509 : re_case_insensitive_compare_uc16,
510 : NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16)
511 :
512 63558 : ExternalReference ExternalReference::re_word_character_map(Isolate* isolate) {
513 : return ExternalReference(
514 63558 : NativeRegExpMacroAssembler::word_character_map_address());
515 : }
516 :
517 62094 : ExternalReference ExternalReference::address_of_static_offsets_vector(
518 : Isolate* isolate) {
519 : return ExternalReference(
520 62094 : reinterpret_cast<Address>(isolate->jsregexp_static_offsets_vector()));
521 : }
522 :
523 587848 : ExternalReference ExternalReference::address_of_regexp_stack_limit(
524 : Isolate* isolate) {
525 587848 : return ExternalReference(isolate->regexp_stack()->limit_address());
526 : }
527 :
528 62094 : ExternalReference ExternalReference::address_of_regexp_stack_memory_address(
529 : Isolate* isolate) {
530 62094 : return ExternalReference(isolate->regexp_stack()->memory_address());
531 : }
532 :
533 62094 : ExternalReference ExternalReference::address_of_regexp_stack_memory_size(
534 : Isolate* isolate) {
535 62094 : return ExternalReference(isolate->regexp_stack()->memory_size_address());
536 : }
537 :
538 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_acos_function, base::ieee754::acos,
539 : BUILTIN_FP_CALL)
540 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_acosh_function, base::ieee754::acosh,
541 : BUILTIN_FP_FP_CALL)
542 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_asin_function, base::ieee754::asin,
543 : BUILTIN_FP_CALL)
544 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_asinh_function, base::ieee754::asinh,
545 : BUILTIN_FP_FP_CALL)
546 61671 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_atan_function, base::ieee754::atan,
547 : BUILTIN_FP_CALL)
548 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_atanh_function, base::ieee754::atanh,
549 : BUILTIN_FP_FP_CALL)
550 61667 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_atan2_function, base::ieee754::atan2,
551 : BUILTIN_FP_FP_CALL)
552 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_cbrt_function, base::ieee754::cbrt,
553 : BUILTIN_FP_FP_CALL)
554 61809 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_cos_function, base::ieee754::cos,
555 : BUILTIN_FP_CALL)
556 61661 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_cosh_function, base::ieee754::cosh,
557 : BUILTIN_FP_CALL)
558 61686 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_exp_function, base::ieee754::exp,
559 : BUILTIN_FP_CALL)
560 61661 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_expm1_function, base::ieee754::expm1,
561 : BUILTIN_FP_FP_CALL)
562 61822 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_log_function, base::ieee754::log,
563 : BUILTIN_FP_CALL)
564 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_log1p_function, base::ieee754::log1p,
565 : BUILTIN_FP_CALL)
566 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_log10_function, base::ieee754::log10,
567 : BUILTIN_FP_CALL)
568 61654 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_log2_function, base::ieee754::log2,
569 : BUILTIN_FP_CALL)
570 61806 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_sin_function, base::ieee754::sin,
571 : BUILTIN_FP_CALL)
572 61661 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_sinh_function, base::ieee754::sinh,
573 : BUILTIN_FP_CALL)
574 61706 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_tan_function, base::ieee754::tan,
575 : BUILTIN_FP_CALL)
576 61661 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_tanh_function, base::ieee754::tanh,
577 : BUILTIN_FP_CALL)
578 61874 : FUNCTION_REFERENCE_WITH_TYPE(ieee754_pow_function, base::ieee754::pow,
579 : BUILTIN_FP_FP_CALL)
580 :
581 2821961 : void* libc_memchr(void* string, int character, size_t search_length) {
582 2821961 : return memchr(string, character, search_length);
583 : }
584 :
585 61706 : FUNCTION_REFERENCE(libc_memchr_function, libc_memchr)
586 :
587 13021801 : void* libc_memcpy(void* dest, const void* src, size_t n) {
588 13021801 : return memcpy(dest, src, n);
589 : }
590 :
591 65358 : FUNCTION_REFERENCE(libc_memcpy_function, libc_memcpy)
592 :
593 166551 : void* libc_memmove(void* dest, const void* src, size_t n) {
594 166551 : return memmove(dest, src, n);
595 : }
596 :
597 62042 : FUNCTION_REFERENCE(libc_memmove_function, libc_memmove)
598 :
599 567145 : void* libc_memset(void* dest, int value, size_t n) {
600 : DCHECK_EQ(static_cast<byte>(value), value);
601 567145 : return memset(dest, value, n);
602 : }
603 :
604 62842 : FUNCTION_REFERENCE(libc_memset_function, libc_memset)
605 :
606 61538 : ExternalReference ExternalReference::printf_function() {
607 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(std::printf)));
608 : }
609 :
610 61594 : FUNCTION_REFERENCE(refill_math_random, MathRandom::RefillCache)
611 :
612 : template <typename SubjectChar, typename PatternChar>
613 246824 : ExternalReference ExternalReference::search_string_raw() {
614 : auto f = SearchStringRaw<SubjectChar, PatternChar>;
615 246824 : return ExternalReference(Redirect(FUNCTION_ADDR(f)));
616 : }
617 :
618 61762 : FUNCTION_REFERENCE(jsarray_array_join_concat_to_sequential_string,
619 : JSArray::ArrayJoinConcatToSequentialString)
620 :
621 61538 : ExternalReference ExternalReference::search_string_raw_one_one() {
622 61538 : return search_string_raw<const uint8_t, const uint8_t>();
623 : }
624 :
625 61538 : ExternalReference ExternalReference::search_string_raw_one_two() {
626 61538 : return search_string_raw<const uint8_t, const uc16>();
627 : }
628 :
629 61538 : ExternalReference ExternalReference::search_string_raw_two_one() {
630 61538 : return search_string_raw<const uc16, const uint8_t>();
631 : }
632 :
633 61538 : ExternalReference ExternalReference::search_string_raw_two_two() {
634 61538 : return search_string_raw<const uc16, const uc16>();
635 : }
636 :
637 62882 : FUNCTION_REFERENCE(orderedhashmap_gethash_raw, OrderedHashMap::GetHash)
638 :
639 18401 : Address GetOrCreateHash(Isolate* isolate, Address raw_key) {
640 : DisallowHeapAllocation no_gc;
641 36802 : return Object(raw_key)->GetOrCreateHash(isolate).ptr();
642 : }
643 :
644 61650 : FUNCTION_REFERENCE(get_or_create_hash_raw, GetOrCreateHash)
645 :
646 12738 : static Address JSReceiverCreateIdentityHash(Isolate* isolate, Address raw_key) {
647 12738 : JSReceiver key = JSReceiver::cast(Object(raw_key));
648 25476 : return JSReceiver::CreateIdentityHash(isolate, key).ptr();
649 : }
650 :
651 61594 : FUNCTION_REFERENCE(jsreceiver_create_identity_hash,
652 : JSReceiverCreateIdentityHash)
653 :
654 42793746 : static uint32_t ComputeSeededIntegerHash(Isolate* isolate, uint32_t key) {
655 : DisallowHeapAllocation no_gc;
656 42793746 : return ComputeSeededHash(key, HashSeed(isolate));
657 : }
658 :
659 62670 : FUNCTION_REFERENCE(compute_integer_hash, ComputeSeededIntegerHash)
660 61594 : FUNCTION_REFERENCE(copy_fast_number_jsarray_elements_to_typed_array,
661 : CopyFastNumberJSArrayElementsToTypedArray)
662 61594 : FUNCTION_REFERENCE(copy_typed_array_elements_to_typed_array,
663 : CopyTypedArrayElementsToTypedArray)
664 61594 : FUNCTION_REFERENCE(copy_typed_array_elements_slice, CopyTypedArrayElementsSlice)
665 62151 : FUNCTION_REFERENCE(try_internalize_string_function,
666 : StringTable::LookupStringIfExists_NoAllocate)
667 :
668 1816509 : static Address LexicographicCompareWrapper(Isolate* isolate, Address smi_x,
669 : Address smi_y) {
670 : Smi x(smi_x);
671 : Smi y(smi_y);
672 1816509 : return Smi::LexicographicCompare(isolate, x, y);
673 : }
674 :
675 61594 : FUNCTION_REFERENCE(smi_lexicographic_compare_function,
676 : LexicographicCompareWrapper)
677 :
678 61538 : FUNCTION_REFERENCE(check_object_type, CheckObjectType)
679 :
680 : #ifdef V8_INTL_SUPPORT
681 :
682 774 : static Address ConvertOneByteToLower(Address raw_src, Address raw_dst) {
683 774 : String src = String::cast(Object(raw_src));
684 774 : String dst = String::cast(Object(raw_dst));
685 1548 : return Intl::ConvertOneByteToLower(src, dst).ptr();
686 : }
687 61594 : FUNCTION_REFERENCE(intl_convert_one_byte_to_lower, ConvertOneByteToLower)
688 :
689 61594 : ExternalReference ExternalReference::intl_to_latin1_lower_table() {
690 61594 : uint8_t* ptr = const_cast<uint8_t*>(Intl::ToLatin1LowerTable());
691 61594 : return ExternalReference(reinterpret_cast<Address>(ptr));
692 : }
693 : #endif // V8_INTL_SUPPORT
694 :
695 : // Explicit instantiations for all combinations of 1- and 2-byte strings.
696 : template ExternalReference
697 : ExternalReference::search_string_raw<const uint8_t, const uint8_t>();
698 : template ExternalReference
699 : ExternalReference::search_string_raw<const uint8_t, const uc16>();
700 : template ExternalReference
701 : ExternalReference::search_string_raw<const uc16, const uint8_t>();
702 : template ExternalReference
703 : ExternalReference::search_string_raw<const uc16, const uc16>();
704 :
705 12904374 : ExternalReference ExternalReference::FromRawAddress(Address address) {
706 12904374 : return ExternalReference(address);
707 : }
708 :
709 61538 : ExternalReference ExternalReference::cpu_features() {
710 : DCHECK(CpuFeatures::initialized_);
711 61538 : return ExternalReference(&CpuFeatures::supported_);
712 : }
713 :
714 61590 : ExternalReference ExternalReference::promise_hook_address(Isolate* isolate) {
715 61590 : return ExternalReference(isolate->promise_hook_address());
716 : }
717 :
718 61758 : ExternalReference ExternalReference::async_event_delegate_address(
719 : Isolate* isolate) {
720 61758 : return ExternalReference(isolate->async_event_delegate_address());
721 : }
722 :
723 : ExternalReference
724 62290 : ExternalReference::promise_hook_or_async_event_delegate_address(
725 : Isolate* isolate) {
726 : return ExternalReference(
727 62290 : isolate->promise_hook_or_async_event_delegate_address());
728 : }
729 :
730 62710 : ExternalReference ExternalReference::
731 : promise_hook_or_debug_is_active_or_async_event_delegate_address(
732 : Isolate* isolate) {
733 : return ExternalReference(
734 : isolate
735 62710 : ->promise_hook_or_debug_is_active_or_async_event_delegate_address());
736 : }
737 :
738 61538 : ExternalReference ExternalReference::debug_execution_mode_address(
739 : Isolate* isolate) {
740 61538 : return ExternalReference(isolate->debug_execution_mode_address());
741 : }
742 :
743 61934 : ExternalReference ExternalReference::debug_is_active_address(Isolate* isolate) {
744 61934 : return ExternalReference(isolate->debug()->is_active_address());
745 : }
746 :
747 61926 : ExternalReference ExternalReference::debug_hook_on_function_call_address(
748 : Isolate* isolate) {
749 61926 : return ExternalReference(isolate->debug()->hook_on_function_call_address());
750 : }
751 :
752 61876 : ExternalReference ExternalReference::runtime_function_table_address(
753 : Isolate* isolate) {
754 : return ExternalReference(
755 123758 : const_cast<Runtime::Function*>(Runtime::RuntimeFunctionTable(isolate)));
756 : }
757 :
758 131848 : static Address InvalidatePrototypeChainsWrapper(Address raw_map) {
759 131848 : Map map = Map::cast(Object(raw_map));
760 263696 : return JSObject::InvalidatePrototypeChains(map).ptr();
761 : }
762 :
763 62042 : FUNCTION_REFERENCE(invalidate_prototype_chains_function,
764 : InvalidatePrototypeChainsWrapper)
765 :
766 0 : double modulo_double_double(double x, double y) { return Modulo(x, y); }
767 :
768 61538 : FUNCTION_REFERENCE_WITH_TYPE(mod_two_doubles_operation, modulo_double_double,
769 : BUILTIN_FP_FP_CALL)
770 :
771 61590 : ExternalReference ExternalReference::debug_suspended_generator_address(
772 : Isolate* isolate) {
773 61590 : return ExternalReference(isolate->debug()->suspended_generator_address());
774 : }
775 :
776 62766 : ExternalReference ExternalReference::debug_restart_fp_address(
777 : Isolate* isolate) {
778 62766 : return ExternalReference(isolate->debug()->restart_fp_address());
779 : }
780 :
781 788308 : ExternalReference ExternalReference::fast_c_call_caller_fp_address(
782 : Isolate* isolate) {
783 : return ExternalReference(
784 788308 : isolate->isolate_data()->fast_c_call_caller_fp_address());
785 : }
786 :
787 424920 : ExternalReference ExternalReference::fast_c_call_caller_pc_address(
788 : Isolate* isolate) {
789 : return ExternalReference(
790 424920 : isolate->isolate_data()->fast_c_call_caller_pc_address());
791 : }
792 :
793 61594 : FUNCTION_REFERENCE(call_enqueue_microtask_function,
794 : MicrotaskQueue::CallEnqueueMicrotask)
795 :
796 0 : static int64_t atomic_pair_load(intptr_t address) {
797 0 : return std::atomic_load(reinterpret_cast<std::atomic<int64_t>*>(address));
798 : }
799 :
800 61538 : ExternalReference ExternalReference::atomic_pair_load_function() {
801 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_load)));
802 : }
803 :
804 0 : static void atomic_pair_store(intptr_t address, int value_low, int value_high) {
805 : int64_t value =
806 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
807 0 : std::atomic_store(reinterpret_cast<std::atomic<int64_t>*>(address), value);
808 0 : }
809 :
810 61538 : ExternalReference ExternalReference::atomic_pair_store_function() {
811 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_store)));
812 : }
813 :
814 0 : static int64_t atomic_pair_add(intptr_t address, int value_low,
815 : int value_high) {
816 : int64_t value =
817 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
818 0 : return std::atomic_fetch_add(reinterpret_cast<std::atomic<int64_t>*>(address),
819 0 : value);
820 : }
821 :
822 61538 : ExternalReference ExternalReference::atomic_pair_add_function() {
823 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_add)));
824 : }
825 :
826 0 : static int64_t atomic_pair_sub(intptr_t address, int value_low,
827 : int value_high) {
828 : int64_t value =
829 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
830 0 : return std::atomic_fetch_sub(reinterpret_cast<std::atomic<int64_t>*>(address),
831 0 : value);
832 : }
833 :
834 61538 : ExternalReference ExternalReference::atomic_pair_sub_function() {
835 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_sub)));
836 : }
837 :
838 0 : static int64_t atomic_pair_and(intptr_t address, int value_low,
839 : int value_high) {
840 : int64_t value =
841 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
842 0 : return std::atomic_fetch_and(reinterpret_cast<std::atomic<int64_t>*>(address),
843 0 : value);
844 : }
845 :
846 61538 : ExternalReference ExternalReference::atomic_pair_and_function() {
847 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_and)));
848 : }
849 :
850 0 : static int64_t atomic_pair_or(intptr_t address, int value_low, int value_high) {
851 : int64_t value =
852 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
853 0 : return std::atomic_fetch_or(reinterpret_cast<std::atomic<int64_t>*>(address),
854 0 : value);
855 : }
856 :
857 61538 : ExternalReference ExternalReference::atomic_pair_or_function() {
858 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_or)));
859 : }
860 :
861 0 : static int64_t atomic_pair_xor(intptr_t address, int value_low,
862 : int value_high) {
863 : int64_t value =
864 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
865 0 : return std::atomic_fetch_xor(reinterpret_cast<std::atomic<int64_t>*>(address),
866 0 : value);
867 : }
868 :
869 61538 : ExternalReference ExternalReference::atomic_pair_xor_function() {
870 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_xor)));
871 : }
872 :
873 0 : static int64_t atomic_pair_exchange(intptr_t address, int value_low,
874 : int value_high) {
875 : int64_t value =
876 0 : static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF);
877 0 : return std::atomic_exchange(reinterpret_cast<std::atomic<int64_t>*>(address),
878 0 : value);
879 : }
880 :
881 61538 : ExternalReference ExternalReference::atomic_pair_exchange_function() {
882 61538 : return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_exchange)));
883 : }
884 :
885 0 : static uint64_t atomic_pair_compare_exchange(intptr_t address,
886 : int old_value_low,
887 : int old_value_high,
888 : int new_value_low,
889 : int new_value_high) {
890 0 : uint64_t old_value = static_cast<uint64_t>(old_value_high) << 32 |
891 0 : (old_value_low & 0xFFFFFFFF);
892 0 : uint64_t new_value = static_cast<uint64_t>(new_value_high) << 32 |
893 0 : (new_value_low & 0xFFFFFFFF);
894 0 : std::atomic_compare_exchange_strong(
895 : reinterpret_cast<std::atomic<uint64_t>*>(address), &old_value, new_value);
896 0 : return old_value;
897 : }
898 :
899 61538 : FUNCTION_REFERENCE(atomic_pair_compare_exchange_function,
900 : atomic_pair_compare_exchange)
901 :
902 0 : static int EnterMicrotaskContextWrapper(HandleScopeImplementer* hsi,
903 : Address raw_context) {
904 : Context context = Context::cast(Object(raw_context));
905 : hsi->EnterMicrotaskContext(context);
906 0 : return 0;
907 : }
908 :
909 61818 : FUNCTION_REFERENCE(call_enter_context_function, EnterMicrotaskContextWrapper)
910 :
911 580147 : bool operator==(ExternalReference lhs, ExternalReference rhs) {
912 580147 : return lhs.address() == rhs.address();
913 : }
914 :
915 0 : bool operator!=(ExternalReference lhs, ExternalReference rhs) {
916 0 : return !(lhs == rhs);
917 : }
918 :
919 2685677 : size_t hash_value(ExternalReference reference) {
920 2685698 : return base::hash<Address>()(reference.address());
921 : }
922 :
923 82 : std::ostream& operator<<(std::ostream& os, ExternalReference reference) {
924 82 : os << reinterpret_cast<const void*>(reference.address());
925 82 : const Runtime::Function* fn = Runtime::FunctionForEntry(reference.address());
926 111 : if (fn) os << "<" << fn->name << ".entry>";
927 82 : return os;
928 : }
929 :
930 0 : void abort_with_reason(int reason) {
931 0 : if (IsValidAbortReason(reason)) {
932 0 : const char* message = GetAbortReason(static_cast<AbortReason>(reason));
933 0 : base::OS::PrintError("abort: %s\n", message);
934 : } else {
935 0 : base::OS::PrintError("abort: <unknown reason: %d>\n", reason);
936 : }
937 0 : base::OS::Abort();
938 : UNREACHABLE();
939 : }
940 :
941 : #undef FUNCTION_REFERENCE
942 : #undef FUNCTION_REFERENCE_WITH_ISOLATE
943 : #undef FUNCTION_REFERENCE_WITH_TYPE
944 :
945 : } // namespace internal
946 120216 : } // namespace v8
|