| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \ | 158 V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \ |
| 159 error_message_for_code_gen_from_strings) \ | 159 error_message_for_code_gen_from_strings) \ |
| 160 V(TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX, JSFunction, \ | 160 V(TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX, JSFunction, \ |
| 161 to_complete_property_descriptor) \ | 161 to_complete_property_descriptor) \ |
| 162 V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \ | 162 V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \ |
| 163 V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \ | 163 V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \ |
| 164 V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap) \ | 164 V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap) \ |
| 165 V(PROXY_ENUMERATE_INDEX, JSFunction, proxy_enumerate) \ | 165 V(PROXY_ENUMERATE_INDEX, JSFunction, proxy_enumerate) \ |
| 166 V(OBSERVERS_NOTIFY_CHANGE_INDEX, JSFunction, observers_notify_change) \ | 166 V(OBSERVERS_NOTIFY_CHANGE_INDEX, JSFunction, observers_notify_change) \ |
| 167 V(OBSERVERS_DELIVER_CHANGES_INDEX, JSFunction, observers_deliver_changes) \ | 167 V(OBSERVERS_DELIVER_CHANGES_INDEX, JSFunction, observers_deliver_changes) \ |
| 168 V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map) \ |
| 169 V(STRICT_MODE_GENERATOR_FUNCTION_MAP_INDEX, Map, \ |
| 170 strict_mode_generator_function_map) \ |
| 171 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, \ |
| 172 generator_object_prototype_map) \ |
| 168 V(RANDOM_SEED_INDEX, ByteArray, random_seed) | 173 V(RANDOM_SEED_INDEX, ByteArray, random_seed) |
| 169 | 174 |
| 170 // JSFunctions are pairs (context, function code), sometimes also called | 175 // JSFunctions are pairs (context, function code), sometimes also called |
| 171 // closures. A Context object is used to represent function contexts and | 176 // closures. A Context object is used to represent function contexts and |
| 172 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). | 177 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). |
| 173 // | 178 // |
| 174 // At runtime, the contexts build a stack in parallel to the execution | 179 // At runtime, the contexts build a stack in parallel to the execution |
| 175 // stack, with the top-most context being the current context. All contexts | 180 // stack, with the top-most context being the current context. All contexts |
| 176 // have the following slots: | 181 // have the following slots: |
| 177 // | 182 // |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 EMBEDDER_DATA_INDEX, | 293 EMBEDDER_DATA_INDEX, |
| 289 ALLOW_CODE_GEN_FROM_STRINGS_INDEX, | 294 ALLOW_CODE_GEN_FROM_STRINGS_INDEX, |
| 290 ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, | 295 ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, |
| 291 TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX, | 296 TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX, |
| 292 DERIVED_HAS_TRAP_INDEX, | 297 DERIVED_HAS_TRAP_INDEX, |
| 293 DERIVED_GET_TRAP_INDEX, | 298 DERIVED_GET_TRAP_INDEX, |
| 294 DERIVED_SET_TRAP_INDEX, | 299 DERIVED_SET_TRAP_INDEX, |
| 295 PROXY_ENUMERATE_INDEX, | 300 PROXY_ENUMERATE_INDEX, |
| 296 OBSERVERS_NOTIFY_CHANGE_INDEX, | 301 OBSERVERS_NOTIFY_CHANGE_INDEX, |
| 297 OBSERVERS_DELIVER_CHANGES_INDEX, | 302 OBSERVERS_DELIVER_CHANGES_INDEX, |
| 303 GENERATOR_FUNCTION_MAP_INDEX, |
| 304 STRICT_MODE_GENERATOR_FUNCTION_MAP_INDEX, |
| 305 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, |
| 298 RANDOM_SEED_INDEX, | 306 RANDOM_SEED_INDEX, |
| 299 | 307 |
| 300 // Properties from here are treated as weak references by the full GC. | 308 // Properties from here are treated as weak references by the full GC. |
| 301 // Scavenge treats them as strong references. | 309 // Scavenge treats them as strong references. |
| 302 OPTIMIZED_FUNCTIONS_LIST, // Weak. | 310 OPTIMIZED_FUNCTIONS_LIST, // Weak. |
| 303 MAP_CACHE_INDEX, // Weak. | 311 MAP_CACHE_INDEX, // Weak. |
| 304 NEXT_CONTEXT_LINK, // Weak. | 312 NEXT_CONTEXT_LINK, // Weak. |
| 305 | 313 |
| 306 // Total number of slots. | 314 // Total number of slots. |
| 307 NATIVE_CONTEXT_SLOTS, | 315 NATIVE_CONTEXT_SLOTS, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 ContextLookupFlags flags, | 440 ContextLookupFlags flags, |
| 433 int* index, | 441 int* index, |
| 434 PropertyAttributes* attributes, | 442 PropertyAttributes* attributes, |
| 435 BindingFlags* binding_flags); | 443 BindingFlags* binding_flags); |
| 436 | 444 |
| 437 // Code generation support. | 445 // Code generation support. |
| 438 static int SlotOffset(int index) { | 446 static int SlotOffset(int index) { |
| 439 return kHeaderSize + index * kPointerSize - kHeapObjectTag; | 447 return kHeaderSize + index * kPointerSize - kHeapObjectTag; |
| 440 } | 448 } |
| 441 | 449 |
| 450 static int FunctionMapIndex(LanguageMode language_mode, bool is_generator) { |
| 451 return is_generator |
| 452 ? (language_mode == CLASSIC_MODE |
| 453 ? GENERATOR_FUNCTION_MAP_INDEX |
| 454 : STRICT_MODE_GENERATOR_FUNCTION_MAP_INDEX) |
| 455 : (language_mode == CLASSIC_MODE |
| 456 ? FUNCTION_MAP_INDEX |
| 457 : STRICT_MODE_FUNCTION_MAP_INDEX); |
| 458 } |
| 459 |
| 442 static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize; | 460 static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize; |
| 443 | 461 |
| 444 // GC support. | 462 // GC support. |
| 445 typedef FixedBodyDescriptor< | 463 typedef FixedBodyDescriptor< |
| 446 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; | 464 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; |
| 447 | 465 |
| 448 typedef FixedBodyDescriptor< | 466 typedef FixedBodyDescriptor< |
| 449 kHeaderSize, | 467 kHeaderSize, |
| 450 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, | 468 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, |
| 451 kSize> MarkCompactBodyDescriptor; | 469 kSize> MarkCompactBodyDescriptor; |
| 452 | 470 |
| 453 private: | 471 private: |
| 454 // Unchecked access to the slots. | 472 // Unchecked access to the slots. |
| 455 Object* unchecked_previous() { return get(PREVIOUS_INDEX); } | 473 Object* unchecked_previous() { return get(PREVIOUS_INDEX); } |
| 456 | 474 |
| 457 #ifdef DEBUG | 475 #ifdef DEBUG |
| 458 // Bootstrapping-aware type checks. | 476 // Bootstrapping-aware type checks. |
| 459 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); | 477 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); |
| 460 static bool IsBootstrappingOrGlobalObject(Object* object); | 478 static bool IsBootstrappingOrGlobalObject(Object* object); |
| 461 #endif | 479 #endif |
| 462 | 480 |
| 463 STATIC_CHECK(kHeaderSize == Internals::kContextHeaderSize); | 481 STATIC_CHECK(kHeaderSize == Internals::kContextHeaderSize); |
| 464 STATIC_CHECK(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); | 482 STATIC_CHECK(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
| 465 }; | 483 }; |
| 466 | 484 |
| 467 } } // namespace v8::internal | 485 } } // namespace v8::internal |
| 468 | 486 |
| 469 #endif // V8_CONTEXTS_H_ | 487 #endif // V8_CONTEXTS_H_ |
| OLD | NEW |