| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 do { | 258 do { |
| 259 if (FLAG_trace_contexts) { | 259 if (FLAG_trace_contexts) { |
| 260 PrintF(" - looking in context %p", reinterpret_cast<void*>(*context)); | 260 PrintF(" - looking in context %p", reinterpret_cast<void*>(*context)); |
| 261 if (context->IsScriptContext()) PrintF(" (script context)"); | 261 if (context->IsScriptContext()) PrintF(" (script context)"); |
| 262 if (context->IsNativeContext()) PrintF(" (native context)"); | 262 if (context->IsNativeContext()) PrintF(" (native context)"); |
| 263 PrintF("\n"); | 263 PrintF("\n"); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // 1. Check global objects, subjects of with, and extension objects. | 266 // 1. Check global objects, subjects of with, and extension objects. |
| 267 if ((context->IsNativeContext() || context->IsWithContext() || | 267 if ((context->IsNativeContext() || |
| 268 (context->IsWithContext() && ((flags & SKIP_WITH_CONTEXT) == 0)) || |
| 268 context->IsFunctionContext() || context->IsBlockContext()) && | 269 context->IsFunctionContext() || context->IsBlockContext()) && |
| 269 context->extension_receiver() != nullptr) { | 270 context->extension_receiver() != nullptr) { |
| 270 Handle<JSReceiver> object(context->extension_receiver()); | 271 Handle<JSReceiver> object(context->extension_receiver()); |
| 271 | 272 |
| 272 if (context->IsNativeContext()) { | 273 if (context->IsNativeContext()) { |
| 273 if (FLAG_trace_contexts) { | 274 if (FLAG_trace_contexts) { |
| 274 PrintF(" - trying other script contexts\n"); | 275 PrintF(" - trying other script contexts\n"); |
| 275 } | 276 } |
| 276 // Try other script contexts. | 277 // Try other script contexts. |
| 277 Handle<ScriptContextTable> script_contexts( | 278 Handle<ScriptContextTable> script_contexts( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 PrintF("=> found in catch context\n"); | 378 PrintF("=> found in catch context\n"); |
| 378 } | 379 } |
| 379 *index = Context::THROWN_OBJECT_INDEX; | 380 *index = Context::THROWN_OBJECT_INDEX; |
| 380 *attributes = NONE; | 381 *attributes = NONE; |
| 381 *binding_flags = MUTABLE_IS_INITIALIZED; | 382 *binding_flags = MUTABLE_IS_INITIALIZED; |
| 382 return context; | 383 return context; |
| 383 } | 384 } |
| 384 } | 385 } |
| 385 | 386 |
| 386 // 3. Prepare to continue with the previous (next outermost) context. | 387 // 3. Prepare to continue with the previous (next outermost) context. |
| 387 if (context->IsNativeContext()) { | 388 if (context->IsNativeContext() || |
| 389 ((flags & STOP_AT_DECLARATION_SCOPE) != 0 && |
| 390 context->is_declaration_context())) { |
| 388 follow_context_chain = false; | 391 follow_context_chain = false; |
| 389 } else { | 392 } else { |
| 390 context = Handle<Context>(context->previous(), isolate); | 393 context = Handle<Context>(context->previous(), isolate); |
| 391 } | 394 } |
| 392 } while (follow_context_chain); | 395 } while (follow_context_chain); |
| 393 | 396 |
| 394 if (FLAG_trace_contexts) { | 397 if (FLAG_trace_contexts) { |
| 395 PrintF("=> no property/slot found\n"); | 398 PrintF("=> no property/slot found\n"); |
| 396 } | 399 } |
| 397 return Handle<Object>::null(); | 400 return Handle<Object>::null(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 // During bootstrapping we allow all objects to pass as global | 584 // During bootstrapping we allow all objects to pass as global |
| 582 // objects. This is necessary to fix circular dependencies. | 585 // objects. This is necessary to fix circular dependencies. |
| 583 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 586 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
| 584 isolate->bootstrapper()->IsActive() || | 587 isolate->bootstrapper()->IsActive() || |
| 585 object->IsGlobalObject(); | 588 object->IsGlobalObject(); |
| 586 } | 589 } |
| 587 #endif | 590 #endif |
| 588 | 591 |
| 589 } // namespace internal | 592 } // namespace internal |
| 590 } // namespace v8 | 593 } // namespace v8 |
| OLD | NEW |