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 { | |
|
adamk
2014/11/06 20:18:06
Please add a comment for this class. What is it fo
Dmitry Lomov (no reviews)
2014/11/07 10:18:48
Done.
| |
| 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; | |
| 200 int slot_index; | |
| 201 VariableMode mode; | |
| 202 InitializationFlag init_flag; | |
| 203 MaybeAssignedFlag maybe_assigned_flag; | |
| 204 }; | |
| 205 | |
| 206 int size() const { return Smi::cast(get(kSizeSlot))->value(); } | |
|
adamk
2014/11/06 20:18:05
Just a question: are const methods that common? I
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Make methods 'const' if possible is the parctice
| |
| 207 | |
| 208 static Handle<Context> GetContext(Handle<GlobalContextTable> table, int i) { | |
| 209 DCHECK(i < table->size()); | |
| 210 return Handle<Context>::cast(FixedArray::get(table, i + 1)); | |
|
adamk
2014/11/06 20:18:06
This and the various other +1s in the .cc file mig
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Yes, I think it is too much fuss.
| |
| 211 } | |
| 212 | |
| 213 static bool Lookup(Handle<GlobalContextTable> table, Handle<String> name, | |
|
adamk
2014/11/06 20:18:06
This method could use a comment, at least for the
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Done.
| |
| 214 LookupResult* result); | |
| 215 | |
| 216 // table may be null. | |
|
adamk
2014/11/06 20:18:05
Not clear what this means, it certainly can't be a
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Stray comment, removed.
| |
| 217 static Handle<GlobalContextTable> Extend(Handle<GlobalContextTable> table, | |
|
adamk
2014/11/06 20:18:05
MUST_USE_RESULT?
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Done.
| |
| 218 Handle<Context> global_context); | |
| 219 | |
| 220 private: | |
| 221 static const int kSizeSlot = 0; | |
| 222 }; | |
|
adamk
2014/11/06 20:18:05
nit: DISALLOW_IMPLICIT_CONSTRUCTORS
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Done.
| |
| 187 | 223 |
| 188 // JSFunctions are pairs (context, function code), sometimes also called | 224 // JSFunctions are pairs (context, function code), sometimes also called |
| 189 // closures. A Context object is used to represent function contexts and | 225 // closures. A Context object is used to represent function contexts and |
| 190 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). | 226 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). |
| 191 // | 227 // |
| 192 // At runtime, the contexts build a stack in parallel to the execution | 228 // 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 | 229 // stack, with the top-most context being the current context. All contexts |
| 194 // have the following slots: | 230 // have the following slots: |
| 195 // | 231 // |
| 196 // [ closure ] This is the current function. It is the same for all | 232 // [ 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, | 389 NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE, |
| 354 SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, | 390 SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, |
| 355 STRICT_GENERATOR_FUNCTION_MAP_INDEX, | 391 STRICT_GENERATOR_FUNCTION_MAP_INDEX, |
| 356 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, | 392 GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, |
| 357 ITERATOR_RESULT_MAP_INDEX, | 393 ITERATOR_RESULT_MAP_INDEX, |
| 358 MAP_ITERATOR_MAP_INDEX, | 394 MAP_ITERATOR_MAP_INDEX, |
| 359 SET_ITERATOR_MAP_INDEX, | 395 SET_ITERATOR_MAP_INDEX, |
| 360 ITERATOR_SYMBOL_INDEX, | 396 ITERATOR_SYMBOL_INDEX, |
| 361 UNSCOPABLES_SYMBOL_INDEX, | 397 UNSCOPABLES_SYMBOL_INDEX, |
| 362 ARRAY_VALUES_ITERATOR_INDEX, | 398 ARRAY_VALUES_ITERATOR_INDEX, |
| 399 GLOBAL_CONTEXT_TABLE_INDEX, | |
| 363 | 400 |
| 364 // Properties from here are treated as weak references by the full GC. | 401 // Properties from here are treated as weak references by the full GC. |
| 365 // Scavenge treats them as strong references. | 402 // Scavenge treats them as strong references. |
| 366 OPTIMIZED_FUNCTIONS_LIST, // Weak. | 403 OPTIMIZED_FUNCTIONS_LIST, // Weak. |
| 367 OPTIMIZED_CODE_LIST, // Weak. | 404 OPTIMIZED_CODE_LIST, // Weak. |
| 368 DEOPTIMIZED_CODE_LIST, // Weak. | 405 DEOPTIMIZED_CODE_LIST, // Weak. |
| 369 MAP_CACHE_INDEX, // Weak. | 406 MAP_CACHE_INDEX, // Weak. |
| 370 NEXT_CONTEXT_LINK, // Weak. | 407 NEXT_CONTEXT_LINK, // Weak. |
| 371 | 408 |
| 372 // Total number of slots. | 409 // Total number of slots. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 | 585 |
| 549 #ifdef DEBUG | 586 #ifdef DEBUG |
| 550 // Bootstrapping-aware type checks. | 587 // Bootstrapping-aware type checks. |
| 551 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); | 588 static bool IsBootstrappingOrValidParentContext(Object* object, Context* kid); |
| 552 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object); | 589 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object); |
| 553 #endif | 590 #endif |
| 554 | 591 |
| 555 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); | 592 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); |
| 556 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); | 593 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
| 557 }; | 594 }; |
| 558 | |
| 559 } } // namespace v8::internal | 595 } } // namespace v8::internal |
| 560 | 596 |
| 561 #endif // V8_CONTEXTS_H_ | 597 #endif // V8_CONTEXTS_H_ |
| OLD | NEW |