| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 Node* const input = node->InputAt(0); | 740 Node* const input = node->InputAt(0); |
| 741 Reduction reduction = ReduceJSToStringInput(input); | 741 Reduction reduction = ReduceJSToStringInput(input); |
| 742 if (reduction.Changed()) { | 742 if (reduction.Changed()) { |
| 743 NodeProperties::ReplaceWithValue(node, reduction.replacement()); | 743 NodeProperties::ReplaceWithValue(node, reduction.replacement()); |
| 744 return reduction; | 744 return reduction; |
| 745 } | 745 } |
| 746 return NoChange(); | 746 return NoChange(); |
| 747 } | 747 } |
| 748 | 748 |
| 749 | 749 |
| 750 static bool IsGlobalObject(Node* node) { | |
| 751 return NodeProperties::IsTyped(node) && | |
| 752 NodeProperties::GetBounds(node).upper->Is(Type::GlobalObject()); | |
| 753 } | |
| 754 | |
| 755 | |
| 756 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { | 750 Reduction JSTypedLowering::ReduceJSLoadNamed(Node* node) { |
| 757 if (IsGlobalObject(node->InputAt(0))) { | 751 Node* object = NodeProperties::GetValueInput(node, 0); |
| 752 Type* object_type = NodeProperties::GetBounds(object).upper; |
| 753 if (object_type->Is(Type::GlobalObject())) { |
| 758 // Optimize global constants like "undefined", "Infinity", and "NaN". | 754 // Optimize global constants like "undefined", "Infinity", and "NaN". |
| 759 Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle(); | 755 Handle<Name> name = LoadNamedParametersOf(node->op()).name().handle(); |
| 760 Handle<Object> constant_value = factory()->GlobalConstantFor(name); | 756 Handle<Object> constant_value = factory()->GlobalConstantFor(name); |
| 761 if (!constant_value.is_null()) { | 757 if (!constant_value.is_null()) { |
| 762 Node* constant = jsgraph()->Constant(constant_value); | 758 Node* constant = jsgraph()->Constant(constant_value); |
| 763 NodeProperties::ReplaceWithValue(node, constant); | 759 NodeProperties::ReplaceWithValue(node, constant); |
| 764 return Replace(constant); | 760 return Replace(constant); |
| 765 } | 761 } |
| 766 } | 762 } |
| 767 return NoChange(); | 763 return NoChange(); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 } | 1096 } |
| 1101 | 1097 |
| 1102 | 1098 |
| 1103 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1099 MachineOperatorBuilder* JSTypedLowering::machine() const { |
| 1104 return jsgraph()->machine(); | 1100 return jsgraph()->machine(); |
| 1105 } | 1101 } |
| 1106 | 1102 |
| 1107 } // namespace compiler | 1103 } // namespace compiler |
| 1108 } // namespace internal | 1104 } // namespace internal |
| 1109 } // namespace v8 | 1105 } // namespace v8 |
| OLD | NEW |