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 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 // declaration scope. That's just a small performance shortcut. | 67 // declaration scope. That's just a small performance shortcut. |
68 return ext->IsContextExtension() || | 68 return ext->IsContextExtension() || |
69 ScopeInfo::cast(ext)->is_declaration_scope(); | 69 ScopeInfo::cast(ext)->is_declaration_scope(); |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 Context* Context::declaration_context() { | 73 Context* Context::declaration_context() { |
74 Context* current = this; | 74 Context* current = this; |
75 while (!current->is_declaration_context()) { | 75 while (!current->is_declaration_context()) { |
76 current = current->previous(); | 76 current = current->previous(); |
77 DCHECK(current->closure() == closure()); | 77 // Note: the closure may change while finding the declaration context, |
78 // e.g., for sloppy direct eval | |
78 } | 79 } |
79 return current; | 80 return current; |
80 } | 81 } |
81 | 82 |
82 Context* Context::closure_context() { | 83 Context* Context::closure_context() { |
83 Context* current = this; | 84 Context* current = this; |
84 while (!current->IsFunctionContext() && !current->IsScriptContext() && | 85 while (!current->IsFunctionContext() && !current->IsScriptContext() && |
85 !current->IsNativeContext()) { | 86 !current->IsNativeContext()) { |
86 current = current->previous(); | 87 current = current->previous(); |
87 DCHECK(current->closure() == closure()); | 88 DCHECK(current->closure() == closure()); |
(...skipping 17 matching lines...) Expand all Loading... | |
105 JSReceiver* Context::extension_receiver() { | 106 JSReceiver* Context::extension_receiver() { |
106 DCHECK(IsNativeContext() || IsWithContext() || | 107 DCHECK(IsNativeContext() || IsWithContext() || |
107 IsFunctionContext() || IsBlockContext()); | 108 IsFunctionContext() || IsBlockContext()); |
108 return IsWithContext() ? JSReceiver::cast( | 109 return IsWithContext() ? JSReceiver::cast( |
109 ContextExtension::cast(extension())->extension()) | 110 ContextExtension::cast(extension())->extension()) |
110 : extension_object(); | 111 : extension_object(); |
111 } | 112 } |
112 | 113 |
113 ScopeInfo* Context::scope_info() { | 114 ScopeInfo* Context::scope_info() { |
114 DCHECK(!IsNativeContext()); | 115 DCHECK(!IsNativeContext()); |
115 if (IsFunctionContext() || IsModuleContext()) { | 116 if (IsFunctionContext() || IsModuleContext()) { |
adamk
2016/11/10 19:32:07
I think you want to add "|| IsEvalContext()" here.
Dan Ehrenberg
2016/11/11 23:51:57
Added that here and in a bunch of other places
| |
116 return closure()->shared()->scope_info(); | 117 return closure()->shared()->scope_info(); |
117 } | 118 } |
118 HeapObject* object = extension(); | 119 HeapObject* object = extension(); |
119 if (object->IsContextExtension()) { | 120 if (object->IsContextExtension()) { |
120 DCHECK(IsBlockContext() || IsCatchContext() || IsWithContext() || | 121 DCHECK(IsBlockContext() || IsCatchContext() || IsWithContext() || |
121 IsDebugEvaluateContext()); | 122 IsDebugEvaluateContext()); |
122 object = ContextExtension::cast(object)->scope_info(); | 123 object = ContextExtension::cast(object)->scope_info(); |
123 } | 124 } |
124 return ScopeInfo::cast(object); | 125 return ScopeInfo::cast(object); |
125 } | 126 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 | 589 |
589 int previous_value = errors_thrown()->value(); | 590 int previous_value = errors_thrown()->value(); |
590 set_errors_thrown(Smi::FromInt(previous_value + 1)); | 591 set_errors_thrown(Smi::FromInt(previous_value + 1)); |
591 } | 592 } |
592 | 593 |
593 | 594 |
594 int Context::GetErrorsThrown() { return errors_thrown()->value(); } | 595 int Context::GetErrorsThrown() { return errors_thrown()->value(); } |
595 | 596 |
596 } // namespace internal | 597 } // namespace internal |
597 } // namespace v8 | 598 } // namespace v8 |
OLD | NEW |