| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include "src/contexts.h" | 5 #include "src/contexts.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/scopeinfo.h" | 10 #include "src/scopeinfo.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 | 39 |
| 40 bool ScriptContextTable::Lookup(Handle<ScriptContextTable> table, | 40 bool ScriptContextTable::Lookup(Handle<ScriptContextTable> table, |
| 41 Handle<String> name, LookupResult* result) { | 41 Handle<String> name, LookupResult* result) { |
| 42 for (int i = 0; i < table->used(); i++) { | 42 for (int i = 0; i < table->used(); i++) { |
| 43 Handle<Context> context = GetContext(table, i); | 43 Handle<Context> context = GetContext(table, i); |
| 44 DCHECK(context->IsScriptContext()); | 44 DCHECK(context->IsScriptContext()); |
| 45 Handle<ScopeInfo> scope_info(context->scope_info()); | 45 Handle<ScopeInfo> scope_info(context->scope_info()); |
| 46 int slot_index = ScopeInfo::ContextSlotIndex( | 46 int slot_index = ScopeInfo::ContextSlotIndex( |
| 47 scope_info, name, &result->mode, &result->location, &result->init_flag, | 47 scope_info, name, &result->mode, &result->init_flag, |
| 48 &result->maybe_assigned_flag); | 48 &result->maybe_assigned_flag); |
| 49 | 49 |
| 50 if (slot_index >= 0 && result->location == VariableLocation::CONTEXT) { | 50 if (slot_index >= 0) { |
| 51 result->context_index = i; | 51 result->context_index = i; |
| 52 result->slot_index = slot_index; | 52 result->slot_index = slot_index; |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 | 59 |
| 60 bool Context::is_declaration_context() { | 60 bool Context::is_declaration_context() { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 // 2. Check the context proper if it has slots. | 327 // 2. Check the context proper if it has slots. |
| 328 if (context->IsFunctionContext() || context->IsBlockContext() || | 328 if (context->IsFunctionContext() || context->IsBlockContext() || |
| 329 context->IsScriptContext()) { | 329 context->IsScriptContext()) { |
| 330 // Use serialized scope information of functions and blocks to search | 330 // Use serialized scope information of functions and blocks to search |
| 331 // for the context index. | 331 // for the context index. |
| 332 Handle<ScopeInfo> scope_info(context->IsFunctionContext() | 332 Handle<ScopeInfo> scope_info(context->IsFunctionContext() |
| 333 ? context->closure()->shared()->scope_info() | 333 ? context->closure()->shared()->scope_info() |
| 334 : context->scope_info()); | 334 : context->scope_info()); |
| 335 VariableMode mode; | 335 VariableMode mode; |
| 336 VariableLocation location; | |
| 337 InitializationFlag init_flag; | 336 InitializationFlag init_flag; |
| 338 // TODO(sigurds) Figure out whether maybe_assigned_flag should | 337 // TODO(sigurds) Figure out whether maybe_assigned_flag should |
| 339 // be used to compute binding_flags. | 338 // be used to compute binding_flags. |
| 340 MaybeAssignedFlag maybe_assigned_flag; | 339 MaybeAssignedFlag maybe_assigned_flag; |
| 341 int slot_index = ScopeInfo::ContextSlotIndex( | 340 int slot_index = ScopeInfo::ContextSlotIndex( |
| 342 scope_info, name, &mode, &location, &init_flag, &maybe_assigned_flag); | 341 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); |
| 343 DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); | 342 DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); |
| 344 if (slot_index >= 0 && location == VariableLocation::CONTEXT) { | 343 if (slot_index >= 0) { |
| 345 if (FLAG_trace_contexts) { | 344 if (FLAG_trace_contexts) { |
| 346 PrintF("=> found local in context slot %d (mode = %d)\n", | 345 PrintF("=> found local in context slot %d (mode = %d)\n", |
| 347 slot_index, mode); | 346 slot_index, mode); |
| 348 } | 347 } |
| 349 *index = slot_index; | 348 *index = slot_index; |
| 350 GetAttributesAndBindingFlags(mode, init_flag, attributes, | 349 GetAttributesAndBindingFlags(mode, init_flag, attributes, |
| 351 binding_flags); | 350 binding_flags); |
| 352 return context; | 351 return context; |
| 353 } | 352 } |
| 354 | 353 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // During bootstrapping we allow all objects to pass as global | 581 // During bootstrapping we allow all objects to pass as global |
| 583 // objects. This is necessary to fix circular dependencies. | 582 // objects. This is necessary to fix circular dependencies. |
| 584 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 583 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
| 585 isolate->bootstrapper()->IsActive() || | 584 isolate->bootstrapper()->IsActive() || |
| 586 object->IsGlobalObject(); | 585 object->IsGlobalObject(); |
| 587 } | 586 } |
| 588 #endif | 587 #endif |
| 589 | 588 |
| 590 } // namespace internal | 589 } // namespace internal |
| 591 } // namespace v8 | 590 } // namespace v8 |
| OLD | NEW |