8 #include "src/objects/fixed-array.h" 11 #include "src/objects/object-macros.h" 21 class RegExpMatchInfo;
23 enum ContextLookupFlags {
24 FOLLOW_CONTEXT_CHAIN = 1 << 0,
25 FOLLOW_PROTOTYPE_CHAIN = 1 << 1,
26 STOP_AT_DECLARATION_SCOPE = 1 << 2,
27 SKIP_WITH_CONTEXT = 1 << 3,
29 DONT_FOLLOW_CHAINS = 0,
30 FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN,
42 #define NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ 43 V(ASYNC_FUNCTION_PROMISE_CREATE_INDEX, JSFunction, \ 44 async_function_promise_create) \ 45 V(IS_ARRAYLIKE, JSFunction, is_arraylike) \ 46 V(GENERATOR_NEXT_INTERNAL, JSFunction, generator_next_internal) \ 47 V(MAKE_ERROR_INDEX, JSFunction, make_error) \ 48 V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error) \ 49 V(MAKE_SYNTAX_ERROR_INDEX, JSFunction, make_syntax_error) \ 50 V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error) \ 51 V(MAKE_URI_ERROR_INDEX, JSFunction, make_uri_error) \ 52 V(OBJECT_CREATE, JSFunction, object_create) \ 53 V(OBJECT_DEFINE_PROPERTIES, JSFunction, object_define_properties) \ 54 V(OBJECT_DEFINE_PROPERTY, JSFunction, object_define_property) \ 55 V(OBJECT_GET_PROTOTYPE_OF, JSFunction, object_get_prototype_of) \ 56 V(OBJECT_IS_EXTENSIBLE, JSFunction, object_is_extensible) \ 57 V(OBJECT_IS_FROZEN, JSFunction, object_is_frozen) \ 58 V(OBJECT_IS_SEALED, JSFunction, object_is_sealed) \ 59 V(OBJECT_KEYS, JSFunction, object_keys) \ 60 V(REGEXP_INTERNAL_MATCH, JSFunction, regexp_internal_match) \ 61 V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply) \ 62 V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct) \ 63 V(REFLECT_DEFINE_PROPERTY_INDEX, JSFunction, reflect_define_property) \ 64 V(REFLECT_DELETE_PROPERTY_INDEX, JSFunction, reflect_delete_property) \ 65 V(MATH_FLOOR_INDEX, JSFunction, math_floor) \ 66 V(MATH_POW_INDEX, JSFunction, math_pow) \ 67 V(NEW_PROMISE_CAPABILITY_INDEX, JSFunction, new_promise_capability) \ 68 V(PROMISE_INTERNAL_CONSTRUCTOR_INDEX, JSFunction, \ 69 promise_internal_constructor) \ 70 V(IS_PROMISE_INDEX, JSFunction, is_promise) \ 71 V(PROMISE_THEN_INDEX, JSFunction, promise_then) 73 #define NATIVE_CONTEXT_IMPORTED_FIELDS(V) \ 74 V(ARRAY_ENTRIES_ITERATOR_INDEX, JSFunction, array_entries_iterator) \ 75 V(ARRAY_FOR_EACH_ITERATOR_INDEX, JSFunction, array_for_each_iterator) \ 76 V(ARRAY_KEYS_ITERATOR_INDEX, JSFunction, array_keys_iterator) \ 77 V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ 78 V(ERROR_FUNCTION_INDEX, JSFunction, error_function) \ 79 V(ERROR_TO_STRING, JSFunction, error_to_string) \ 80 V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function) \ 81 V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \ 82 V(GLOBAL_PROXY_FUNCTION_INDEX, JSFunction, global_proxy_function) \ 83 V(MAP_DELETE_INDEX, JSFunction, map_delete) \ 84 V(MAP_GET_INDEX, JSFunction, map_get) \ 85 V(MAP_HAS_INDEX, JSFunction, map_has) \ 86 V(MAP_SET_INDEX, JSFunction, map_set) \ 87 V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \ 88 V(OBJECT_VALUE_OF, JSFunction, object_value_of) \ 89 V(OBJECT_TO_STRING, JSFunction, object_to_string) \ 90 V(PROMISE_ALL_INDEX, JSFunction, promise_all) \ 91 V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \ 92 V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \ 93 V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function) \ 94 V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function) \ 95 V(SET_ADD_INDEX, JSFunction, set_add) \ 96 V(SET_DELETE_INDEX, JSFunction, set_delete) \ 97 V(SET_HAS_INDEX, JSFunction, set_has) \ 98 V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function) \ 99 V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function) \ 100 V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function) \ 101 V(WASM_COMPILE_ERROR_FUNCTION_INDEX, JSFunction, \ 102 wasm_compile_error_function) \ 103 V(WASM_LINK_ERROR_FUNCTION_INDEX, JSFunction, wasm_link_error_function) \ 104 V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction, \ 105 wasm_runtime_error_function) \ 106 V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set) \ 107 V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get) \ 108 V(WEAKSET_ADD_INDEX, JSFunction, weakset_add) 110 #define NATIVE_CONTEXT_FIELDS(V) \ 111 V(GLOBAL_PROXY_INDEX, JSGlobalProxy, global_proxy_object) \ 115 V(EMBEDDER_DATA_INDEX, HeapObject, embedder_data) \ 117 V(ACCESSOR_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, \ 118 accessor_property_descriptor_map) \ 119 V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \ 120 V(ARRAY_BUFFER_FUN_INDEX, JSFunction, array_buffer_fun) \ 121 V(ARRAY_BUFFER_MAP_INDEX, Map, array_buffer_map) \ 122 V(ARRAY_BUFFER_NOINIT_FUN_INDEX, JSFunction, array_buffer_noinit_fun) \ 123 V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \ 124 V(ARRAY_JOIN_STACK_INDEX, HeapObject, array_join_stack) \ 125 V(ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX, Map, async_from_sync_iterator_map) \ 126 V(ASYNC_FUNCTION_AWAIT_REJECT_SHARED_FUN, SharedFunctionInfo, \ 127 async_function_await_reject_shared_fun) \ 128 V(ASYNC_FUNCTION_AWAIT_RESOLVE_SHARED_FUN, SharedFunctionInfo, \ 129 async_function_await_resolve_shared_fun) \ 130 V(ASYNC_FUNCTION_FUNCTION_INDEX, JSFunction, async_function_constructor) \ 131 V(ASYNC_FUNCTION_OBJECT_MAP_INDEX, Map, async_function_object_map) \ 132 V(ASYNC_GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \ 133 async_generator_function_function) \ 134 V(ASYNC_ITERATOR_VALUE_UNWRAP_SHARED_FUN, SharedFunctionInfo, \ 135 async_iterator_value_unwrap_shared_fun) \ 136 V(ASYNC_GENERATOR_AWAIT_REJECT_SHARED_FUN, SharedFunctionInfo, \ 137 async_generator_await_reject_shared_fun) \ 138 V(ASYNC_GENERATOR_AWAIT_RESOLVE_SHARED_FUN, SharedFunctionInfo, \ 139 async_generator_await_resolve_shared_fun) \ 140 V(ASYNC_GENERATOR_YIELD_RESOLVE_SHARED_FUN, SharedFunctionInfo, \ 141 async_generator_yield_resolve_shared_fun) \ 142 V(ASYNC_GENERATOR_RETURN_RESOLVE_SHARED_FUN, SharedFunctionInfo, \ 143 async_generator_return_resolve_shared_fun) \ 144 V(ASYNC_GENERATOR_RETURN_CLOSED_RESOLVE_SHARED_FUN, SharedFunctionInfo, \ 145 async_generator_return_closed_resolve_shared_fun) \ 146 V(ASYNC_GENERATOR_RETURN_CLOSED_REJECT_SHARED_FUN, SharedFunctionInfo, \ 147 async_generator_return_closed_reject_shared_fun) \ 148 V(ATOMICS_OBJECT, JSObject, atomics_object) \ 149 V(BIGINT_FUNCTION_INDEX, JSFunction, bigint_function) \ 150 V(BIGINT64_ARRAY_FUN_INDEX, JSFunction, bigint64_array_fun) \ 151 V(BIGUINT64_ARRAY_FUN_INDEX, JSFunction, biguint64_array_fun) \ 152 V(BOOLEAN_FUNCTION_INDEX, JSFunction, boolean_function) \ 153 V(BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX, Map, \ 154 bound_function_with_constructor_map) \ 155 V(BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX, Map, \ 156 bound_function_without_constructor_map) \ 157 V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \ 158 call_as_constructor_delegate) \ 159 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \ 160 V(CALLSITE_FUNCTION_INDEX, JSFunction, callsite_function) \ 161 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \ 162 V(DATA_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, data_property_descriptor_map) \ 163 V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \ 164 V(DATE_FUNCTION_INDEX, JSFunction, date_function) \ 165 V(DEBUG_CONTEXT_ID_INDEX, Object, debug_context_id) \ 166 V(EMPTY_FUNCTION_INDEX, JSFunction, empty_function) \ 167 V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \ 168 error_message_for_code_gen_from_strings) \ 169 V(ERRORS_THROWN_INDEX, Smi, errors_thrown) \ 170 V(EXTRAS_EXPORTS_OBJECT_INDEX, JSObject, extras_binding_object) \ 171 V(EXTRAS_UTILS_OBJECT_INDEX, Object, extras_utils_object) \ 172 V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map) \ 173 V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, FixedArray, \ 174 fast_template_instantiations_cache) \ 175 V(FLOAT32_ARRAY_FUN_INDEX, JSFunction, float32_array_fun) \ 176 V(FLOAT64_ARRAY_FUN_INDEX, JSFunction, float64_array_fun) \ 177 V(FUNCTION_FUNCTION_INDEX, JSFunction, function_function) \ 178 V(GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction, \ 179 generator_function_function) \ 180 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \ 181 V(ASYNC_GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, \ 182 async_generator_object_prototype_map) \ 183 V(INITIAL_ARRAY_ITERATOR_MAP_INDEX, Map, initial_array_iterator_map) \ 184 V(INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 185 initial_array_iterator_prototype) \ 186 V(INITIAL_ARRAY_PROTOTYPE_INDEX, JSObject, initial_array_prototype) \ 187 V(INITIAL_ERROR_PROTOTYPE_INDEX, JSObject, initial_error_prototype) \ 188 V(INITIAL_GENERATOR_PROTOTYPE_INDEX, JSObject, initial_generator_prototype) \ 189 V(INITIAL_ASYNC_GENERATOR_PROTOTYPE_INDEX, JSObject, \ 190 initial_async_generator_prototype) \ 191 V(INITIAL_ITERATOR_PROTOTYPE_INDEX, JSObject, initial_iterator_prototype) \ 192 V(INITIAL_MAP_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 193 initial_map_iterator_prototype) \ 194 V(INITIAL_MAP_PROTOTYPE_MAP_INDEX, Map, initial_map_prototype_map) \ 195 V(INITIAL_OBJECT_PROTOTYPE_INDEX, JSObject, initial_object_prototype) \ 196 V(INITIAL_SET_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 197 initial_set_iterator_prototype) \ 198 V(INITIAL_SET_PROTOTYPE_INDEX, JSObject, initial_set_prototype) \ 199 V(INITIAL_SET_PROTOTYPE_MAP_INDEX, Map, initial_set_prototype_map) \ 200 V(INITIAL_STRING_ITERATOR_MAP_INDEX, Map, initial_string_iterator_map) \ 201 V(INITIAL_STRING_ITERATOR_PROTOTYPE_INDEX, JSObject, \ 202 initial_string_iterator_prototype) \ 203 V(INITIAL_STRING_PROTOTYPE_INDEX, JSObject, initial_string_prototype) \ 204 V(INITIAL_WEAKMAP_PROTOTYPE_MAP_INDEX, Map, initial_weakmap_prototype_map) \ 205 V(INITIAL_WEAKSET_PROTOTYPE_MAP_INDEX, Map, initial_weakset_prototype_map) \ 206 V(INT16_ARRAY_FUN_INDEX, JSFunction, int16_array_fun) \ 207 V(INT32_ARRAY_FUN_INDEX, JSFunction, int32_array_fun) \ 208 V(INT8_ARRAY_FUN_INDEX, JSFunction, int8_array_fun) \ 209 V(INTERNAL_ARRAY_FUNCTION_INDEX, JSFunction, internal_array_function) \ 210 V(INTL_COLLATOR_FUNCTION_INDEX, JSFunction, intl_collator_function) \ 211 V(INTL_DATE_TIME_FORMAT_FUNCTION_INDEX, JSFunction, \ 212 intl_date_time_format_function) \ 213 V(INTL_NUMBER_FORMAT_FUNCTION_INDEX, JSFunction, \ 214 intl_number_format_function) \ 215 V(INTL_LOCALE_FUNCTION_INDEX, JSFunction, intl_locale_function) \ 216 V(INTL_SEGMENT_ITERATOR_MAP_INDEX, Map, intl_segment_iterator_map) \ 217 V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \ 218 V(JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX, Map, \ 219 js_array_packed_smi_elements_map) \ 220 V(JS_ARRAY_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map, \ 221 js_array_holey_smi_elements_map) \ 222 V(JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX, Map, js_array_packed_elements_map) \ 223 V(JS_ARRAY_HOLEY_ELEMENTS_MAP_INDEX, Map, js_array_holey_elements_map) \ 224 V(JS_ARRAY_PACKED_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ 225 js_array_packed_double_elements_map) \ 226 V(JS_ARRAY_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ 227 js_array_holey_double_elements_map) \ 228 V(JS_MAP_FUN_INDEX, JSFunction, js_map_fun) \ 229 V(JS_MAP_MAP_INDEX, Map, js_map_map) \ 230 V(JS_MODULE_NAMESPACE_MAP, Map, js_module_namespace_map) \ 231 V(JS_SET_FUN_INDEX, JSFunction, js_set_fun) \ 232 V(JS_SET_MAP_INDEX, Map, js_set_map) \ 233 V(JS_WEAK_CELL_MAP_INDEX, Map, js_weak_cell_map) \ 234 V(JS_WEAK_FACTORY_CLEANUP_ITERATOR_MAP_INDEX, Map, \ 235 js_weak_factory_cleanup_iterator_map) \ 236 V(JS_WEAK_MAP_FUN_INDEX, JSFunction, js_weak_map_fun) \ 237 V(JS_WEAK_REF_MAP_INDEX, Map, js_weak_ref_map) \ 238 V(JS_WEAK_SET_FUN_INDEX, JSFunction, js_weak_set_fun) \ 239 V(MAP_CACHE_INDEX, Object, map_cache) \ 240 V(MAP_KEY_ITERATOR_MAP_INDEX, Map, map_key_iterator_map) \ 241 V(MAP_KEY_VALUE_ITERATOR_MAP_INDEX, Map, map_key_value_iterator_map) \ 242 V(MAP_VALUE_ITERATOR_MAP_INDEX, Map, map_value_iterator_map) \ 243 V(MATH_RANDOM_INDEX_INDEX, Smi, math_random_index) \ 244 V(MATH_RANDOM_STATE_INDEX, ByteArray, math_random_state) \ 245 V(MATH_RANDOM_CACHE_INDEX, FixedDoubleArray, math_random_cache) \ 246 V(MESSAGE_LISTENERS_INDEX, TemplateList, message_listeners) \ 247 V(NATIVES_UTILS_OBJECT_INDEX, Object, natives_utils_object) \ 248 V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \ 249 V(NUMBER_FUNCTION_INDEX, JSFunction, number_function) \ 250 V(OBJECT_FUNCTION_INDEX, JSFunction, object_function) \ 251 V(OBJECT_FUNCTION_PROTOTYPE_MAP_INDEX, Map, object_function_prototype_map) \ 252 V(OPAQUE_REFERENCE_FUNCTION_INDEX, JSFunction, opaque_reference_function) \ 253 V(PROXY_CALLABLE_MAP_INDEX, Map, proxy_callable_map) \ 254 V(PROXY_CONSTRUCTOR_MAP_INDEX, Map, proxy_constructor_map) \ 255 V(PROXY_FUNCTION_INDEX, JSFunction, proxy_function) \ 256 V(PROXY_MAP_INDEX, Map, proxy_map) \ 257 V(PROXY_REVOCABLE_RESULT_MAP_INDEX, Map, proxy_revocable_result_map) \ 258 V(PROXY_REVOKE_SHARED_FUN, SharedFunctionInfo, proxy_revoke_shared_fun) \ 259 V(PROMISE_GET_CAPABILITIES_EXECUTOR_SHARED_FUN, SharedFunctionInfo, \ 260 promise_get_capabilities_executor_shared_fun) \ 261 V(PROMISE_CAPABILITY_DEFAULT_REJECT_SHARED_FUN_INDEX, SharedFunctionInfo, \ 262 promise_capability_default_reject_shared_fun) \ 263 V(PROMISE_CAPABILITY_DEFAULT_RESOLVE_SHARED_FUN_INDEX, SharedFunctionInfo, \ 264 promise_capability_default_resolve_shared_fun) \ 265 V(PROMISE_THEN_FINALLY_SHARED_FUN, SharedFunctionInfo, \ 266 promise_then_finally_shared_fun) \ 267 V(PROMISE_CATCH_FINALLY_SHARED_FUN, SharedFunctionInfo, \ 268 promise_catch_finally_shared_fun) \ 269 V(PROMISE_VALUE_THUNK_FINALLY_SHARED_FUN, SharedFunctionInfo, \ 270 promise_value_thunk_finally_shared_fun) \ 271 V(PROMISE_THROWER_FINALLY_SHARED_FUN, SharedFunctionInfo, \ 272 promise_thrower_finally_shared_fun) \ 273 V(PROMISE_ALL_RESOLVE_ELEMENT_SHARED_FUN, SharedFunctionInfo, \ 274 promise_all_resolve_element_shared_fun) \ 275 V(PROMISE_PROTOTYPE_INDEX, JSObject, promise_prototype) \ 276 V(REGEXP_EXEC_FUNCTION_INDEX, JSFunction, regexp_exec_function) \ 277 V(REGEXP_FUNCTION_INDEX, JSFunction, regexp_function) \ 278 V(REGEXP_LAST_MATCH_INFO_INDEX, RegExpMatchInfo, regexp_last_match_info) \ 279 V(REGEXP_INTERNAL_MATCH_INFO_INDEX, RegExpMatchInfo, \ 280 regexp_internal_match_info) \ 281 V(REGEXP_PROTOTYPE_MAP_INDEX, Map, regexp_prototype_map) \ 282 V(INITIAL_REGEXP_STRING_ITERATOR_PROTOTYPE_MAP_INDEX, Map, \ 283 initial_regexp_string_iterator_prototype_map) \ 284 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map) \ 285 V(REGEXP_PROTOTYPE_INDEX, JSObject, regexp_prototype) \ 286 V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) \ 287 V(SECURITY_TOKEN_INDEX, Object, security_token) \ 288 V(SERIALIZED_OBJECTS, FixedArray, serialized_objects) \ 289 V(SET_VALUE_ITERATOR_MAP_INDEX, Map, set_value_iterator_map) \ 290 V(SET_KEY_VALUE_ITERATOR_MAP_INDEX, Map, set_key_value_iterator_map) \ 291 V(SHARED_ARRAY_BUFFER_FUN_INDEX, JSFunction, shared_array_buffer_fun) \ 292 V(SLOPPY_ARGUMENTS_MAP_INDEX, Map, sloppy_arguments_map) \ 293 V(SLOW_ALIASED_ARGUMENTS_MAP_INDEX, Map, slow_aliased_arguments_map) \ 294 V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \ 295 V(SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP, Map, \ 296 slow_object_with_null_prototype_map) \ 297 V(SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP, Map, \ 298 slow_object_with_object_prototype_map) \ 299 V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, SimpleNumberDictionary, \ 300 slow_template_instantiations_cache) \ 303 V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map) \ 304 V(SLOPPY_FUNCTION_WITH_NAME_MAP_INDEX, Map, sloppy_function_with_name_map) \ 305 V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ 306 sloppy_function_without_prototype_map) \ 307 V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \ 308 sloppy_function_with_readonly_prototype_map) \ 309 V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \ 310 V(STRICT_FUNCTION_WITH_NAME_MAP_INDEX, Map, strict_function_with_name_map) \ 311 V(STRICT_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \ 312 strict_function_with_readonly_prototype_map) \ 313 V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ 314 strict_function_without_prototype_map) \ 315 V(METHOD_WITH_NAME_MAP_INDEX, Map, method_with_name_map) \ 316 V(METHOD_WITH_HOME_OBJECT_MAP_INDEX, Map, method_with_home_object_map) \ 317 V(METHOD_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \ 318 method_with_name_and_home_object_map) \ 319 V(ASYNC_FUNCTION_MAP_INDEX, Map, async_function_map) \ 320 V(ASYNC_FUNCTION_WITH_NAME_MAP_INDEX, Map, async_function_with_name_map) \ 321 V(ASYNC_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map, \ 322 async_function_with_home_object_map) \ 323 V(ASYNC_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \ 324 async_function_with_name_and_home_object_map) \ 325 V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map) \ 326 V(GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map, \ 327 generator_function_with_name_map) \ 328 V(GENERATOR_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map, \ 329 generator_function_with_home_object_map) \ 330 V(GENERATOR_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \ 331 generator_function_with_name_and_home_object_map) \ 332 V(ASYNC_GENERATOR_FUNCTION_MAP_INDEX, Map, async_generator_function_map) \ 333 V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map, \ 334 async_generator_function_with_name_map) \ 335 V(ASYNC_GENERATOR_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map, \ 336 async_generator_function_with_home_object_map) \ 337 V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map, \ 338 async_generator_function_with_name_and_home_object_map) \ 339 V(CLASS_FUNCTION_MAP_INDEX, Map, class_function_map) \ 340 V(STRING_FUNCTION_INDEX, JSFunction, string_function) \ 341 V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \ 342 V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ 343 V(NATIVE_FUNCTION_MAP_INDEX, Map, native_function_map) \ 344 V(WASM_EXCEPTION_CONSTRUCTOR_INDEX, JSFunction, wasm_exception_constructor) \ 345 V(WASM_GLOBAL_CONSTRUCTOR_INDEX, JSFunction, wasm_global_constructor) \ 346 V(WASM_INSTANCE_CONSTRUCTOR_INDEX, JSFunction, wasm_instance_constructor) \ 347 V(WASM_MEMORY_CONSTRUCTOR_INDEX, JSFunction, wasm_memory_constructor) \ 348 V(WASM_MODULE_CONSTRUCTOR_INDEX, JSFunction, wasm_module_constructor) \ 349 V(WASM_TABLE_CONSTRUCTOR_INDEX, JSFunction, wasm_table_constructor) \ 350 V(TYPED_ARRAY_FUN_INDEX, JSFunction, typed_array_function) \ 351 V(TYPED_ARRAY_PROTOTYPE_INDEX, JSObject, typed_array_prototype) \ 352 V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \ 353 V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ 354 V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \ 355 V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ 356 NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ 357 NATIVE_CONTEXT_IMPORTED_FIELDS(V) 372 InitializationFlag init_flag;
373 MaybeAssignedFlag maybe_assigned_flag;
376 inline int used()
const;
377 inline void set_used(
int used);
387 V8_WARN_UNUSED_RESULT
391 V8_WARN_UNUSED_RESULT
395 static const int kUsedSlotIndex = 0;
396 static const int kFirstContextSlotIndex = 1;
397 static const int kMinLength = kFirstContextSlotIndex;
449 NEVER_READ_ONLY_SPACE
454 V8_INLINE
int length()
const;
455 V8_INLINE
void set_length(
int value);
458 V8_INLINE
Object*
get(
int index)
const;
459 V8_INLINE
void set(
int index,
Object* value);
461 V8_INLINE
void set(
int index,
Object* value, WriteBarrierMode mode);
464 #define CONTEXT_FIELDS(V) \ 465 V(kLengthOffset, kTaggedSize) \ 468 V(kStartOfTaggedFieldsOffset, 0) \ 469 V(kStartOfStrongFieldsOffset, 0) \ 471 V(kScopeInfoOffset, kTaggedSize) \ 472 V(kPreviousOffset, kTaggedSize) \ 473 V(kExtensionOffset, kTaggedSize) \ 474 V(kNativeContextOffset, kTaggedSize) \ 478 V(kTodoHeaderSize, 0) 480 DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, CONTEXT_FIELDS)
481 #undef CONTEXT_FIELDS 484 V8_INLINE
static constexpr
int SizeFor(
int length) {
487 return kHeaderSize + length * kTaggedSize;
492 V8_INLINE
static constexpr
int OffsetOfElementAt(
int index) {
493 return SizeFor(index);
496 V8_INLINE
static constexpr
int SlotOffset(
int index) {
497 return SizeFor(index) - kHeapObjectTag;
509 NATIVE_CONTEXT_INDEX,
512 #define NATIVE_CONTEXT_SLOT(index, type, name) index, 513 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_SLOT)
514 #undef NATIVE_CONTEXT_SLOT 519 DEOPTIMIZED_CODE_LIST,
523 NATIVE_CONTEXT_SLOTS,
524 FIRST_WEAK_SLOT = OPTIMIZED_CODE_LIST,
525 FIRST_JS_ARRAY_MAP_SLOT = JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX,
528 MIN_CONTEXT_SLOTS = GLOBAL_PROXY_INDEX,
531 THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS,
534 WRAPPED_CONTEXT_INDEX = MIN_CONTEXT_SLOTS,
535 WHITE_LIST_INDEX = MIN_CONTEXT_SLOTS + 1
540 static const int FIRST_FUNCTION_MAP_INDEX = SLOPPY_FUNCTION_MAP_INDEX;
541 static const int LAST_FUNCTION_MAP_INDEX = CLASS_FUNCTION_MAP_INDEX;
543 static const int kNoContext = 0;
544 static const int kInvalidContext = 1;
546 void ResetErrorsThrown();
547 void IncrementErrorsThrown();
548 int GetErrorsThrown();
551 inline void set_scope_info(
ScopeInfo scope_info);
553 inline void set_previous(
Context context);
555 inline Object* next_context_link();
557 inline bool has_extension();
559 inline void set_extension(
HeapObject*
object);
571 bool is_declaration_context();
592 inline bool IsFunctionContext()
const;
593 inline bool IsCatchContext()
const;
594 inline bool IsWithContext()
const;
595 inline bool IsDebugEvaluateContext()
const;
596 inline bool IsAwaitContext()
const;
597 inline bool IsBlockContext()
const;
598 inline bool IsModuleContext()
const;
599 inline bool IsEvalContext()
const;
600 inline bool IsScriptContext()
const;
602 inline bool HasSameSecurityTokenAs(
Context that)
const;
606 void AddOptimizedCode(
Code code);
607 void SetOptimizedCodeListHead(
Object* head);
608 Object* OptimizedCodeListHead();
609 void SetDeoptimizedCodeListHead(
Object* head);
610 Object* DeoptimizedCodeListHead();
616 static int IntrinsicIndexForName(
const unsigned char* name,
int length);
618 #define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \ 619 inline void set_##name(type##ArgType value); \ 620 inline bool is_##name(type##ArgType value) const; \ 621 inline type##ArgType name() const; 622 NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS)
623 #undef NATIVE_CONTEXT_FIELD_ACCESSORS 647 int* index, PropertyAttributes* attributes,
648 InitializationFlag* init_flag,
649 VariableMode* variable_mode,
650 bool* is_sloppy_function_name =
nullptr);
652 static inline int FunctionMapIndex(LanguageMode language_mode,
653 FunctionKind kind,
bool has_prototype_slot,
654 bool has_shared_name,
655 bool needs_home_object);
657 static int ArrayMapIndex(ElementsKind elements_kind) {
658 DCHECK(IsFastElementsKind(elements_kind));
659 return elements_kind + FIRST_JS_ARRAY_MAP_SLOT;
662 inline Map GetInitialJSArrayMap(ElementsKind kind)
const;
664 static const int kNotFound = -1;
675 V8_EXPORT_PRIVATE
static bool IsBootstrappingOrNativeContext(
Isolate* isolate,
677 static bool IsBootstrappingOrValidParentContext(
Object*
object,
Context kid);
696 #define NATIVE_CONTEXT_FIELDS_DEF(V) \ 698 V(kStartOfNativeContextFieldsOffset, \ 699 (FIRST_WEAK_SLOT - MIN_CONTEXT_SLOTS) * kTaggedSize) \ 700 V(kEndOfStrongFieldsOffset, 0) \ 701 V(kStartOfWeakFieldsOffset, \ 702 (NATIVE_CONTEXT_SLOTS - FIRST_WEAK_SLOT) * kTaggedSize) \ 703 V(kEndOfWeakFieldsOffset, 0) \ 704 V(kEndOfNativeContextFieldsOffset, 0) \ 705 V(kEndOfTaggedFieldsOffset, 0) \ 707 V(kMicrotaskQueueOffset, kSystemPointerSize) \ 711 DEFINE_FIELD_OFFSET_CONSTANTS(Context::kTodoHeaderSize,
712 NATIVE_CONTEXT_FIELDS_DEF)
713 #undef NATIVE_CONTEXT_FIELDS_DEF 718 STATIC_ASSERT(OffsetOfElementAt(EMBEDDER_DATA_INDEX) ==
719 Internals::kNativeContextEmbedderDataOffset);
724 typedef Context::Field ContextField;
729 #include "src/objects/object-macros-undef.h" 731 #endif // V8_CONTEXTS_H_