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 #ifndef V8_CODEGEN_EXTERNAL_REFERENCE_H_ 6 #define V8_CODEGEN_EXTERNAL_REFERENCE_H_ 7 8 #include "src/common/globals.h" 9 #include "src/runtime/runtime.h" 10 11 namespace v8 { 12 13 class ApiFunction; 14 class CFunctionInfo; 15 16 namespace internal { 17 18 class Isolate; 19 class Page; 20 class SCTableReference; 21 class StatsCounter; 22 23 //------------------------------------------------------------------------------ 24 // External references 25 26 #define EXTERNAL_REFERENCE_LIST_WITH_ISOLATE(V) \ 27 V(isolate_address, "isolate") \ 28 V(builtins_table, "builtins_table") \ 29 V(handle_scope_implementer_address, \ 30 "Isolate::handle_scope_implementer_address") \ 31 V(address_of_interpreter_entry_trampoline_instruction_start, \ 32 "Address of the InterpreterEntryTrampoline instruction start") \ 33 V(interpreter_dispatch_counters, "Interpreter::dispatch_counters") \ 34 V(interpreter_dispatch_table_address, "Interpreter::dispatch_table_address") \ 35 V(date_cache_stamp, "date_cache_stamp") \ 36 V(stress_deopt_count, "Isolate::stress_deopt_count_address()") \ 37 V(force_slow_path, "Isolate::force_slow_path_address()") \ 38 V(isolate_root, "Isolate::isolate_root()") \ 39 V(allocation_sites_list_address, "Heap::allocation_sites_list_address()") \ 40 V(address_of_jslimit, "StackGuard::address_of_jslimit()") \ 41 V(address_of_real_jslimit, "StackGuard::address_of_real_jslimit()") \ 42 V(heap_is_marking_flag_address, "heap_is_marking_flag_address") \ 43 V(new_space_allocation_top_address, "Heap::NewSpaceAllocationTopAddress()") \ 44 V(new_space_allocation_limit_address, \ 45 "Heap::NewSpaceAllocationLimitAddress()") \ 46 V(old_space_allocation_top_address, "Heap::OldSpaceAllocationTopAddress") \ 47 V(old_space_allocation_limit_address, \ 48 "Heap::OldSpaceAllocationLimitAddress") \ 49 V(handle_scope_level_address, "HandleScope::level") \ 50 V(handle_scope_next_address, "HandleScope::next") \ 51 V(handle_scope_limit_address, "HandleScope::limit") \ 52 V(scheduled_exception_address, "Isolate::scheduled_exception") \ 53 V(address_of_pending_message, "address_of_pending_message") \ 54 V(promise_hook_flags_address, "Isolate::promise_hook_flags_address()") \ 55 V(promise_hook_address, "Isolate::promise_hook_address()") \ 56 V(async_event_delegate_address, "Isolate::async_event_delegate_address()") \ 57 V(debug_execution_mode_address, "Isolate::debug_execution_mode_address()") \ 58 V(debug_is_active_address, "Debug::is_active_address()") \ 59 V(debug_hook_on_function_call_address, \ 60 "Debug::hook_on_function_call_address()") \ 61 V(runtime_function_table_address, \ 62 "Runtime::runtime_function_table_address()") \ 63 V(is_profiling_address, "Isolate::is_profiling") \ 64 V(debug_suspended_generator_address, \ 65 "Debug::step_suspended_generator_address()") \ 66 V(fast_c_call_caller_fp_address, \ 67 "IsolateData::fast_c_call_caller_fp_address") \ 68 V(fast_c_call_caller_pc_address, \ 69 "IsolateData::fast_c_call_caller_pc_address") \ 70 V(fast_api_call_target_address, "IsolateData::fast_api_call_target_address") \ 71 V(stack_is_iterable_address, "IsolateData::stack_is_iterable_address") \ 72 V(address_of_regexp_stack_limit_address, \ 73 "RegExpStack::limit_address_address()") \ 74 V(address_of_regexp_stack_memory_top_address, \ 75 "RegExpStack::memory_top_address_address()") \ 76 V(address_of_regexp_stack_stack_pointer, \ 77 "RegExpStack::stack_pointer_address()") \ 78 V(address_of_static_offsets_vector, "OffsetsVector::static_offsets_vector") \ 79 V(thread_in_wasm_flag_address_address, \ 80 "Isolate::thread_in_wasm_flag_address_address") \ 81 V(javascript_execution_assert, "javascript_execution_assert") \ 82 EXTERNAL_REFERENCE_LIST_WITH_ISOLATE_SANDBOXED_EXTERNAL_POINTERS(V) 83 84 #ifdef V8_SANDBOXED_EXTERNAL_POINTERS 85 #define EXTERNAL_REFERENCE_LIST_WITH_ISOLATE_SANDBOXED_EXTERNAL_POINTERS(V) \ 86 V(external_pointer_table_address, \ 87 "Isolate::external_pointer_table_address(" \ 88 ")") 89 #else 90 #define EXTERNAL_REFERENCE_LIST_WITH_ISOLATE_SANDBOXED_EXTERNAL_POINTERS(V) 91 #endif // V8_SANDBOXED_EXTERNAL_POINTERS 92 93 #define EXTERNAL_REFERENCE_LIST(V) \ 94 V(abort_with_reason, "abort_with_reason") \ 95 V(address_of_builtin_subclassing_flag, "FLAG_builtin_subclassing") \ 96 V(address_of_double_abs_constant, "double_absolute_constant") \ 97 V(address_of_double_neg_constant, "double_negate_constant") \ 98 V(address_of_enable_experimental_regexp_engine, \ 99 "address_of_enable_experimental_regexp_engine") \ 100 V(address_of_float_abs_constant, "float_absolute_constant") \ 101 V(address_of_float_neg_constant, "float_negate_constant") \ 102 V(address_of_min_int, "LDoubleConstant::min_int") \ 103 V(address_of_mock_arraybuffer_allocator_flag, \ 104 "FLAG_mock_arraybuffer_allocator") \ 105 V(address_of_one_half, "LDoubleConstant::one_half") \ 106 V(address_of_runtime_stats_flag, "TracingFlags::runtime_stats") \ 107 V(address_of_shared_string_table_flag, "FLAG_shared_string_table") \ 108 V(address_of_the_hole_nan, "the_hole_nan") \ 109 V(address_of_uint32_bias, "uint32_bias") \ 110 V(baseline_pc_for_bytecode_offset, "BaselinePCForBytecodeOffset") \ 111 V(baseline_pc_for_next_executed_bytecode, \ 112 "BaselinePCForNextExecutedBytecode") \ 113 V(bytecode_size_table_address, "Bytecodes::bytecode_size_table_address") \ 114 V(check_object_type, "check_object_type") \ 115 V(compute_integer_hash, "ComputeSeededHash") \ 116 V(compute_output_frames_function, "Deoptimizer::ComputeOutputFrames()") \ 117 V(copy_fast_number_jsarray_elements_to_typed_array, \ 118 "copy_fast_number_jsarray_elements_to_typed_array") \ 119 V(copy_typed_array_elements_slice, "copy_typed_array_elements_slice") \ 120 V(copy_typed_array_elements_to_typed_array, \ 121 "copy_typed_array_elements_to_typed_array") \ 122 V(cpu_features, "cpu_features") \ 123 V(delete_handle_scope_extensions, "HandleScope::DeleteExtensions") \ 124 V(ephemeron_key_write_barrier_function, \ 125 "Heap::EphemeronKeyWriteBarrierFromCode") \ 126 V(f64_acos_wrapper_function, "f64_acos_wrapper") \ 127 V(f64_asin_wrapper_function, "f64_asin_wrapper") \ 128 V(f64_mod_wrapper_function, "f64_mod_wrapper") \ 129 V(get_date_field_function, "JSDate::GetField") \ 130 V(get_or_create_hash_raw, "get_or_create_hash_raw") \ 131 V(gsab_byte_length, "GsabByteLength") \ 132 V(ieee754_acos_function, "base::ieee754::acos") \ 133 V(ieee754_acosh_function, "base::ieee754::acosh") \ 134 V(ieee754_asin_function, "base::ieee754::asin") \ 135 V(ieee754_asinh_function, "base::ieee754::asinh") \ 136 V(ieee754_atan_function, "base::ieee754::atan") \ 137 V(ieee754_atan2_function, "base::ieee754::atan2") \ 138 V(ieee754_atanh_function, "base::ieee754::atanh") \ 139 V(ieee754_cbrt_function, "base::ieee754::cbrt") \ 140 V(ieee754_cos_function, "base::ieee754::cos") \ 141 V(ieee754_cosh_function, "base::ieee754::cosh") \ 142 V(ieee754_exp_function, "base::ieee754::exp") \ 143 V(ieee754_expm1_function, "base::ieee754::expm1") \ 144 V(ieee754_log_function, "base::ieee754::log") \ 145 V(ieee754_log10_function, "base::ieee754::log10") \ 146 V(ieee754_log1p_function, "base::ieee754::log1p") \ 147 V(ieee754_log2_function, "base::ieee754::log2") \ 148 V(ieee754_pow_function, "base::ieee754::pow") \ 149 V(ieee754_sin_function, "base::ieee754::sin") \ 150 V(ieee754_sinh_function, "base::ieee754::sinh") \ 151 V(ieee754_tan_function, "base::ieee754::tan") \ 152 V(ieee754_tanh_function, "base::ieee754::tanh") \ 153 V(insert_remembered_set_function, "Heap::InsertIntoRememberedSetFromCode") \ 154 V(invalidate_prototype_chains_function, \ 155 "JSObject::InvalidatePrototypeChains()") \ 156 V(invoke_accessor_getter_callback, "InvokeAccessorGetterCallback") \ 157 V(invoke_function_callback, "InvokeFunctionCallback") \ 158 V(jsarray_array_join_concat_to_sequential_string, \ 159 "jsarray_array_join_concat_to_sequential_string") \ 160 V(jsreceiver_create_identity_hash, "jsreceiver_create_identity_hash") \ 161 V(libc_memchr_function, "libc_memchr") \ 162 V(libc_memcpy_function, "libc_memcpy") \ 163 V(libc_memmove_function, "libc_memmove") \ 164 V(libc_memset_function, "libc_memset") \ 165 V(relaxed_memcpy_function, "relaxed_memcpy") \ 166 V(relaxed_memmove_function, "relaxed_memmove") \ 167 V(mod_two_doubles_operation, "mod_two_doubles") \ 168 V(mutable_big_int_absolute_add_and_canonicalize_function, \ 169 "MutableBigInt_AbsoluteAddAndCanonicalize") \ 170 V(mutable_big_int_absolute_compare_function, \ 171 "MutableBigInt_AbsoluteCompare") \ 172 V(mutable_big_int_absolute_sub_and_canonicalize_function, \ 173 "MutableBigInt_AbsoluteSubAndCanonicalize") \ 174 V(new_deoptimizer_function, "Deoptimizer::New()") \ 175 V(orderedhashmap_gethash_raw, "orderedhashmap_gethash_raw") \ 176 V(printf_function, "printf") \ 177 V(refill_math_random, "MathRandom::RefillCache") \ 178 V(search_string_raw_one_one, "search_string_raw_one_one") \ 179 V(search_string_raw_one_two, "search_string_raw_one_two") \ 180 V(search_string_raw_two_one, "search_string_raw_two_one") \ 181 V(search_string_raw_two_two, "search_string_raw_two_two") \ 182 V(string_write_to_flat_one_byte, "string_write_to_flat_one_byte") \ 183 V(string_write_to_flat_two_byte, "string_write_to_flat_two_byte") \ 184 V(external_one_byte_string_get_chars, "external_one_byte_string_get_chars") \ 185 V(external_two_byte_string_get_chars, "external_two_byte_string_get_chars") \ 186 V(smi_lexicographic_compare_function, "smi_lexicographic_compare_function") \ 187 V(string_to_array_index_function, "String::ToArrayIndex") \ 188 V(try_string_to_index_or_lookup_existing, \ 189 "try_string_to_index_or_lookup_existing") \ 190 IF_WASM(V, wasm_call_trap_callback_for_testing, \ 191 "wasm::call_trap_callback_for_testing") \ 192 IF_WASM(V, wasm_f32_ceil, "wasm::f32_ceil_wrapper") \ 193 IF_WASM(V, wasm_f32_floor, "wasm::f32_floor_wrapper") \ 194 IF_WASM(V, wasm_f32_nearest_int, "wasm::f32_nearest_int_wrapper") \ 195 IF_WASM(V, wasm_f32_trunc, "wasm::f32_trunc_wrapper") \ 196 IF_WASM(V, wasm_f64_ceil, "wasm::f64_ceil_wrapper") \ 197 IF_WASM(V, wasm_f64_floor, "wasm::f64_floor_wrapper") \ 198 IF_WASM(V, wasm_f64_nearest_int, "wasm::f64_nearest_int_wrapper") \ 199 IF_WASM(V, wasm_f64_trunc, "wasm::f64_trunc_wrapper") \ 200 IF_WASM(V, wasm_float32_to_int64, "wasm::float32_to_int64_wrapper") \ 201 IF_WASM(V, wasm_float32_to_uint64, "wasm::float32_to_uint64_wrapper") \ 202 IF_WASM(V, wasm_float32_to_int64_sat, "wasm::float32_to_int64_sat_wrapper") \ 203 IF_WASM(V, wasm_float32_to_uint64_sat, \ 204 "wasm::float32_to_uint64_sat_wrapper") \ 205 IF_WASM(V, wasm_float64_pow, "wasm::float64_pow") \ 206 IF_WASM(V, wasm_float64_to_int64, "wasm::float64_to_int64_wrapper") \ 207 IF_WASM(V, wasm_float64_to_uint64, "wasm::float64_to_uint64_wrapper") \ 208 IF_WASM(V, wasm_float64_to_int64_sat, "wasm::float64_to_int64_sat_wrapper") \ 209 IF_WASM(V, wasm_float64_to_uint64_sat, \ 210 "wasm::float64_to_uint64_sat_wrapper") \ 211 IF_WASM(V, wasm_int64_div, "wasm::int64_div") \ 212 IF_WASM(V, wasm_int64_mod, "wasm::int64_mod") \ 213 IF_WASM(V, wasm_int64_to_float32, "wasm::int64_to_float32_wrapper") \ 214 IF_WASM(V, wasm_int64_to_float64, "wasm::int64_to_float64_wrapper") \ 215 IF_WASM(V, wasm_uint64_div, "wasm::uint64_div") \ 216 IF_WASM(V, wasm_uint64_mod, "wasm::uint64_mod") \ 217 IF_WASM(V, wasm_uint64_to_float32, "wasm::uint64_to_float32_wrapper") \ 218 IF_WASM(V, wasm_uint64_to_float64, "wasm::uint64_to_float64_wrapper") \ 219 IF_WASM(V, wasm_word32_ctz, "wasm::word32_ctz") \ 220 IF_WASM(V, wasm_word32_popcnt, "wasm::word32_popcnt") \ 221 IF_WASM(V, wasm_word32_rol, "wasm::word32_rol") \ 222 IF_WASM(V, wasm_word32_ror, "wasm::word32_ror") \ 223 IF_WASM(V, wasm_word64_rol, "wasm::word64_rol") \ 224 IF_WASM(V, wasm_word64_ror, "wasm::word64_ror") \ 225 IF_WASM(V, wasm_word64_ctz, "wasm::word64_ctz") \ 226 IF_WASM(V, wasm_word64_popcnt, "wasm::word64_popcnt") \ 227 IF_WASM(V, wasm_f64x2_ceil, "wasm::f64x2_ceil_wrapper") \ 228 IF_WASM(V, wasm_f64x2_floor, "wasm::f64x2_floor_wrapper") \ 229 IF_WASM(V, wasm_f64x2_trunc, "wasm::f64x2_trunc_wrapper") \ 230 IF_WASM(V, wasm_f64x2_nearest_int, "wasm::f64x2_nearest_int_wrapper") \ 231 IF_WASM(V, wasm_f32x4_ceil, "wasm::f32x4_ceil_wrapper") \ 232 IF_WASM(V, wasm_f32x4_floor, "wasm::f32x4_floor_wrapper") \ 233 IF_WASM(V, wasm_f32x4_trunc, "wasm::f32x4_trunc_wrapper") \ 234 IF_WASM(V, wasm_f32x4_nearest_int, "wasm::f32x4_nearest_int_wrapper") \ 235 IF_WASM(V, wasm_memory_init, "wasm::memory_init") \ 236 IF_WASM(V, wasm_memory_copy, "wasm::memory_copy") \ 237 IF_WASM(V, wasm_memory_fill, "wasm::memory_fill") \ 238 IF_WASM(V, wasm_array_copy, "wasm::array_copy") \ 239 V(address_of_wasm_i8x16_swizzle_mask, "wasm_i8x16_swizzle_mask") \ 240 V(address_of_wasm_i8x16_popcnt_mask, "wasm_i8x16_popcnt_mask") \ 241 V(address_of_wasm_i8x16_splat_0x01, "wasm_i8x16_splat_0x01") \ 242 V(address_of_wasm_i8x16_splat_0x0f, "wasm_i8x16_splat_0x0f") \ 243 V(address_of_wasm_i8x16_splat_0x33, "wasm_i8x16_splat_0x33") \ 244 V(address_of_wasm_i8x16_splat_0x55, "wasm_i8x16_splat_0x55") \ 245 V(address_of_wasm_i16x8_splat_0x0001, "wasm_16x8_splat_0x0001") \ 246 V(address_of_wasm_f64x2_convert_low_i32x4_u_int_mask, \ 247 "wasm_f64x2_convert_low_i32x4_u_int_mask") \ 248 V(supports_wasm_simd_128_address, "wasm::supports_wasm_simd_128_address") \ 249 V(address_of_wasm_double_2_power_52, "wasm_double_2_power_52") \ 250 V(address_of_wasm_int32_max_as_double, "wasm_int32_max_as_double") \ 251 V(address_of_wasm_uint32_max_as_double, "wasm_uint32_max_as_double") \ 252 V(address_of_wasm_int32_overflow_as_float, "wasm_int32_overflow_as_float") \ 253 V(supports_cetss_address, "CpuFeatures::supports_cetss_address") \ 254 V(write_barrier_marking_from_code_function, "WriteBarrier::MarkingFromCode") \ 255 V(call_enqueue_microtask_function, "MicrotaskQueue::CallEnqueueMicrotask") \ 256 V(call_enter_context_function, "call_enter_context_function") \ 257 V(atomic_pair_load_function, "atomic_pair_load_function") \ 258 V(atomic_pair_store_function, "atomic_pair_store_function") \ 259 V(atomic_pair_add_function, "atomic_pair_add_function") \ 260 V(atomic_pair_sub_function, "atomic_pair_sub_function") \ 261 V(atomic_pair_and_function, "atomic_pair_and_function") \ 262 V(atomic_pair_or_function, "atomic_pair_or_function") \ 263 V(atomic_pair_xor_function, "atomic_pair_xor_function") \ 264 V(atomic_pair_exchange_function, "atomic_pair_exchange_function") \ 265 V(atomic_pair_compare_exchange_function, \ 266 "atomic_pair_compare_exchange_function") \ 267 IF_TSAN(V, tsan_relaxed_store_function_8_bits, \ 268 "tsan_relaxed_store_function_8_bits") \ 269 IF_TSAN(V, tsan_relaxed_store_function_16_bits, \ 270 "tsan_relaxed_store_function_16_bits") \ 271 IF_TSAN(V, tsan_relaxed_store_function_32_bits, \ 272 "tsan_relaxed_store_function_32_bits") \ 273 IF_TSAN(V, tsan_relaxed_store_function_64_bits, \ 274 "tsan_relaxed_store_function_64_bits") \ 275 IF_TSAN(V, tsan_seq_cst_store_function_8_bits, \ 276 "tsan_seq_cst_store_function_8_bits") \ 277 IF_TSAN(V, tsan_seq_cst_store_function_16_bits, \ 278 "tsan_seq_cst_store_function_16_bits") \ 279 IF_TSAN(V, tsan_seq_cst_store_function_32_bits, \ 280 "tsan_seq_cst_store_function_32_bits") \ 281 IF_TSAN(V, tsan_seq_cst_store_function_64_bits, \ 282 "tsan_seq_cst_store_function_64_bits") \ 283 IF_TSAN(V, tsan_relaxed_load_function_32_bits, \ 284 "tsan_relaxed_load_function_32_bits") \ 285 IF_TSAN(V, tsan_relaxed_load_function_64_bits, \ 286 "tsan_relaxed_load_function_64_bits") \ 287 V(js_finalization_registry_remove_cell_from_unregister_token_map, \ 288 "JSFinalizationRegistry::RemoveCellFromUnregisterTokenMap") \ 289 V(re_case_insensitive_compare_unicode, \ 290 "RegExpMacroAssembler::CaseInsensitiveCompareUnicode()") \ 291 V(re_case_insensitive_compare_non_unicode, \ 292 "RegExpMacroAssembler::CaseInsensitiveCompareNonUnicode()") \ 293 V(re_is_character_in_range_array, \ 294 "RegExpMacroAssembler::IsCharacterInRangeArray()") \ 295 V(re_check_stack_guard_state, \ 296 "RegExpMacroAssembler*::CheckStackGuardState()") \ 297 V(re_grow_stack, "NativeRegExpMacroAssembler::GrowStack()") \ 298 V(re_word_character_map, "NativeRegExpMacroAssembler::word_character_map") \ 299 V(re_match_for_call_from_js, "IrregexpInterpreter::MatchForCallFromJs") \ 300 V(re_experimental_match_for_call_from_js, \ 301 "ExperimentalRegExp::MatchForCallFromJs") \ 302 EXTERNAL_REFERENCE_LIST_INTL(V) \ 303 EXTERNAL_REFERENCE_LIST_SANDBOX(V) \ 304 EXTERNAL_REFERENCE_LIST_SANDBOXED_EXTERNAL_POINTERS(V) 305 #ifdef V8_INTL_SUPPORT 306 #define EXTERNAL_REFERENCE_LIST_INTL(V) \ 307 V(intl_convert_one_byte_to_lower, "intl_convert_one_byte_to_lower") \ 308 V(intl_to_latin1_lower_table, "intl_to_latin1_lower_table") \ 309 V(intl_ascii_collation_weights_l1, "Intl::AsciiCollationWeightsL1") \ 310 V(intl_ascii_collation_weights_l3, "Intl::AsciiCollationWeightsL3") 311 #else 312 #define EXTERNAL_REFERENCE_LIST_INTL(V) 313 #endif // V8_INTL_SUPPORT 314 315 #ifdef V8_SANDBOXED_POINTERS 316 #define EXTERNAL_REFERENCE_LIST_SANDBOX(V) \ 317 V(sandbox_base_address, "Sandbox::base()") \ 318 V(sandbox_end_address, "Sandbox::end()") \ 319 V(empty_backing_store_buffer, "EmptyBackingStoreBuffer()") 320 #else 321 #define EXTERNAL_REFERENCE_LIST_SANDBOX(V) 322 #endif // V8_SANDBOXED_POINTERS 323 324 #ifdef V8_SANDBOXED_EXTERNAL_POINTERS 325 #define EXTERNAL_REFERENCE_LIST_SANDBOXED_EXTERNAL_POINTERS(V) \ 326 V(external_pointer_table_allocate_entry, \ 327 "ExternalPointerTable::AllocateEntry") 328 #else 329 #define EXTERNAL_REFERENCE_LIST_SANDBOXED_EXTERNAL_POINTERS(V) 330 #endif // V8_SANDBOXED_EXTERNAL_POINTERS 331 332 // An ExternalReference represents a C++ address used in the generated 333 // code. All references to C++ functions and variables must be encapsulated 334 // in an ExternalReference instance. This is done in order to track the 335 // origin of all external references in the code so that they can be bound 336 // to the correct addresses when deserializing a heap. 337 class ExternalReference { 338 public: 339 // Used in the simulator to support different native api calls. 340 enum Type { 341 // Builtin call. 342 // Address f(v8::internal::Arguments). 343 BUILTIN_CALL, // default 344 345 // Builtin call returning object pair. 346 // ObjectPair f(v8::internal::Arguments). 347 BUILTIN_CALL_PAIR, 348 349 // TODO(mslekova): Once FAST_C_CALL is supported in the simulator, 350 // the following four specific types and their special handling 351 // can be removed, as the generic call supports them. 352 353 // Builtin that takes float arguments and returns an int. 354 // int f(double, double). 355 BUILTIN_COMPARE_CALL, 356 357 // Builtin call that returns floating point. 358 // double f(double, double). 359 BUILTIN_FP_FP_CALL, 360 361 // Builtin call that returns floating point. 362 // double f(double). 363 BUILTIN_FP_CALL, 364 365 // Builtin call that returns floating point. 366 // double f(double, int). 367 BUILTIN_FP_INT_CALL, 368 369 // Direct call to API function callback. 370 // void f(v8::FunctionCallbackInfo&) 371 DIRECT_API_CALL, 372 373 // Call to function callback via InvokeFunctionCallback. 374 // void f(v8::FunctionCallbackInfo&, v8::FunctionCallback) 375 PROFILING_API_CALL, 376 377 // Direct call to accessor getter callback. 378 // void f(Local<Name> property, PropertyCallbackInfo& info) 379 DIRECT_GETTER_CALL, 380 381 // Call to accessor getter callback via InvokeAccessorGetterCallback. 382 // void f(Local<Name> property, PropertyCallbackInfo& info, 383 // AccessorNameGetterCallback callback) 384 PROFILING_GETTER_CALL, 385 386 // C call, either representing a fast API call or used in tests. 387 // Can have arbitrary signature from the types supported by the fast API. 388 FAST_C_CALL 389 }; 390 391 #define COUNT_EXTERNAL_REFERENCE(name, desc) +1 392 static constexpr int kExternalReferenceCountIsolateIndependent = 393 EXTERNAL_REFERENCE_LIST(COUNT_EXTERNAL_REFERENCE); 394 static constexpr int kExternalReferenceCountIsolateDependent = 395 EXTERNAL_REFERENCE_LIST_WITH_ISOLATE(COUNT_EXTERNAL_REFERENCE); 396 #undef COUNT_EXTERNAL_REFERENCE 397 398 static V8_EXPORT_PRIVATE ExternalReference 399 address_of_pending_message(LocalIsolate* local_isolate); 400 ExternalReference()401 ExternalReference() : address_(kNullAddress) {} 402 static ExternalReference Create(const SCTableReference& table_ref); 403 static ExternalReference Create(StatsCounter* counter); 404 static V8_EXPORT_PRIVATE ExternalReference Create(ApiFunction* ptr, 405 Type type); 406 // The following version is used by JSCallReducer in the compiler 407 // to create a reference for a fast API call, with one or more 408 // overloads. In simulator builds, it additionally "registers" 409 // the overloads with the simulator to ensure it maintains a 410 // mapping of callable Address'es to a function signature, encoding 411 // GP and FP arguments. 412 static V8_EXPORT_PRIVATE ExternalReference 413 Create(Isolate* isolate, ApiFunction* ptr, Type type, Address* c_functions, 414 const CFunctionInfo* const* c_signatures, unsigned num_functions); 415 static ExternalReference Create(const Runtime::Function* f); 416 static ExternalReference Create(IsolateAddressId id, Isolate* isolate); 417 static ExternalReference Create(Runtime::FunctionId id); 418 static V8_EXPORT_PRIVATE ExternalReference 419 Create(Address address, Type type = ExternalReference::BUILTIN_CALL); 420 421 template <typename SubjectChar, typename PatternChar> 422 static ExternalReference search_string_raw(); 423 424 V8_EXPORT_PRIVATE static ExternalReference FromRawAddress(Address address); 425 426 #define DECL_EXTERNAL_REFERENCE(name, desc) \ 427 V8_EXPORT_PRIVATE static ExternalReference name(); 428 EXTERNAL_REFERENCE_LIST(DECL_EXTERNAL_REFERENCE) 429 #undef DECL_EXTERNAL_REFERENCE 430 431 #define DECL_EXTERNAL_REFERENCE(name, desc) \ 432 static V8_EXPORT_PRIVATE ExternalReference name(Isolate* isolate); 433 EXTERNAL_REFERENCE_LIST_WITH_ISOLATE(DECL_EXTERNAL_REFERENCE) 434 #undef DECL_EXTERNAL_REFERENCE 435 436 V8_EXPORT_PRIVATE V8_NOINLINE static ExternalReference 437 runtime_function_table_address_for_unittests(Isolate* isolate); 438 439 static V8_EXPORT_PRIVATE ExternalReference 440 address_of_load_from_stack_count(const char* function_name); 441 static V8_EXPORT_PRIVATE ExternalReference 442 address_of_store_to_stack_count(const char* function_name); 443 address()444 Address address() const { return address_; } 445 446 private: ExternalReference(Address address)447 explicit ExternalReference(Address address) : address_(address) {} 448 ExternalReference(void * address)449 explicit ExternalReference(void* address) 450 : address_(reinterpret_cast<Address>(address)) {} 451 452 static Address Redirect(Address address_arg, 453 Type type = ExternalReference::BUILTIN_CALL); 454 455 Address address_; 456 }; 457 ASSERT_TRIVIALLY_COPYABLE(ExternalReference); 458 459 V8_EXPORT_PRIVATE bool operator==(ExternalReference, ExternalReference); 460 bool operator!=(ExternalReference, ExternalReference); 461 462 size_t hash_value(ExternalReference); 463 464 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ExternalReference); 465 466 void abort_with_reason(int reason); 467 468 } // namespace internal 469 } // namespace v8 470 471 #endif // V8_CODEGEN_EXTERNAL_REFERENCE_H_ 472