1 // Copyright 2012 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_OBJECTS_CONTEXTS_H_ 6 #define V8_OBJECTS_CONTEXTS_H_ 7 8 #include "include/v8-promise.h" 9 #include "src/objects/fixed-array.h" 10 #include "src/objects/function-kind.h" 11 #include "src/objects/ordered-hash-table.h" 12 #include "src/objects/osr-optimized-code-cache.h" 13 // Has to be the last include (doesn't have include guards): 14 #include "src/objects/object-macros.h" 15 16 namespace v8 { 17 namespace internal { 18 19 class JSGlobalObject; 20 class JSGlobalProxy; 21 class MicrotaskQueue; 22 class NativeContext; 23 class RegExpMatchInfo; 24 25 enum ContextLookupFlags { 26 FOLLOW_CONTEXT_CHAIN = 1 << 0, 27 FOLLOW_PROTOTYPE_CHAIN = 1 << 1, 28 29 DONT_FOLLOW_CHAINS = 0, 30 FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN, 31 }; 32 33 // Heap-allocated activation contexts. 34 // 35 // Contexts are implemented as FixedArray-like objects having a fixed 36 // header with a set of common fields. 37 // 38 // Note: Context must have no virtual functions and Context objects 39 // must always be allocated via Heap::AllocateContext() or 40 // Factory::NewContext. 41 42 #define NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ 43 V(GENERATOR_NEXT_INTERNAL, JSFunction, generator_next_internal) \ 44 V(ASYNC_MODULE_EVALUATE_INTERNAL, JSFunction, \ 45 async_module_evaluate_internal) \ 46 V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply) \ 47 V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \ 48 V(PROMISE_THEN_INDEX, JSFunction, promise_then) \ 49 V(FUNCTION_PROTOTYPE_APPLY_INDEX, JSFunction, function_prototype_apply) 50 51 #define NATIVE_CONTEXT_FIELDS(V) \ 52 V(GLOBAL_PROXY_INDEX, JSGlobalProxy, global_proxy_object) \ 53 /* TODO(ishell): Actually we store exactly EmbedderDataArray here but */ \ 54 /* it's already UBSan-fiendly and doesn't require a star... So declare */ \ 55 /* it as a HeapObject for now. */ \ 56 V(EMBEDDER_DATA_INDEX, HeapObject, embedder_data) \ 57 V(CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX, HeapObject, \ 58 continuation_preserved_embedder_data) \ 59 NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ 60 /* TypedArray constructors - these must stay in order! */ \ 61 V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \ 62 V(INT8_ARRAY_FUN_INDEX, JSFunction, int8_array_fun) \ 63 V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \ 64 V(INT16_ARRAY_FUN_INDEX, JSFunction, int16_array_fun) \ 65 V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ 66 V(INT32_ARRAY_FUN_INDEX, JSFunction, int32_array_fun) \ 67 V(FLOAT32_ARRAY_FUN_INDEX, JSFunction, float32_array_fun) \ 68 V(FLOAT64_ARRAY_FUN_INDEX, JSFunction, float64_array_fun) \ 69 V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ 70 V(BIGUINT64_ARRAY_FUN_INDEX, JSFunction, biguint64_array_fun) \ 71 V(BIGINT64_ARRAY_FUN_INDEX, JSFunction, bigint64_array_fun) \ 72 V(RAB_GSAB_UINT8_ARRAY_MAP_INDEX, Map, rab_gsab_uint8_array_map) \ 73 V(RAB_GSAB_INT8_ARRAY_MAP_INDEX, Map, rab_gsab_int8_array_map) \ 74 V(RAB_GSAB_UINT16_ARRAY_MAP_INDEX, Map, rab_gsab_uint16_array_map) \ 75 V(RAB_GSAB_INT16_ARRAY_MAP_INDEX, Map, rab_gsab_int16_array_map) \ 76 V(RAB_GSAB_UINT32_ARRAY_MAP_INDEX, Map, rab_gsab_uint32_array_map) \ 77 V(RAB_GSAB_INT32_ARRAY_MAP_INDEX, Map, rab_gsab_int32_array_map) \ 78 V(RAB_GSAB_FLOAT32_ARRAY_MAP_INDEX, Map, rab_gsab_float32_array_map) \ 79 V(RAB_GSAB_FLOAT64_ARRAY_MAP_INDEX, Map, rab_gsab_float64_array_map) \ 80 V(RAB_GSAB_UINT8_CLAMPED_ARRAY_MAP_INDEX, Map, \ 81 rab_gsab_uint8_clamped_array_map) \ 82 V(RAB_GSAB_BIGUINT64_ARRAY_MAP_INDEX, Map, rab_gsab_biguint64_array_map) \ 83 V(RAB_GSAB_BIGINT64_ARRAY_MAP_INDEX, Map, rab_gsab_bigint64_array_map) \ 84 /* Below is alpha-sorted */ \ 85 V(ACCESSOR_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, \ 86 accessor_property_descriptor_map) \ 87 V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \ 88 V(ARRAY_BUFFER_FUN_INDEX, JSFunction, array_buffer_fun) \ 89 V(ARRAY_BUFFER_MAP_INDEX, Map, array_buffer_map) \ 90 V(ARRAY_BUFFER_NOINIT_FUN_INDEX, JSFunction, array_buffer_noinit_fun) \ 91 V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \ 92 V(ARRAY_JOIN_STACK_INDEX, HeapObject, array_join_stack) \ 93 V(ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX, Map, async_from_sync_iterator_map) \ 94 V(ASYNC_FUNCTION_FUNCTION_INDEX, JSFunction, async_function_constructor) \ 95 V(ASYNC_FUNCTION_OBJECT_MAP_INDEX, Map, async_function_object_map) \ 96 V(ASYNC_GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \ 97 async_generator_function_function) \ 98 V(ATOMICS_OBJECT, JSObject, atomics_object) \ 99 V(BIGINT_FUNCTION_INDEX, JSFunction, bigint_function) \ 100 V(BOOLEAN_FUNCTION_INDEX, JSFunction, boolean_function) \ 101 V(BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX, Map, \ 102 bound_function_with_constructor_map) \ 103 V(BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX, Map, \ 104 bound_function_without_constructor_map) \ 105 V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \ 106 call_as_constructor_delegate) \ 107 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \ 108 V(CALL_ASYNC_MODULE_FULFILLED, JSFunction, call_async_module_fulfilled) \ 109 V(CALL_ASYNC_MODULE_REJECTED, JSFunction, call_async_module_rejected) \ 110 V(CALLSITE_FUNCTION_INDEX, JSFunction, callsite_function) \ 111 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \ 112 V(DATA_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, data_property_descriptor_map) \ 113 V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \ 114 V(DATE_FUNCTION_INDEX, JSFunction, date_function) \ 115 V(DEBUG_CONTEXT_ID_INDEX, Object, debug_context_id) \ 116 V(EMPTY_FUNCTION_INDEX, JSFunction, empty_function) \ 117 V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \ 118 error_message_for_code_gen_from_strings) \ 119 V(ERRORS_THROWN_INDEX, Smi, errors_thrown) \ 120 V(EXTRAS_BINDING_OBJECT_INDEX, JSObject, extras_binding_object) \ 121 V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map) \ 122 V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, FixedArray, \ 123 fast_template_instantiations_cache) \ 124 V(FUNCTION_FUNCTION_INDEX, JSFunction, function_function) \ 125 V(FUNCTION_PROTOTYPE_INDEX, JSObject, function_prototype) \ 126 V(GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \ 127 generator_function_function) \ 128 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \ 129 V(ASYNC_GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, \ 130 async_generator_object_prototype_map) \ 131 V(INITIAL_ARRAY_ITERATOR_MAP_INDEX, Map, initial_array_iterator_map) \ 132 V(INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 133 initial_array_iterator_prototype) \ 134 V(INITIAL_ARRAY_PROTOTYPE_INDEX, JSObject, initial_array_prototype) \ 135 V(INITIAL_ERROR_PROTOTYPE_INDEX, JSObject, initial_error_prototype) \ 136 V(INITIAL_GENERATOR_PROTOTYPE_INDEX, JSObject, initial_generator_prototype) \ 137 V(INITIAL_ASYNC_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 138 initial_async_iterator_prototype) \ 139 V(INITIAL_ASYNC_GENERATOR_PROTOTYPE_INDEX, JSObject, \ 140 initial_async_generator_prototype) \ 141 V(INITIAL_ITERATOR_PROTOTYPE_INDEX, JSObject, initial_iterator_prototype) \ 142 V(INITIAL_MAP_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 143 initial_map_iterator_prototype) \ 144 V(INITIAL_MAP_PROTOTYPE_MAP_INDEX, Map, initial_map_prototype_map) \ 145 V(INITIAL_OBJECT_PROTOTYPE_INDEX, JSObject, initial_object_prototype) \ 146 V(INITIAL_SET_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 147 initial_set_iterator_prototype) \ 148 V(INITIAL_SET_PROTOTYPE_INDEX, JSObject, initial_set_prototype) \ 149 V(INITIAL_SET_PROTOTYPE_MAP_INDEX, Map, initial_set_prototype_map) \ 150 V(INITIAL_STRING_ITERATOR_MAP_INDEX, Map, initial_string_iterator_map) \ 151 V(INITIAL_STRING_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 152 initial_string_iterator_prototype) \ 153 V(INITIAL_STRING_PROTOTYPE_INDEX, JSObject, initial_string_prototype) \ 154 V(INITIAL_WEAKMAP_PROTOTYPE_MAP_INDEX, Map, initial_weakmap_prototype_map) \ 155 V(INITIAL_WEAKSET_PROTOTYPE_MAP_INDEX, Map, initial_weakset_prototype_map) \ 156 V(INTL_COLLATOR_FUNCTION_INDEX, JSFunction, intl_collator_function) \ 157 V(INTL_DATE_TIME_FORMAT_FUNCTION_INDEX, JSFunction, \ 158 intl_date_time_format_function) \ 159 V(INTL_DISPLAY_NAMES_FUNCTION_INDEX, JSFunction, \ 160 intl_display_names_function) \ 161 V(INTL_NUMBER_FORMAT_FUNCTION_INDEX, JSFunction, \ 162 intl_number_format_function) \ 163 V(INTL_LOCALE_FUNCTION_INDEX, JSFunction, intl_locale_function) \ 164 V(INTL_LIST_FORMAT_FUNCTION_INDEX, JSFunction, intl_list_format_function) \ 165 V(INTL_PLURAL_RULES_FUNCTION_INDEX, JSFunction, intl_plural_rules_function) \ 166 V(INTL_RELATIVE_TIME_FORMAT_FUNCTION_INDEX, JSFunction, \ 167 intl_relative_time_format_function) \ 168 V(INTL_SEGMENTER_FUNCTION_INDEX, JSFunction, intl_segmenter_function) \ 169 V(INTL_SEGMENTS_MAP_INDEX, Map, intl_segments_map) \ 170 V(INTL_SEGMENT_ITERATOR_MAP_INDEX, Map, intl_segment_iterator_map) \ 171 V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \ 172 V(JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX, Map, \ 173 js_array_packed_smi_elements_map) \ 174 V(JS_ARRAY_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map, \ 175 js_array_holey_smi_elements_map) \ 176 V(JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX, Map, js_array_packed_elements_map) \ 177 V(JS_ARRAY_HOLEY_ELEMENTS_MAP_INDEX, Map, js_array_holey_elements_map) \ 178 V(JS_ARRAY_PACKED_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ 179 js_array_packed_double_elements_map) \ 180 V(JS_ARRAY_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ 181 js_array_holey_double_elements_map) \ 182 V(JS_MAP_FUN_INDEX, JSFunction, js_map_fun) \ 183 V(JS_MAP_MAP_INDEX, Map, js_map_map) \ 184 V(JS_MODULE_NAMESPACE_MAP, Map, js_module_namespace_map) \ 185 V(JS_SET_FUN_INDEX, JSFunction, js_set_fun) \ 186 V(JS_SET_MAP_INDEX, Map, js_set_map) \ 187 V(JS_WEAK_MAP_FUN_INDEX, JSFunction, js_weak_map_fun) \ 188 V(JS_WEAK_SET_FUN_INDEX, JSFunction, js_weak_set_fun) \ 189 V(JS_WEAK_REF_FUNCTION_INDEX, JSFunction, js_weak_ref_fun) \ 190 V(JS_FINALIZATION_REGISTRY_FUNCTION_INDEX, JSFunction, \ 191 js_finalization_registry_fun) \ 192 V(JS_TEMPORAL_CALENDAR_FUNCTION_INDEX, JSFunction, \ 193 temporal_calendar_function) \ 194 V(JS_TEMPORAL_DURATION_FUNCTION_INDEX, JSFunction, \ 195 temporal_duration_function) \ 196 V(JS_TEMPORAL_INSTANT_FUNCTION_INDEX, JSFunction, temporal_instant_function) \ 197 V(JS_TEMPORAL_PLAIN_DATE_FUNCTION_INDEX, JSFunction, \ 198 temporal_plain_date_function) \ 199 V(JS_TEMPORAL_PLAIN_DATE_TIME_FUNCTION_INDEX, JSFunction, \ 200 temporal_plain_date_time_function) \ 201 V(JS_TEMPORAL_PLAIN_MONTH_DAY_FUNCTION_INDEX, JSFunction, \ 202 temporal_plain_month_day_function) \ 203 V(JS_TEMPORAL_PLAIN_TIME_FUNCTION_INDEX, JSFunction, \ 204 temporal_plain_time_function) \ 205 V(JS_TEMPORAL_PLAIN_YEAR_MONTH_FUNCTION_INDEX, JSFunction, \ 206 temporal_plain_year_month_function) \ 207 V(JS_TEMPORAL_TIME_ZONE_FUNCTION_INDEX, JSFunction, \ 208 temporal_time_zone_function) \ 209 V(JS_TEMPORAL_ZONED_DATE_TIME_FUNCTION_INDEX, JSFunction, \ 210 temporal_zoned_date_time_function) \ 211 V(TEMPORAL_INSTANT_FIXED_ARRAY_FROM_ITERABLE_FUNCTION_INDEX, JSFunction, \ 212 temporal_instant_fixed_array_from_iterable) \ 213 V(STRING_FIXED_ARRAY_FROM_ITERABLE_FUNCTION_INDEX, JSFunction, \ 214 string_fixed_array_from_iterable) \ 215 /* Context maps */ \ 216 V(NATIVE_CONTEXT_MAP_INDEX, Map, native_context_map) \ 217 V(FUNCTION_CONTEXT_MAP_INDEX, Map, function_context_map) \ 218 V(MODULE_CONTEXT_MAP_INDEX, Map, module_context_map) \ 219 V(EVAL_CONTEXT_MAP_INDEX, Map, eval_context_map) \ 220 V(SCRIPT_CONTEXT_MAP_INDEX, Map, script_context_map) \ 221 V(AWAIT_CONTEXT_MAP_INDEX, Map, await_context_map) \ 222 V(BLOCK_CONTEXT_MAP_INDEX, Map, block_context_map) \ 223 V(CATCH_CONTEXT_MAP_INDEX, Map, catch_context_map) \ 224 V(WITH_CONTEXT_MAP_INDEX, Map, with_context_map) \ 225 V(DEBUG_EVALUATE_CONTEXT_MAP_INDEX, Map, debug_evaluate_context_map) \ 226 V(MAP_CACHE_INDEX, Object, map_cache) \ 227 V(MAP_KEY_ITERATOR_MAP_INDEX, Map, map_key_iterator_map) \ 228 V(MAP_KEY_VALUE_ITERATOR_MAP_INDEX, Map, map_key_value_iterator_map) \ 229 V(MAP_VALUE_ITERATOR_MAP_INDEX, Map, map_value_iterator_map) \ 230 V(MATH_RANDOM_INDEX_INDEX, Smi, math_random_index) \ 231 V(MATH_RANDOM_STATE_INDEX, ByteArray, math_random_state) \ 232 V(MATH_RANDOM_CACHE_INDEX, FixedDoubleArray, math_random_cache) \ 233 V(MESSAGE_LISTENERS_INDEX, TemplateList, message_listeners) \ 234 V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \ 235 V(NUMBER_FUNCTION_INDEX, JSFunction, number_function) \ 236 V(OBJECT_FUNCTION_INDEX, JSFunction, object_function) \ 237 V(OBJECT_FUNCTION_PROTOTYPE_INDEX, JSObject, object_function_prototype) \ 238 V(OBJECT_FUNCTION_PROTOTYPE_MAP_INDEX, Map, object_function_prototype_map) \ 239 V(PROMISE_HOOK_INIT_FUNCTION_INDEX, Object, promise_hook_init_function) \ 240 V(PROMISE_HOOK_BEFORE_FUNCTION_INDEX, Object, promise_hook_before_function) \ 241 V(PROMISE_HOOK_AFTER_FUNCTION_INDEX, Object, promise_hook_after_function) \ 242 V(PROMISE_HOOK_RESOLVE_FUNCTION_INDEX, Object, \ 243 promise_hook_resolve_function) \ 244 V(PROXY_CALLABLE_MAP_INDEX, Map, proxy_callable_map) \ 245 V(PROXY_CONSTRUCTOR_MAP_INDEX, Map, proxy_constructor_map) \ 246 V(PROXY_FUNCTION_INDEX, JSFunction, proxy_function) \ 247 V(PROXY_MAP_INDEX, Map, proxy_map) \ 248 V(PROXY_REVOCABLE_RESULT_MAP_INDEX, Map, proxy_revocable_result_map) \ 249 V(PROMISE_PROTOTYPE_INDEX, JSObject, promise_prototype) \ 250 V(RECORDER_CONTEXT_ID, Object, recorder_context_id) \ 251 V(REGEXP_EXEC_FUNCTION_INDEX, JSFunction, regexp_exec_function) \ 252 V(REGEXP_FUNCTION_INDEX, JSFunction, regexp_function) \ 253 V(REGEXP_LAST_MATCH_INFO_INDEX, RegExpMatchInfo, regexp_last_match_info) \ 254 V(REGEXP_MATCH_ALL_FUNCTION_INDEX, JSFunction, regexp_match_all_function) \ 255 V(REGEXP_MATCH_FUNCTION_INDEX, JSFunction, regexp_match_function) \ 256 V(REGEXP_PROTOTYPE_INDEX, JSObject, regexp_prototype) \ 257 V(REGEXP_PROTOTYPE_MAP_INDEX, Map, regexp_prototype_map) \ 258 V(REGEXP_REPLACE_FUNCTION_INDEX, JSFunction, regexp_replace_function) \ 259 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map) \ 260 V(REGEXP_RESULT_WITH_INDICES_MAP_INDEX, Map, regexp_result_with_indices_map) \ 261 V(REGEXP_RESULT_INDICES_MAP_INDEX, Map, regexp_result_indices_map) \ 262 V(REGEXP_SEARCH_FUNCTION_INDEX, JSFunction, regexp_search_function) \ 263 V(REGEXP_SPLIT_FUNCTION_INDEX, JSFunction, regexp_split_function) \ 264 V(INITIAL_REGEXP_STRING_ITERATOR_PROTOTYPE_MAP_INDEX, Map, \ 265 initial_regexp_string_iterator_prototype_map) \ 266 V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) \ 267 V(SCRIPT_EXECUTION_CALLBACK_INDEX, Object, script_execution_callback) \ 268 V(SECURITY_TOKEN_INDEX, Object, security_token) \ 269 V(SERIALIZED_OBJECTS, FixedArray, serialized_objects) \ 270 V(SET_VALUE_ITERATOR_MAP_INDEX, Map, set_value_iterator_map) \ 271 V(SET_KEY_VALUE_ITERATOR_MAP_INDEX, Map, set_key_value_iterator_map) \ 272 V(SHARED_ARRAY_BUFFER_FUN_INDEX, JSFunction, shared_array_buffer_fun) \ 273 V(SLOPPY_ARGUMENTS_MAP_INDEX, Map, sloppy_arguments_map) \ 274 V(SLOW_ALIASED_ARGUMENTS_MAP_INDEX, Map, slow_aliased_arguments_map) \ 275 V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \ 276 V(SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP, Map, \ 277 slow_object_with_null_prototype_map) \ 278 V(SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP, Map, \ 279 slow_object_with_object_prototype_map) \ 280 V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, SimpleNumberDictionary, \ 281 slow_template_instantiations_cache) \ 282 V(ATOMICS_WAITASYNC_PROMISES, OrderedHashSet, atomics_waitasync_promises) \ 283 V(WASM_DEBUG_MAPS, FixedArray, wasm_debug_maps) \ 284 /* Fast Path Protectors */ \ 285 V(REGEXP_SPECIES_PROTECTOR_INDEX, PropertyCell, regexp_species_protector) \ 286 /* All *_FUNCTION_MAP_INDEX definitions used by Context::FunctionMapIndex */ \ 287 /* must remain together. */ \ 288 V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map) \ 289 V(SLOPPY_FUNCTION_WITH_NAME_MAP_INDEX, Map, sloppy_function_with_name_map) \ 290 V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ 291 sloppy_function_without_prototype_map) \ 292 V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \ 293 sloppy_function_with_readonly_prototype_map) \ 294 V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \ 295 V(STRICT_FUNCTION_WITH_NAME_MAP_INDEX, Map, strict_function_with_name_map) \ 296 V(STRICT_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \ 297 strict_function_with_readonly_prototype_map) \ 298 V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ 299 strict_function_without_prototype_map) \ 300 V(METHOD_WITH_NAME_MAP_INDEX, Map, method_with_name_map) \ 301 V(ASYNC_FUNCTION_MAP_INDEX, Map, async_function_map) \ 302 V(ASYNC_FUNCTION_WITH_NAME_MAP_INDEX, Map, async_function_with_name_map) \ 303 V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map) \ 304 V(GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map, \ 305 generator_function_with_name_map) \ 306 V(ASYNC_GENERATOR_FUNCTION_MAP_INDEX, Map, async_generator_function_map) \ 307 V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map, \ 308 async_generator_function_with_name_map) \ 309 V(CLASS_FUNCTION_MAP_INDEX, Map, class_function_map) \ 310 V(STRING_FUNCTION_INDEX, JSFunction, string_function) \ 311 V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \ 312 V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ 313 V(WASM_EXPORTED_FUNCTION_MAP_INDEX, Map, wasm_exported_function_map) \ 314 V(WASM_TAG_CONSTRUCTOR_INDEX, JSFunction, wasm_tag_constructor) \ 315 V(WASM_EXCEPTION_CONSTRUCTOR_INDEX, JSFunction, wasm_exception_constructor) \ 316 V(WASM_GLOBAL_CONSTRUCTOR_INDEX, JSFunction, wasm_global_constructor) \ 317 V(WASM_INSTANCE_CONSTRUCTOR_INDEX, JSFunction, wasm_instance_constructor) \ 318 V(WASM_MEMORY_CONSTRUCTOR_INDEX, JSFunction, wasm_memory_constructor) \ 319 V(WASM_MODULE_CONSTRUCTOR_INDEX, JSFunction, wasm_module_constructor) \ 320 V(WASM_TABLE_CONSTRUCTOR_INDEX, JSFunction, wasm_table_constructor) \ 321 V(WASM_SUSPENDER_CONSTRUCTOR_INDEX, JSFunction, wasm_suspender_constructor) \ 322 V(TEMPLATE_WEAKMAP_INDEX, HeapObject, template_weakmap) \ 323 V(TYPED_ARRAY_FUN_INDEX, JSFunction, typed_array_function) \ 324 V(TYPED_ARRAY_PROTOTYPE_INDEX, JSObject, typed_array_prototype) \ 325 V(ARRAY_ENTRIES_ITERATOR_INDEX, JSFunction, array_entries_iterator) \ 326 V(ARRAY_FOR_EACH_ITERATOR_INDEX, JSFunction, array_for_each_iterator) \ 327 V(ARRAY_KEYS_ITERATOR_INDEX, JSFunction, array_keys_iterator) \ 328 V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ 329 V(ERROR_FUNCTION_INDEX, JSFunction, error_function) \ 330 V(ERROR_TO_STRING, JSFunction, error_to_string) \ 331 V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function) \ 332 V(AGGREGATE_ERROR_FUNCTION_INDEX, JSFunction, aggregate_error_function) \ 333 V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \ 334 V(GLOBAL_PARSE_FLOAT_FUN_INDEX, JSFunction, global_parse_float_fun) \ 335 V(GLOBAL_PARSE_INT_FUN_INDEX, JSFunction, global_parse_int_fun) \ 336 V(GLOBAL_PROXY_FUNCTION_INDEX, JSFunction, global_proxy_function) \ 337 V(MAP_DELETE_INDEX, JSFunction, map_delete) \ 338 V(MAP_GET_INDEX, JSFunction, map_get) \ 339 V(MAP_HAS_INDEX, JSFunction, map_has) \ 340 V(MAP_SET_INDEX, JSFunction, map_set) \ 341 V(FINALIZATION_REGISTRY_CLEANUP_SOME, JSFunction, \ 342 finalization_registry_cleanup_some) \ 343 V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \ 344 V(FUNCTION_TO_STRING_INDEX, JSFunction, function_to_string) \ 345 V(OBJECT_TO_STRING, JSFunction, object_to_string) \ 346 V(OBJECT_VALUE_OF_FUNCTION_INDEX, JSFunction, object_value_of_function) \ 347 V(PROMISE_ALL_INDEX, JSFunction, promise_all) \ 348 V(PROMISE_ALL_SETTLED_INDEX, JSFunction, promise_all_settled) \ 349 V(PROMISE_ANY_INDEX, JSFunction, promise_any) \ 350 V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \ 351 V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function) \ 352 V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function) \ 353 V(SET_ADD_INDEX, JSFunction, set_add) \ 354 V(SET_DELETE_INDEX, JSFunction, set_delete) \ 355 V(SET_HAS_INDEX, JSFunction, set_has) \ 356 V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function) \ 357 V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function) \ 358 V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function) \ 359 V(WASM_COMPILE_ERROR_FUNCTION_INDEX, JSFunction, \ 360 wasm_compile_error_function) \ 361 V(WASM_LINK_ERROR_FUNCTION_INDEX, JSFunction, wasm_link_error_function) \ 362 V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, \ 363 wasm_runtime_error_function) \ 364 V(WASM_EXCEPTION_ERROR_FUNCTION_INDEX, JSFunction, \ 365 wasm_exception_error_function) \ 366 V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set) \ 367 V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get) \ 368 V(WEAKMAP_DELETE_INDEX, JSFunction, weakmap_delete) \ 369 V(WEAKSET_ADD_INDEX, JSFunction, weakset_add) \ 370 V(WRAPPED_FUNCTION_MAP_INDEX, Map, wrapped_function_map) \ 371 V(RETAINED_MAPS, Object, retained_maps) \ 372 V(OSR_CODE_CACHE_INDEX, OSROptimizedCodeCache, osr_code_cache) 373 374 #include "torque-generated/src/objects/contexts-tq.inc" 375 376 // A table of all script contexts. Every loaded top-level script with top-level 377 // lexical declarations contributes its ScriptContext into this table. 378 // 379 // The table is a fixed array, its first slot is the current used count and 380 // the subsequent slots 1..used contain ScriptContexts. 381 382 struct VariableLookupResult; 383 class ScriptContextTable : public FixedArray { 384 public: 385 DECL_CAST(ScriptContextTable) 386 387 DECL_RELEASE_ACQUIRE_INT_ACCESSORS(used) 388 389 static inline Handle<Context> GetContext(Isolate* isolate, 390 Handle<ScriptContextTable> table, 391 int i); 392 inline Context get_context(int i) const; 393 inline Context get_context(int i, AcquireLoadTag tag) const; 394 395 DECL_ACCESSORS(names_to_context_index, NameToIndexHashTable) 396 397 // Adds local names from `script_context` to the hash table. 398 static void AddLocalNamesFromContext( 399 Isolate* isolate, Handle<ScriptContextTable> script_context_table, 400 Handle<Context> script_context, bool ignore_duplicates, 401 int script_context_index); 402 403 // Lookup a variable `name` in a ScriptContextTable. 404 // If it returns true, the variable is found and `result` contains 405 // valid information about its location. 406 // If it returns false, `result` is untouched. 407 V8_WARN_UNUSED_RESULT 408 V8_EXPORT_PRIVATE bool Lookup(Handle<String> name, 409 VariableLookupResult* result); 410 411 V8_WARN_UNUSED_RESULT 412 V8_EXPORT_PRIVATE static Handle<ScriptContextTable> Extend( 413 Isolate* isolate, Handle<ScriptContextTable> table, 414 Handle<Context> script_context, bool ignore_duplicates = false); 415 416 static const int kHashTableIndex = 0; 417 static const int kUsedSlotIndex = 1; 418 static const int kFirstContextSlotIndex = 2; 419 static const int kMinLength = kFirstContextSlotIndex; 420 421 static const int kHashTableOffset = OffsetOfElementAt(kHashTableIndex); 422 423 OBJECT_CONSTRUCTORS(ScriptContextTable, FixedArray); 424 }; 425 426 // JSFunctions are pairs (context, function code), sometimes also called 427 // closures. A Context object is used to represent function contexts and 428 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). 429 // 430 // At runtime, the contexts build a stack in parallel to the execution 431 // stack, with the top-most context being the current context. All contexts 432 // have the following slots: 433 // 434 // [ scope_info ] This is the scope info describing the current context. It 435 // contains the names of statically allocated context slots, 436 // and stack-allocated locals. The names are needed for 437 // dynamic lookups in the presence of 'with' or 'eval', and 438 // for the debugger. 439 // 440 // [ previous ] A pointer to the previous context. 441 // 442 // [ extension ] Additional data. This slot is only available when 443 // ScopeInfo::HasContextExtensionSlot returns true. 444 // 445 // For native contexts, it contains the global object. 446 // For module contexts, it contains the module object. 447 // For await contexts, it contains the generator object. 448 // For var block contexts, it may contain an "extension 449 // object". 450 // For with contexts, it contains an "extension object". 451 // 452 // An "extension object" is used to dynamically extend a 453 // context with additional variables, namely in the 454 // implementation of the 'with' construct and the 'eval' 455 // construct. For instance, Context::Lookup also searches 456 // the extension object for properties. (Storing the 457 // extension object is the original purpose of this context 458 // slot, hence the name.) 459 // 460 // In addition, function contexts with sloppy eval may have statically 461 // allocated context slots to store local variables/functions that are accessed 462 // from inner functions (via static context addresses) or through 'eval' 463 // (dynamic context lookups). 464 // The native context contains additional slots for fast access to native 465 // properties. 466 // 467 // Finally, with Harmony scoping, the JSFunction representing a top level 468 // script will have the ScriptContext rather than a FunctionContext. 469 // Script contexts from all top-level scripts are gathered in 470 // ScriptContextTable. 471 472 class Context : public TorqueGeneratedContext<Context, HeapObject> { 473 public: 474 NEVER_READ_ONLY_SPACE 475 476 using TorqueGeneratedContext::length; // Non-atomic. 477 using TorqueGeneratedContext::set_length; // Non-atomic. 478 DECL_RELAXED_SMI_ACCESSORS(length) 479 480 // Setter and getter for elements. 481 // Note the plain accessors use relaxed semantics. 482 // TODO(jgruber): Make that explicit through tags. 483 V8_INLINE Object get(int index) const; 484 V8_INLINE Object get(PtrComprCageBase cage_base, int index) const; 485 V8_INLINE void set(int index, Object value, 486 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 487 // Accessors with acquire-release semantics. 488 V8_INLINE Object get(int index, AcquireLoadTag) const; 489 V8_INLINE Object get(PtrComprCageBase cage_base, int index, 490 AcquireLoadTag) const; 491 V8_INLINE void set(int index, Object value, WriteBarrierMode mode, 492 ReleaseStoreTag); 493 494 static const int kScopeInfoOffset = kElementsOffset; 495 static const int kPreviousOffset = kScopeInfoOffset + kTaggedSize; 496 497 /* Header size. */ \ 498 /* TODO(ishell): use this as header size once MIN_CONTEXT_SLOTS */ \ 499 /* is removed in favour of offset-based access to common fields. */ \ 500 static const int kTodoHeaderSize = kPreviousOffset + kTaggedSize; 501 502 // If the extension slot exists, it is the first slot after the header. 503 static const int kExtensionOffset = kTodoHeaderSize; 504 505 // Garbage collection support. SizeFor(int length)506 V8_INLINE static constexpr int SizeFor(int length) { 507 // TODO(v8:9287): This is a workaround for GCMole build failures. 508 int result = kElementsOffset + length * kTaggedSize; 509 DCHECK_EQ(TorqueGeneratedContext::SizeFor(length), result); 510 return result; 511 } 512 513 // Code Generation support. 514 // Offset of the element from the beginning of object. OffsetOfElementAt(int index)515 V8_INLINE static constexpr int OffsetOfElementAt(int index) { 516 return SizeFor(index); 517 } 518 // Offset of the element from the heap object pointer. SlotOffset(int index)519 V8_INLINE static constexpr int SlotOffset(int index) { 520 return OffsetOfElementAt(index) - kHeapObjectTag; 521 } 522 523 // Initializes the variable slots of the context. Lexical variables that need 524 // initialization are filled with the hole. 525 void Initialize(Isolate* isolate); 526 527 // TODO(ishell): eventually migrate to the offset based access instead of 528 // index-based. 529 // The default context slot layout; indices are FixedArray slot indices. 530 enum Field { 531 // TODO(shell): use offset-based approach for accessing common values. 532 // These slots are in all contexts. 533 SCOPE_INFO_INDEX, 534 PREVIOUS_INDEX, 535 536 // This slot only exists if ScopeInfo::HasContextExtensionSlot returns true. 537 EXTENSION_INDEX, 538 539 // These slots are only in native contexts. 540 #define NATIVE_CONTEXT_SLOT(index, type, name) index, 541 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_SLOT) 542 #undef NATIVE_CONTEXT_SLOT 543 544 // Properties from here are treated as weak references by the full GC. 545 // Scavenge treats them as strong references. 546 OPTIMIZED_CODE_LIST, // Weak. 547 DEOPTIMIZED_CODE_LIST, // Weak. 548 NEXT_CONTEXT_LINK, // Weak. 549 550 // Total number of slots. 551 NATIVE_CONTEXT_SLOTS, 552 FIRST_WEAK_SLOT = OPTIMIZED_CODE_LIST, 553 FIRST_JS_ARRAY_MAP_SLOT = JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX, 554 555 // TODO(shell): Remove, once it becomes zero 556 MIN_CONTEXT_SLOTS = EXTENSION_INDEX, 557 MIN_CONTEXT_EXTENDED_SLOTS = EXTENSION_INDEX + 1, 558 559 // This slot holds the thrown value in catch contexts. 560 THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS, 561 562 // These slots hold values in debug evaluate contexts. 563 WRAPPED_CONTEXT_INDEX = MIN_CONTEXT_EXTENDED_SLOTS 564 }; 565 566 static const int kExtensionSize = 567 (MIN_CONTEXT_EXTENDED_SLOTS - MIN_CONTEXT_SLOTS) * kTaggedSize; 568 static const int kExtendedHeaderSize = kTodoHeaderSize + kExtensionSize; 569 570 // A region of native context entries containing maps for functions created 571 // by Builtin::kFastNewClosure. 572 static const int FIRST_FUNCTION_MAP_INDEX = SLOPPY_FUNCTION_MAP_INDEX; 573 static const int LAST_FUNCTION_MAP_INDEX = CLASS_FUNCTION_MAP_INDEX; 574 575 static const int FIRST_FIXED_TYPED_ARRAY_FUN_INDEX = UINT8_ARRAY_FUN_INDEX; 576 static const int FIRST_RAB_GSAB_TYPED_ARRAY_MAP_INDEX = 577 RAB_GSAB_UINT8_ARRAY_MAP_INDEX; 578 579 static const int kNoContext = 0; 580 static const int kInvalidContext = 1; 581 582 // Direct slot access. 583 DECL_ACCESSORS(scope_info, ScopeInfo) 584 585 inline Object unchecked_previous() const; 586 inline Context previous() const; 587 588 inline Object next_context_link() const; 589 590 inline bool has_extension() const; 591 inline HeapObject extension() const; 592 V8_EXPORT_PRIVATE void set_extension( 593 HeapObject object, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 594 JSObject extension_object() const; 595 JSReceiver extension_receiver() const; 596 597 // Find the module context (assuming there is one) and return the associated 598 // module object. 599 SourceTextModule module() const; 600 601 // Get the context where var declarations will be hoisted to, which 602 // may be the context itself. 603 Context declaration_context() const; 604 bool is_declaration_context() const; 605 606 // Get the next closure's context on the context chain. 607 Context closure_context() const; 608 609 // Returns a JSGlobalProxy object or null. 610 V8_EXPORT_PRIVATE JSGlobalProxy global_proxy() const; 611 612 // Get the JSGlobalObject object. 613 V8_EXPORT_PRIVATE JSGlobalObject global_object() const; 614 615 // Get the script context by traversing the context chain. 616 Context script_context() const; 617 618 // Compute the native context. 619 inline NativeContext native_context() const; 620 621 // Predicates for context types. IsNativeContext is already defined on 622 // Object. 623 inline bool IsFunctionContext() const; 624 inline bool IsCatchContext() const; 625 inline bool IsWithContext() const; 626 inline bool IsDebugEvaluateContext() const; 627 inline bool IsAwaitContext() const; 628 inline bool IsBlockContext() const; 629 inline bool IsModuleContext() const; 630 inline bool IsEvalContext() const; 631 inline bool IsScriptContext() const; 632 633 inline bool HasSameSecurityTokenAs(Context that) const; 634 635 Handle<Object> ErrorMessageForCodeGenerationFromStrings(); 636 637 static int IntrinsicIndexForName(Handle<String> name); 638 static int IntrinsicIndexForName(const unsigned char* name, int length); 639 640 #define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \ 641 inline void set_##name(type value); \ 642 inline bool is_##name(type value) const; \ 643 inline type name() const; \ 644 inline type name(AcquireLoadTag) const; 645 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS) 646 #undef NATIVE_CONTEXT_FIELD_ACCESSORS 647 648 // Lookup the slot called name, starting with the current context. 649 // There are three possibilities: 650 // 651 // 1) result->IsContext(): 652 // The binding was found in a context. *index is always the 653 // non-negative slot index. *attributes is NONE for var and let 654 // declarations, READ_ONLY for const declarations (never ABSENT). 655 // 656 // 2) result->IsJSObject(): 657 // The binding was found as a named property in a context extension 658 // object (i.e., was introduced via eval), as a property on the subject 659 // of with, or as a property of the global object. *index is -1 and 660 // *attributes is not ABSENT. 661 // 662 // 3) result->IsModule(): 663 // The binding was found in module imports or exports. 664 // *attributes is never ABSENT. imports are READ_ONLY. 665 // 666 // 4) result.is_null(): 667 // There was no binding found, *index is always -1 and *attributes is 668 // always ABSENT. 669 static Handle<Object> Lookup(Handle<Context> context, Handle<String> name, 670 ContextLookupFlags flags, int* index, 671 PropertyAttributes* attributes, 672 InitializationFlag* init_flag, 673 VariableMode* variable_mode, 674 bool* is_sloppy_function_name = nullptr); 675 676 static inline int FunctionMapIndex(LanguageMode language_mode, 677 FunctionKind kind, bool has_shared_name); 678 ArrayMapIndex(ElementsKind elements_kind)679 static int ArrayMapIndex(ElementsKind elements_kind) { 680 DCHECK(IsFastElementsKind(elements_kind)); 681 return elements_kind + FIRST_JS_ARRAY_MAP_SLOT; 682 } 683 684 inline Map GetInitialJSArrayMap(ElementsKind kind) const; 685 686 static const int kNotFound = -1; 687 688 // Dispatched behavior. 689 DECL_PRINTER(Context) 690 DECL_VERIFIER(Context) 691 692 class BodyDescriptor; 693 694 #ifdef VERIFY_HEAP 695 V8_EXPORT_PRIVATE void VerifyExtensionSlot(HeapObject extension); 696 #endif 697 698 private: 699 #ifdef DEBUG 700 // Bootstrapping-aware type checks. 701 static bool IsBootstrappingOrValidParentContext(Object object, Context kid); 702 #endif 703 704 friend class Factory; 705 inline void set_previous(Context context, 706 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 707 708 TQ_OBJECT_CONSTRUCTORS(Context) 709 }; 710 711 class NativeContext : public Context { 712 public: 713 DECL_CAST(NativeContext) 714 // TODO(neis): Move some stuff from Context here. 715 716 inline void AllocateExternalPointerEntries(Isolate* isolate); 717 718 // NativeContext fields are read concurrently from background threads; any 719 // concurrent writes of affected fields must have acquire-release semantics, 720 // thus we hide the non-atomic setter. Note this doesn't protect fully since 721 // one could still use Context::set and/or write directly using offsets (e.g. 722 // from CSA/Torque). 723 void set(int index, Object value, WriteBarrierMode mode) = delete; 724 V8_INLINE void set(int index, Object value, WriteBarrierMode mode, 725 ReleaseStoreTag); 726 727 // [microtask_queue]: pointer to the MicrotaskQueue object. 728 DECL_GETTER(microtask_queue, MicrotaskQueue*) 729 inline void set_microtask_queue(Isolate* isolate, MicrotaskQueue* queue); 730 731 inline void synchronized_set_script_context_table( 732 ScriptContextTable script_context_table); 733 inline ScriptContextTable synchronized_script_context_table() const; 734 735 // Caution, hack: this getter ignores the AcquireLoadTag. The global_object 736 // slot is safe to read concurrently since it is immutable after 737 // initialization. This function should *not* be used from anywhere other 738 // than heap-refs.cc. 739 // TODO(jgruber): Remove this function after NativeContextRef is actually 740 // never serialized and BROKER_NATIVE_CONTEXT_FIELDS is removed. global_object()741 JSGlobalObject global_object() { return Context::global_object(); } global_object(AcquireLoadTag)742 JSGlobalObject global_object(AcquireLoadTag) { 743 return Context::global_object(); 744 } 745 746 // Dispatched behavior. 747 DECL_PRINTER(NativeContext) 748 DECL_VERIFIER(NativeContext) 749 750 // Layout description. 751 #define NATIVE_CONTEXT_FIELDS_DEF(V) \ 752 /* TODO(ishell): move definition of common context offsets to Context. */ \ 753 V(kStartOfNativeContextFieldsOffset, \ 754 (FIRST_WEAK_SLOT - MIN_CONTEXT_EXTENDED_SLOTS) * kTaggedSize) \ 755 V(kEndOfStrongFieldsOffset, 0) \ 756 V(kStartOfWeakFieldsOffset, \ 757 (NATIVE_CONTEXT_SLOTS - FIRST_WEAK_SLOT) * kTaggedSize) \ 758 V(kEndOfWeakFieldsOffset, 0) \ 759 V(kEndOfNativeContextFieldsOffset, 0) \ 760 V(kEndOfTaggedFieldsOffset, 0) \ 761 /* Raw data. */ \ 762 V(kMicrotaskQueueOffset, kSystemPointerSize) \ 763 /* Total size. */ \ 764 V(kSize, 0) 765 766 DEFINE_FIELD_OFFSET_CONSTANTS(Context::kExtendedHeaderSize, 767 NATIVE_CONTEXT_FIELDS_DEF) 768 #undef NATIVE_CONTEXT_FIELDS_DEF 769 770 class BodyDescriptor; 771 772 // The native context stores a list of all optimized code and a list of all 773 // deoptimized code, which are needed by the deoptimizer. 774 V8_EXPORT_PRIVATE void AddOptimizedCode(CodeT code); 775 inline void SetOptimizedCodeListHead(Object head); 776 inline Object OptimizedCodeListHead(); 777 inline void SetDeoptimizedCodeListHead(Object head); 778 inline Object DeoptimizedCodeListHead(); 779 780 void ResetErrorsThrown(); 781 void IncrementErrorsThrown(); 782 int GetErrorsThrown(); 783 784 #ifdef V8_ENABLE_JAVASCRIPT_PROMISE_HOOKS 785 void RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise, 786 Handle<Object> parent); 787 #endif 788 789 private: 790 STATIC_ASSERT(OffsetOfElementAt(EMBEDDER_DATA_INDEX) == 791 Internals::kNativeContextEmbedderDataOffset); 792 793 OBJECT_CONSTRUCTORS(NativeContext, Context); 794 }; 795 796 using ContextField = Context::Field; 797 798 } // namespace internal 799 } // namespace v8 800 801 #include "src/objects/object-macros-undef.h" 802 803 #endif // V8_OBJECTS_CONTEXTS_H_ 804