| 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-global-object-specialization.h" | 5 #include "src/compiler/js-global-object-specialization.h" |
| 6 | 6 |
| 7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) { | 66 Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) { |
| 67 DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); | 67 DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); |
| 68 Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); | 68 Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); |
| 69 Node* effect = NodeProperties::GetEffectInput(node); | 69 Node* effect = NodeProperties::GetEffectInput(node); |
| 70 Node* control = NodeProperties::GetControlInput(node); | 70 Node* control = NodeProperties::GetControlInput(node); |
| 71 | 71 |
| 72 // Try to lookup the name on the script context table first (lexical scoping). | 72 // Try to lookup the name on the script context table first (lexical scoping). |
| 73 ScriptContextTableLookupResult result; | 73 ScriptContextTableLookupResult result; |
| 74 if (LookupInScriptContextTable(name, &result)) { | 74 if (LookupInScriptContextTable(name, &result)) { |
| 75 if (result.context->is_the_hole(result.index)) return NoChange(); | 75 if (result.context->is_the_hole(isolate(), result.index)) return NoChange(); |
| 76 Node* context = jsgraph()->HeapConstant(result.context); | 76 Node* context = jsgraph()->HeapConstant(result.context); |
| 77 Node* value = effect = graph()->NewNode( | 77 Node* value = effect = graph()->NewNode( |
| 78 javascript()->LoadContext(0, result.index, result.immutable), context, | 78 javascript()->LoadContext(0, result.index, result.immutable), context, |
| 79 context, effect); | 79 context, effect); |
| 80 ReplaceWithValue(node, value, effect); | 80 ReplaceWithValue(node, value, effect); |
| 81 return Replace(value); | 81 return Replace(value); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Lookup on the global object instead. We only deal with own data | 84 // Lookup on the global object instead. We only deal with own data |
| 85 // properties of the global object here (represented as PropertyCell). | 85 // properties of the global object here (represented as PropertyCell). |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { | 146 Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { |
| 147 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); | 147 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); |
| 148 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); | 148 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); |
| 149 Node* value = NodeProperties::GetValueInput(node, 0); | 149 Node* value = NodeProperties::GetValueInput(node, 0); |
| 150 Node* effect = NodeProperties::GetEffectInput(node); | 150 Node* effect = NodeProperties::GetEffectInput(node); |
| 151 Node* control = NodeProperties::GetControlInput(node); | 151 Node* control = NodeProperties::GetControlInput(node); |
| 152 | 152 |
| 153 // Try to lookup the name on the script context table first (lexical scoping). | 153 // Try to lookup the name on the script context table first (lexical scoping). |
| 154 ScriptContextTableLookupResult result; | 154 ScriptContextTableLookupResult result; |
| 155 if (LookupInScriptContextTable(name, &result)) { | 155 if (LookupInScriptContextTable(name, &result)) { |
| 156 if (result.context->is_the_hole(result.index)) return NoChange(); | 156 if (result.context->is_the_hole(isolate(), result.index)) return NoChange(); |
| 157 if (result.immutable) return NoChange(); | 157 if (result.immutable) return NoChange(); |
| 158 Node* context = jsgraph()->HeapConstant(result.context); | 158 Node* context = jsgraph()->HeapConstant(result.context); |
| 159 effect = graph()->NewNode(javascript()->StoreContext(0, result.index), | 159 effect = graph()->NewNode(javascript()->StoreContext(0, result.index), |
| 160 context, value, context, effect, control); | 160 context, value, context, effect, control); |
| 161 ReplaceWithValue(node, value, effect, control); | 161 ReplaceWithValue(node, value, effect, control); |
| 162 return Replace(value); | 162 return Replace(value); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Lookup on the global object instead. We only deal with own data | 165 // Lookup on the global object instead. We only deal with own data |
| 166 // properties of the global object here (represented as PropertyCell). | 166 // properties of the global object here (represented as PropertyCell). |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return jsgraph()->javascript(); | 278 return jsgraph()->javascript(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { | 281 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { |
| 282 return jsgraph()->simplified(); | 282 return jsgraph()->simplified(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace compiler | 285 } // namespace compiler |
| 286 } // namespace internal | 286 } // namespace internal |
| 287 } // namespace v8 | 287 } // namespace v8 |
| OLD | NEW |