summaryrefslogtreecommitdiff
path: root/deps/v8/src/contexts.h
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-01-07 18:38:38 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2015-01-07 22:11:18 +0100
commitdad73f645cde6920e79db956e7ef82ed640d7615 (patch)
tree7ba3f3fc7e0722c5f130065461b7c56f571af383 /deps/v8/src/contexts.h
parent53ba494537259b18b346dc6150d6a100c557e08f (diff)
downloadnode-new-dad73f645cde6920e79db956e7ef82ed640d7615.tar.gz
deps: upgrade v8 to 3.31.74.1
PR-URL: https://github.com/iojs/io.js/pull/243 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'deps/v8/src/contexts.h')
-rw-r--r--deps/v8/src/contexts.h79
1 files changed, 68 insertions, 11 deletions
diff --git a/deps/v8/src/contexts.h b/deps/v8/src/contexts.h
index dc77861b25..cd3ff14211 100644
--- a/deps/v8/src/contexts.h
+++ b/deps/v8/src/contexts.h
@@ -98,6 +98,7 @@ enum BindingFlags {
V(TO_INTEGER_FUN_INDEX, JSFunction, to_integer_fun) \
V(TO_UINT32_FUN_INDEX, JSFunction, to_uint32_fun) \
V(TO_INT32_FUN_INDEX, JSFunction, to_int32_fun) \
+ V(TO_LENGTH_FUN_INDEX, JSFunction, to_length_fun) \
V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \
V(INSTANTIATE_FUN_INDEX, JSFunction, instantiate_fun) \
V(CONFIGURE_INSTANCE_FUN_INDEX, JSFunction, configure_instance_fun) \
@@ -181,9 +182,63 @@ enum BindingFlags {
V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \
V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \
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(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table)
+
+
+// A table of all script contexts. Every loaded top-level script with top-level
+// lexical declarations contributes its ScriptContext into this table.
+//
+// The table is a fixed array, its first slot is the current used count and
+// the subsequent slots 1..used contain ScriptContexts.
+class ScriptContextTable : public FixedArray {
+ public:
+ // Conversions.
+ static ScriptContextTable* cast(Object* context) {
+ DCHECK(context->IsScriptContextTable());
+ return reinterpret_cast<ScriptContextTable*>(context);
+ }
+
+ struct LookupResult {
+ int context_index;
+ int slot_index;
+ VariableMode mode;
+ InitializationFlag init_flag;
+ MaybeAssignedFlag maybe_assigned_flag;
+ };
+
+ int used() const { return Smi::cast(get(kUsedSlot))->value(); }
+
+ void set_used(int used) { set(kUsedSlot, Smi::FromInt(used)); }
+
+ static Handle<Context> GetContext(Handle<ScriptContextTable> table, int i) {
+ DCHECK(i < table->used());
+ return Handle<Context>::cast(FixedArray::get(table, i + 1));
+ }
+
+ // Lookup a variable `name` in a ScriptContextTable.
+ // If it returns true, the variable is found and `result` contains
+ // valid information about its location.
+ // If it returns false, `result` is untouched.
+ MUST_USE_RESULT
+ static bool Lookup(Handle<ScriptContextTable> table, Handle<String> name,
+ LookupResult* result);
+
+ MUST_USE_RESULT
+ static Handle<ScriptContextTable> Extend(Handle<ScriptContextTable> table,
+ Handle<Context> script_context);
+
+ static int GetContextOffset(int context_index) {
+ return kFirstContextOffset + context_index * kPointerSize;
+ }
+
+ private:
+ static const int kUsedSlot = 0;
+ static const int kFirstContextOffset =
+ FixedArray::kHeaderSize + (kUsedSlot + 1) * kPointerSize;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScriptContextTable);
+};
// JSFunctions are pairs (context, function code), sometimes also called
// closures. A Context object is used to represent function contexts and
@@ -228,7 +283,9 @@ enum BindingFlags {
// properties.
//
// Finally, with Harmony scoping, the JSFunction representing a top level
-// script will have the GlobalContext rather than a FunctionContext.
+// script will have the ScriptContext rather than a FunctionContext.
+// Script contexts from all top-level scripts are gathered in
+// ScriptContextTable.
class Context: public FixedArray {
public:
@@ -357,16 +414,16 @@ class Context: public FixedArray {
ITERATOR_RESULT_MAP_INDEX,
MAP_ITERATOR_MAP_INDEX,
SET_ITERATOR_MAP_INDEX,
- ITERATOR_SYMBOL_INDEX,
- UNSCOPABLES_SYMBOL_INDEX,
ARRAY_VALUES_ITERATOR_INDEX,
+ SCRIPT_CONTEXT_TABLE_INDEX,
+ MAP_CACHE_INDEX,
+ TO_LENGTH_FUN_INDEX,
// Properties from here are treated as weak references by the full GC.
// Scavenge treats them as strong references.
OPTIMIZED_FUNCTIONS_LIST, // Weak.
OPTIMIZED_CODE_LIST, // Weak.
DEOPTIMIZED_CODE_LIST, // Weak.
- MAP_CACHE_INDEX, // Weak.
NEXT_CONTEXT_LINK, // Weak.
// Total number of slots.
@@ -412,8 +469,8 @@ class Context: public FixedArray {
// The builtins object.
JSBuiltinsObject* builtins();
- // Get the innermost global context by traversing the context chain.
- Context* global_context();
+ // Get the script context by traversing the context chain.
+ Context* script_context();
// Compute the native context by traversing the context chain.
Context* native_context();
@@ -445,9 +502,9 @@ class Context: public FixedArray {
Map* map = this->map();
return map == map->GetHeap()->module_context_map();
}
- bool IsGlobalContext() {
+ bool IsScriptContext() {
Map* map = this->map();
- return map == map->GetHeap()->global_context_map();
+ return map == map->GetHeap()->script_context_map();
}
bool HasSameSecurityTokenAs(Context* that) {