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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 Node* const control = graph()->start(); | 807 Node* const control = graph()->start(); |
808 Reduction const r = Reduce(graph()->NewNode( | 808 Reduction const r = Reduce(graph()->NewNode( |
809 javascript()->LoadNamed(name, feedback), receiver, vector, context, | 809 javascript()->LoadNamed(name, feedback), receiver, vector, context, |
810 EmptyFrameState(), EmptyFrameState(), effect, control)); | 810 EmptyFrameState(), EmptyFrameState(), effect, control)); |
811 ASSERT_TRUE(r.Changed()); | 811 ASSERT_TRUE(r.Changed()); |
812 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), | 812 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), |
813 receiver, effect, control)); | 813 receiver, effect, control)); |
814 } | 814 } |
815 | 815 |
816 | 816 |
817 TEST_F(JSTypedLoweringTest, JSLoadNamedFunctionPrototype) { | |
818 VectorSlotPair feedback; | |
819 Handle<Name> name = factory()->prototype_string(); | |
820 Handle<JSFunction> function = isolate()->object_function(); | |
821 Handle<JSObject> function_prototype(JSObject::cast(function->prototype())); | |
822 Node* const receiver = Parameter(Type::Constant(function, zone()), 0); | |
823 Node* const vector = Parameter(Type::Internal(), 1); | |
824 Node* const context = Parameter(Type::Internal(), 2); | |
825 Node* const effect = graph()->start(); | |
826 Node* const control = graph()->start(); | |
827 Reduction const r = Reduce(graph()->NewNode( | |
828 javascript()->LoadNamed(name, feedback), receiver, vector, context, | |
829 EmptyFrameState(), EmptyFrameState(), effect, control)); | |
830 ASSERT_TRUE(r.Changed()); | |
831 EXPECT_THAT(r.replacement(), IsHeapConstant(function_prototype)); | |
832 } | |
833 | |
834 | |
835 // ----------------------------------------------------------------------------- | 817 // ----------------------------------------------------------------------------- |
836 // JSAdd | 818 // JSAdd |
837 | 819 |
838 | 820 |
839 TEST_F(JSTypedLoweringTest, JSAddWithString) { | 821 TEST_F(JSTypedLoweringTest, JSAddWithString) { |
840 BinaryOperationHints const hints = BinaryOperationHints::Any(); | 822 BinaryOperationHints const hints = BinaryOperationHints::Any(); |
841 Node* lhs = Parameter(Type::String(), 0); | 823 Node* lhs = Parameter(Type::String(), 0); |
842 Node* rhs = Parameter(Type::String(), 1); | 824 Node* rhs = Parameter(Type::String(), 1); |
843 Node* context = Parameter(Type::Any(), 2); | 825 Node* context = Parameter(Type::Any(), 2); |
844 Node* frame_state0 = EmptyFrameState(); | 826 Node* frame_state0 = EmptyFrameState(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, | 898 Node* dummy = graph()->NewNode(javascript()->ToObject(), instanceOf, context, |
917 frame_state, effect, control); | 899 frame_state, effect, control); |
918 Reduction r = Reduce(instanceOf); | 900 Reduction r = Reduce(instanceOf); |
919 ASSERT_FALSE(r.Changed()); | 901 ASSERT_FALSE(r.Changed()); |
920 ASSERT_EQ(instanceOf, dummy->InputAt(0)); | 902 ASSERT_EQ(instanceOf, dummy->InputAt(0)); |
921 } | 903 } |
922 | 904 |
923 } // namespace compiler | 905 } // namespace compiler |
924 } // namespace internal | 906 } // namespace internal |
925 } // namespace v8 | 907 } // namespace v8 |
OLD | NEW |