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/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/node-aux-data-inl.h" | 9 #include "src/compiler/node-aux-data-inl.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
11 #include "src/compiler/node-properties-inl.h" | 11 #include "src/compiler/node-properties-inl.h" |
12 #include "src/types.h" | 12 #include "src/types.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 namespace compiler { | 16 namespace compiler { |
17 | 17 |
18 // TODO(turbofan): js-typed-lowering improvements possible | 18 // TODO(turbofan): js-typed-lowering improvements possible |
19 // - immediately put in type bounds for all new nodes | 19 // - immediately put in type bounds for all new nodes |
20 // - relax effects from generic but not-side-effecting operations | 20 // - relax effects from generic but not-side-effecting operations |
| 21 // - relax effects for ToNumber(mixed) |
21 | 22 |
22 | 23 |
23 // Relax the effects of {node} by immediately replacing effect uses of {node} | 24 // Relax the effects of {node} by immediately replacing effect uses of {node} |
24 // with the effect input to {node}. | 25 // with the effect input to {node}. |
25 // TODO(turbofan): replace the effect input to {node} with {graph->start()}. | 26 // TODO(turbofan): replace the effect input to {node} with {graph->start()}. |
26 // TODO(titzer): move into a GraphEditor? | 27 // TODO(titzer): move into a GraphEditor? |
27 static void RelaxEffects(Node* node) { | 28 static void RelaxEffects(Node* node) { |
28 NodeProperties::ReplaceWithValue(node, node, NULL); | 29 NodeProperties::ReplaceWithValue(node, node, NULL); |
29 } | 30 } |
30 | 31 |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 // to simply reuse the context of the {node}. However, ToNumber() | 724 // to simply reuse the context of the {node}. However, ToNumber() |
724 // does not require a context anyways, so it's safe to discard it | 725 // does not require a context anyways, so it's safe to discard it |
725 // here and pass the dummy context. | 726 // here and pass the dummy context. |
726 value = graph()->NewNode(javascript()->ToNumber(), value, | 727 value = graph()->NewNode(javascript()->ToNumber(), value, |
727 jsgraph()->NoContextConstant(), | 728 jsgraph()->NoContextConstant(), |
728 graph()->start(), graph()->start()); | 729 graph()->start(), graph()->start()); |
729 } | 730 } |
730 node->ReplaceInput(i, value); | 731 node->ReplaceInput(i, value); |
731 } | 732 } |
732 node->TrimInputCount(input_count); | 733 node->TrimInputCount(input_count); |
733 } else { | |
734 // JSToNumber(x:plain-primitive,context) => JSToNumber(x,no-context) | |
735 node->ReplaceInput(1, jsgraph()->NoContextConstant()); | |
736 } | 734 } |
737 return Changed(node); | 735 return Changed(node); |
738 } | 736 } |
739 return NoChange(); | 737 return NoChange(); |
740 } | 738 } |
741 | 739 |
742 | 740 |
743 Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { | 741 Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { |
744 if (input->opcode() == IrOpcode::kJSToString) { | 742 if (input->opcode() == IrOpcode::kJSToString) { |
745 // Recursively try to reduce the input first. | 743 // Recursively try to reduce the input first. |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 } | 1037 } |
1040 | 1038 |
1041 | 1039 |
1042 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1040 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1043 return jsgraph()->machine(); | 1041 return jsgraph()->machine(); |
1044 } | 1042 } |
1045 | 1043 |
1046 } // namespace compiler | 1044 } // namespace compiler |
1047 } // namespace internal | 1045 } // namespace internal |
1048 } // namespace v8 | 1046 } // namespace v8 |
OLD | NEW |