Chromium Code Reviews| Index: src/contexts.h |
| diff --git a/src/contexts.h b/src/contexts.h |
| index dc77861b2578be34e1169ae932c50554adfbfa76..4023c0b51eec352cbfa4bf83a8865bd7f1c53399 100644 |
| --- a/src/contexts.h |
| +++ b/src/contexts.h |
| @@ -183,7 +183,43 @@ enum BindingFlags { |
| V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \ |
| V(ITERATOR_SYMBOL_INDEX, Symbol, iterator_symbol) \ |
| V(UNSCOPABLES_SYMBOL_INDEX, Symbol, unscopables_symbol) \ |
| - V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) |
| + V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ |
| + V(GLOBAL_CONTEXT_TABLE_INDEX, GlobalContextTable, global_context_table) |
| + |
| + |
| +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.
|
| + public: |
| + // Conversions. |
| + static GlobalContextTable* cast(Object* context) { |
| + DCHECK(context->IsGlobalContextTable()); |
| + return reinterpret_cast<GlobalContextTable*>(context); |
| + } |
| + |
| + struct LookupResult { |
| + int context_index; |
| + int slot_index; |
| + VariableMode mode; |
| + InitializationFlag init_flag; |
| + MaybeAssignedFlag maybe_assigned_flag; |
| + }; |
| + |
| + 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
|
| + |
| + static Handle<Context> GetContext(Handle<GlobalContextTable> table, int i) { |
| + DCHECK(i < table->size()); |
| + 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.
|
| + } |
| + |
| + 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.
|
| + LookupResult* result); |
| + |
| + // 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.
|
| + 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.
|
| + Handle<Context> global_context); |
| + |
| + private: |
| + static const int kSizeSlot = 0; |
| +}; |
|
adamk
2014/11/06 20:18:05
nit: DISALLOW_IMPLICIT_CONSTRUCTORS
Dmitry Lomov (no reviews)
2014/11/07 10:18:47
Done.
|
| // JSFunctions are pairs (context, function code), sometimes also called |
| // closures. A Context object is used to represent function contexts and |
| @@ -360,6 +396,7 @@ class Context: public FixedArray { |
| ITERATOR_SYMBOL_INDEX, |
| UNSCOPABLES_SYMBOL_INDEX, |
| ARRAY_VALUES_ITERATOR_INDEX, |
| + GLOBAL_CONTEXT_TABLE_INDEX, |
| // Properties from here are treated as weak references by the full GC. |
| // Scavenge treats them as strong references. |
| @@ -555,7 +592,6 @@ class Context: public FixedArray { |
| STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); |
| STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
| }; |
| - |
| } } // namespace v8::internal |
| #endif // V8_CONTEXTS_H_ |