| 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 <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 case Runtime::kInlineJSValueGetValue: | 67 case Runtime::kInlineJSValueGetValue: |
| 68 return ReduceJSValueGetValue(node); | 68 return ReduceJSValueGetValue(node); |
| 69 case Runtime::kInlineMapGetInstanceType: | 69 case Runtime::kInlineMapGetInstanceType: |
| 70 return ReduceMapGetInstanceType(node); | 70 return ReduceMapGetInstanceType(node); |
| 71 case Runtime::kInlineMathClz32: | 71 case Runtime::kInlineMathClz32: |
| 72 return ReduceMathClz32(node); | 72 return ReduceMathClz32(node); |
| 73 case Runtime::kInlineMathFloor: | 73 case Runtime::kInlineMathFloor: |
| 74 return ReduceMathFloor(node); | 74 return ReduceMathFloor(node); |
| 75 case Runtime::kInlineMathSqrt: | 75 case Runtime::kInlineMathSqrt: |
| 76 return ReduceMathSqrt(node); | 76 return ReduceMathSqrt(node); |
| 77 case Runtime::kInlineOneByteSeqStringGetChar: | |
| 78 return ReduceSeqStringGetChar(node, String::ONE_BYTE_ENCODING); | |
| 79 case Runtime::kInlineOneByteSeqStringSetChar: | |
| 80 return ReduceSeqStringSetChar(node, String::ONE_BYTE_ENCODING); | |
| 81 case Runtime::kInlineStringGetLength: | 77 case Runtime::kInlineStringGetLength: |
| 82 return ReduceStringGetLength(node); | 78 return ReduceStringGetLength(node); |
| 83 case Runtime::kInlineTwoByteSeqStringGetChar: | |
| 84 return ReduceSeqStringGetChar(node, String::TWO_BYTE_ENCODING); | |
| 85 case Runtime::kInlineTwoByteSeqStringSetChar: | |
| 86 return ReduceSeqStringSetChar(node, String::TWO_BYTE_ENCODING); | |
| 87 case Runtime::kInlineValueOf: | 79 case Runtime::kInlineValueOf: |
| 88 return ReduceValueOf(node); | 80 return ReduceValueOf(node); |
| 89 case Runtime::kInlineIsMinusZero: | 81 case Runtime::kInlineIsMinusZero: |
| 90 return ReduceIsMinusZero(node); | 82 return ReduceIsMinusZero(node); |
| 91 case Runtime::kInlineFixedArrayGet: | 83 case Runtime::kInlineFixedArrayGet: |
| 92 return ReduceFixedArrayGet(node); | 84 return ReduceFixedArrayGet(node); |
| 93 case Runtime::kInlineFixedArraySet: | 85 case Runtime::kInlineFixedArraySet: |
| 94 return ReduceFixedArraySet(node); | 86 return ReduceFixedArraySet(node); |
| 95 case Runtime::kInlineGetTypeFeedbackVector: | 87 case Runtime::kInlineGetTypeFeedbackVector: |
| 96 return ReduceGetTypeFeedbackVector(node); | 88 return ReduceGetTypeFeedbackVector(node); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (!machine()->Float64RoundDown().IsSupported()) return NoChange(); | 321 if (!machine()->Float64RoundDown().IsSupported()) return NoChange(); |
| 330 return Change(node, machine()->Float64RoundDown().op()); | 322 return Change(node, machine()->Float64RoundDown().op()); |
| 331 } | 323 } |
| 332 | 324 |
| 333 | 325 |
| 334 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { | 326 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { |
| 335 return Change(node, machine()->Float64Sqrt()); | 327 return Change(node, machine()->Float64Sqrt()); |
| 336 } | 328 } |
| 337 | 329 |
| 338 | 330 |
| 339 Reduction JSIntrinsicLowering::ReduceSeqStringGetChar( | |
| 340 Node* node, String::Encoding encoding) { | |
| 341 Node* effect = NodeProperties::GetEffectInput(node); | |
| 342 Node* control = NodeProperties::GetControlInput(node); | |
| 343 RelaxControls(node); | |
| 344 node->ReplaceInput(2, effect); | |
| 345 node->ReplaceInput(3, control); | |
| 346 node->TrimInputCount(4); | |
| 347 NodeProperties::ChangeOp( | |
| 348 node, | |
| 349 simplified()->LoadElement(AccessBuilder::ForSeqStringChar(encoding))); | |
| 350 return Changed(node); | |
| 351 } | |
| 352 | |
| 353 | |
| 354 Reduction JSIntrinsicLowering::ReduceSeqStringSetChar( | |
| 355 Node* node, String::Encoding encoding) { | |
| 356 // Note: The intrinsic has a strange argument order, so we need to reshuffle. | |
| 357 Node* index = NodeProperties::GetValueInput(node, 0); | |
| 358 Node* chr = NodeProperties::GetValueInput(node, 1); | |
| 359 Node* string = NodeProperties::GetValueInput(node, 2); | |
| 360 Node* effect = NodeProperties::GetEffectInput(node); | |
| 361 Node* control = NodeProperties::GetControlInput(node); | |
| 362 ReplaceWithValue(node, string, node); | |
| 363 NodeProperties::RemoveType(node); | |
| 364 node->ReplaceInput(0, string); | |
| 365 node->ReplaceInput(1, index); | |
| 366 node->ReplaceInput(2, chr); | |
| 367 node->ReplaceInput(3, effect); | |
| 368 node->ReplaceInput(4, control); | |
| 369 node->TrimInputCount(5); | |
| 370 NodeProperties::ChangeOp( | |
| 371 node, | |
| 372 simplified()->StoreElement(AccessBuilder::ForSeqStringChar(encoding))); | |
| 373 return Changed(node); | |
| 374 } | |
| 375 | |
| 376 | |
| 377 Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { | 331 Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { |
| 378 Node* value = NodeProperties::GetValueInput(node, 0); | 332 Node* value = NodeProperties::GetValueInput(node, 0); |
| 379 Node* effect = NodeProperties::GetEffectInput(node); | 333 Node* effect = NodeProperties::GetEffectInput(node); |
| 380 Node* control = NodeProperties::GetControlInput(node); | 334 Node* control = NodeProperties::GetControlInput(node); |
| 381 return Change(node, simplified()->LoadField(AccessBuilder::ForStringLength()), | 335 return Change(node, simplified()->LoadField(AccessBuilder::ForStringLength()), |
| 382 value, effect, control); | 336 value, effect, control); |
| 383 } | 337 } |
| 384 | 338 |
| 385 | 339 |
| 386 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { | 340 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 } | 685 } |
| 732 | 686 |
| 733 | 687 |
| 734 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 688 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
| 735 return jsgraph()->simplified(); | 689 return jsgraph()->simplified(); |
| 736 } | 690 } |
| 737 | 691 |
| 738 } // namespace compiler | 692 } // namespace compiler |
| 739 } // namespace internal | 693 } // namespace internal |
| 740 } // namespace v8 | 694 } // namespace v8 |
| OLD | NEW |