| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 javascript()->LoadContext(0, result.index, result.immutable), context, | 67 javascript()->LoadContext(0, result.index, result.immutable), context, |
| 68 context, effect); | 68 context, effect); |
| 69 ReplaceWithValue(node, value, effect); | 69 ReplaceWithValue(node, value, effect); |
| 70 return Replace(value); | 70 return Replace(value); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // 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 |
| 74 // properties of the global object here (represented as PropertyCell). | 74 // properties of the global object here (represented as PropertyCell). |
| 75 LookupIterator it(global_object, name, LookupIterator::OWN); | 75 LookupIterator it(global_object, name, LookupIterator::OWN); |
| 76 if (it.state() != LookupIterator::DATA) return NoChange(); | 76 if (it.state() != LookupIterator::DATA) return NoChange(); |
| 77 if (!it.GetHolder<JSObject>()->IsJSGlobalObject()) return NoChange(); |
| 77 Handle<PropertyCell> property_cell = it.GetPropertyCell(); | 78 Handle<PropertyCell> property_cell = it.GetPropertyCell(); |
| 78 PropertyDetails property_details = property_cell->property_details(); | 79 PropertyDetails property_details = property_cell->property_details(); |
| 79 Handle<Object> property_cell_value(property_cell->value(), isolate()); | 80 Handle<Object> property_cell_value(property_cell->value(), isolate()); |
| 80 | 81 |
| 81 // Load from non-configurable, read-only data property on the global | 82 // Load from non-configurable, read-only data property on the global |
| 82 // object can be constant-folded, even without deoptimization support. | 83 // object can be constant-folded, even without deoptimization support. |
| 83 if (!property_details.IsConfigurable() && property_details.IsReadOnly()) { | 84 if (!property_details.IsConfigurable() && property_details.IsReadOnly()) { |
| 84 Node* value = jsgraph()->Constant(property_cell_value); | 85 Node* value = jsgraph()->Constant(property_cell_value); |
| 85 ReplaceWithValue(node, value); | 86 ReplaceWithValue(node, value); |
| 86 return Replace(value); | 87 return Replace(value); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 effect = graph()->NewNode(javascript()->StoreContext(0, result.index), | 148 effect = graph()->NewNode(javascript()->StoreContext(0, result.index), |
| 148 context, value, context, effect, control); | 149 context, value, context, effect, control); |
| 149 ReplaceWithValue(node, value, effect, control); | 150 ReplaceWithValue(node, value, effect, control); |
| 150 return Replace(value); | 151 return Replace(value); |
| 151 } | 152 } |
| 152 | 153 |
| 153 // Lookup on the global object instead. We only deal with own data | 154 // Lookup on the global object instead. We only deal with own data |
| 154 // properties of the global object here (represented as PropertyCell). | 155 // properties of the global object here (represented as PropertyCell). |
| 155 LookupIterator it(global_object, name, LookupIterator::OWN); | 156 LookupIterator it(global_object, name, LookupIterator::OWN); |
| 156 if (it.state() != LookupIterator::DATA) return NoChange(); | 157 if (it.state() != LookupIterator::DATA) return NoChange(); |
| 158 if (!it.GetHolder<JSObject>()->IsJSGlobalObject()) return NoChange(); |
| 157 Handle<PropertyCell> property_cell = it.GetPropertyCell(); | 159 Handle<PropertyCell> property_cell = it.GetPropertyCell(); |
| 158 PropertyDetails property_details = property_cell->property_details(); | 160 PropertyDetails property_details = property_cell->property_details(); |
| 159 Handle<Object> property_cell_value(property_cell->value(), isolate()); | 161 Handle<Object> property_cell_value(property_cell->value(), isolate()); |
| 160 | 162 |
| 161 // Don't even bother trying to lower stores to read-only data properties. | 163 // Don't even bother trying to lower stores to read-only data properties. |
| 162 if (property_details.IsReadOnly()) return NoChange(); | 164 if (property_details.IsReadOnly()) return NoChange(); |
| 163 switch (property_details.cell_type()) { | 165 switch (property_details.cell_type()) { |
| 164 case PropertyCellType::kUndefined: { | 166 case PropertyCellType::kUndefined: { |
| 165 return NoChange(); | 167 return NoChange(); |
| 166 } | 168 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 } | 275 } |
| 274 | 276 |
| 275 | 277 |
| 276 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { | 278 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { |
| 277 return jsgraph()->simplified(); | 279 return jsgraph()->simplified(); |
| 278 } | 280 } |
| 279 | 281 |
| 280 } // namespace compiler | 282 } // namespace compiler |
| 281 } // namespace internal | 283 } // namespace internal |
| 282 } // namespace v8 | 284 } // namespace v8 |
| OLD | NEW |