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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/debug.h" | 8 #include "src/debug.h" |
9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // 1. Check global objects, subjects of with, and extension objects. | 100 // 1. Check global objects, subjects of with, and extension objects. |
101 if (context->IsNativeContext() || | 101 if (context->IsNativeContext() || |
102 context->IsWithContext() || | 102 context->IsWithContext() || |
103 (context->IsFunctionContext() && context->has_extension())) { | 103 (context->IsFunctionContext() && context->has_extension())) { |
104 Handle<JSReceiver> object( | 104 Handle<JSReceiver> object( |
105 JSReceiver::cast(context->extension()), isolate); | 105 JSReceiver::cast(context->extension()), isolate); |
106 // Context extension objects needs to behave as if they have no | 106 // Context extension objects needs to behave as if they have no |
107 // prototype. So even if we want to follow prototype chains, we need | 107 // prototype. So even if we want to follow prototype chains, we need |
108 // to only do a local lookup for context extension objects. | 108 // to only do a local lookup for context extension objects. |
| 109 Maybe<PropertyAttributes> maybe; |
109 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || | 110 if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 || |
110 object->IsJSContextExtensionObject()) { | 111 object->IsJSContextExtensionObject()) { |
111 *attributes = JSReceiver::GetOwnPropertyAttributes(object, name); | 112 maybe = JSReceiver::GetOwnPropertyAttributes(object, name); |
112 } else { | 113 } else { |
113 *attributes = JSReceiver::GetPropertyAttributes(object, name); | 114 maybe = JSReceiver::GetPropertyAttributes(object, name); |
114 } | 115 } |
115 if (isolate->has_pending_exception()) return Handle<Object>(); | 116 if (!maybe.has_value) return Handle<Object>(); |
| 117 ASSERT(!isolate->has_pending_exception()); |
| 118 *attributes = maybe.value; |
116 | 119 |
117 if (*attributes != ABSENT) { | 120 if (maybe.value != ABSENT) { |
118 if (FLAG_trace_contexts) { | 121 if (FLAG_trace_contexts) { |
119 PrintF("=> found property in context object %p\n", | 122 PrintF("=> found property in context object %p\n", |
120 reinterpret_cast<void*>(*object)); | 123 reinterpret_cast<void*>(*object)); |
121 } | 124 } |
122 return object; | 125 return object; |
123 } | 126 } |
124 } | 127 } |
125 | 128 |
126 // 2. Check the context proper if it has slots. | 129 // 2. Check the context proper if it has slots. |
127 if (context->IsFunctionContext() || context->IsBlockContext()) { | 130 if (context->IsFunctionContext() || context->IsBlockContext()) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { | 370 bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) { |
368 // During bootstrapping we allow all objects to pass as global | 371 // During bootstrapping we allow all objects to pass as global |
369 // objects. This is necessary to fix circular dependencies. | 372 // objects. This is necessary to fix circular dependencies. |
370 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 373 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
371 isolate->bootstrapper()->IsActive() || | 374 isolate->bootstrapper()->IsActive() || |
372 object->IsGlobalObject(); | 375 object->IsGlobalObject(); |
373 } | 376 } |
374 #endif | 377 #endif |
375 | 378 |
376 } } // namespace v8::internal | 379 } } // namespace v8::internal |
OLD | NEW |