OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/js-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/compilation-dependencies.h" | 8 #include "src/compilation-dependencies.h" |
9 #include "src/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) { | 56 Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) { |
57 DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); | 57 DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); |
58 Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); | 58 Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); |
59 Node* effect = NodeProperties::GetEffectInput(node); | 59 Node* effect = NodeProperties::GetEffectInput(node); |
60 Node* control = NodeProperties::GetControlInput(node); | 60 Node* control = NodeProperties::GetControlInput(node); |
61 | 61 |
62 // Try to lookup the name on the script context table first (lexical scoping). | 62 // Try to lookup the name on the script context table first (lexical scoping). |
63 ScriptContextTableLookupResult result; | 63 ScriptContextTableLookupResult result; |
64 if (LookupInScriptContextTable(name, &result)) { | 64 if (LookupInScriptContextTable(name, &result)) { |
| 65 if (result.context->is_the_hole(result.index)) return NoChange(); |
65 Node* context = jsgraph()->Constant(result.context); | 66 Node* context = jsgraph()->Constant(result.context); |
66 Node* value = effect = graph()->NewNode( | 67 Node* value = effect = graph()->NewNode( |
67 javascript()->LoadContext(0, result.index, result.immutable), context, | 68 javascript()->LoadContext(0, result.index, result.immutable), context, |
68 context, effect); | 69 context, effect); |
69 return Replace(node, value, effect); | 70 return Replace(node, value, effect); |
70 } | 71 } |
71 | 72 |
72 // Lookup on the global object instead. We only deal with own data | 73 // Lookup on the global object instead. We only deal with own data |
73 // properties of the global object here (represented as PropertyCell). | 74 // properties of the global object here (represented as PropertyCell). |
74 LookupIterator it(global_object(), name, LookupIterator::OWN); | 75 LookupIterator it(global_object(), name, LookupIterator::OWN); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); | 137 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); |
137 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); | 138 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); |
138 Node* value = NodeProperties::GetValueInput(node, 2); | 139 Node* value = NodeProperties::GetValueInput(node, 2); |
139 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); | 140 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); |
140 Node* effect = NodeProperties::GetEffectInput(node); | 141 Node* effect = NodeProperties::GetEffectInput(node); |
141 Node* control = NodeProperties::GetControlInput(node); | 142 Node* control = NodeProperties::GetControlInput(node); |
142 | 143 |
143 // Try to lookup the name on the script context table first (lexical scoping). | 144 // Try to lookup the name on the script context table first (lexical scoping). |
144 ScriptContextTableLookupResult result; | 145 ScriptContextTableLookupResult result; |
145 if (LookupInScriptContextTable(name, &result)) { | 146 if (LookupInScriptContextTable(name, &result)) { |
| 147 if (result.context->is_the_hole(result.index)) return NoChange(); |
146 if (result.immutable) return NoChange(); | 148 if (result.immutable) return NoChange(); |
147 Node* context = jsgraph()->Constant(result.context); | 149 Node* context = jsgraph()->Constant(result.context); |
148 effect = graph()->NewNode(javascript()->StoreContext(0, result.index), | 150 effect = graph()->NewNode(javascript()->StoreContext(0, result.index), |
149 context, value, context, effect, control); | 151 context, value, context, effect, control); |
150 return Replace(node, value, effect, control); | 152 return Replace(node, value, effect, control); |
151 } | 153 } |
152 | 154 |
153 // Lookup on the global object instead. We only deal with own data | 155 // Lookup on the global object instead. We only deal with own data |
154 // properties of the global object here (represented as PropertyCell). | 156 // properties of the global object here (represented as PropertyCell). |
155 LookupIterator it(global_object(), name, LookupIterator::OWN); | 157 LookupIterator it(global_object(), name, LookupIterator::OWN); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 if (!name->IsString()) return false; | 665 if (!name->IsString()) return false; |
664 Handle<ScriptContextTable> script_context_table( | 666 Handle<ScriptContextTable> script_context_table( |
665 global_object()->native_context()->script_context_table()); | 667 global_object()->native_context()->script_context_table()); |
666 ScriptContextTable::LookupResult lookup_result; | 668 ScriptContextTable::LookupResult lookup_result; |
667 if (!ScriptContextTable::Lookup(script_context_table, | 669 if (!ScriptContextTable::Lookup(script_context_table, |
668 Handle<String>::cast(name), &lookup_result)) { | 670 Handle<String>::cast(name), &lookup_result)) { |
669 return false; | 671 return false; |
670 } | 672 } |
671 Handle<Context> script_context = ScriptContextTable::GetContext( | 673 Handle<Context> script_context = ScriptContextTable::GetContext( |
672 script_context_table, lookup_result.context_index); | 674 script_context_table, lookup_result.context_index); |
673 if (script_context->is_the_hole(lookup_result.slot_index)) return false; | |
674 result->context = script_context; | 675 result->context = script_context; |
675 result->immutable = IsImmutableVariableMode(lookup_result.mode); | 676 result->immutable = IsImmutableVariableMode(lookup_result.mode); |
676 result->index = lookup_result.slot_index; | 677 result->index = lookup_result.slot_index; |
677 return true; | 678 return true; |
678 } | 679 } |
679 | 680 |
680 | 681 |
681 Graph* JSNativeContextSpecialization::graph() const { | 682 Graph* JSNativeContextSpecialization::graph() const { |
682 return jsgraph()->graph(); | 683 return jsgraph()->graph(); |
683 } | 684 } |
(...skipping 24 matching lines...) Expand all Loading... |
708 } | 709 } |
709 | 710 |
710 | 711 |
711 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 712 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
712 return jsgraph()->simplified(); | 713 return jsgraph()->simplified(); |
713 } | 714 } |
714 | 715 |
715 } // namespace compiler | 716 } // namespace compiler |
716 } // namespace internal | 717 } // namespace internal |
717 } // namespace v8 | 718 } // namespace v8 |
OLD | NEW |