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/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 Handle<Object> value = OpParameter<Unique<Object> >(result).handle(); | 160 Handle<Object> value = OpParameter<Unique<Object> >(result).handle(); |
161 CHECK_EQ(*expected, *value); | 161 CHECK_EQ(*expected, *value); |
162 } | 162 } |
163 }; | 163 }; |
164 | 164 |
165 static Type* kStringTypes[] = {Type::InternalizedString(), Type::OtherString(), | 165 static Type* kStringTypes[] = {Type::InternalizedString(), Type::OtherString(), |
166 Type::String()}; | 166 Type::String()}; |
167 | 167 |
168 | 168 |
169 static Type* kInt32Types[] = { | 169 static Type* kInt32Types[] = { |
170 Type::UnsignedSmall(), Type::NegativeSigned32(), | 170 Type::UnsignedSmall(), Type::OtherSignedSmall(), Type::OtherUnsigned31(), |
171 Type::NonNegativeSigned32(), Type::SignedSmall(), | 171 Type::OtherUnsigned32(), Type::OtherSigned32(), Type::SignedSmall(), |
172 Type::Signed32(), Type::Unsigned32(), | 172 Type::Signed32(), Type::Unsigned32(), Type::Integral32()}; |
173 Type::Integral32()}; | |
174 | 173 |
175 | 174 |
176 static Type* kNumberTypes[] = { | 175 static Type* kNumberTypes[] = { |
177 Type::UnsignedSmall(), Type::NegativeSigned32(), | 176 Type::UnsignedSmall(), Type::OtherSignedSmall(), Type::OtherUnsigned31(), |
178 Type::NonNegativeSigned32(), Type::SignedSmall(), | 177 Type::OtherUnsigned32(), Type::OtherSigned32(), Type::SignedSmall(), |
179 Type::Signed32(), Type::Unsigned32(), | 178 Type::Signed32(), Type::Unsigned32(), Type::Integral32(), |
180 Type::Integral32(), Type::MinusZero(), | 179 Type::MinusZero(), Type::NaN(), Type::OtherNumber(), |
181 Type::NaN(), Type::OrderedNumber(), | 180 Type::OrderedNumber(), Type::Number()}; |
182 Type::PlainNumber(), Type::Number()}; | |
183 | 181 |
184 | 182 |
185 static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), | 183 static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), |
186 Type::Number(), Type::String(), Type::Object()}; | 184 Type::Number(), Type::String(), Type::Object()}; |
187 | 185 |
188 | 186 |
189 static Type* I32Type(bool is_signed) { | 187 static Type* I32Type(bool is_signed) { |
190 return is_signed ? Type::Signed32() : Type::Unsigned32(); | 188 return is_signed ? Type::Signed32() : Type::Unsigned32(); |
191 } | 189 } |
192 | 190 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 void set(int idx, const Operator* op, bool s) { | 297 void set(int idx, const Operator* op, bool s) { |
300 ops[idx] = op; | 298 ops[idx] = op; |
301 signedness[idx] = s; | 299 signedness[idx] = s; |
302 } | 300 } |
303 }; | 301 }; |
304 | 302 |
305 | 303 |
306 TEST(Int32BitwiseShifts) { | 304 TEST(Int32BitwiseShifts) { |
307 JSBitwiseShiftTypedLoweringTester R; | 305 JSBitwiseShiftTypedLoweringTester R; |
308 | 306 |
309 Type* types[] = {Type::SignedSmall(), Type::UnsignedSmall(), | 307 Type* types[] = { |
310 Type::NegativeSigned32(), Type::NonNegativeSigned32(), | 308 Type::SignedSmall(), Type::UnsignedSmall(), Type::OtherSigned32(), |
311 Type::Unsigned32(), Type::Signed32(), | 309 Type::Unsigned32(), Type::Signed32(), Type::MinusZero(), |
312 Type::MinusZero(), Type::NaN(), | 310 Type::NaN(), Type::OtherNumber(), Type::Undefined(), |
313 Type::Undefined(), Type::Null(), | 311 Type::Null(), Type::Boolean(), Type::Number(), |
314 Type::Boolean(), Type::Number(), | 312 Type::String()}; |
315 Type::PlainNumber(), Type::String()}; | |
316 | 313 |
317 for (size_t i = 0; i < arraysize(types); ++i) { | 314 for (size_t i = 0; i < arraysize(types); ++i) { |
318 Node* p0 = R.Parameter(types[i], 0); | 315 Node* p0 = R.Parameter(types[i], 0); |
319 | 316 |
320 for (size_t j = 0; j < arraysize(types); ++j) { | 317 for (size_t j = 0; j < arraysize(types); ++j) { |
321 Node* p1 = R.Parameter(types[j], 1); | 318 Node* p1 = R.Parameter(types[j], 1); |
322 | 319 |
323 for (int k = 0; k < R.kNumberOps; k += 2) { | 320 for (int k = 0; k < R.kNumberOps; k += 2) { |
324 Node* add = R.Binop(R.ops[k], p0, p1); | 321 Node* add = R.Binop(R.ops[k], p0, p1); |
325 Node* r = R.reduce(add); | 322 Node* r = R.reduce(add); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ops[idx] = op; | 362 ops[idx] = op; |
366 signedness[idx] = s; | 363 signedness[idx] = s; |
367 } | 364 } |
368 }; | 365 }; |
369 | 366 |
370 | 367 |
371 TEST(Int32BitwiseBinops) { | 368 TEST(Int32BitwiseBinops) { |
372 JSBitwiseTypedLoweringTester R; | 369 JSBitwiseTypedLoweringTester R; |
373 | 370 |
374 Type* types[] = { | 371 Type* types[] = { |
375 Type::SignedSmall(), Type::UnsignedSmall(), Type::Unsigned32(), | 372 Type::SignedSmall(), Type::UnsignedSmall(), Type::Unsigned32(), |
376 Type::Signed32(), Type::MinusZero(), Type::NaN(), | 373 Type::Signed32(), Type::MinusZero(), Type::NaN(), |
377 Type::OrderedNumber(), Type::PlainNumber(), Type::Undefined(), | 374 Type::OtherNumber(), Type::Undefined(), Type::Null(), |
378 Type::Null(), Type::Boolean(), Type::Number(), | 375 Type::Boolean(), Type::Number(), Type::String()}; |
379 Type::String()}; | |
380 | 376 |
381 for (size_t i = 0; i < arraysize(types); ++i) { | 377 for (size_t i = 0; i < arraysize(types); ++i) { |
382 Node* p0 = R.Parameter(types[i], 0); | 378 Node* p0 = R.Parameter(types[i], 0); |
383 | 379 |
384 for (size_t j = 0; j < arraysize(types); ++j) { | 380 for (size_t j = 0; j < arraysize(types); ++j) { |
385 Node* p1 = R.Parameter(types[j], 1); | 381 Node* p1 = R.Parameter(types[j], 1); |
386 | 382 |
387 for (int k = 0; k < R.kNumberOps; k += 2) { | 383 for (int k = 0; k < R.kNumberOps; k += 2) { |
388 Node* add = R.Binop(R.ops[k], p0, p1); | 384 Node* add = R.Binop(R.ops[k], p0, p1); |
389 Node* r = R.reduce(add); | 385 Node* r = R.reduce(add); |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 CHECK_EQ(p1, r->InputAt(0)); | 1294 CHECK_EQ(p1, r->InputAt(0)); |
1299 CHECK_EQ(p0, r->InputAt(1)); | 1295 CHECK_EQ(p0, r->InputAt(1)); |
1300 } else { | 1296 } else { |
1301 CHECK_EQ(p0, r->InputAt(0)); | 1297 CHECK_EQ(p0, r->InputAt(0)); |
1302 CHECK_EQ(p1, r->InputAt(1)); | 1298 CHECK_EQ(p1, r->InputAt(1)); |
1303 } | 1299 } |
1304 } | 1300 } |
1305 } | 1301 } |
1306 } | 1302 } |
1307 } | 1303 } |
OLD | NEW |