| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_CONTEXTS_H_ | 5 #ifndef V8_CONTEXTS_H_ |
| 6 #define V8_CONTEXTS_H_ | 6 #define V8_CONTEXTS_H_ |
| 7 | 7 |
| 8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 js_array_fast_smi_elements_map_index) \ | 204 js_array_fast_smi_elements_map_index) \ |
| 205 V(JS_ARRAY_FAST_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map, \ | 205 V(JS_ARRAY_FAST_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map, \ |
| 206 js_array_fast_holey_smi_elements_map_index) \ | 206 js_array_fast_holey_smi_elements_map_index) \ |
| 207 V(JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, Map, js_array_fast_elements_map_index) \ | 207 V(JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, Map, js_array_fast_elements_map_index) \ |
| 208 V(JS_ARRAY_FAST_HOLEY_ELEMENTS_MAP_INDEX, Map, \ | 208 V(JS_ARRAY_FAST_HOLEY_ELEMENTS_MAP_INDEX, Map, \ |
| 209 js_array_fast_holey_elements_map_index) \ | 209 js_array_fast_holey_elements_map_index) \ |
| 210 V(JS_ARRAY_FAST_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ | 210 V(JS_ARRAY_FAST_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ |
| 211 js_array_fast_double_elements_map_index) \ | 211 js_array_fast_double_elements_map_index) \ |
| 212 V(JS_ARRAY_FAST_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ | 212 V(JS_ARRAY_FAST_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX, Map, \ |
| 213 js_array_fast_holey_double_elements_map_index) \ | 213 js_array_fast_holey_double_elements_map_index) \ |
| 214 V(JS_ARRAY_FAST_SMI_ELEMENTS_STRONG_MAP_INDEX, Map, \ | |
| 215 js_array_fast_smi_elements_strong_map_index) \ | |
| 216 V(JS_ARRAY_FAST_HOLEY_SMI_ELEMENTS_STRONG_MAP_INDEX, Map, \ | |
| 217 js_array_fast_holey_smi_elements_strong_map_index) \ | |
| 218 V(JS_ARRAY_FAST_ELEMENTS_STRONG_MAP_INDEX, Map, \ | |
| 219 js_array_fast_elements_strong_map_index) \ | |
| 220 V(JS_ARRAY_FAST_HOLEY_ELEMENTS_STRONG_MAP_INDEX, Map, \ | |
| 221 js_array_fast_holey_elements_strong_map_index) \ | |
| 222 V(JS_ARRAY_FAST_DOUBLE_ELEMENTS_STRONG_MAP_INDEX, Map, \ | |
| 223 js_array_fast_double_elements_strong_map_index) \ | |
| 224 V(JS_ARRAY_FAST_HOLEY_DOUBLE_ELEMENTS_STRONG_MAP_INDEX, Map, \ | |
| 225 js_array_fast_holey_double_elements_strong_map_index) \ | |
| 226 V(JS_MAP_FUN_INDEX, JSFunction, js_map_fun) \ | 214 V(JS_MAP_FUN_INDEX, JSFunction, js_map_fun) \ |
| 227 V(JS_MAP_MAP_INDEX, Map, js_map_map) \ | 215 V(JS_MAP_MAP_INDEX, Map, js_map_map) \ |
| 228 V(JS_OBJECT_STRONG_MAP_INDEX, Map, js_object_strong_map) \ | |
| 229 V(JS_SET_FUN_INDEX, JSFunction, js_set_fun) \ | 216 V(JS_SET_FUN_INDEX, JSFunction, js_set_fun) \ |
| 230 V(JS_SET_MAP_INDEX, Map, js_set_map) \ | 217 V(JS_SET_MAP_INDEX, Map, js_set_map) \ |
| 231 V(JS_WEAK_MAP_FUN_INDEX, JSFunction, js_weak_map_fun) \ | 218 V(JS_WEAK_MAP_FUN_INDEX, JSFunction, js_weak_map_fun) \ |
| 232 V(JS_WEAK_SET_FUN_INDEX, JSFunction, js_weak_set_fun) \ | 219 V(JS_WEAK_SET_FUN_INDEX, JSFunction, js_weak_set_fun) \ |
| 233 V(MAP_CACHE_INDEX, Object, map_cache) \ | 220 V(MAP_CACHE_INDEX, Object, map_cache) \ |
| 234 V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \ | 221 V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \ |
| 235 V(STRING_ITERATOR_MAP_INDEX, Map, string_iterator_map) \ | 222 V(STRING_ITERATOR_MAP_INDEX, Map, string_iterator_map) \ |
| 236 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \ | 223 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \ |
| 237 V(NATIVES_UTILS_OBJECT_INDEX, Object, natives_utils_object) \ | 224 V(NATIVES_UTILS_OBJECT_INDEX, Object, natives_utils_object) \ |
| 238 V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \ | 225 V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 262 V(WASM_FUNCTION_MAP_INDEX, Map, wasm_function_map) \ | 249 V(WASM_FUNCTION_MAP_INDEX, Map, wasm_function_map) \ |
| 263 V(SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, Map, sloppy_generator_function_map) \ | 250 V(SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, Map, sloppy_generator_function_map) \ |
| 264 V(SLOW_ALIASED_ARGUMENTS_MAP_INDEX, Map, slow_aliased_arguments_map) \ | 251 V(SLOW_ALIASED_ARGUMENTS_MAP_INDEX, Map, slow_aliased_arguments_map) \ |
| 265 V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \ | 252 V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map) \ |
| 266 V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \ | 253 V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \ |
| 267 V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ | 254 V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ |
| 268 strict_function_without_prototype_map) \ | 255 strict_function_without_prototype_map) \ |
| 269 V(STRICT_GENERATOR_FUNCTION_MAP_INDEX, Map, strict_generator_function_map) \ | 256 V(STRICT_GENERATOR_FUNCTION_MAP_INDEX, Map, strict_generator_function_map) \ |
| 270 V(STRING_FUNCTION_INDEX, JSFunction, string_function) \ | 257 V(STRING_FUNCTION_INDEX, JSFunction, string_function) \ |
| 271 V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \ | 258 V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \ |
| 272 V(STRONG_CONSTRUCTOR_MAP_INDEX, Map, strong_constructor_map) \ | |
| 273 V(STRONG_FUNCTION_MAP_INDEX, Map, strong_function_map) \ | |
| 274 V(STRONG_GENERATOR_FUNCTION_MAP_INDEX, Map, strong_generator_function_map) \ | |
| 275 V(STRONG_MAP_CACHE_INDEX, Object, strong_map_cache) \ | |
| 276 V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ | 259 V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ |
| 277 V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \ | 260 V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \ |
| 278 V(UINT16X8_FUNCTION_INDEX, JSFunction, uint16x8_function) \ | 261 V(UINT16X8_FUNCTION_INDEX, JSFunction, uint16x8_function) \ |
| 279 V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ | 262 V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ |
| 280 V(UINT32X4_FUNCTION_INDEX, JSFunction, uint32x4_function) \ | 263 V(UINT32X4_FUNCTION_INDEX, JSFunction, uint32x4_function) \ |
| 281 V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \ | 264 V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \ |
| 282 V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ | 265 V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ |
| 283 V(UINT8X16_FUNCTION_INDEX, JSFunction, uint8x16_function) \ | 266 V(UINT8X16_FUNCTION_INDEX, JSFunction, uint8x16_function) \ |
| 284 NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ | 267 NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ |
| 285 NATIVE_CONTEXT_IMPORTED_FIELDS(V) | 268 NATIVE_CONTEXT_IMPORTED_FIELDS(V) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // Scavenge treats them as strong references. | 392 // Scavenge treats them as strong references. |
| 410 OPTIMIZED_FUNCTIONS_LIST, // Weak. | 393 OPTIMIZED_FUNCTIONS_LIST, // Weak. |
| 411 OPTIMIZED_CODE_LIST, // Weak. | 394 OPTIMIZED_CODE_LIST, // Weak. |
| 412 DEOPTIMIZED_CODE_LIST, // Weak. | 395 DEOPTIMIZED_CODE_LIST, // Weak. |
| 413 NEXT_CONTEXT_LINK, // Weak. | 396 NEXT_CONTEXT_LINK, // Weak. |
| 414 | 397 |
| 415 // Total number of slots. | 398 // Total number of slots. |
| 416 NATIVE_CONTEXT_SLOTS, | 399 NATIVE_CONTEXT_SLOTS, |
| 417 FIRST_WEAK_SLOT = OPTIMIZED_FUNCTIONS_LIST, | 400 FIRST_WEAK_SLOT = OPTIMIZED_FUNCTIONS_LIST, |
| 418 FIRST_JS_ARRAY_MAP_SLOT = JS_ARRAY_FAST_SMI_ELEMENTS_MAP_INDEX, | 401 FIRST_JS_ARRAY_MAP_SLOT = JS_ARRAY_FAST_SMI_ELEMENTS_MAP_INDEX, |
| 419 FIRST_JS_ARRAY_STRONG_MAP_SLOT = | |
| 420 JS_ARRAY_FAST_SMI_ELEMENTS_STRONG_MAP_INDEX, | |
| 421 | 402 |
| 422 MIN_CONTEXT_SLOTS = GLOBAL_PROXY_INDEX, | 403 MIN_CONTEXT_SLOTS = GLOBAL_PROXY_INDEX, |
| 423 // This slot holds the thrown value in catch contexts. | 404 // This slot holds the thrown value in catch contexts. |
| 424 THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS, | 405 THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS, |
| 425 }; | 406 }; |
| 426 | 407 |
| 427 void IncrementErrorsThrown(); | 408 void IncrementErrorsThrown(); |
| 428 int GetErrorsThrown(); | 409 int GetErrorsThrown(); |
| 429 | 410 |
| 430 // Direct slot access. | 411 // Direct slot access. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 PropertyAttributes* attributes, | 513 PropertyAttributes* attributes, |
| 533 BindingFlags* binding_flags); | 514 BindingFlags* binding_flags); |
| 534 | 515 |
| 535 // Code generation support. | 516 // Code generation support. |
| 536 static int SlotOffset(int index) { | 517 static int SlotOffset(int index) { |
| 537 return kHeaderSize + index * kPointerSize - kHeapObjectTag; | 518 return kHeaderSize + index * kPointerSize - kHeapObjectTag; |
| 538 } | 519 } |
| 539 | 520 |
| 540 static int FunctionMapIndex(LanguageMode language_mode, FunctionKind kind) { | 521 static int FunctionMapIndex(LanguageMode language_mode, FunctionKind kind) { |
| 541 if (IsGeneratorFunction(kind)) { | 522 if (IsGeneratorFunction(kind)) { |
| 542 return is_strong(language_mode) ? STRONG_GENERATOR_FUNCTION_MAP_INDEX : | 523 return is_strict(language_mode) ? STRICT_GENERATOR_FUNCTION_MAP_INDEX |
| 543 is_strict(language_mode) ? STRICT_GENERATOR_FUNCTION_MAP_INDEX | |
| 544 : SLOPPY_GENERATOR_FUNCTION_MAP_INDEX; | 524 : SLOPPY_GENERATOR_FUNCTION_MAP_INDEX; |
| 545 } | 525 } |
| 546 | 526 |
| 547 if (IsClassConstructor(kind)) { | 527 if (IsClassConstructor(kind)) { |
| 548 // Use strict function map (no own "caller" / "arguments") | 528 // Use strict function map (no own "caller" / "arguments") |
| 549 return is_strong(language_mode) ? STRONG_CONSTRUCTOR_MAP_INDEX | 529 return STRICT_FUNCTION_MAP_INDEX; |
| 550 : STRICT_FUNCTION_MAP_INDEX; | |
| 551 } | 530 } |
| 552 | 531 |
| 553 if (IsArrowFunction(kind) || IsConciseMethod(kind) || | 532 if (IsArrowFunction(kind) || IsConciseMethod(kind) || |
| 554 IsAccessorFunction(kind)) { | 533 IsAccessorFunction(kind)) { |
| 555 return is_strong(language_mode) | 534 return STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX; |
| 556 ? STRONG_FUNCTION_MAP_INDEX | |
| 557 : STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX; | |
| 558 } | 535 } |
| 559 | 536 |
| 560 return is_strong(language_mode) ? STRONG_FUNCTION_MAP_INDEX : | 537 return is_strict(language_mode) ? STRICT_FUNCTION_MAP_INDEX |
| 561 is_strict(language_mode) ? STRICT_FUNCTION_MAP_INDEX | |
| 562 : SLOPPY_FUNCTION_MAP_INDEX; | 538 : SLOPPY_FUNCTION_MAP_INDEX; |
| 563 } | 539 } |
| 564 | 540 |
| 565 static int ArrayMapIndex(ElementsKind elements_kind, | 541 static int ArrayMapIndex(ElementsKind elements_kind) { |
| 566 Strength strength = Strength::WEAK) { | |
| 567 DCHECK(IsFastElementsKind(elements_kind)); | 542 DCHECK(IsFastElementsKind(elements_kind)); |
| 568 return elements_kind + (is_strong(strength) ? FIRST_JS_ARRAY_STRONG_MAP_SLOT | 543 return elements_kind + FIRST_JS_ARRAY_MAP_SLOT; |
| 569 : FIRST_JS_ARRAY_MAP_SLOT); | |
| 570 } | 544 } |
| 571 | 545 |
| 572 static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize; | 546 static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize; |
| 573 static const int kNotFound = -1; | 547 static const int kNotFound = -1; |
| 574 | 548 |
| 575 // GC support. | 549 // GC support. |
| 576 typedef FixedBodyDescriptor< | 550 typedef FixedBodyDescriptor< |
| 577 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; | 551 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; |
| 578 | 552 |
| 579 typedef FixedBodyDescriptor< | 553 typedef FixedBodyDescriptor< |
| 580 kHeaderSize, | 554 kHeaderSize, |
| 581 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, | 555 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, |
| 582 kSize> MarkCompactBodyDescriptor; | 556 kSize> MarkCompactBodyDescriptor; |
| 583 | 557 |
| 584 private: | 558 private: |
| 585 #ifdef DEBUG | 559 #ifdef DEBUG |
| 586 // Bootstrapping-aware type checks. | 560 // Bootstrapping-aware type checks. |
| 587 static bool IsBootstrappingOrNativeContext(Isolate* isolate, Object* object); | 561 static bool IsBootstrappingOrNativeContext(Isolate* isolate, Object* object); |
| 588 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); | 562 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); |
| 589 #endif | 563 #endif |
| 590 | 564 |
| 591 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); | 565 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); |
| 592 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); | 566 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
| 593 }; | 567 }; |
| 594 | 568 |
| 595 } // namespace internal | 569 } // namespace internal |
| 596 } // namespace v8 | 570 } // namespace v8 |
| 597 | 571 |
| 598 #endif // V8_CONTEXTS_H_ | 572 #endif // V8_CONTEXTS_H_ |
| OLD | NEW |