11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#include "src/codegen/external-reference.h" 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci#include "include/v8-fast-api-calls.h" 81cb0ef41Sopenharmony_ci#include "src/api/api-inl.h" 91cb0ef41Sopenharmony_ci#include "src/base/ieee754.h" 101cb0ef41Sopenharmony_ci#include "src/codegen/cpu-features.h" 111cb0ef41Sopenharmony_ci#include "src/common/globals.h" 121cb0ef41Sopenharmony_ci#include "src/date/date.h" 131cb0ef41Sopenharmony_ci#include "src/debug/debug.h" 141cb0ef41Sopenharmony_ci#include "src/deoptimizer/deoptimizer.h" 151cb0ef41Sopenharmony_ci#include "src/execution/encoded-c-signature.h" 161cb0ef41Sopenharmony_ci#include "src/execution/isolate-utils.h" 171cb0ef41Sopenharmony_ci#include "src/execution/isolate.h" 181cb0ef41Sopenharmony_ci#include "src/execution/microtask-queue.h" 191cb0ef41Sopenharmony_ci#include "src/execution/simulator.h" 201cb0ef41Sopenharmony_ci#include "src/heap/heap-inl.h" 211cb0ef41Sopenharmony_ci#include "src/heap/heap.h" 221cb0ef41Sopenharmony_ci#include "src/ic/stub-cache.h" 231cb0ef41Sopenharmony_ci#include "src/interpreter/interpreter.h" 241cb0ef41Sopenharmony_ci#include "src/logging/counters.h" 251cb0ef41Sopenharmony_ci#include "src/logging/log.h" 261cb0ef41Sopenharmony_ci#include "src/numbers/hash-seed-inl.h" 271cb0ef41Sopenharmony_ci#include "src/numbers/math-random.h" 281cb0ef41Sopenharmony_ci#include "src/objects/elements.h" 291cb0ef41Sopenharmony_ci#include "src/objects/object-type.h" 301cb0ef41Sopenharmony_ci#include "src/objects/objects-inl.h" 311cb0ef41Sopenharmony_ci#include "src/objects/ordered-hash-table.h" 321cb0ef41Sopenharmony_ci#include "src/regexp/experimental/experimental.h" 331cb0ef41Sopenharmony_ci#include "src/regexp/regexp-interpreter.h" 341cb0ef41Sopenharmony_ci#include "src/regexp/regexp-macro-assembler-arch.h" 351cb0ef41Sopenharmony_ci#include "src/regexp/regexp-stack.h" 361cb0ef41Sopenharmony_ci#include "src/strings/string-search.h" 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 391cb0ef41Sopenharmony_ci#include "src/wasm/wasm-external-refs.h" 401cb0ef41Sopenharmony_ci#endif // V8_ENABLE_WEBASSEMBLY 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci#ifdef V8_INTL_SUPPORT 431cb0ef41Sopenharmony_ci#include "src/base/platform/wrappers.h" 441cb0ef41Sopenharmony_ci#include "src/base/strings.h" 451cb0ef41Sopenharmony_ci#include "src/objects/intl-objects.h" 461cb0ef41Sopenharmony_ci#endif // V8_INTL_SUPPORT 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_cinamespace v8 { 491cb0ef41Sopenharmony_cinamespace internal { 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci// ----------------------------------------------------------------------------- 521cb0ef41Sopenharmony_ci// Common double constants. 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ciconstexpr double double_min_int_constant = kMinInt; 551cb0ef41Sopenharmony_ciconstexpr double double_one_half_constant = 0.5; 561cb0ef41Sopenharmony_ciconstexpr uint64_t double_the_hole_nan_constant = kHoleNanInt64; 571cb0ef41Sopenharmony_ciconstexpr double double_uint32_bias_constant = 581cb0ef41Sopenharmony_ci static_cast<double>(kMaxUInt32) + 1; 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 611cb0ef41Sopenharmony_ci uint32_t a; 621cb0ef41Sopenharmony_ci uint32_t b; 631cb0ef41Sopenharmony_ci uint32_t c; 641cb0ef41Sopenharmony_ci uint32_t d; 651cb0ef41Sopenharmony_ci} float_absolute_constant = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 681cb0ef41Sopenharmony_ci uint32_t a; 691cb0ef41Sopenharmony_ci uint32_t b; 701cb0ef41Sopenharmony_ci uint32_t c; 711cb0ef41Sopenharmony_ci uint32_t d; 721cb0ef41Sopenharmony_ci} float_negate_constant = {0x80000000, 0x80000000, 0x80000000, 0x80000000}; 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 751cb0ef41Sopenharmony_ci uint64_t a; 761cb0ef41Sopenharmony_ci uint64_t b; 771cb0ef41Sopenharmony_ci} double_absolute_constant = {uint64_t{0x7FFFFFFFFFFFFFFF}, 781cb0ef41Sopenharmony_ci uint64_t{0x7FFFFFFFFFFFFFFF}}; 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 811cb0ef41Sopenharmony_ci uint64_t a; 821cb0ef41Sopenharmony_ci uint64_t b; 831cb0ef41Sopenharmony_ci} double_negate_constant = {uint64_t{0x8000000000000000}, 841cb0ef41Sopenharmony_ci uint64_t{0x8000000000000000}}; 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 871cb0ef41Sopenharmony_ci uint64_t a; 881cb0ef41Sopenharmony_ci uint64_t b; 891cb0ef41Sopenharmony_ci} wasm_i8x16_swizzle_mask = {uint64_t{0x70707070'70707070}, 901cb0ef41Sopenharmony_ci uint64_t{0x70707070'70707070}}; 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 931cb0ef41Sopenharmony_ci uint64_t a; 941cb0ef41Sopenharmony_ci uint64_t b; 951cb0ef41Sopenharmony_ci} wasm_i8x16_popcnt_mask = {uint64_t{0x03020201'02010100}, 961cb0ef41Sopenharmony_ci uint64_t{0x04030302'03020201}}; 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 991cb0ef41Sopenharmony_ci uint64_t a; 1001cb0ef41Sopenharmony_ci uint64_t b; 1011cb0ef41Sopenharmony_ci} wasm_i8x16_splat_0x01 = {uint64_t{0x01010101'01010101}, 1021cb0ef41Sopenharmony_ci uint64_t{0x01010101'01010101}}; 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1051cb0ef41Sopenharmony_ci uint64_t a; 1061cb0ef41Sopenharmony_ci uint64_t b; 1071cb0ef41Sopenharmony_ci} wasm_i8x16_splat_0x0f = {uint64_t{0x0F0F0F0F'0F0F0F0F}, 1081cb0ef41Sopenharmony_ci uint64_t{0x0F0F0F0F'0F0F0F0F}}; 1091cb0ef41Sopenharmony_ci 1101cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1111cb0ef41Sopenharmony_ci uint64_t a; 1121cb0ef41Sopenharmony_ci uint64_t b; 1131cb0ef41Sopenharmony_ci} wasm_i8x16_splat_0x33 = {uint64_t{0x33333333'33333333}, 1141cb0ef41Sopenharmony_ci uint64_t{0x33333333'33333333}}; 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1171cb0ef41Sopenharmony_ci uint64_t a; 1181cb0ef41Sopenharmony_ci uint64_t b; 1191cb0ef41Sopenharmony_ci} wasm_i8x16_splat_0x55 = {uint64_t{0x55555555'55555555}, 1201cb0ef41Sopenharmony_ci uint64_t{0x55555555'55555555}}; 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1231cb0ef41Sopenharmony_ci uint64_t a; 1241cb0ef41Sopenharmony_ci uint64_t b; 1251cb0ef41Sopenharmony_ci} wasm_i16x8_splat_0x0001 = {uint64_t{0x00010001'00010001}, 1261cb0ef41Sopenharmony_ci uint64_t{0x00010001'00010001}}; 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1291cb0ef41Sopenharmony_ci uint64_t a; 1301cb0ef41Sopenharmony_ci uint64_t b; 1311cb0ef41Sopenharmony_ci} wasm_f64x2_convert_low_i32x4_u_int_mask = {uint64_t{0x4330000043300000}, 1321cb0ef41Sopenharmony_ci uint64_t{0x4330000043300000}}; 1331cb0ef41Sopenharmony_ci 1341cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1351cb0ef41Sopenharmony_ci uint64_t a; 1361cb0ef41Sopenharmony_ci uint64_t b; 1371cb0ef41Sopenharmony_ci} wasm_double_2_power_52 = {uint64_t{0x4330000000000000}, 1381cb0ef41Sopenharmony_ci uint64_t{0x4330000000000000}}; 1391cb0ef41Sopenharmony_ci 1401cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1411cb0ef41Sopenharmony_ci uint64_t a; 1421cb0ef41Sopenharmony_ci uint64_t b; 1431cb0ef41Sopenharmony_ci} wasm_int32_max_as_double = {uint64_t{0x41dfffffffc00000}, 1441cb0ef41Sopenharmony_ci uint64_t{0x41dfffffffc00000}}; 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1471cb0ef41Sopenharmony_ci uint64_t a; 1481cb0ef41Sopenharmony_ci uint64_t b; 1491cb0ef41Sopenharmony_ci} wasm_uint32_max_as_double = {uint64_t{0x41efffffffe00000}, 1501cb0ef41Sopenharmony_ci uint64_t{0x41efffffffe00000}}; 1511cb0ef41Sopenharmony_ci 1521cb0ef41Sopenharmony_ci// This is 2147483648.0, which is 1 more than INT32_MAX. 1531cb0ef41Sopenharmony_ciconstexpr struct alignas(16) { 1541cb0ef41Sopenharmony_ci uint32_t a; 1551cb0ef41Sopenharmony_ci uint32_t b; 1561cb0ef41Sopenharmony_ci uint32_t c; 1571cb0ef41Sopenharmony_ci uint32_t d; 1581cb0ef41Sopenharmony_ci} wasm_int32_overflow_as_float = { 1591cb0ef41Sopenharmony_ci uint32_t{0x4f00'0000}, 1601cb0ef41Sopenharmony_ci uint32_t{0x4f00'0000}, 1611cb0ef41Sopenharmony_ci uint32_t{0x4f00'0000}, 1621cb0ef41Sopenharmony_ci uint32_t{0x4f00'0000}, 1631cb0ef41Sopenharmony_ci}; 1641cb0ef41Sopenharmony_ci 1651cb0ef41Sopenharmony_ci// Implementation of ExternalReference 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_cistatic ExternalReference::Type BuiltinCallTypeForResultSize(int result_size) { 1681cb0ef41Sopenharmony_ci switch (result_size) { 1691cb0ef41Sopenharmony_ci case 1: 1701cb0ef41Sopenharmony_ci return ExternalReference::BUILTIN_CALL; 1711cb0ef41Sopenharmony_ci case 2: 1721cb0ef41Sopenharmony_ci return ExternalReference::BUILTIN_CALL_PAIR; 1731cb0ef41Sopenharmony_ci } 1741cb0ef41Sopenharmony_ci UNREACHABLE(); 1751cb0ef41Sopenharmony_ci} 1761cb0ef41Sopenharmony_ci 1771cb0ef41Sopenharmony_ci// static 1781cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(ApiFunction* fun, Type type) { 1791cb0ef41Sopenharmony_ci return ExternalReference(Redirect(fun->address(), type)); 1801cb0ef41Sopenharmony_ci} 1811cb0ef41Sopenharmony_ci 1821cb0ef41Sopenharmony_ci// static 1831cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create( 1841cb0ef41Sopenharmony_ci Isolate* isolate, ApiFunction* fun, Type type, Address* c_functions, 1851cb0ef41Sopenharmony_ci const CFunctionInfo* const* c_signatures, unsigned num_functions) { 1861cb0ef41Sopenharmony_ci#ifdef V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS 1871cb0ef41Sopenharmony_ci isolate->simulator_data()->RegisterFunctionsAndSignatures( 1881cb0ef41Sopenharmony_ci c_functions, c_signatures, num_functions); 1891cb0ef41Sopenharmony_ci#endif // V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS 1901cb0ef41Sopenharmony_ci return ExternalReference(Redirect(fun->address(), type)); 1911cb0ef41Sopenharmony_ci} 1921cb0ef41Sopenharmony_ci 1931cb0ef41Sopenharmony_ci// static 1941cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(Runtime::FunctionId id) { 1951cb0ef41Sopenharmony_ci return Create(Runtime::FunctionForId(id)); 1961cb0ef41Sopenharmony_ci} 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci// static 1991cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(const Runtime::Function* f) { 2001cb0ef41Sopenharmony_ci return ExternalReference( 2011cb0ef41Sopenharmony_ci Redirect(f->entry, BuiltinCallTypeForResultSize(f->result_size))); 2021cb0ef41Sopenharmony_ci} 2031cb0ef41Sopenharmony_ci 2041cb0ef41Sopenharmony_ci// static 2051cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(Address address, Type type) { 2061cb0ef41Sopenharmony_ci return ExternalReference(Redirect(address, type)); 2071cb0ef41Sopenharmony_ci} 2081cb0ef41Sopenharmony_ci 2091cb0ef41Sopenharmony_ciExternalReference ExternalReference::isolate_address(Isolate* isolate) { 2101cb0ef41Sopenharmony_ci return ExternalReference(isolate); 2111cb0ef41Sopenharmony_ci} 2121cb0ef41Sopenharmony_ci 2131cb0ef41Sopenharmony_ciExternalReference ExternalReference::builtins_table(Isolate* isolate) { 2141cb0ef41Sopenharmony_ci return ExternalReference(isolate->builtin_table()); 2151cb0ef41Sopenharmony_ci} 2161cb0ef41Sopenharmony_ci 2171cb0ef41Sopenharmony_ciExternalReference ExternalReference::handle_scope_implementer_address( 2181cb0ef41Sopenharmony_ci Isolate* isolate) { 2191cb0ef41Sopenharmony_ci return ExternalReference(isolate->handle_scope_implementer_address()); 2201cb0ef41Sopenharmony_ci} 2211cb0ef41Sopenharmony_ci 2221cb0ef41Sopenharmony_ci#ifdef V8_SANDBOXED_POINTERS 2231cb0ef41Sopenharmony_ciExternalReference ExternalReference::sandbox_base_address() { 2241cb0ef41Sopenharmony_ci return ExternalReference(GetProcessWideSandbox()->base_address()); 2251cb0ef41Sopenharmony_ci} 2261cb0ef41Sopenharmony_ci 2271cb0ef41Sopenharmony_ciExternalReference ExternalReference::sandbox_end_address() { 2281cb0ef41Sopenharmony_ci return ExternalReference(GetProcessWideSandbox()->end_address()); 2291cb0ef41Sopenharmony_ci} 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_ciExternalReference ExternalReference::empty_backing_store_buffer() { 2321cb0ef41Sopenharmony_ci return ExternalReference(GetProcessWideSandbox() 2331cb0ef41Sopenharmony_ci ->constants() 2341cb0ef41Sopenharmony_ci .empty_backing_store_buffer_address()); 2351cb0ef41Sopenharmony_ci} 2361cb0ef41Sopenharmony_ci#endif // V8_SANDBOXED_POINTERS 2371cb0ef41Sopenharmony_ci 2381cb0ef41Sopenharmony_ci#ifdef V8_SANDBOXED_EXTERNAL_POINTERS 2391cb0ef41Sopenharmony_ciExternalReference ExternalReference::external_pointer_table_address( 2401cb0ef41Sopenharmony_ci Isolate* isolate) { 2411cb0ef41Sopenharmony_ci return ExternalReference(isolate->external_pointer_table_address()); 2421cb0ef41Sopenharmony_ci} 2431cb0ef41Sopenharmony_ci#endif // V8_SANDBOXED_EXTERNAL_POINTERS 2441cb0ef41Sopenharmony_ci 2451cb0ef41Sopenharmony_ciExternalReference ExternalReference::interpreter_dispatch_table_address( 2461cb0ef41Sopenharmony_ci Isolate* isolate) { 2471cb0ef41Sopenharmony_ci return ExternalReference(isolate->interpreter()->dispatch_table_address()); 2481cb0ef41Sopenharmony_ci} 2491cb0ef41Sopenharmony_ci 2501cb0ef41Sopenharmony_ciExternalReference ExternalReference::interpreter_dispatch_counters( 2511cb0ef41Sopenharmony_ci Isolate* isolate) { 2521cb0ef41Sopenharmony_ci return ExternalReference( 2531cb0ef41Sopenharmony_ci isolate->interpreter()->bytecode_dispatch_counters_table()); 2541cb0ef41Sopenharmony_ci} 2551cb0ef41Sopenharmony_ci 2561cb0ef41Sopenharmony_ciExternalReference 2571cb0ef41Sopenharmony_ciExternalReference::address_of_interpreter_entry_trampoline_instruction_start( 2581cb0ef41Sopenharmony_ci Isolate* isolate) { 2591cb0ef41Sopenharmony_ci return ExternalReference( 2601cb0ef41Sopenharmony_ci isolate->interpreter() 2611cb0ef41Sopenharmony_ci ->address_of_interpreter_entry_trampoline_instruction_start()); 2621cb0ef41Sopenharmony_ci} 2631cb0ef41Sopenharmony_ci 2641cb0ef41Sopenharmony_ciExternalReference ExternalReference::bytecode_size_table_address() { 2651cb0ef41Sopenharmony_ci return ExternalReference( 2661cb0ef41Sopenharmony_ci interpreter::Bytecodes::bytecode_size_table_address()); 2671cb0ef41Sopenharmony_ci} 2681cb0ef41Sopenharmony_ci 2691cb0ef41Sopenharmony_ci// static 2701cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(StatsCounter* counter) { 2711cb0ef41Sopenharmony_ci return ExternalReference( 2721cb0ef41Sopenharmony_ci reinterpret_cast<Address>(counter->GetInternalPointer())); 2731cb0ef41Sopenharmony_ci} 2741cb0ef41Sopenharmony_ci 2751cb0ef41Sopenharmony_ci// static 2761cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(IsolateAddressId id, 2771cb0ef41Sopenharmony_ci Isolate* isolate) { 2781cb0ef41Sopenharmony_ci return ExternalReference(isolate->get_address_from_id(id)); 2791cb0ef41Sopenharmony_ci} 2801cb0ef41Sopenharmony_ci 2811cb0ef41Sopenharmony_ci// static 2821cb0ef41Sopenharmony_ciExternalReference ExternalReference::Create(const SCTableReference& table_ref) { 2831cb0ef41Sopenharmony_ci return ExternalReference(table_ref.address()); 2841cb0ef41Sopenharmony_ci} 2851cb0ef41Sopenharmony_ci 2861cb0ef41Sopenharmony_cinamespace { 2871cb0ef41Sopenharmony_ci 2881cb0ef41Sopenharmony_ci// Helper function to verify that all types in a list of types are scalar. 2891cb0ef41Sopenharmony_ci// This includes primitive types (int, Address) and pointer types. We also 2901cb0ef41Sopenharmony_ci// allow void. 2911cb0ef41Sopenharmony_citemplate <typename T> 2921cb0ef41Sopenharmony_ciconstexpr bool AllScalar() { 2931cb0ef41Sopenharmony_ci return std::is_scalar<T>::value || std::is_void<T>::value; 2941cb0ef41Sopenharmony_ci} 2951cb0ef41Sopenharmony_ci 2961cb0ef41Sopenharmony_citemplate <typename T1, typename T2, typename... Rest> 2971cb0ef41Sopenharmony_ciconstexpr bool AllScalar() { 2981cb0ef41Sopenharmony_ci return AllScalar<T1>() && AllScalar<T2, Rest...>(); 2991cb0ef41Sopenharmony_ci} 3001cb0ef41Sopenharmony_ci 3011cb0ef41Sopenharmony_ci// Checks a function pointer's type for compatibility with the 3021cb0ef41Sopenharmony_ci// ExternalReference calling mechanism. Specifically, all arguments 3031cb0ef41Sopenharmony_ci// as well as the result type must pass the AllScalar check above, 3041cb0ef41Sopenharmony_ci// because we expect each item to fit into one register or stack slot. 3051cb0ef41Sopenharmony_citemplate <typename T> 3061cb0ef41Sopenharmony_cistruct IsValidExternalReferenceType; 3071cb0ef41Sopenharmony_ci 3081cb0ef41Sopenharmony_citemplate <typename Result, typename... Args> 3091cb0ef41Sopenharmony_cistruct IsValidExternalReferenceType<Result (*)(Args...)> { 3101cb0ef41Sopenharmony_ci static const bool value = AllScalar<Result, Args...>(); 3111cb0ef41Sopenharmony_ci}; 3121cb0ef41Sopenharmony_ci 3131cb0ef41Sopenharmony_citemplate <typename Result, typename Class, typename... Args> 3141cb0ef41Sopenharmony_cistruct IsValidExternalReferenceType<Result (Class::*)(Args...)> { 3151cb0ef41Sopenharmony_ci static const bool value = AllScalar<Result, Args...>(); 3161cb0ef41Sopenharmony_ci}; 3171cb0ef41Sopenharmony_ci 3181cb0ef41Sopenharmony_ci} // namespace 3191cb0ef41Sopenharmony_ci 3201cb0ef41Sopenharmony_ci#define FUNCTION_REFERENCE(Name, Target) \ 3211cb0ef41Sopenharmony_ci ExternalReference ExternalReference::Name() { \ 3221cb0ef41Sopenharmony_ci STATIC_ASSERT(IsValidExternalReferenceType<decltype(&Target)>::value); \ 3231cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(Target))); \ 3241cb0ef41Sopenharmony_ci } 3251cb0ef41Sopenharmony_ci 3261cb0ef41Sopenharmony_ci#define FUNCTION_REFERENCE_WITH_TYPE(Name, Target, Type) \ 3271cb0ef41Sopenharmony_ci ExternalReference ExternalReference::Name() { \ 3281cb0ef41Sopenharmony_ci STATIC_ASSERT(IsValidExternalReferenceType<decltype(&Target)>::value); \ 3291cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(Target), Type)); \ 3301cb0ef41Sopenharmony_ci } 3311cb0ef41Sopenharmony_ci 3321cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(write_barrier_marking_from_code_function, 3331cb0ef41Sopenharmony_ci WriteBarrier::MarkingFromCode) 3341cb0ef41Sopenharmony_ci 3351cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(insert_remembered_set_function, 3361cb0ef41Sopenharmony_ci Heap::InsertIntoRememberedSetFromCode) 3371cb0ef41Sopenharmony_ci 3381cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(delete_handle_scope_extensions, 3391cb0ef41Sopenharmony_ci HandleScope::DeleteExtensions) 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(ephemeron_key_write_barrier_function, 3421cb0ef41Sopenharmony_ci Heap::EphemeronKeyWriteBarrierFromCode) 3431cb0ef41Sopenharmony_ci 3441cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(get_date_field_function, JSDate::GetField) 3451cb0ef41Sopenharmony_ci 3461cb0ef41Sopenharmony_ciExternalReference ExternalReference::date_cache_stamp(Isolate* isolate) { 3471cb0ef41Sopenharmony_ci return ExternalReference(isolate->date_cache()->stamp_address()); 3481cb0ef41Sopenharmony_ci} 3491cb0ef41Sopenharmony_ci 3501cb0ef41Sopenharmony_ci// static 3511cb0ef41Sopenharmony_ciExternalReference 3521cb0ef41Sopenharmony_ciExternalReference::runtime_function_table_address_for_unittests( 3531cb0ef41Sopenharmony_ci Isolate* isolate) { 3541cb0ef41Sopenharmony_ci return runtime_function_table_address(isolate); 3551cb0ef41Sopenharmony_ci} 3561cb0ef41Sopenharmony_ci 3571cb0ef41Sopenharmony_ci// static 3581cb0ef41Sopenharmony_ciAddress ExternalReference::Redirect(Address address, Type type) { 3591cb0ef41Sopenharmony_ci#ifdef USE_SIMULATOR 3601cb0ef41Sopenharmony_ci return SimulatorBase::RedirectExternalReference(address, type); 3611cb0ef41Sopenharmony_ci#else 3621cb0ef41Sopenharmony_ci return address; 3631cb0ef41Sopenharmony_ci#endif 3641cb0ef41Sopenharmony_ci} 3651cb0ef41Sopenharmony_ci 3661cb0ef41Sopenharmony_ciExternalReference ExternalReference::stress_deopt_count(Isolate* isolate) { 3671cb0ef41Sopenharmony_ci return ExternalReference(isolate->stress_deopt_count_address()); 3681cb0ef41Sopenharmony_ci} 3691cb0ef41Sopenharmony_ci 3701cb0ef41Sopenharmony_ciExternalReference ExternalReference::force_slow_path(Isolate* isolate) { 3711cb0ef41Sopenharmony_ci return ExternalReference(isolate->force_slow_path_address()); 3721cb0ef41Sopenharmony_ci} 3731cb0ef41Sopenharmony_ci 3741cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(new_deoptimizer_function, Deoptimizer::New) 3751cb0ef41Sopenharmony_ci 3761cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(compute_output_frames_function, 3771cb0ef41Sopenharmony_ci Deoptimizer::ComputeOutputFrames) 3781cb0ef41Sopenharmony_ci 3791cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32_trunc, wasm::f32_trunc_wrapper) 3801cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32_floor, wasm::f32_floor_wrapper) 3811cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32_ceil, wasm::f32_ceil_wrapper) 3821cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32_nearest_int, wasm::f32_nearest_int_wrapper) 3831cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64_trunc, wasm::f64_trunc_wrapper) 3841cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64_floor, wasm::f64_floor_wrapper) 3851cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64_ceil, wasm::f64_ceil_wrapper) 3861cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64_nearest_int, wasm::f64_nearest_int_wrapper) 3871cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_int64_to_float32, 3881cb0ef41Sopenharmony_ci wasm::int64_to_float32_wrapper) 3891cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_uint64_to_float32, 3901cb0ef41Sopenharmony_ci wasm::uint64_to_float32_wrapper) 3911cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_int64_to_float64, 3921cb0ef41Sopenharmony_ci wasm::int64_to_float64_wrapper) 3931cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_uint64_to_float64, 3941cb0ef41Sopenharmony_ci wasm::uint64_to_float64_wrapper) 3951cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float32_to_int64, 3961cb0ef41Sopenharmony_ci wasm::float32_to_int64_wrapper) 3971cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float32_to_uint64, 3981cb0ef41Sopenharmony_ci wasm::float32_to_uint64_wrapper) 3991cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float64_to_int64, 4001cb0ef41Sopenharmony_ci wasm::float64_to_int64_wrapper) 4011cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float64_to_uint64, 4021cb0ef41Sopenharmony_ci wasm::float64_to_uint64_wrapper) 4031cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float32_to_int64_sat, 4041cb0ef41Sopenharmony_ci wasm::float32_to_int64_sat_wrapper) 4051cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float32_to_uint64_sat, 4061cb0ef41Sopenharmony_ci wasm::float32_to_uint64_sat_wrapper) 4071cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float64_to_int64_sat, 4081cb0ef41Sopenharmony_ci wasm::float64_to_int64_sat_wrapper) 4091cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float64_to_uint64_sat, 4101cb0ef41Sopenharmony_ci wasm::float64_to_uint64_sat_wrapper) 4111cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_int64_div, wasm::int64_div_wrapper) 4121cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_int64_mod, wasm::int64_mod_wrapper) 4131cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_uint64_div, wasm::uint64_div_wrapper) 4141cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_uint64_mod, wasm::uint64_mod_wrapper) 4151cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word32_ctz, wasm::word32_ctz_wrapper) 4161cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word64_ctz, wasm::word64_ctz_wrapper) 4171cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word32_popcnt, wasm::word32_popcnt_wrapper) 4181cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word64_popcnt, wasm::word64_popcnt_wrapper) 4191cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word32_rol, wasm::word32_rol_wrapper) 4201cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word32_ror, wasm::word32_ror_wrapper) 4211cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word64_rol, wasm::word64_rol_wrapper) 4221cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_word64_ror, wasm::word64_ror_wrapper) 4231cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64x2_ceil, wasm::f64x2_ceil_wrapper) 4241cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64x2_floor, wasm::f64x2_floor_wrapper) 4251cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64x2_trunc, wasm::f64x2_trunc_wrapper) 4261cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f64x2_nearest_int, 4271cb0ef41Sopenharmony_ci wasm::f64x2_nearest_int_wrapper) 4281cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32x4_ceil, wasm::f32x4_ceil_wrapper) 4291cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32x4_floor, wasm::f32x4_floor_wrapper) 4301cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32x4_trunc, wasm::f32x4_trunc_wrapper) 4311cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_f32x4_nearest_int, 4321cb0ef41Sopenharmony_ci wasm::f32x4_nearest_int_wrapper) 4331cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_memory_init, wasm::memory_init_wrapper) 4341cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_memory_copy, wasm::memory_copy_wrapper) 4351cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_memory_fill, wasm::memory_fill_wrapper) 4361cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_float64_pow, wasm::float64_pow_wrapper) 4371cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_call_trap_callback_for_testing, 4381cb0ef41Sopenharmony_ci wasm::call_trap_callback_for_testing) 4391cb0ef41Sopenharmony_ciIF_WASM(FUNCTION_REFERENCE, wasm_array_copy, wasm::array_copy_wrapper) 4401cb0ef41Sopenharmony_ci 4411cb0ef41Sopenharmony_cistatic void f64_acos_wrapper(Address data) { 4421cb0ef41Sopenharmony_ci double input = ReadUnalignedValue<double>(data); 4431cb0ef41Sopenharmony_ci WriteUnalignedValue(data, base::ieee754::acos(input)); 4441cb0ef41Sopenharmony_ci} 4451cb0ef41Sopenharmony_ci 4461cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(f64_acos_wrapper_function, f64_acos_wrapper) 4471cb0ef41Sopenharmony_ci 4481cb0ef41Sopenharmony_cistatic void f64_asin_wrapper(Address data) { 4491cb0ef41Sopenharmony_ci double input = ReadUnalignedValue<double>(data); 4501cb0ef41Sopenharmony_ci WriteUnalignedValue<double>(data, base::ieee754::asin(input)); 4511cb0ef41Sopenharmony_ci} 4521cb0ef41Sopenharmony_ci 4531cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(f64_asin_wrapper_function, f64_asin_wrapper) 4541cb0ef41Sopenharmony_ci 4551cb0ef41Sopenharmony_ci 4561cb0ef41Sopenharmony_cistatic void f64_mod_wrapper(Address data) { 4571cb0ef41Sopenharmony_ci double dividend = ReadUnalignedValue<double>(data); 4581cb0ef41Sopenharmony_ci double divisor = ReadUnalignedValue<double>(data + sizeof(dividend)); 4591cb0ef41Sopenharmony_ci WriteUnalignedValue<double>(data, Modulo(dividend, divisor)); 4601cb0ef41Sopenharmony_ci} 4611cb0ef41Sopenharmony_ci 4621cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(f64_mod_wrapper_function, f64_mod_wrapper) 4631cb0ef41Sopenharmony_ci 4641cb0ef41Sopenharmony_ciExternalReference ExternalReference::isolate_root(Isolate* isolate) { 4651cb0ef41Sopenharmony_ci return ExternalReference(isolate->isolate_root()); 4661cb0ef41Sopenharmony_ci} 4671cb0ef41Sopenharmony_ci 4681cb0ef41Sopenharmony_ciExternalReference ExternalReference::allocation_sites_list_address( 4691cb0ef41Sopenharmony_ci Isolate* isolate) { 4701cb0ef41Sopenharmony_ci return ExternalReference(isolate->heap()->allocation_sites_list_address()); 4711cb0ef41Sopenharmony_ci} 4721cb0ef41Sopenharmony_ci 4731cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_jslimit(Isolate* isolate) { 4741cb0ef41Sopenharmony_ci Address address = isolate->stack_guard()->address_of_jslimit(); 4751cb0ef41Sopenharmony_ci // For efficient generated code, this should be root-register-addressable. 4761cb0ef41Sopenharmony_ci DCHECK(isolate->root_register_addressable_region().contains(address)); 4771cb0ef41Sopenharmony_ci return ExternalReference(address); 4781cb0ef41Sopenharmony_ci} 4791cb0ef41Sopenharmony_ci 4801cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_real_jslimit(Isolate* isolate) { 4811cb0ef41Sopenharmony_ci Address address = isolate->stack_guard()->address_of_real_jslimit(); 4821cb0ef41Sopenharmony_ci // For efficient generated code, this should be root-register-addressable. 4831cb0ef41Sopenharmony_ci DCHECK(isolate->root_register_addressable_region().contains(address)); 4841cb0ef41Sopenharmony_ci return ExternalReference(address); 4851cb0ef41Sopenharmony_ci} 4861cb0ef41Sopenharmony_ci 4871cb0ef41Sopenharmony_ciExternalReference ExternalReference::heap_is_marking_flag_address( 4881cb0ef41Sopenharmony_ci Isolate* isolate) { 4891cb0ef41Sopenharmony_ci return ExternalReference(isolate->heap()->IsMarkingFlagAddress()); 4901cb0ef41Sopenharmony_ci} 4911cb0ef41Sopenharmony_ci 4921cb0ef41Sopenharmony_ciExternalReference ExternalReference::new_space_allocation_top_address( 4931cb0ef41Sopenharmony_ci Isolate* isolate) { 4941cb0ef41Sopenharmony_ci return ExternalReference(isolate->heap()->NewSpaceAllocationTopAddress()); 4951cb0ef41Sopenharmony_ci} 4961cb0ef41Sopenharmony_ci 4971cb0ef41Sopenharmony_ciExternalReference ExternalReference::new_space_allocation_limit_address( 4981cb0ef41Sopenharmony_ci Isolate* isolate) { 4991cb0ef41Sopenharmony_ci return ExternalReference(isolate->heap()->NewSpaceAllocationLimitAddress()); 5001cb0ef41Sopenharmony_ci} 5011cb0ef41Sopenharmony_ci 5021cb0ef41Sopenharmony_ciExternalReference ExternalReference::old_space_allocation_top_address( 5031cb0ef41Sopenharmony_ci Isolate* isolate) { 5041cb0ef41Sopenharmony_ci return ExternalReference(isolate->heap()->OldSpaceAllocationTopAddress()); 5051cb0ef41Sopenharmony_ci} 5061cb0ef41Sopenharmony_ci 5071cb0ef41Sopenharmony_ciExternalReference ExternalReference::old_space_allocation_limit_address( 5081cb0ef41Sopenharmony_ci Isolate* isolate) { 5091cb0ef41Sopenharmony_ci return ExternalReference(isolate->heap()->OldSpaceAllocationLimitAddress()); 5101cb0ef41Sopenharmony_ci} 5111cb0ef41Sopenharmony_ci 5121cb0ef41Sopenharmony_ciExternalReference ExternalReference::handle_scope_level_address( 5131cb0ef41Sopenharmony_ci Isolate* isolate) { 5141cb0ef41Sopenharmony_ci return ExternalReference(HandleScope::current_level_address(isolate)); 5151cb0ef41Sopenharmony_ci} 5161cb0ef41Sopenharmony_ci 5171cb0ef41Sopenharmony_ciExternalReference ExternalReference::handle_scope_next_address( 5181cb0ef41Sopenharmony_ci Isolate* isolate) { 5191cb0ef41Sopenharmony_ci return ExternalReference(HandleScope::current_next_address(isolate)); 5201cb0ef41Sopenharmony_ci} 5211cb0ef41Sopenharmony_ci 5221cb0ef41Sopenharmony_ciExternalReference ExternalReference::handle_scope_limit_address( 5231cb0ef41Sopenharmony_ci Isolate* isolate) { 5241cb0ef41Sopenharmony_ci return ExternalReference(HandleScope::current_limit_address(isolate)); 5251cb0ef41Sopenharmony_ci} 5261cb0ef41Sopenharmony_ci 5271cb0ef41Sopenharmony_ciExternalReference ExternalReference::scheduled_exception_address( 5281cb0ef41Sopenharmony_ci Isolate* isolate) { 5291cb0ef41Sopenharmony_ci return ExternalReference(isolate->scheduled_exception_address()); 5301cb0ef41Sopenharmony_ci} 5311cb0ef41Sopenharmony_ci 5321cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_pending_message( 5331cb0ef41Sopenharmony_ci Isolate* isolate) { 5341cb0ef41Sopenharmony_ci return ExternalReference(isolate->pending_message_address()); 5351cb0ef41Sopenharmony_ci} 5361cb0ef41Sopenharmony_ci 5371cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_pending_message( 5381cb0ef41Sopenharmony_ci LocalIsolate* local_isolate) { 5391cb0ef41Sopenharmony_ci return ExternalReference(local_isolate->pending_message_address()); 5401cb0ef41Sopenharmony_ci} 5411cb0ef41Sopenharmony_ci 5421cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(abort_with_reason, i::abort_with_reason) 5431cb0ef41Sopenharmony_ci 5441cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_min_int() { 5451cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&double_min_int_constant)); 5461cb0ef41Sopenharmony_ci} 5471cb0ef41Sopenharmony_ci 5481cb0ef41Sopenharmony_ciExternalReference 5491cb0ef41Sopenharmony_ciExternalReference::address_of_mock_arraybuffer_allocator_flag() { 5501cb0ef41Sopenharmony_ci return ExternalReference(&FLAG_mock_arraybuffer_allocator); 5511cb0ef41Sopenharmony_ci} 5521cb0ef41Sopenharmony_ci 5531cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_builtin_subclassing_flag() { 5541cb0ef41Sopenharmony_ci return ExternalReference(&FLAG_builtin_subclassing); 5551cb0ef41Sopenharmony_ci} 5561cb0ef41Sopenharmony_ci 5571cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_runtime_stats_flag() { 5581cb0ef41Sopenharmony_ci return ExternalReference(&TracingFlags::runtime_stats); 5591cb0ef41Sopenharmony_ci} 5601cb0ef41Sopenharmony_ci 5611cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_shared_string_table_flag() { 5621cb0ef41Sopenharmony_ci return ExternalReference(&FLAG_shared_string_table); 5631cb0ef41Sopenharmony_ci} 5641cb0ef41Sopenharmony_ci 5651cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_load_from_stack_count( 5661cb0ef41Sopenharmony_ci const char* function_name) { 5671cb0ef41Sopenharmony_ci return ExternalReference( 5681cb0ef41Sopenharmony_ci Isolate::load_from_stack_count_address(function_name)); 5691cb0ef41Sopenharmony_ci} 5701cb0ef41Sopenharmony_ci 5711cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_store_to_stack_count( 5721cb0ef41Sopenharmony_ci const char* function_name) { 5731cb0ef41Sopenharmony_ci return ExternalReference( 5741cb0ef41Sopenharmony_ci Isolate::store_to_stack_count_address(function_name)); 5751cb0ef41Sopenharmony_ci} 5761cb0ef41Sopenharmony_ci 5771cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_one_half() { 5781cb0ef41Sopenharmony_ci return ExternalReference( 5791cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&double_one_half_constant)); 5801cb0ef41Sopenharmony_ci} 5811cb0ef41Sopenharmony_ci 5821cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_the_hole_nan() { 5831cb0ef41Sopenharmony_ci return ExternalReference( 5841cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&double_the_hole_nan_constant)); 5851cb0ef41Sopenharmony_ci} 5861cb0ef41Sopenharmony_ci 5871cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_uint32_bias() { 5881cb0ef41Sopenharmony_ci return ExternalReference( 5891cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&double_uint32_bias_constant)); 5901cb0ef41Sopenharmony_ci} 5911cb0ef41Sopenharmony_ci 5921cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_float_abs_constant() { 5931cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&float_absolute_constant)); 5941cb0ef41Sopenharmony_ci} 5951cb0ef41Sopenharmony_ci 5961cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_float_neg_constant() { 5971cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&float_negate_constant)); 5981cb0ef41Sopenharmony_ci} 5991cb0ef41Sopenharmony_ci 6001cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_double_abs_constant() { 6011cb0ef41Sopenharmony_ci return ExternalReference( 6021cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&double_absolute_constant)); 6031cb0ef41Sopenharmony_ci} 6041cb0ef41Sopenharmony_ci 6051cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_double_neg_constant() { 6061cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&double_negate_constant)); 6071cb0ef41Sopenharmony_ci} 6081cb0ef41Sopenharmony_ci 6091cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i8x16_swizzle_mask() { 6101cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i8x16_swizzle_mask)); 6111cb0ef41Sopenharmony_ci} 6121cb0ef41Sopenharmony_ci 6131cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i8x16_popcnt_mask() { 6141cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i8x16_popcnt_mask)); 6151cb0ef41Sopenharmony_ci} 6161cb0ef41Sopenharmony_ci 6171cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i8x16_splat_0x01() { 6181cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i8x16_splat_0x01)); 6191cb0ef41Sopenharmony_ci} 6201cb0ef41Sopenharmony_ci 6211cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i8x16_splat_0x0f() { 6221cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i8x16_splat_0x0f)); 6231cb0ef41Sopenharmony_ci} 6241cb0ef41Sopenharmony_ci 6251cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i8x16_splat_0x33() { 6261cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i8x16_splat_0x33)); 6271cb0ef41Sopenharmony_ci} 6281cb0ef41Sopenharmony_ci 6291cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i8x16_splat_0x55() { 6301cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i8x16_splat_0x55)); 6311cb0ef41Sopenharmony_ci} 6321cb0ef41Sopenharmony_ci 6331cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_i16x8_splat_0x0001() { 6341cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_i16x8_splat_0x0001)); 6351cb0ef41Sopenharmony_ci} 6361cb0ef41Sopenharmony_ci 6371cb0ef41Sopenharmony_ciExternalReference 6381cb0ef41Sopenharmony_ciExternalReference::address_of_wasm_f64x2_convert_low_i32x4_u_int_mask() { 6391cb0ef41Sopenharmony_ci return ExternalReference( 6401cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&wasm_f64x2_convert_low_i32x4_u_int_mask)); 6411cb0ef41Sopenharmony_ci} 6421cb0ef41Sopenharmony_ci 6431cb0ef41Sopenharmony_ciExternalReference ExternalReference::supports_wasm_simd_128_address() { 6441cb0ef41Sopenharmony_ci return ExternalReference( 6451cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&CpuFeatures::supports_wasm_simd_128_)); 6461cb0ef41Sopenharmony_ci} 6471cb0ef41Sopenharmony_ci 6481cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_double_2_power_52() { 6491cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(&wasm_double_2_power_52)); 6501cb0ef41Sopenharmony_ci} 6511cb0ef41Sopenharmony_ci 6521cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_int32_max_as_double() { 6531cb0ef41Sopenharmony_ci return ExternalReference( 6541cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&wasm_int32_max_as_double)); 6551cb0ef41Sopenharmony_ci} 6561cb0ef41Sopenharmony_ci 6571cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_uint32_max_as_double() { 6581cb0ef41Sopenharmony_ci return ExternalReference( 6591cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&wasm_uint32_max_as_double)); 6601cb0ef41Sopenharmony_ci} 6611cb0ef41Sopenharmony_ci 6621cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_wasm_int32_overflow_as_float() { 6631cb0ef41Sopenharmony_ci return ExternalReference( 6641cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&wasm_int32_overflow_as_float)); 6651cb0ef41Sopenharmony_ci} 6661cb0ef41Sopenharmony_ci 6671cb0ef41Sopenharmony_ciExternalReference ExternalReference::supports_cetss_address() { 6681cb0ef41Sopenharmony_ci return ExternalReference( 6691cb0ef41Sopenharmony_ci reinterpret_cast<Address>(&CpuFeatures::supports_cetss_)); 6701cb0ef41Sopenharmony_ci} 6711cb0ef41Sopenharmony_ci 6721cb0ef41Sopenharmony_ciExternalReference 6731cb0ef41Sopenharmony_ciExternalReference::address_of_enable_experimental_regexp_engine() { 6741cb0ef41Sopenharmony_ci return ExternalReference(&FLAG_enable_experimental_regexp_engine); 6751cb0ef41Sopenharmony_ci} 6761cb0ef41Sopenharmony_ci 6771cb0ef41Sopenharmony_cinamespace { 6781cb0ef41Sopenharmony_ci 6791cb0ef41Sopenharmony_cistatic uintptr_t BaselinePCForBytecodeOffset(Address raw_code_obj, 6801cb0ef41Sopenharmony_ci int bytecode_offset, 6811cb0ef41Sopenharmony_ci Address raw_bytecode_array) { 6821cb0ef41Sopenharmony_ci Code code_obj = Code::cast(Object(raw_code_obj)); 6831cb0ef41Sopenharmony_ci BytecodeArray bytecode_array = 6841cb0ef41Sopenharmony_ci BytecodeArray::cast(Object(raw_bytecode_array)); 6851cb0ef41Sopenharmony_ci return code_obj.GetBaselineStartPCForBytecodeOffset(bytecode_offset, 6861cb0ef41Sopenharmony_ci bytecode_array); 6871cb0ef41Sopenharmony_ci} 6881cb0ef41Sopenharmony_ci 6891cb0ef41Sopenharmony_cistatic uintptr_t BaselinePCForNextExecutedBytecode(Address raw_code_obj, 6901cb0ef41Sopenharmony_ci int bytecode_offset, 6911cb0ef41Sopenharmony_ci Address raw_bytecode_array) { 6921cb0ef41Sopenharmony_ci Code code_obj = Code::cast(Object(raw_code_obj)); 6931cb0ef41Sopenharmony_ci BytecodeArray bytecode_array = 6941cb0ef41Sopenharmony_ci BytecodeArray::cast(Object(raw_bytecode_array)); 6951cb0ef41Sopenharmony_ci return code_obj.GetBaselinePCForNextExecutedBytecode(bytecode_offset, 6961cb0ef41Sopenharmony_ci bytecode_array); 6971cb0ef41Sopenharmony_ci} 6981cb0ef41Sopenharmony_ci 6991cb0ef41Sopenharmony_ci} // namespace 7001cb0ef41Sopenharmony_ci 7011cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(baseline_pc_for_bytecode_offset, BaselinePCForBytecodeOffset) 7021cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(baseline_pc_for_next_executed_bytecode, 7031cb0ef41Sopenharmony_ci BaselinePCForNextExecutedBytecode) 7041cb0ef41Sopenharmony_ci 7051cb0ef41Sopenharmony_ciExternalReference ExternalReference::thread_in_wasm_flag_address_address( 7061cb0ef41Sopenharmony_ci Isolate* isolate) { 7071cb0ef41Sopenharmony_ci return ExternalReference(isolate->thread_in_wasm_flag_address_address()); 7081cb0ef41Sopenharmony_ci} 7091cb0ef41Sopenharmony_ci 7101cb0ef41Sopenharmony_ciExternalReference ExternalReference::is_profiling_address(Isolate* isolate) { 7111cb0ef41Sopenharmony_ci return ExternalReference(isolate->is_profiling_address()); 7121cb0ef41Sopenharmony_ci} 7131cb0ef41Sopenharmony_ci 7141cb0ef41Sopenharmony_ciExternalReference ExternalReference::invoke_function_callback() { 7151cb0ef41Sopenharmony_ci Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); 7161cb0ef41Sopenharmony_ci ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL; 7171cb0ef41Sopenharmony_ci ApiFunction thunk_fun(thunk_address); 7181cb0ef41Sopenharmony_ci return ExternalReference::Create(&thunk_fun, thunk_type); 7191cb0ef41Sopenharmony_ci} 7201cb0ef41Sopenharmony_ci 7211cb0ef41Sopenharmony_ciExternalReference ExternalReference::invoke_accessor_getter_callback() { 7221cb0ef41Sopenharmony_ci Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); 7231cb0ef41Sopenharmony_ci ExternalReference::Type thunk_type = ExternalReference::PROFILING_GETTER_CALL; 7241cb0ef41Sopenharmony_ci ApiFunction thunk_fun(thunk_address); 7251cb0ef41Sopenharmony_ci return ExternalReference::Create(&thunk_fun, thunk_type); 7261cb0ef41Sopenharmony_ci} 7271cb0ef41Sopenharmony_ci 7281cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 7291cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerX64::CheckStackGuardState 7301cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_IA32 7311cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerIA32::CheckStackGuardState 7321cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_ARM64 7331cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerARM64::CheckStackGuardState 7341cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_ARM 7351cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerARM::CheckStackGuardState 7361cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 7371cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerPPC::CheckStackGuardState 7381cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_MIPS 7391cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState 7401cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_MIPS64 7411cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState 7421cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_LOONG64 7431cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerLOONG64::CheckStackGuardState 7441cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_S390 7451cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState 7461cb0ef41Sopenharmony_ci#elif V8_TARGET_ARCH_RISCV64 7471cb0ef41Sopenharmony_ci#define re_stack_check_func RegExpMacroAssemblerRISCV::CheckStackGuardState 7481cb0ef41Sopenharmony_ci#else 7491cb0ef41Sopenharmony_ciUNREACHABLE(); 7501cb0ef41Sopenharmony_ci#endif 7511cb0ef41Sopenharmony_ci 7521cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_check_stack_guard_state, re_stack_check_func) 7531cb0ef41Sopenharmony_ci#undef re_stack_check_func 7541cb0ef41Sopenharmony_ci 7551cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_grow_stack, NativeRegExpMacroAssembler::GrowStack) 7561cb0ef41Sopenharmony_ci 7571cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_match_for_call_from_js, 7581cb0ef41Sopenharmony_ci IrregexpInterpreter::MatchForCallFromJs) 7591cb0ef41Sopenharmony_ci 7601cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_experimental_match_for_call_from_js, 7611cb0ef41Sopenharmony_ci ExperimentalRegExp::MatchForCallFromJs) 7621cb0ef41Sopenharmony_ci 7631cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_case_insensitive_compare_unicode, 7641cb0ef41Sopenharmony_ci NativeRegExpMacroAssembler::CaseInsensitiveCompareUnicode) 7651cb0ef41Sopenharmony_ci 7661cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_case_insensitive_compare_non_unicode, 7671cb0ef41Sopenharmony_ci NativeRegExpMacroAssembler::CaseInsensitiveCompareNonUnicode) 7681cb0ef41Sopenharmony_ci 7691cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(re_is_character_in_range_array, 7701cb0ef41Sopenharmony_ci RegExpMacroAssembler::IsCharacterInRangeArray) 7711cb0ef41Sopenharmony_ci 7721cb0ef41Sopenharmony_ciExternalReference ExternalReference::re_word_character_map() { 7731cb0ef41Sopenharmony_ci return ExternalReference( 7741cb0ef41Sopenharmony_ci NativeRegExpMacroAssembler::word_character_map_address()); 7751cb0ef41Sopenharmony_ci} 7761cb0ef41Sopenharmony_ci 7771cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_static_offsets_vector( 7781cb0ef41Sopenharmony_ci Isolate* isolate) { 7791cb0ef41Sopenharmony_ci return ExternalReference( 7801cb0ef41Sopenharmony_ci reinterpret_cast<Address>(isolate->jsregexp_static_offsets_vector())); 7811cb0ef41Sopenharmony_ci} 7821cb0ef41Sopenharmony_ci 7831cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_regexp_stack_limit_address( 7841cb0ef41Sopenharmony_ci Isolate* isolate) { 7851cb0ef41Sopenharmony_ci return ExternalReference(isolate->regexp_stack()->limit_address_address()); 7861cb0ef41Sopenharmony_ci} 7871cb0ef41Sopenharmony_ci 7881cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_regexp_stack_memory_top_address( 7891cb0ef41Sopenharmony_ci Isolate* isolate) { 7901cb0ef41Sopenharmony_ci return ExternalReference( 7911cb0ef41Sopenharmony_ci isolate->regexp_stack()->memory_top_address_address()); 7921cb0ef41Sopenharmony_ci} 7931cb0ef41Sopenharmony_ci 7941cb0ef41Sopenharmony_ciExternalReference ExternalReference::address_of_regexp_stack_stack_pointer( 7951cb0ef41Sopenharmony_ci Isolate* isolate) { 7961cb0ef41Sopenharmony_ci return ExternalReference(isolate->regexp_stack()->stack_pointer_address()); 7971cb0ef41Sopenharmony_ci} 7981cb0ef41Sopenharmony_ci 7991cb0ef41Sopenharmony_ciExternalReference ExternalReference::javascript_execution_assert( 8001cb0ef41Sopenharmony_ci Isolate* isolate) { 8011cb0ef41Sopenharmony_ci return ExternalReference(isolate->javascript_execution_assert_address()); 8021cb0ef41Sopenharmony_ci} 8031cb0ef41Sopenharmony_ci 8041cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_acos_function, base::ieee754::acos, 8051cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8061cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_acosh_function, base::ieee754::acosh, 8071cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8081cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_asin_function, base::ieee754::asin, 8091cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8101cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_asinh_function, base::ieee754::asinh, 8111cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8121cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_atan_function, base::ieee754::atan, 8131cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8141cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_atanh_function, base::ieee754::atanh, 8151cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8161cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_atan2_function, base::ieee754::atan2, 8171cb0ef41Sopenharmony_ci BUILTIN_FP_FP_CALL) 8181cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_cbrt_function, base::ieee754::cbrt, 8191cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8201cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_cos_function, base::ieee754::cos, 8211cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8221cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_cosh_function, base::ieee754::cosh, 8231cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8241cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_exp_function, base::ieee754::exp, 8251cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8261cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_expm1_function, base::ieee754::expm1, 8271cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8281cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_log_function, base::ieee754::log, 8291cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8301cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_log1p_function, base::ieee754::log1p, 8311cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8321cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_log10_function, base::ieee754::log10, 8331cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8341cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_log2_function, base::ieee754::log2, 8351cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8361cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_sin_function, base::ieee754::sin, 8371cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8381cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_sinh_function, base::ieee754::sinh, 8391cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8401cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_tan_function, base::ieee754::tan, 8411cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8421cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_tanh_function, base::ieee754::tanh, 8431cb0ef41Sopenharmony_ci BUILTIN_FP_CALL) 8441cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(ieee754_pow_function, base::ieee754::pow, 8451cb0ef41Sopenharmony_ci BUILTIN_FP_FP_CALL) 8461cb0ef41Sopenharmony_ci 8471cb0ef41Sopenharmony_civoid* libc_memchr(void* string, int character, size_t search_length) { 8481cb0ef41Sopenharmony_ci return memchr(string, character, search_length); 8491cb0ef41Sopenharmony_ci} 8501cb0ef41Sopenharmony_ci 8511cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(libc_memchr_function, libc_memchr) 8521cb0ef41Sopenharmony_ci 8531cb0ef41Sopenharmony_civoid* libc_memcpy(void* dest, const void* src, size_t n) { 8541cb0ef41Sopenharmony_ci return memcpy(dest, src, n); 8551cb0ef41Sopenharmony_ci} 8561cb0ef41Sopenharmony_ci 8571cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(libc_memcpy_function, libc_memcpy) 8581cb0ef41Sopenharmony_ci 8591cb0ef41Sopenharmony_civoid* libc_memmove(void* dest, const void* src, size_t n) { 8601cb0ef41Sopenharmony_ci return memmove(dest, src, n); 8611cb0ef41Sopenharmony_ci} 8621cb0ef41Sopenharmony_ci 8631cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(libc_memmove_function, libc_memmove) 8641cb0ef41Sopenharmony_ci 8651cb0ef41Sopenharmony_civoid* libc_memset(void* dest, int value, size_t n) { 8661cb0ef41Sopenharmony_ci DCHECK_EQ(static_cast<byte>(value), value); 8671cb0ef41Sopenharmony_ci return memset(dest, value, n); 8681cb0ef41Sopenharmony_ci} 8691cb0ef41Sopenharmony_ci 8701cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(libc_memset_function, libc_memset) 8711cb0ef41Sopenharmony_ci 8721cb0ef41Sopenharmony_civoid relaxed_memcpy(volatile base::Atomic8* dest, 8731cb0ef41Sopenharmony_ci volatile const base::Atomic8* src, size_t n) { 8741cb0ef41Sopenharmony_ci base::Relaxed_Memcpy(dest, src, n); 8751cb0ef41Sopenharmony_ci} 8761cb0ef41Sopenharmony_ci 8771cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(relaxed_memcpy_function, relaxed_memcpy) 8781cb0ef41Sopenharmony_ci 8791cb0ef41Sopenharmony_civoid relaxed_memmove(volatile base::Atomic8* dest, 8801cb0ef41Sopenharmony_ci volatile const base::Atomic8* src, size_t n) { 8811cb0ef41Sopenharmony_ci base::Relaxed_Memmove(dest, src, n); 8821cb0ef41Sopenharmony_ci} 8831cb0ef41Sopenharmony_ci 8841cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(relaxed_memmove_function, relaxed_memmove) 8851cb0ef41Sopenharmony_ci 8861cb0ef41Sopenharmony_ciExternalReference ExternalReference::printf_function() { 8871cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(std::printf))); 8881cb0ef41Sopenharmony_ci} 8891cb0ef41Sopenharmony_ci 8901cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(refill_math_random, MathRandom::RefillCache) 8911cb0ef41Sopenharmony_ci 8921cb0ef41Sopenharmony_citemplate <typename SubjectChar, typename PatternChar> 8931cb0ef41Sopenharmony_ciExternalReference ExternalReference::search_string_raw() { 8941cb0ef41Sopenharmony_ci auto f = SearchStringRaw<SubjectChar, PatternChar>; 8951cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(f))); 8961cb0ef41Sopenharmony_ci} 8971cb0ef41Sopenharmony_ci 8981cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(jsarray_array_join_concat_to_sequential_string, 8991cb0ef41Sopenharmony_ci JSArray::ArrayJoinConcatToSequentialString) 9001cb0ef41Sopenharmony_ci 9011cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(gsab_byte_length, JSArrayBuffer::GsabByteLength) 9021cb0ef41Sopenharmony_ci 9031cb0ef41Sopenharmony_ciExternalReference ExternalReference::search_string_raw_one_one() { 9041cb0ef41Sopenharmony_ci return search_string_raw<const uint8_t, const uint8_t>(); 9051cb0ef41Sopenharmony_ci} 9061cb0ef41Sopenharmony_ci 9071cb0ef41Sopenharmony_ciExternalReference ExternalReference::search_string_raw_one_two() { 9081cb0ef41Sopenharmony_ci return search_string_raw<const uint8_t, const base::uc16>(); 9091cb0ef41Sopenharmony_ci} 9101cb0ef41Sopenharmony_ci 9111cb0ef41Sopenharmony_ciExternalReference ExternalReference::search_string_raw_two_one() { 9121cb0ef41Sopenharmony_ci return search_string_raw<const base::uc16, const uint8_t>(); 9131cb0ef41Sopenharmony_ci} 9141cb0ef41Sopenharmony_ci 9151cb0ef41Sopenharmony_ciExternalReference ExternalReference::search_string_raw_two_two() { 9161cb0ef41Sopenharmony_ci return search_string_raw<const base::uc16, const base::uc16>(); 9171cb0ef41Sopenharmony_ci} 9181cb0ef41Sopenharmony_ci 9191cb0ef41Sopenharmony_cinamespace { 9201cb0ef41Sopenharmony_ci 9211cb0ef41Sopenharmony_civoid StringWriteToFlatOneByte(Address source, uint8_t* sink, int32_t start, 9221cb0ef41Sopenharmony_ci int32_t length) { 9231cb0ef41Sopenharmony_ci return String::WriteToFlat<uint8_t>(String::cast(Object(source)), sink, start, 9241cb0ef41Sopenharmony_ci length); 9251cb0ef41Sopenharmony_ci} 9261cb0ef41Sopenharmony_ci 9271cb0ef41Sopenharmony_civoid StringWriteToFlatTwoByte(Address source, uint16_t* sink, int32_t start, 9281cb0ef41Sopenharmony_ci int32_t length) { 9291cb0ef41Sopenharmony_ci return String::WriteToFlat<uint16_t>(String::cast(Object(source)), sink, 9301cb0ef41Sopenharmony_ci start, length); 9311cb0ef41Sopenharmony_ci} 9321cb0ef41Sopenharmony_ci 9331cb0ef41Sopenharmony_ciconst uint8_t* ExternalOneByteStringGetChars(Address string) { 9341cb0ef41Sopenharmony_ci PtrComprCageBase cage_base = GetPtrComprCageBaseFromOnHeapAddress(string); 9351cb0ef41Sopenharmony_ci // The following CHECK is a workaround to prevent a CFI bug where 9361cb0ef41Sopenharmony_ci // ExternalOneByteStringGetChars() and ExternalTwoByteStringGetChars() are 9371cb0ef41Sopenharmony_ci // merged by the linker, resulting in one of the input type's vtable address 9381cb0ef41Sopenharmony_ci // failing the address range check. 9391cb0ef41Sopenharmony_ci // TODO(chromium:1160961): Consider removing the CHECK when CFI is fixed. 9401cb0ef41Sopenharmony_ci CHECK(Object(string).IsExternalOneByteString(cage_base)); 9411cb0ef41Sopenharmony_ci return ExternalOneByteString::cast(Object(string)).GetChars(cage_base); 9421cb0ef41Sopenharmony_ci} 9431cb0ef41Sopenharmony_ciconst uint16_t* ExternalTwoByteStringGetChars(Address string) { 9441cb0ef41Sopenharmony_ci PtrComprCageBase cage_base = GetPtrComprCageBaseFromOnHeapAddress(string); 9451cb0ef41Sopenharmony_ci // The following CHECK is a workaround to prevent a CFI bug where 9461cb0ef41Sopenharmony_ci // ExternalOneByteStringGetChars() and ExternalTwoByteStringGetChars() are 9471cb0ef41Sopenharmony_ci // merged by the linker, resulting in one of the input type's vtable address 9481cb0ef41Sopenharmony_ci // failing the address range check. 9491cb0ef41Sopenharmony_ci // TODO(chromium:1160961): Consider removing the CHECK when CFI is fixed. 9501cb0ef41Sopenharmony_ci CHECK(Object(string).IsExternalTwoByteString(cage_base)); 9511cb0ef41Sopenharmony_ci return ExternalTwoByteString::cast(Object(string)).GetChars(cage_base); 9521cb0ef41Sopenharmony_ci} 9531cb0ef41Sopenharmony_ci 9541cb0ef41Sopenharmony_ci} // namespace 9551cb0ef41Sopenharmony_ci 9561cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(string_write_to_flat_one_byte, StringWriteToFlatOneByte) 9571cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(string_write_to_flat_two_byte, StringWriteToFlatTwoByte) 9581cb0ef41Sopenharmony_ci 9591cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(external_one_byte_string_get_chars, 9601cb0ef41Sopenharmony_ci ExternalOneByteStringGetChars) 9611cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(external_two_byte_string_get_chars, 9621cb0ef41Sopenharmony_ci ExternalTwoByteStringGetChars) 9631cb0ef41Sopenharmony_ci 9641cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(orderedhashmap_gethash_raw, OrderedHashMap::GetHash) 9651cb0ef41Sopenharmony_ci 9661cb0ef41Sopenharmony_ciAddress GetOrCreateHash(Isolate* isolate, Address raw_key) { 9671cb0ef41Sopenharmony_ci DisallowGarbageCollection no_gc; 9681cb0ef41Sopenharmony_ci return Object(raw_key).GetOrCreateHash(isolate).ptr(); 9691cb0ef41Sopenharmony_ci} 9701cb0ef41Sopenharmony_ci 9711cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(get_or_create_hash_raw, GetOrCreateHash) 9721cb0ef41Sopenharmony_ci 9731cb0ef41Sopenharmony_cistatic Address JSReceiverCreateIdentityHash(Isolate* isolate, Address raw_key) { 9741cb0ef41Sopenharmony_ci JSReceiver key = JSReceiver::cast(Object(raw_key)); 9751cb0ef41Sopenharmony_ci return JSReceiver::CreateIdentityHash(isolate, key).ptr(); 9761cb0ef41Sopenharmony_ci} 9771cb0ef41Sopenharmony_ci 9781cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(jsreceiver_create_identity_hash, 9791cb0ef41Sopenharmony_ci JSReceiverCreateIdentityHash) 9801cb0ef41Sopenharmony_ci 9811cb0ef41Sopenharmony_cistatic uint32_t ComputeSeededIntegerHash(Isolate* isolate, int32_t key) { 9821cb0ef41Sopenharmony_ci DisallowGarbageCollection no_gc; 9831cb0ef41Sopenharmony_ci return ComputeSeededHash(static_cast<uint32_t>(key), HashSeed(isolate)); 9841cb0ef41Sopenharmony_ci} 9851cb0ef41Sopenharmony_ci 9861cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(compute_integer_hash, ComputeSeededIntegerHash) 9871cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(copy_fast_number_jsarray_elements_to_typed_array, 9881cb0ef41Sopenharmony_ci CopyFastNumberJSArrayElementsToTypedArray) 9891cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(copy_typed_array_elements_to_typed_array, 9901cb0ef41Sopenharmony_ci CopyTypedArrayElementsToTypedArray) 9911cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(copy_typed_array_elements_slice, CopyTypedArrayElementsSlice) 9921cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(try_string_to_index_or_lookup_existing, 9931cb0ef41Sopenharmony_ci StringTable::TryStringToIndexOrLookupExisting) 9941cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(string_to_array_index_function, String::ToArrayIndex) 9951cb0ef41Sopenharmony_ci 9961cb0ef41Sopenharmony_cistatic Address LexicographicCompareWrapper(Isolate* isolate, Address smi_x, 9971cb0ef41Sopenharmony_ci Address smi_y) { 9981cb0ef41Sopenharmony_ci Smi x(smi_x); 9991cb0ef41Sopenharmony_ci Smi y(smi_y); 10001cb0ef41Sopenharmony_ci return Smi::LexicographicCompare(isolate, x, y); 10011cb0ef41Sopenharmony_ci} 10021cb0ef41Sopenharmony_ci 10031cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(smi_lexicographic_compare_function, 10041cb0ef41Sopenharmony_ci LexicographicCompareWrapper) 10051cb0ef41Sopenharmony_ci 10061cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(mutable_big_int_absolute_add_and_canonicalize_function, 10071cb0ef41Sopenharmony_ci MutableBigInt_AbsoluteAddAndCanonicalize) 10081cb0ef41Sopenharmony_ci 10091cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(mutable_big_int_absolute_compare_function, 10101cb0ef41Sopenharmony_ci MutableBigInt_AbsoluteCompare) 10111cb0ef41Sopenharmony_ci 10121cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(mutable_big_int_absolute_sub_and_canonicalize_function, 10131cb0ef41Sopenharmony_ci MutableBigInt_AbsoluteSubAndCanonicalize) 10141cb0ef41Sopenharmony_ci 10151cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(check_object_type, CheckObjectType) 10161cb0ef41Sopenharmony_ci 10171cb0ef41Sopenharmony_ci#ifdef V8_INTL_SUPPORT 10181cb0ef41Sopenharmony_ci 10191cb0ef41Sopenharmony_cistatic Address ConvertOneByteToLower(Address raw_src, Address raw_dst) { 10201cb0ef41Sopenharmony_ci String src = String::cast(Object(raw_src)); 10211cb0ef41Sopenharmony_ci String dst = String::cast(Object(raw_dst)); 10221cb0ef41Sopenharmony_ci return Intl::ConvertOneByteToLower(src, dst).ptr(); 10231cb0ef41Sopenharmony_ci} 10241cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(intl_convert_one_byte_to_lower, ConvertOneByteToLower) 10251cb0ef41Sopenharmony_ci 10261cb0ef41Sopenharmony_ciExternalReference ExternalReference::intl_to_latin1_lower_table() { 10271cb0ef41Sopenharmony_ci uint8_t* ptr = const_cast<uint8_t*>(Intl::ToLatin1LowerTable()); 10281cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(ptr)); 10291cb0ef41Sopenharmony_ci} 10301cb0ef41Sopenharmony_ci 10311cb0ef41Sopenharmony_ciExternalReference ExternalReference::intl_ascii_collation_weights_l1() { 10321cb0ef41Sopenharmony_ci uint8_t* ptr = const_cast<uint8_t*>(Intl::AsciiCollationWeightsL1()); 10331cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(ptr)); 10341cb0ef41Sopenharmony_ci} 10351cb0ef41Sopenharmony_ci 10361cb0ef41Sopenharmony_ciExternalReference ExternalReference::intl_ascii_collation_weights_l3() { 10371cb0ef41Sopenharmony_ci uint8_t* ptr = const_cast<uint8_t*>(Intl::AsciiCollationWeightsL3()); 10381cb0ef41Sopenharmony_ci return ExternalReference(reinterpret_cast<Address>(ptr)); 10391cb0ef41Sopenharmony_ci} 10401cb0ef41Sopenharmony_ci 10411cb0ef41Sopenharmony_ci#endif // V8_INTL_SUPPORT 10421cb0ef41Sopenharmony_ci 10431cb0ef41Sopenharmony_ci// Explicit instantiations for all combinations of 1- and 2-byte strings. 10441cb0ef41Sopenharmony_citemplate ExternalReference 10451cb0ef41Sopenharmony_ciExternalReference::search_string_raw<const uint8_t, const uint8_t>(); 10461cb0ef41Sopenharmony_citemplate ExternalReference 10471cb0ef41Sopenharmony_ciExternalReference::search_string_raw<const uint8_t, const base::uc16>(); 10481cb0ef41Sopenharmony_citemplate ExternalReference 10491cb0ef41Sopenharmony_ciExternalReference::search_string_raw<const base::uc16, const uint8_t>(); 10501cb0ef41Sopenharmony_citemplate ExternalReference 10511cb0ef41Sopenharmony_ciExternalReference::search_string_raw<const base::uc16, const base::uc16>(); 10521cb0ef41Sopenharmony_ci 10531cb0ef41Sopenharmony_ciExternalReference ExternalReference::FromRawAddress(Address address) { 10541cb0ef41Sopenharmony_ci return ExternalReference(address); 10551cb0ef41Sopenharmony_ci} 10561cb0ef41Sopenharmony_ci 10571cb0ef41Sopenharmony_ciExternalReference ExternalReference::cpu_features() { 10581cb0ef41Sopenharmony_ci DCHECK(CpuFeatures::initialized_); 10591cb0ef41Sopenharmony_ci return ExternalReference(&CpuFeatures::supported_); 10601cb0ef41Sopenharmony_ci} 10611cb0ef41Sopenharmony_ci 10621cb0ef41Sopenharmony_ciExternalReference ExternalReference::promise_hook_flags_address( 10631cb0ef41Sopenharmony_ci Isolate* isolate) { 10641cb0ef41Sopenharmony_ci return ExternalReference(isolate->promise_hook_flags_address()); 10651cb0ef41Sopenharmony_ci} 10661cb0ef41Sopenharmony_ci 10671cb0ef41Sopenharmony_ciExternalReference ExternalReference::promise_hook_address(Isolate* isolate) { 10681cb0ef41Sopenharmony_ci return ExternalReference(isolate->promise_hook_address()); 10691cb0ef41Sopenharmony_ci} 10701cb0ef41Sopenharmony_ci 10711cb0ef41Sopenharmony_ciExternalReference ExternalReference::async_event_delegate_address( 10721cb0ef41Sopenharmony_ci Isolate* isolate) { 10731cb0ef41Sopenharmony_ci return ExternalReference(isolate->async_event_delegate_address()); 10741cb0ef41Sopenharmony_ci} 10751cb0ef41Sopenharmony_ci 10761cb0ef41Sopenharmony_ciExternalReference ExternalReference::debug_execution_mode_address( 10771cb0ef41Sopenharmony_ci Isolate* isolate) { 10781cb0ef41Sopenharmony_ci return ExternalReference(isolate->debug_execution_mode_address()); 10791cb0ef41Sopenharmony_ci} 10801cb0ef41Sopenharmony_ci 10811cb0ef41Sopenharmony_ciExternalReference ExternalReference::debug_is_active_address(Isolate* isolate) { 10821cb0ef41Sopenharmony_ci return ExternalReference(isolate->debug()->is_active_address()); 10831cb0ef41Sopenharmony_ci} 10841cb0ef41Sopenharmony_ci 10851cb0ef41Sopenharmony_ciExternalReference ExternalReference::debug_hook_on_function_call_address( 10861cb0ef41Sopenharmony_ci Isolate* isolate) { 10871cb0ef41Sopenharmony_ci return ExternalReference(isolate->debug()->hook_on_function_call_address()); 10881cb0ef41Sopenharmony_ci} 10891cb0ef41Sopenharmony_ci 10901cb0ef41Sopenharmony_ciExternalReference ExternalReference::runtime_function_table_address( 10911cb0ef41Sopenharmony_ci Isolate* isolate) { 10921cb0ef41Sopenharmony_ci return ExternalReference( 10931cb0ef41Sopenharmony_ci const_cast<Runtime::Function*>(Runtime::RuntimeFunctionTable(isolate))); 10941cb0ef41Sopenharmony_ci} 10951cb0ef41Sopenharmony_ci 10961cb0ef41Sopenharmony_cistatic Address InvalidatePrototypeChainsWrapper(Address raw_map) { 10971cb0ef41Sopenharmony_ci Map map = Map::cast(Object(raw_map)); 10981cb0ef41Sopenharmony_ci return JSObject::InvalidatePrototypeChains(map).ptr(); 10991cb0ef41Sopenharmony_ci} 11001cb0ef41Sopenharmony_ci 11011cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(invalidate_prototype_chains_function, 11021cb0ef41Sopenharmony_ci InvalidatePrototypeChainsWrapper) 11031cb0ef41Sopenharmony_ci 11041cb0ef41Sopenharmony_cidouble modulo_double_double(double x, double y) { return Modulo(x, y); } 11051cb0ef41Sopenharmony_ci 11061cb0ef41Sopenharmony_ciFUNCTION_REFERENCE_WITH_TYPE(mod_two_doubles_operation, modulo_double_double, 11071cb0ef41Sopenharmony_ci BUILTIN_FP_FP_CALL) 11081cb0ef41Sopenharmony_ci 11091cb0ef41Sopenharmony_ciExternalReference ExternalReference::debug_suspended_generator_address( 11101cb0ef41Sopenharmony_ci Isolate* isolate) { 11111cb0ef41Sopenharmony_ci return ExternalReference(isolate->debug()->suspended_generator_address()); 11121cb0ef41Sopenharmony_ci} 11131cb0ef41Sopenharmony_ci 11141cb0ef41Sopenharmony_ciExternalReference ExternalReference::fast_c_call_caller_fp_address( 11151cb0ef41Sopenharmony_ci Isolate* isolate) { 11161cb0ef41Sopenharmony_ci return ExternalReference( 11171cb0ef41Sopenharmony_ci isolate->isolate_data()->fast_c_call_caller_fp_address()); 11181cb0ef41Sopenharmony_ci} 11191cb0ef41Sopenharmony_ci 11201cb0ef41Sopenharmony_ciExternalReference ExternalReference::fast_c_call_caller_pc_address( 11211cb0ef41Sopenharmony_ci Isolate* isolate) { 11221cb0ef41Sopenharmony_ci return ExternalReference( 11231cb0ef41Sopenharmony_ci isolate->isolate_data()->fast_c_call_caller_pc_address()); 11241cb0ef41Sopenharmony_ci} 11251cb0ef41Sopenharmony_ci 11261cb0ef41Sopenharmony_ciExternalReference ExternalReference::fast_api_call_target_address( 11271cb0ef41Sopenharmony_ci Isolate* isolate) { 11281cb0ef41Sopenharmony_ci return ExternalReference( 11291cb0ef41Sopenharmony_ci isolate->isolate_data()->fast_api_call_target_address()); 11301cb0ef41Sopenharmony_ci} 11311cb0ef41Sopenharmony_ci 11321cb0ef41Sopenharmony_ciExternalReference ExternalReference::stack_is_iterable_address( 11331cb0ef41Sopenharmony_ci Isolate* isolate) { 11341cb0ef41Sopenharmony_ci return ExternalReference( 11351cb0ef41Sopenharmony_ci isolate->isolate_data()->stack_is_iterable_address()); 11361cb0ef41Sopenharmony_ci} 11371cb0ef41Sopenharmony_ci 11381cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(call_enqueue_microtask_function, 11391cb0ef41Sopenharmony_ci MicrotaskQueue::CallEnqueueMicrotask) 11401cb0ef41Sopenharmony_ci 11411cb0ef41Sopenharmony_cistatic int64_t atomic_pair_load(intptr_t address) { 11421cb0ef41Sopenharmony_ci return std::atomic_load(reinterpret_cast<std::atomic<int64_t>*>(address)); 11431cb0ef41Sopenharmony_ci} 11441cb0ef41Sopenharmony_ci 11451cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_load_function() { 11461cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_load))); 11471cb0ef41Sopenharmony_ci} 11481cb0ef41Sopenharmony_ci 11491cb0ef41Sopenharmony_cistatic void atomic_pair_store(intptr_t address, int value_low, int value_high) { 11501cb0ef41Sopenharmony_ci int64_t value = 11511cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 11521cb0ef41Sopenharmony_ci std::atomic_store(reinterpret_cast<std::atomic<int64_t>*>(address), value); 11531cb0ef41Sopenharmony_ci} 11541cb0ef41Sopenharmony_ci 11551cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_store_function() { 11561cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_store))); 11571cb0ef41Sopenharmony_ci} 11581cb0ef41Sopenharmony_ci 11591cb0ef41Sopenharmony_cistatic int64_t atomic_pair_add(intptr_t address, int value_low, 11601cb0ef41Sopenharmony_ci int value_high) { 11611cb0ef41Sopenharmony_ci int64_t value = 11621cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 11631cb0ef41Sopenharmony_ci return std::atomic_fetch_add(reinterpret_cast<std::atomic<int64_t>*>(address), 11641cb0ef41Sopenharmony_ci value); 11651cb0ef41Sopenharmony_ci} 11661cb0ef41Sopenharmony_ci 11671cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_add_function() { 11681cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_add))); 11691cb0ef41Sopenharmony_ci} 11701cb0ef41Sopenharmony_ci 11711cb0ef41Sopenharmony_cistatic int64_t atomic_pair_sub(intptr_t address, int value_low, 11721cb0ef41Sopenharmony_ci int value_high) { 11731cb0ef41Sopenharmony_ci int64_t value = 11741cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 11751cb0ef41Sopenharmony_ci return std::atomic_fetch_sub(reinterpret_cast<std::atomic<int64_t>*>(address), 11761cb0ef41Sopenharmony_ci value); 11771cb0ef41Sopenharmony_ci} 11781cb0ef41Sopenharmony_ci 11791cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_sub_function() { 11801cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_sub))); 11811cb0ef41Sopenharmony_ci} 11821cb0ef41Sopenharmony_ci 11831cb0ef41Sopenharmony_cistatic int64_t atomic_pair_and(intptr_t address, int value_low, 11841cb0ef41Sopenharmony_ci int value_high) { 11851cb0ef41Sopenharmony_ci int64_t value = 11861cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 11871cb0ef41Sopenharmony_ci return std::atomic_fetch_and(reinterpret_cast<std::atomic<int64_t>*>(address), 11881cb0ef41Sopenharmony_ci value); 11891cb0ef41Sopenharmony_ci} 11901cb0ef41Sopenharmony_ci 11911cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_and_function() { 11921cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_and))); 11931cb0ef41Sopenharmony_ci} 11941cb0ef41Sopenharmony_ci 11951cb0ef41Sopenharmony_cistatic int64_t atomic_pair_or(intptr_t address, int value_low, int value_high) { 11961cb0ef41Sopenharmony_ci int64_t value = 11971cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 11981cb0ef41Sopenharmony_ci return std::atomic_fetch_or(reinterpret_cast<std::atomic<int64_t>*>(address), 11991cb0ef41Sopenharmony_ci value); 12001cb0ef41Sopenharmony_ci} 12011cb0ef41Sopenharmony_ci 12021cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_or_function() { 12031cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_or))); 12041cb0ef41Sopenharmony_ci} 12051cb0ef41Sopenharmony_ci 12061cb0ef41Sopenharmony_cistatic int64_t atomic_pair_xor(intptr_t address, int value_low, 12071cb0ef41Sopenharmony_ci int value_high) { 12081cb0ef41Sopenharmony_ci int64_t value = 12091cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 12101cb0ef41Sopenharmony_ci return std::atomic_fetch_xor(reinterpret_cast<std::atomic<int64_t>*>(address), 12111cb0ef41Sopenharmony_ci value); 12121cb0ef41Sopenharmony_ci} 12131cb0ef41Sopenharmony_ci 12141cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_xor_function() { 12151cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_xor))); 12161cb0ef41Sopenharmony_ci} 12171cb0ef41Sopenharmony_ci 12181cb0ef41Sopenharmony_cistatic int64_t atomic_pair_exchange(intptr_t address, int value_low, 12191cb0ef41Sopenharmony_ci int value_high) { 12201cb0ef41Sopenharmony_ci int64_t value = 12211cb0ef41Sopenharmony_ci static_cast<int64_t>(value_high) << 32 | (value_low & 0xFFFFFFFF); 12221cb0ef41Sopenharmony_ci return std::atomic_exchange(reinterpret_cast<std::atomic<int64_t>*>(address), 12231cb0ef41Sopenharmony_ci value); 12241cb0ef41Sopenharmony_ci} 12251cb0ef41Sopenharmony_ci 12261cb0ef41Sopenharmony_ciExternalReference ExternalReference::atomic_pair_exchange_function() { 12271cb0ef41Sopenharmony_ci return ExternalReference(Redirect(FUNCTION_ADDR(atomic_pair_exchange))); 12281cb0ef41Sopenharmony_ci} 12291cb0ef41Sopenharmony_ci 12301cb0ef41Sopenharmony_cistatic uint64_t atomic_pair_compare_exchange(intptr_t address, 12311cb0ef41Sopenharmony_ci int old_value_low, 12321cb0ef41Sopenharmony_ci int old_value_high, 12331cb0ef41Sopenharmony_ci int new_value_low, 12341cb0ef41Sopenharmony_ci int new_value_high) { 12351cb0ef41Sopenharmony_ci uint64_t old_value = static_cast<uint64_t>(old_value_high) << 32 | 12361cb0ef41Sopenharmony_ci (old_value_low & 0xFFFFFFFF); 12371cb0ef41Sopenharmony_ci uint64_t new_value = static_cast<uint64_t>(new_value_high) << 32 | 12381cb0ef41Sopenharmony_ci (new_value_low & 0xFFFFFFFF); 12391cb0ef41Sopenharmony_ci std::atomic_compare_exchange_strong( 12401cb0ef41Sopenharmony_ci reinterpret_cast<std::atomic<uint64_t>*>(address), &old_value, new_value); 12411cb0ef41Sopenharmony_ci return old_value; 12421cb0ef41Sopenharmony_ci} 12431cb0ef41Sopenharmony_ci 12441cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(atomic_pair_compare_exchange_function, 12451cb0ef41Sopenharmony_ci atomic_pair_compare_exchange) 12461cb0ef41Sopenharmony_ci 12471cb0ef41Sopenharmony_ci#ifdef V8_IS_TSAN 12481cb0ef41Sopenharmony_cinamespace { 12491cb0ef41Sopenharmony_ci// Mimics the store in generated code by having a relaxed store to the same 12501cb0ef41Sopenharmony_ci// address, with the same value. This is done in order for TSAN to see these 12511cb0ef41Sopenharmony_ci// stores from generated code. 12521cb0ef41Sopenharmony_ci// Note that {value} is an int64_t irrespective of the store size. This is on 12531cb0ef41Sopenharmony_ci// purpose to keep the function signatures the same across stores. The 12541cb0ef41Sopenharmony_ci// static_cast inside the method will ignore the bits which will not be stored. 12551cb0ef41Sopenharmony_civoid tsan_relaxed_store_8_bits(Address addr, int64_t value) { 12561cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 12571cb0ef41Sopenharmony_ci base::Relaxed_Store(reinterpret_cast<base::Atomic8*>(addr), 12581cb0ef41Sopenharmony_ci static_cast<base::Atomic8>(value)); 12591cb0ef41Sopenharmony_ci#else 12601cb0ef41Sopenharmony_ci UNREACHABLE(); 12611cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 12621cb0ef41Sopenharmony_ci} 12631cb0ef41Sopenharmony_ci 12641cb0ef41Sopenharmony_civoid tsan_relaxed_store_16_bits(Address addr, int64_t value) { 12651cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 12661cb0ef41Sopenharmony_ci base::Relaxed_Store(reinterpret_cast<base::Atomic16*>(addr), 12671cb0ef41Sopenharmony_ci static_cast<base::Atomic16>(value)); 12681cb0ef41Sopenharmony_ci#else 12691cb0ef41Sopenharmony_ci UNREACHABLE(); 12701cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 12711cb0ef41Sopenharmony_ci} 12721cb0ef41Sopenharmony_ci 12731cb0ef41Sopenharmony_civoid tsan_relaxed_store_32_bits(Address addr, int64_t value) { 12741cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 12751cb0ef41Sopenharmony_ci base::Relaxed_Store(reinterpret_cast<base::Atomic32*>(addr), 12761cb0ef41Sopenharmony_ci static_cast<base::Atomic32>(value)); 12771cb0ef41Sopenharmony_ci#else 12781cb0ef41Sopenharmony_ci UNREACHABLE(); 12791cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 12801cb0ef41Sopenharmony_ci} 12811cb0ef41Sopenharmony_ci 12821cb0ef41Sopenharmony_civoid tsan_relaxed_store_64_bits(Address addr, int64_t value) { 12831cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 12841cb0ef41Sopenharmony_ci base::Relaxed_Store(reinterpret_cast<base::Atomic64*>(addr), 12851cb0ef41Sopenharmony_ci static_cast<base::Atomic64>(value)); 12861cb0ef41Sopenharmony_ci#else 12871cb0ef41Sopenharmony_ci UNREACHABLE(); 12881cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 12891cb0ef41Sopenharmony_ci} 12901cb0ef41Sopenharmony_ci 12911cb0ef41Sopenharmony_ci// Same as above, for sequentially consistent stores. 12921cb0ef41Sopenharmony_civoid tsan_seq_cst_store_8_bits(Address addr, int64_t value) { 12931cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 12941cb0ef41Sopenharmony_ci base::SeqCst_Store(reinterpret_cast<base::Atomic8*>(addr), 12951cb0ef41Sopenharmony_ci static_cast<base::Atomic8>(value)); 12961cb0ef41Sopenharmony_ci#else 12971cb0ef41Sopenharmony_ci UNREACHABLE(); 12981cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 12991cb0ef41Sopenharmony_ci} 13001cb0ef41Sopenharmony_ci 13011cb0ef41Sopenharmony_civoid tsan_seq_cst_store_16_bits(Address addr, int64_t value) { 13021cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 13031cb0ef41Sopenharmony_ci base::SeqCst_Store(reinterpret_cast<base::Atomic16*>(addr), 13041cb0ef41Sopenharmony_ci static_cast<base::Atomic16>(value)); 13051cb0ef41Sopenharmony_ci#else 13061cb0ef41Sopenharmony_ci UNREACHABLE(); 13071cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 13081cb0ef41Sopenharmony_ci} 13091cb0ef41Sopenharmony_ci 13101cb0ef41Sopenharmony_civoid tsan_seq_cst_store_32_bits(Address addr, int64_t value) { 13111cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 13121cb0ef41Sopenharmony_ci base::SeqCst_Store(reinterpret_cast<base::Atomic32*>(addr), 13131cb0ef41Sopenharmony_ci static_cast<base::Atomic32>(value)); 13141cb0ef41Sopenharmony_ci#else 13151cb0ef41Sopenharmony_ci UNREACHABLE(); 13161cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 13171cb0ef41Sopenharmony_ci} 13181cb0ef41Sopenharmony_ci 13191cb0ef41Sopenharmony_civoid tsan_seq_cst_store_64_bits(Address addr, int64_t value) { 13201cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 13211cb0ef41Sopenharmony_ci base::SeqCst_Store(reinterpret_cast<base::Atomic64*>(addr), 13221cb0ef41Sopenharmony_ci static_cast<base::Atomic64>(value)); 13231cb0ef41Sopenharmony_ci#else 13241cb0ef41Sopenharmony_ci UNREACHABLE(); 13251cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 13261cb0ef41Sopenharmony_ci} 13271cb0ef41Sopenharmony_ci 13281cb0ef41Sopenharmony_ci// Same as above, for relaxed loads. 13291cb0ef41Sopenharmony_cibase::Atomic32 tsan_relaxed_load_32_bits(Address addr, int64_t value) { 13301cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 13311cb0ef41Sopenharmony_ci return base::Relaxed_Load(reinterpret_cast<base::Atomic32*>(addr)); 13321cb0ef41Sopenharmony_ci#else 13331cb0ef41Sopenharmony_ci UNREACHABLE(); 13341cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 13351cb0ef41Sopenharmony_ci} 13361cb0ef41Sopenharmony_ci 13371cb0ef41Sopenharmony_cibase::Atomic64 tsan_relaxed_load_64_bits(Address addr, int64_t value) { 13381cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_X64 13391cb0ef41Sopenharmony_ci return base::Relaxed_Load(reinterpret_cast<base::Atomic64*>(addr)); 13401cb0ef41Sopenharmony_ci#else 13411cb0ef41Sopenharmony_ci UNREACHABLE(); 13421cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_X64 13431cb0ef41Sopenharmony_ci} 13441cb0ef41Sopenharmony_ci 13451cb0ef41Sopenharmony_ci} // namespace 13461cb0ef41Sopenharmony_ci#endif // V8_IS_TSAN 13471cb0ef41Sopenharmony_ci 13481cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_relaxed_store_function_8_bits, 13491cb0ef41Sopenharmony_ci tsan_relaxed_store_8_bits) 13501cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_relaxed_store_function_16_bits, 13511cb0ef41Sopenharmony_ci tsan_relaxed_store_16_bits) 13521cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_relaxed_store_function_32_bits, 13531cb0ef41Sopenharmony_ci tsan_relaxed_store_32_bits) 13541cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_relaxed_store_function_64_bits, 13551cb0ef41Sopenharmony_ci tsan_relaxed_store_64_bits) 13561cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_seq_cst_store_function_8_bits, 13571cb0ef41Sopenharmony_ci tsan_seq_cst_store_8_bits) 13581cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_seq_cst_store_function_16_bits, 13591cb0ef41Sopenharmony_ci tsan_seq_cst_store_16_bits) 13601cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_seq_cst_store_function_32_bits, 13611cb0ef41Sopenharmony_ci tsan_seq_cst_store_32_bits) 13621cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_seq_cst_store_function_64_bits, 13631cb0ef41Sopenharmony_ci tsan_seq_cst_store_64_bits) 13641cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_relaxed_load_function_32_bits, 13651cb0ef41Sopenharmony_ci tsan_relaxed_load_32_bits) 13661cb0ef41Sopenharmony_ciIF_TSAN(FUNCTION_REFERENCE, tsan_relaxed_load_function_64_bits, 13671cb0ef41Sopenharmony_ci tsan_relaxed_load_64_bits) 13681cb0ef41Sopenharmony_ci 13691cb0ef41Sopenharmony_cistatic int EnterMicrotaskContextWrapper(HandleScopeImplementer* hsi, 13701cb0ef41Sopenharmony_ci Address raw_context) { 13711cb0ef41Sopenharmony_ci Context context = Context::cast(Object(raw_context)); 13721cb0ef41Sopenharmony_ci hsi->EnterMicrotaskContext(context); 13731cb0ef41Sopenharmony_ci return 0; 13741cb0ef41Sopenharmony_ci} 13751cb0ef41Sopenharmony_ci 13761cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(call_enter_context_function, EnterMicrotaskContextWrapper) 13771cb0ef41Sopenharmony_ci 13781cb0ef41Sopenharmony_ciFUNCTION_REFERENCE( 13791cb0ef41Sopenharmony_ci js_finalization_registry_remove_cell_from_unregister_token_map, 13801cb0ef41Sopenharmony_ci JSFinalizationRegistry::RemoveCellFromUnregisterTokenMap) 13811cb0ef41Sopenharmony_ci 13821cb0ef41Sopenharmony_ci#ifdef V8_SANDBOXED_EXTERNAL_POINTERS 13831cb0ef41Sopenharmony_ciFUNCTION_REFERENCE(external_pointer_table_allocate_entry, 13841cb0ef41Sopenharmony_ci ExternalPointerTable::AllocateEntry) 13851cb0ef41Sopenharmony_ci#endif 13861cb0ef41Sopenharmony_ci 13871cb0ef41Sopenharmony_cibool operator==(ExternalReference lhs, ExternalReference rhs) { 13881cb0ef41Sopenharmony_ci return lhs.address() == rhs.address(); 13891cb0ef41Sopenharmony_ci} 13901cb0ef41Sopenharmony_ci 13911cb0ef41Sopenharmony_cibool operator!=(ExternalReference lhs, ExternalReference rhs) { 13921cb0ef41Sopenharmony_ci return !(lhs == rhs); 13931cb0ef41Sopenharmony_ci} 13941cb0ef41Sopenharmony_ci 13951cb0ef41Sopenharmony_cisize_t hash_value(ExternalReference reference) { 13961cb0ef41Sopenharmony_ci if (FLAG_predictable) { 13971cb0ef41Sopenharmony_ci // Avoid ASLR non-determinism in predictable mode. For this, just take the 13981cb0ef41Sopenharmony_ci // lowest 12 bit corresponding to a 4K page size. 13991cb0ef41Sopenharmony_ci return base::hash<Address>()(reference.address() & 0xfff); 14001cb0ef41Sopenharmony_ci } 14011cb0ef41Sopenharmony_ci return base::hash<Address>()(reference.address()); 14021cb0ef41Sopenharmony_ci} 14031cb0ef41Sopenharmony_ci 14041cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, ExternalReference reference) { 14051cb0ef41Sopenharmony_ci os << reinterpret_cast<const void*>(reference.address()); 14061cb0ef41Sopenharmony_ci const Runtime::Function* fn = Runtime::FunctionForEntry(reference.address()); 14071cb0ef41Sopenharmony_ci if (fn) os << "<" << fn->name << ".entry>"; 14081cb0ef41Sopenharmony_ci return os; 14091cb0ef41Sopenharmony_ci} 14101cb0ef41Sopenharmony_ci 14111cb0ef41Sopenharmony_civoid abort_with_reason(int reason) { 14121cb0ef41Sopenharmony_ci if (IsValidAbortReason(reason)) { 14131cb0ef41Sopenharmony_ci const char* message = GetAbortReason(static_cast<AbortReason>(reason)); 14141cb0ef41Sopenharmony_ci base::OS::PrintError("abort: %s\n", message); 14151cb0ef41Sopenharmony_ci } else { 14161cb0ef41Sopenharmony_ci base::OS::PrintError("abort: <unknown reason: %d>\n", reason); 14171cb0ef41Sopenharmony_ci } 14181cb0ef41Sopenharmony_ci base::OS::Abort(); 14191cb0ef41Sopenharmony_ci UNREACHABLE(); 14201cb0ef41Sopenharmony_ci} 14211cb0ef41Sopenharmony_ci 14221cb0ef41Sopenharmony_ci#undef FUNCTION_REFERENCE 14231cb0ef41Sopenharmony_ci#undef FUNCTION_REFERENCE_WITH_TYPE 14241cb0ef41Sopenharmony_ci 14251cb0ef41Sopenharmony_ci} // namespace internal 14261cb0ef41Sopenharmony_ci} // namespace v8 1427