| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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(isolate(), 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         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). | 
| 86   LookupIterator it(global_object(), name, LookupIterator::OWN); | 86   LookupIterator it(global_object(), name, LookupIterator::OWN); | 
| 87   if (it.state() != LookupIterator::DATA) return NoChange(); | 87   if (it.state() != LookupIterator::DATA) return NoChange(); | 
| 88   if (!it.GetHolder<JSObject>()->IsJSGlobalObject()) return NoChange(); | 88   if (!it.GetHolder<JSObject>()->IsJSGlobalObject()) return NoChange(); | 
| 89   Handle<PropertyCell> property_cell = it.GetPropertyCell(); | 89   Handle<PropertyCell> property_cell = it.GetPropertyCell(); | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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(isolate(), 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                               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). | 
| 167   LookupIterator it(global_object(), name, LookupIterator::OWN); | 167   LookupIterator it(global_object(), name, LookupIterator::OWN); | 
| 168   if (it.state() != LookupIterator::DATA) return NoChange(); | 168   if (it.state() != LookupIterator::DATA) return NoChange(); | 
| 169   if (!it.GetHolder<JSObject>()->IsJSGlobalObject()) return NoChange(); | 169   if (!it.GetHolder<JSObject>()->IsJSGlobalObject()) return NoChange(); | 
| 170   Handle<PropertyCell> property_cell = it.GetPropertyCell(); | 170   Handle<PropertyCell> property_cell = it.GetPropertyCell(); | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 273   return jsgraph()->javascript(); | 273   return jsgraph()->javascript(); | 
| 274 } | 274 } | 
| 275 | 275 | 
| 276 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { | 276 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { | 
| 277   return jsgraph()->simplified(); | 277   return jsgraph()->simplified(); | 
| 278 } | 278 } | 
| 279 | 279 | 
| 280 }  // namespace compiler | 280 }  // namespace compiler | 
| 281 }  // namespace internal | 281 }  // namespace internal | 
| 282 }  // namespace v8 | 282 }  // namespace v8 | 
| OLD | NEW | 
|---|