OLD | NEW |
---|---|
1 | 1 |
2 // Copyright 2015 the V8 project authors. All rights reserved. | 2 // Copyright 2015 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include "src/compiler/js-intrinsic-lowering.h" | 6 #include "src/compiler/js-intrinsic-lowering.h" |
7 | 7 |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 case Runtime::kInlineJSValueGetValue: | 46 case Runtime::kInlineJSValueGetValue: |
47 return ReduceJSValueGetValue(node); | 47 return ReduceJSValueGetValue(node); |
48 case Runtime::kInlineMapGetInstanceType: | 48 case Runtime::kInlineMapGetInstanceType: |
49 return ReduceMapGetInstanceType(node); | 49 return ReduceMapGetInstanceType(node); |
50 case Runtime::kInlineMathClz32: | 50 case Runtime::kInlineMathClz32: |
51 return ReduceMathClz32(node); | 51 return ReduceMathClz32(node); |
52 case Runtime::kInlineMathFloor: | 52 case Runtime::kInlineMathFloor: |
53 return ReduceMathFloor(node); | 53 return ReduceMathFloor(node); |
54 case Runtime::kInlineMathSqrt: | 54 case Runtime::kInlineMathSqrt: |
55 return ReduceMathSqrt(node); | 55 return ReduceMathSqrt(node); |
56 case Runtime::kInlineOneByteSeqStringGetChar: | |
57 return ReduceSeqStringGetChar(node, String::ONE_BYTE_ENCODING); | |
58 case Runtime::kInlineOneByteSeqStringSetChar: | |
59 return ReduceSeqStringSetChar(node, String::ONE_BYTE_ENCODING); | |
56 case Runtime::kInlineStringGetLength: | 60 case Runtime::kInlineStringGetLength: |
57 return ReduceStringGetLength(node); | 61 return ReduceStringGetLength(node); |
62 case Runtime::kInlineTwoByteSeqStringGetChar: | |
63 return ReduceSeqStringGetChar(node, String::TWO_BYTE_ENCODING); | |
64 case Runtime::kInlineTwoByteSeqStringSetChar: | |
65 return ReduceSeqStringSetChar(node, String::TWO_BYTE_ENCODING); | |
58 case Runtime::kInlineValueOf: | 66 case Runtime::kInlineValueOf: |
59 return ReduceValueOf(node); | 67 return ReduceValueOf(node); |
60 default: | 68 default: |
61 break; | 69 break; |
62 } | 70 } |
63 return NoChange(); | 71 return NoChange(); |
64 } | 72 } |
65 | 73 |
66 | 74 |
67 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { | 75 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 if (!machine()->HasFloat64RoundDown()) return NoChange(); | 222 if (!machine()->HasFloat64RoundDown()) return NoChange(); |
215 return Change(node, machine()->Float64RoundDown()); | 223 return Change(node, machine()->Float64RoundDown()); |
216 } | 224 } |
217 | 225 |
218 | 226 |
219 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { | 227 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { |
220 return Change(node, machine()->Float64Sqrt()); | 228 return Change(node, machine()->Float64Sqrt()); |
221 } | 229 } |
222 | 230 |
223 | 231 |
232 Reduction JSIntrinsicLowering::ReduceSeqStringGetChar( | |
233 Node* node, String::Encoding encoding) { | |
234 Node* effect = NodeProperties::GetEffectInput(node); | |
235 Node* control = NodeProperties::GetControlInput(node); | |
236 node->set_op( | |
237 simplified()->LoadElement(AccessBuilder::ForSeqStringChar(encoding))); | |
238 node->ReplaceInput(2, effect); | |
239 node->ReplaceInput(3, control); | |
240 node->TrimInputCount(4); | |
241 NodeProperties::ReplaceWithValue(node, node, node); | |
242 return Changed(node); | |
243 } | |
244 | |
245 | |
246 Reduction JSIntrinsicLowering::ReduceSeqStringSetChar( | |
247 Node* node, String::Encoding encoding) { | |
248 // Note: The intrinsic has a strange argument order, so we need to reshuffle. | |
249 Node* index = NodeProperties::GetValueInput(node, 0); | |
250 Node* chr = NodeProperties::GetValueInput(node, 1); | |
251 Node* string = NodeProperties::GetValueInput(node, 2); | |
252 Node* effect = NodeProperties::GetEffectInput(node); | |
253 Node* control = NodeProperties::GetControlInput(node); | |
254 node->set_op( | |
255 simplified()->StoreElement(AccessBuilder::ForSeqStringChar(encoding))); | |
256 node->ReplaceInput(0, string); | |
257 node->ReplaceInput(1, index); | |
258 node->ReplaceInput(2, chr); | |
259 node->ReplaceInput(3, effect); | |
260 node->ReplaceInput(4, control); | |
261 node->TrimInputCount(5); | |
262 NodeProperties::RemoveBounds(node); | |
263 NodeProperties::ReplaceWithValue(node, node, node); | |
Michael Starzinger
2015/03/25 17:41:55
Let's just use "string" as the second argument to
Sven Panne
2015/03/26 08:02:34
Done.
| |
264 return Changed(node); | |
265 } | |
266 | |
267 | |
224 Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { | 268 Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { |
225 Node* value = NodeProperties::GetValueInput(node, 0); | 269 Node* value = NodeProperties::GetValueInput(node, 0); |
226 Node* effect = NodeProperties::GetEffectInput(node); | 270 Node* effect = NodeProperties::GetEffectInput(node); |
227 Node* control = NodeProperties::GetControlInput(node); | 271 Node* control = NodeProperties::GetControlInput(node); |
228 return Change(node, simplified()->LoadField(AccessBuilder::ForStringLength()), | 272 return Change(node, simplified()->LoadField(AccessBuilder::ForStringLength()), |
229 value, effect, control); | 273 value, effect, control); |
230 } | 274 } |
231 | 275 |
232 | 276 |
233 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { | 277 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 } | 368 } |
325 | 369 |
326 | 370 |
327 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 371 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
328 return jsgraph()->machine(); | 372 return jsgraph()->machine(); |
329 } | 373 } |
330 | 374 |
331 } // namespace compiler | 375 } // namespace compiler |
332 } // namespace internal | 376 } // namespace internal |
333 } // namespace v8 | 377 } // namespace v8 |
OLD | NEW |