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/simplified-operator-reducer.h" | 5 #include "src/compiler/simplified-operator-reducer.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if (m.HasValue()) return ReplaceNumber(m.Value()); | 73 if (m.HasValue()) return ReplaceNumber(m.Value()); |
74 if (m.IsChangeTaggedToInt32() || m.IsChangeTaggedSignedToInt32()) { | 74 if (m.IsChangeTaggedToInt32() || m.IsChangeTaggedSignedToInt32()) { |
75 return Replace(m.InputAt(0)); | 75 return Replace(m.InputAt(0)); |
76 } | 76 } |
77 break; | 77 break; |
78 } | 78 } |
79 case IrOpcode::kChangeTaggedToFloat64: | 79 case IrOpcode::kChangeTaggedToFloat64: |
80 case IrOpcode::kTruncateTaggedToFloat64: { | 80 case IrOpcode::kTruncateTaggedToFloat64: { |
81 NumberMatcher m(node->InputAt(0)); | 81 NumberMatcher m(node->InputAt(0)); |
82 if (m.HasValue()) return ReplaceFloat64(m.Value()); | 82 if (m.HasValue()) return ReplaceFloat64(m.Value()); |
83 if (m.IsChangeFloat64ToTagged()) return Replace(m.node()->InputAt(0)); | 83 if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) { |
| 84 return Replace(m.node()->InputAt(0)); |
| 85 } |
84 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) { | 86 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) { |
85 return Change(node, machine()->ChangeInt32ToFloat64(), m.InputAt(0)); | 87 return Change(node, machine()->ChangeInt32ToFloat64(), m.InputAt(0)); |
86 } | 88 } |
87 if (m.IsChangeUint32ToTagged()) { | 89 if (m.IsChangeUint32ToTagged()) { |
88 return Change(node, machine()->ChangeUint32ToFloat64(), m.InputAt(0)); | 90 return Change(node, machine()->ChangeUint32ToFloat64(), m.InputAt(0)); |
89 } | 91 } |
90 break; | 92 break; |
91 } | 93 } |
92 case IrOpcode::kChangeTaggedSignedToInt32: | 94 case IrOpcode::kChangeTaggedSignedToInt32: |
93 case IrOpcode::kChangeTaggedToInt32: { | 95 case IrOpcode::kChangeTaggedToInt32: { |
94 NumberMatcher m(node->InputAt(0)); | 96 NumberMatcher m(node->InputAt(0)); |
95 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); | 97 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); |
96 if (m.IsChangeFloat64ToTagged()) { | 98 if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) { |
97 return Change(node, machine()->ChangeFloat64ToInt32(), m.InputAt(0)); | 99 return Change(node, machine()->ChangeFloat64ToInt32(), m.InputAt(0)); |
98 } | 100 } |
99 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) { | 101 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) { |
100 return Replace(m.InputAt(0)); | 102 return Replace(m.InputAt(0)); |
101 } | 103 } |
102 break; | 104 break; |
103 } | 105 } |
104 case IrOpcode::kChangeTaggedToUint32: { | 106 case IrOpcode::kChangeTaggedToUint32: { |
105 NumberMatcher m(node->InputAt(0)); | 107 NumberMatcher m(node->InputAt(0)); |
106 if (m.HasValue()) return ReplaceUint32(DoubleToUint32(m.Value())); | 108 if (m.HasValue()) return ReplaceUint32(DoubleToUint32(m.Value())); |
107 if (m.IsChangeFloat64ToTagged()) { | 109 if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) { |
108 return Change(node, machine()->ChangeFloat64ToUint32(), m.InputAt(0)); | 110 return Change(node, machine()->ChangeFloat64ToUint32(), m.InputAt(0)); |
109 } | 111 } |
110 if (m.IsChangeUint32ToTagged()) return Replace(m.InputAt(0)); | 112 if (m.IsChangeUint32ToTagged()) return Replace(m.InputAt(0)); |
111 break; | 113 break; |
112 } | 114 } |
113 case IrOpcode::kChangeUint32ToTagged: { | 115 case IrOpcode::kChangeUint32ToTagged: { |
114 Uint32Matcher m(node->InputAt(0)); | 116 Uint32Matcher m(node->InputAt(0)); |
115 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); | 117 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value())); |
116 break; | 118 break; |
117 } | 119 } |
118 case IrOpcode::kTruncateTaggedToWord32: { | 120 case IrOpcode::kTruncateTaggedToWord32: { |
119 NumberMatcher m(node->InputAt(0)); | 121 NumberMatcher m(node->InputAt(0)); |
120 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); | 122 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); |
121 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() || | 123 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() || |
122 m.IsChangeUint32ToTagged()) { | 124 m.IsChangeUint32ToTagged()) { |
123 return Replace(m.InputAt(0)); | 125 return Replace(m.InputAt(0)); |
124 } | 126 } |
125 if (m.IsChangeFloat64ToTagged()) { | 127 if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) { |
126 return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0)); | 128 return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0)); |
127 } | 129 } |
128 break; | 130 break; |
129 } | 131 } |
130 case IrOpcode::kCheckedTaggedToInt32: | 132 case IrOpcode::kCheckedTaggedToInt32: |
131 case IrOpcode::kCheckedTaggedSignedToInt32: { | 133 case IrOpcode::kCheckedTaggedSignedToInt32: { |
132 NodeMatcher m(node->InputAt(0)); | 134 NodeMatcher m(node->InputAt(0)); |
133 if (m.IsConvertTaggedHoleToUndefined()) { | 135 if (m.IsConvertTaggedHoleToUndefined()) { |
134 node->ReplaceInput(0, m.InputAt(0)); | 136 node->ReplaceInput(0, m.InputAt(0)); |
135 return Changed(node); | 137 return Changed(node); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 return jsgraph()->isolate(); | 253 return jsgraph()->isolate(); |
252 } | 254 } |
253 | 255 |
254 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { | 256 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { |
255 return jsgraph()->machine(); | 257 return jsgraph()->machine(); |
256 } | 258 } |
257 | 259 |
258 } // namespace compiler | 260 } // namespace compiler |
259 } // namespace internal | 261 } // namespace internal |
260 } // namespace v8 | 262 } // namespace v8 |
OLD | NEW |