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/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
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/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { | 119 TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) { |
120 Node* input = Parameter(Type::Any(), 0); | 120 Node* input = Parameter(Type::Any(), 0); |
121 Node* context = Parameter(Type::Any(), 1); | 121 Node* context = Parameter(Type::Any(), 1); |
122 Reduction r = Reduce(graph()->NewNode( | 122 Reduction r = Reduce(graph()->NewNode( |
123 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); | 123 javascript()->ToBoolean(ToBooleanHint::kAny), input, context)); |
124 ASSERT_FALSE(r.Changed()); | 124 ASSERT_FALSE(r.Changed()); |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 // ----------------------------------------------------------------------------- | 128 // ----------------------------------------------------------------------------- |
| 129 // JSToName |
| 130 |
| 131 TEST_F(JSTypedLoweringTest, JSToNameWithString) { |
| 132 Node* const input = Parameter(Type::String(), 0); |
| 133 Node* const context = Parameter(Type::Any(), 1); |
| 134 Node* const effect = graph()->start(); |
| 135 Node* const control = graph()->start(); |
| 136 Reduction r = Reduce(graph()->NewNode(javascript()->ToName(), input, context, |
| 137 EmptyFrameState(), effect, control)); |
| 138 ASSERT_TRUE(r.Changed()); |
| 139 EXPECT_EQ(input, r.replacement()); |
| 140 } |
| 141 |
| 142 TEST_F(JSTypedLoweringTest, JSToNameWithSymbol) { |
| 143 Node* const input = Parameter(Type::Symbol(), 0); |
| 144 Node* const context = Parameter(Type::Any(), 1); |
| 145 Node* const effect = graph()->start(); |
| 146 Node* const control = graph()->start(); |
| 147 Reduction r = Reduce(graph()->NewNode(javascript()->ToName(), input, context, |
| 148 EmptyFrameState(), effect, control)); |
| 149 ASSERT_TRUE(r.Changed()); |
| 150 EXPECT_EQ(input, r.replacement()); |
| 151 } |
| 152 |
| 153 TEST_F(JSTypedLoweringTest, JSToNameWithAny) { |
| 154 Node* const input = Parameter(Type::Any(), 0); |
| 155 Node* const context = Parameter(Type::Any(), 1); |
| 156 Node* const effect = graph()->start(); |
| 157 Node* const control = graph()->start(); |
| 158 Reduction r = Reduce(graph()->NewNode(javascript()->ToName(), input, context, |
| 159 EmptyFrameState(), effect, control)); |
| 160 ASSERT_FALSE(r.Changed()); |
| 161 } |
| 162 |
| 163 // ----------------------------------------------------------------------------- |
129 // JSToNumber | 164 // JSToNumber |
130 | 165 |
131 | |
132 TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) { | 166 TEST_F(JSTypedLoweringTest, JSToNumberWithPlainPrimitive) { |
133 Node* const input = Parameter(Type::PlainPrimitive(), 0); | 167 Node* const input = Parameter(Type::PlainPrimitive(), 0); |
134 Node* const context = Parameter(Type::Any(), 1); | 168 Node* const context = Parameter(Type::Any(), 1); |
135 Node* const effect = graph()->start(); | 169 Node* const effect = graph()->start(); |
136 Node* const control = graph()->start(); | 170 Node* const control = graph()->start(); |
137 Reduction r = | 171 Reduction r = |
138 Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, | 172 Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, |
139 EmptyFrameState(), effect, control)); | 173 EmptyFrameState(), effect, control)); |
140 ASSERT_TRUE(r.Changed()); | 174 ASSERT_TRUE(r.Changed()); |
141 EXPECT_THAT(r.replacement(), IsPlainPrimitiveToNumber(input)); | 175 EXPECT_THAT(r.replacement(), IsPlainPrimitiveToNumber(input)); |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 EmptyFrameState(), effect, control)); | 1041 EmptyFrameState(), effect, control)); |
1008 ASSERT_TRUE(r.Changed()); | 1042 ASSERT_TRUE(r.Changed()); |
1009 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( | 1043 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( |
1010 NumberOperationHint::kNumberOrOddball, lhs, | 1044 NumberOperationHint::kNumberOrOddball, lhs, |
1011 rhs, effect, control)); | 1045 rhs, effect, control)); |
1012 } | 1046 } |
1013 | 1047 |
1014 } // namespace compiler | 1048 } // namespace compiler |
1015 } // namespace internal | 1049 } // namespace internal |
1016 } // namespace v8 | 1050 } // namespace v8 |
OLD | NEW |