| 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/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
| 8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
| 9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 // ----------------------------------------------------------------------------- | 410 // ----------------------------------------------------------------------------- |
| 411 // JSToNumber | 411 // JSToNumber |
| 412 | 412 |
| 413 | 413 |
| 414 TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) { | 414 TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) { |
| 415 Node* const input = Parameter(Type::PlainPrimitive(), 0); | 415 Node* const input = Parameter(Type::PlainPrimitive(), 0); |
| 416 Node* const context = Parameter(Type::Any(), 1); | 416 Node* const context = Parameter(Type::Any(), 1); |
| 417 Node* const effect = graph()->start(); | 417 Node* const effect = graph()->start(); |
| 418 Node* const control = graph()->start(); | 418 Node* const control = graph()->start(); |
| 419 Reduction r = | 419 Reduction r = |
| 420 FLAG_turbo_deoptimization | 420 Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, |
| 421 ? Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, | 421 EmptyFrameState(), effect, control)); |
| 422 EmptyFrameState(), effect, control)) | |
| 423 : Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, | |
| 424 effect, control)); | |
| 425 ASSERT_TRUE(r.Changed()); | 422 ASSERT_TRUE(r.Changed()); |
| 426 EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(BitEq(0.0)), | 423 EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(BitEq(0.0)), |
| 427 graph()->start(), control)); | 424 graph()->start(), control)); |
| 428 } | 425 } |
| 429 | 426 |
| 430 | 427 |
| 431 // ----------------------------------------------------------------------------- | 428 // ----------------------------------------------------------------------------- |
| 432 // JSStrictEqual | 429 // JSStrictEqual |
| 433 | 430 |
| 434 | 431 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 Handle<JSTypedArray> array = | 629 Handle<JSTypedArray> array = |
| 633 factory()->NewJSTypedArray(type, buffer, 0, kLength); | 630 factory()->NewJSTypedArray(type, buffer, 0, kLength); |
| 634 int const element_size = static_cast<int>(array->element_size()); | 631 int const element_size = static_cast<int>(array->element_size()); |
| 635 | 632 |
| 636 Node* key = Parameter( | 633 Node* key = Parameter( |
| 637 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); | 634 Type::Range(kMinInt / element_size, kMaxInt / element_size, zone())); |
| 638 Node* base = HeapConstant(array); | 635 Node* base = HeapConstant(array); |
| 639 Node* context = UndefinedConstant(); | 636 Node* context = UndefinedConstant(); |
| 640 Node* effect = graph()->start(); | 637 Node* effect = graph()->start(); |
| 641 Node* control = graph()->start(); | 638 Node* control = graph()->start(); |
| 642 Node* node = graph()->NewNode(javascript()->LoadProperty(feedback), base, | 639 Reduction r = |
| 643 key, context); | 640 Reduce(graph()->NewNode(javascript()->LoadProperty(feedback), base, key, |
| 644 if (FLAG_turbo_deoptimization) { | 641 context, EmptyFrameState(), effect, control)); |
| 645 node->AppendInput(zone(), UndefinedConstant()); | |
| 646 } | |
| 647 node->AppendInput(zone(), effect); | |
| 648 node->AppendInput(zone(), control); | |
| 649 Reduction r = Reduce(node); | |
| 650 | 642 |
| 651 Matcher<Node*> offset_matcher = | 643 Matcher<Node*> offset_matcher = |
| 652 element_size == 1 | 644 element_size == 1 |
| 653 ? key | 645 ? key |
| 654 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size))); | 646 : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size))); |
| 655 | 647 |
| 656 ASSERT_TRUE(r.Changed()); | 648 ASSERT_TRUE(r.Changed()); |
| 657 EXPECT_THAT( | 649 EXPECT_THAT( |
| 658 r.replacement(), | 650 r.replacement(), |
| 659 IsLoadBuffer(BufferAccess(type), | 651 IsLoadBuffer(BufferAccess(type), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 678 ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true); | 670 ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true); |
| 679 | 671 |
| 680 int min = random_number_generator()->NextInt(static_cast<int>(kLength)); | 672 int min = random_number_generator()->NextInt(static_cast<int>(kLength)); |
| 681 int max = random_number_generator()->NextInt(static_cast<int>(kLength)); | 673 int max = random_number_generator()->NextInt(static_cast<int>(kLength)); |
| 682 if (min > max) std::swap(min, max); | 674 if (min > max) std::swap(min, max); |
| 683 Node* key = Parameter(Type::Range(min, max, zone())); | 675 Node* key = Parameter(Type::Range(min, max, zone())); |
| 684 Node* base = HeapConstant(array); | 676 Node* base = HeapConstant(array); |
| 685 Node* context = UndefinedConstant(); | 677 Node* context = UndefinedConstant(); |
| 686 Node* effect = graph()->start(); | 678 Node* effect = graph()->start(); |
| 687 Node* control = graph()->start(); | 679 Node* control = graph()->start(); |
| 688 Node* node = graph()->NewNode(javascript()->LoadProperty(feedback), base, | 680 Reduction r = |
| 689 key, context); | 681 Reduce(graph()->NewNode(javascript()->LoadProperty(feedback), base, key, |
| 690 if (FLAG_turbo_deoptimization) { | 682 context, EmptyFrameState(), effect, control)); |
| 691 node->AppendInput(zone(), UndefinedConstant()); | |
| 692 } | |
| 693 node->AppendInput(zone(), effect); | |
| 694 node->AppendInput(zone(), control); | |
| 695 Reduction r = Reduce(node); | |
| 696 | 683 |
| 697 ASSERT_TRUE(r.Changed()); | 684 ASSERT_TRUE(r.Changed()); |
| 698 EXPECT_THAT( | 685 EXPECT_THAT( |
| 699 r.replacement(), | 686 r.replacement(), |
| 700 IsLoadElement(access, | 687 IsLoadElement(access, |
| 701 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), | 688 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), |
| 702 key, effect, control)); | 689 key, effect, control)); |
| 703 } | 690 } |
| 704 } | 691 } |
| 705 | 692 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 | 855 |
| 869 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), | 856 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), |
| 870 FeedbackVectorICSlot::Invalid()); | 857 FeedbackVectorICSlot::Invalid()); |
| 871 Node* global = Parameter(Type::GlobalObject()); | 858 Node* global = Parameter(Type::GlobalObject()); |
| 872 Node* context = UndefinedConstant(); | 859 Node* context = UndefinedConstant(); |
| 873 Node* effect = graph()->start(); | 860 Node* effect = graph()->start(); |
| 874 Node* control = graph()->start(); | 861 Node* control = graph()->start(); |
| 875 | 862 |
| 876 for (size_t i = 0; i < arraysize(names); i++) { | 863 for (size_t i = 0; i < arraysize(names); i++) { |
| 877 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]); | 864 Unique<Name> name = Unique<Name>::CreateImmovable(names[i]); |
| 878 Node* node = graph()->NewNode(javascript()->LoadNamed(name, feedback), | 865 Reduction r = |
| 879 global, context); | 866 Reduce(graph()->NewNode(javascript()->LoadNamed(name, feedback), global, |
| 880 if (FLAG_turbo_deoptimization) { | 867 context, EmptyFrameState(), effect, control)); |
| 881 node->AppendInput(zone(), EmptyFrameState()); | |
| 882 } | |
| 883 node->AppendInput(zone(), effect); | |
| 884 node->AppendInput(zone(), control); | |
| 885 | 868 |
| 886 Reduction r = Reduce(node); | 869 ASSERT_TRUE(r.Changed()); |
| 887 | |
| 888 EXPECT_THAT(r.replacement(), matches[i]); | 870 EXPECT_THAT(r.replacement(), matches[i]); |
| 889 } | 871 } |
| 890 } | 872 } |
| 891 | 873 |
| 892 } // namespace compiler | 874 } // namespace compiler |
| 893 } // namespace internal | 875 } // namespace internal |
| 894 } // namespace v8 | 876 } // namespace v8 |
| OLD | NEW |