Chromium Code Reviews| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 V(NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, JSFunction, \ | 176 V(NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, JSFunction, \ |
| 177 native_object_notifier_perform_change) \ | 177 native_object_notifier_perform_change) \ |
| 178 V(SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, Map, sloppy_generator_function_map) \ | 178 V(SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, Map, sloppy_generator_function_map) \ |
| 179 V(STRICT_GENERATOR_FUNCTION_MAP_INDEX, Map, strict_generator_function_map) \ | 179 V(STRICT_GENERATOR_FUNCTION_MAP_INDEX, Map, strict_generator_function_map) \ |
| 180 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \ | 180 V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \ |
| 181 V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \ | 181 V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \ |
| 182 V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \ | 182 V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \ |
| 183 V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \ | 183 V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \ |
| 184 V(ITERATOR_SYMBOL_INDEX, Symbol, iterator_symbol) \ | 184 V(ITERATOR_SYMBOL_INDEX, Symbol, iterator_symbol) \ |
| 185 V(UNSCOPABLES_SYMBOL_INDEX, Symbol, unscopables_symbol) \ | 185 V(UNSCOPABLES_SYMBOL_INDEX, Symbol, unscopables_symbol) \ |
| 186 V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) | 186 V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ |
| 187 V(GLOBAL_CONTEXT_TABLE_INDEX, GlobalContextTable, global_context_table) | |
| 188 | |
| 189 | |
| 190 class GlobalContextTable : public FixedArray { | |
| 191 public: | |
| 192 // Conversions. | |
| 193 static GlobalContextTable* cast(Object* context) { | |
| 194 DCHECK(context->IsGlobalContextTable()); | |
| 195 return reinterpret_cast<GlobalContextTable*>(context); | |
| 196 } | |
| 197 | |
| 198 struct LookupResult { | |
| 199 int context_index_; | |
|
rossberg
2014/11/06 12:29:12
Nit: public data fields don't have a trailing "_".
Dmitry Lomov (no reviews)
2014/11/06 17:26:58
Done.
| |
| 200 int slot_index_; | |
| 201 VariableMode mode_; | |
| 202 InitializationFlag init_flag_; | |
| 203 MaybeAssignedFlag maybe_assigned_flag_; | |
|
rossberg
2014/11/06 12:29:12
Do we actually need the two flags for the global c
Dmitry Lomov (no reviews)
2014/11/06 17:26:58
They are used in Context::Lookup.
| |
| 204 }; | |
| 205 | |
| 206 int size() const { return length() - 1; } | |
| 207 | |
| 208 static Handle<Context> GetContext(Handle<GlobalContextTable> table, int i) { | |
| 209 return Handle<Context>::cast(FixedArray::get(table, i)); | |
| 210 } | |
| 211 | |
| 212 static bool Lookup(Handle<GlobalContextTable> table, Handle<String> name, | |
| 213 LookupResult* result); | |
| 214 | |
| 215 // table may be null. | |
| 216 static Handle<GlobalContextTable> Extend(Handle<GlobalContextTable> table, | |
| 217 Handle<Context> global_context); | |
| 218 }; | |
| 187 | 219 |
| 188 // JSFunctions are pairs (context, function code), sometimes also called | 220 // JSFunctions are pairs (context, function code), sometimes also called |
| 189 // closures. A Context object is used to represent function contexts and | 221 // closures. A Context object is used to represent function contexts and |
| 190 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). | 222 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). |
| 191 // | 223 // |
| 192 // At runtime, the contexts build a stack in parallel to the execution | 224 // At runtime, the contexts build a stack in parallel to the execution |
| 193 // stack, with the top-most context being the current context. All contexts | 225 // stack, with the top-most context being the current context. All contexts |
| 194 // have the following slots: | 226 // have the following slots: |
| 195 // | 227 // |
| 196 // [ closure ] This is the current function. It is the same for all | 228 // [ closure ] This is the current function. It is the same for all |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, | 385 NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, |
| 354 SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, | 386 SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, |
| 355 STRICT_GENERATOR_FUNCTION_MAP_INDEX, | 387 STRICT_GENERATOR_FUNCTION_MAP_INDEX, |
| 356 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, | 388 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, |
| 357 ITERATOR_RESULT_MAP_INDEX, | 389 ITERATOR_RESULT_MAP_INDEX, |
| 358 MAP_ITERATOR_MAP_INDEX, | 390 MAP_ITERATOR_MAP_INDEX, |
| 359 SET_ITERATOR_MAP_INDEX, | 391 SET_ITERATOR_MAP_INDEX, |
| 360 ITERATOR_SYMBOL_INDEX, | 392 ITERATOR_SYMBOL_INDEX, |
| 361 UNSCOPABLES_SYMBOL_INDEX, | 393 UNSCOPABLES_SYMBOL_INDEX, |
| 362 ARRAY_VALUES_ITERATOR_INDEX, | 394 ARRAY_VALUES_ITERATOR_INDEX, |
| 395 GLOBAL_CONTEXT_TABLE_INDEX, | |
| 363 | 396 |
| 364 // Properties from here are treated as weak references by the full GC. | 397 // Properties from here are treated as weak references by the full GC. |
| 365 // Scavenge treats them as strong references. | 398 // Scavenge treats them as strong references. |
| 366 OPTIMIZED_FUNCTIONS_LIST, // Weak. | 399 OPTIMIZED_FUNCTIONS_LIST, // Weak. |
| 367 OPTIMIZED_CODE_LIST, // Weak. | 400 OPTIMIZED_CODE_LIST, // Weak. |
| 368 DEOPTIMIZED_CODE_LIST, // Weak. | 401 DEOPTIMIZED_CODE_LIST, // Weak. |
| 369 MAP_CACHE_INDEX, // Weak. | 402 MAP_CACHE_INDEX, // Weak. |
| 370 NEXT_CONTEXT_LINK, // Weak. | 403 NEXT_CONTEXT_LINK, // Weak. |
| 371 | 404 |
| 372 // Total number of slots. | 405 // Total number of slots. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 | 581 |
| 549 #ifdef DEBUG | 582 #ifdef DEBUG |
| 550 // Bootstrapping-aware type checks. | 583 // Bootstrapping-aware type checks. |
| 551 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); | 584 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); |
| 552 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object); | 585 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object); |
| 553 #endif | 586 #endif |
| 554 | 587 |
| 555 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); | 588 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); |
| 556 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); | 589 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
| 557 }; | 590 }; |
| 558 | |
| 559 } } // namespace v8::internal | 591 } } // namespace v8::internal |
| 560 | 592 |
| 561 #endif // V8_CONTEXTS_H_ | 593 #endif // V8_CONTEXTS_H_ |
| OLD | NEW |