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-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
6 | 6 |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 case Runtime::kInlineDeoptimizeNow: | 25 case Runtime::kInlineDeoptimizeNow: |
26 return ReduceInlineDeoptimizeNow(node); | 26 return ReduceInlineDeoptimizeNow(node); |
27 case Runtime::kInlineIsSmi: | 27 case Runtime::kInlineIsSmi: |
28 return ReduceInlineIsSmi(node); | 28 return ReduceInlineIsSmi(node); |
29 case Runtime::kInlineIsNonNegativeSmi: | 29 case Runtime::kInlineIsNonNegativeSmi: |
30 return ReduceInlineIsNonNegativeSmi(node); | 30 return ReduceInlineIsNonNegativeSmi(node); |
31 case Runtime::kInlineIsArray: | 31 case Runtime::kInlineIsArray: |
32 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); | 32 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); |
33 case Runtime::kInlineIsFunction: | 33 case Runtime::kInlineIsFunction: |
34 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); | 34 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); |
35 case Runtime::kInlineJSValueValue: | |
36 return ReduceInlineJSValueValue(node); | |
35 case Runtime::kInlineConstructDouble: | 37 case Runtime::kInlineConstructDouble: |
36 return ReduceInlineConstructDouble(node); | 38 return ReduceInlineConstructDouble(node); |
37 case Runtime::kInlineDoubleLo: | 39 case Runtime::kInlineDoubleLo: |
38 return ReduceInlineDoubleLo(node); | 40 return ReduceInlineDoubleLo(node); |
39 case Runtime::kInlineDoubleHi: | 41 case Runtime::kInlineDoubleHi: |
40 return ReduceInlineDoubleHi(node); | 42 return ReduceInlineDoubleHi(node); |
41 case Runtime::kInlineIsRegExp: | 43 case Runtime::kInlineIsRegExp: |
42 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); | 44 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); |
43 case Runtime::kInlineMathFloor: | 45 case Runtime::kInlineMathFloor: |
44 return ReduceInlineMathFloor(node); | 46 return ReduceInlineMathFloor(node); |
45 case Runtime::kInlineMathSqrt: | 47 case Runtime::kInlineMathSqrt: |
46 return ReduceInlineMathSqrt(node); | 48 return ReduceInlineMathSqrt(node); |
49 case Runtime::kInlineStringLength: | |
50 return ReduceInlineStringLength(node); | |
47 case Runtime::kInlineValueOf: | 51 case Runtime::kInlineValueOf: |
48 return ReduceInlineValueOf(node); | 52 return ReduceInlineValueOf(node); |
49 default: | 53 default: |
50 break; | 54 break; |
51 } | 55 } |
52 return NoChange(); | 56 return NoChange(); |
53 } | 57 } |
54 | 58 |
55 | 59 |
56 Reduction JSIntrinsicLowering::ReduceInlineDeoptimizeNow(Node* node) { | 60 Reduction JSIntrinsicLowering::ReduceInlineDeoptimizeNow(Node* node) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { | 100 Reduction JSIntrinsicLowering::ReduceInlineIsSmi(Node* node) { |
97 return Change(node, simplified()->ObjectIsSmi()); | 101 return Change(node, simplified()->ObjectIsSmi()); |
98 } | 102 } |
99 | 103 |
100 | 104 |
101 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { | 105 Reduction JSIntrinsicLowering::ReduceInlineIsNonNegativeSmi(Node* node) { |
102 return Change(node, simplified()->ObjectIsNonNegativeSmi()); | 106 return Change(node, simplified()->ObjectIsNonNegativeSmi()); |
103 } | 107 } |
104 | 108 |
105 | 109 |
110 Reduction JSIntrinsicLowering::ReduceInlineJSValueValue(Node* node) { | |
111 Node* value = NodeProperties::GetValueInput(node, 0); | |
112 Node* effect = NodeProperties::GetEffectInput(node); | |
113 Node* control = NodeProperties::GetControlInput(node); | |
114 | |
115 Node* result = | |
116 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForValue()), | |
117 value, effect, control); | |
118 NodeProperties::ReplaceWithValue(node, result); | |
titzer
2015/03/18 09:25:53
This looks like a good candidate to mutate in plac
Sven Panne
2015/03/18 10:40:08
Done.
| |
119 return Replace(value); | |
120 } | |
121 | |
122 | |
106 Reduction JSIntrinsicLowering::ReduceInlineConstructDouble(Node* node) { | 123 Reduction JSIntrinsicLowering::ReduceInlineConstructDouble(Node* node) { |
107 Node* high = NodeProperties::GetValueInput(node, 0); | 124 Node* high = NodeProperties::GetValueInput(node, 0); |
108 Node* low = NodeProperties::GetValueInput(node, 1); | 125 Node* low = NodeProperties::GetValueInput(node, 1); |
109 Node* value = | 126 Node* value = |
110 graph()->NewNode(machine()->Float64InsertHighWord32(), | 127 graph()->NewNode(machine()->Float64InsertHighWord32(), |
111 graph()->NewNode(machine()->Float64InsertLowWord32(), | 128 graph()->NewNode(machine()->Float64InsertLowWord32(), |
112 jsgraph()->Constant(0), low), | 129 jsgraph()->Constant(0), low), |
113 high); | 130 high); |
114 NodeProperties::ReplaceWithValue(node, value); | 131 NodeProperties::ReplaceWithValue(node, value); |
115 return Replace(value); | 132 return Replace(value); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 if (!machine()->HasFloat64RoundDown()) return NoChange(); | 187 if (!machine()->HasFloat64RoundDown()) return NoChange(); |
171 return Change(node, machine()->Float64RoundDown()); | 188 return Change(node, machine()->Float64RoundDown()); |
172 } | 189 } |
173 | 190 |
174 | 191 |
175 Reduction JSIntrinsicLowering::ReduceInlineMathSqrt(Node* node) { | 192 Reduction JSIntrinsicLowering::ReduceInlineMathSqrt(Node* node) { |
176 return Change(node, machine()->Float64Sqrt()); | 193 return Change(node, machine()->Float64Sqrt()); |
177 } | 194 } |
178 | 195 |
179 | 196 |
197 Reduction JSIntrinsicLowering::ReduceInlineStringLength(Node* node) { | |
198 Node* value = NodeProperties::GetValueInput(node, 0); | |
199 Node* effect = NodeProperties::GetEffectInput(node); | |
200 Node* control = NodeProperties::GetControlInput(node); | |
201 | |
202 Node* result = graph()->NewNode( | |
203 simplified()->LoadField(AccessBuilder::ForStringLength()), value, effect, | |
204 control); | |
205 NodeProperties::ReplaceWithValue(node, result); | |
titzer
2015/03/18 09:25:53
Same as above.
Sven Panne
2015/03/18 10:40:08
Done.
| |
206 return Replace(value); | |
207 } | |
208 | |
209 | |
180 Reduction JSIntrinsicLowering::ReduceInlineValueOf(Node* node) { | 210 Reduction JSIntrinsicLowering::ReduceInlineValueOf(Node* node) { |
181 // if (%_IsSmi(value)) { | 211 // if (%_IsSmi(value)) { |
182 // return value; | 212 // return value; |
183 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { | 213 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { |
184 // return %_GetValue(value); | 214 // return %_GetValue(value); |
185 // } else { | 215 // } else { |
186 // return value; | 216 // return value; |
187 // } | 217 // } |
188 const Operator* const merge_op = common()->Merge(2); | 218 const Operator* const merge_op = common()->Merge(2); |
189 const Operator* const ephi_op = common()->EffectPhi(2); | 219 const Operator* const ephi_op = common()->EffectPhi(2); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 300 } |
271 | 301 |
272 | 302 |
273 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 303 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
274 return jsgraph()->machine(); | 304 return jsgraph()->machine(); |
275 } | 305 } |
276 | 306 |
277 } // namespace compiler | 307 } // namespace compiler |
278 } // namespace internal | 308 } // namespace internal |
279 } // namespace v8 | 309 } // namespace v8 |
OLD | NEW |