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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 } else { | 1378 } else { |
1379 CHECK_EQ(p0, r->InputAt(0)); | 1379 CHECK_EQ(p0, r->InputAt(0)); |
1380 CHECK_EQ(p1, r->InputAt(1)); | 1380 CHECK_EQ(p1, r->InputAt(1)); |
1381 } | 1381 } |
1382 } | 1382 } |
1383 } | 1383 } |
1384 } | 1384 } |
1385 } | 1385 } |
1386 | 1386 |
1387 | 1387 |
| 1388 TEST(BuiltinMathMax) { |
| 1389 JSTypedLoweringTester R; |
| 1390 |
| 1391 Node* fun = R.HeapConstant(handle(R.isolate->context()->math_max_fun())); |
| 1392 Node* call = R.graph.NewNode(R.javascript.Call(2, NO_CALL_FUNCTION_FLAGS), |
| 1393 fun, R.UndefinedConstant()); |
| 1394 Node* r = R.reduce(call); |
| 1395 R.CheckNumberConstant(-V8_INFINITY, r); |
| 1396 |
| 1397 for (size_t i = 0; i < arraysize(kNumberTypes); i++) { |
| 1398 Type* t0 = kNumberTypes[i]; |
| 1399 Node* p0 = R.Parameter(t0, 0); |
| 1400 Node* call = R.graph.NewNode(R.javascript.Call(3, NO_CALL_FUNCTION_FLAGS), |
| 1401 fun, R.UndefinedConstant(), p0); |
| 1402 Node* r = R.reduce(call); |
| 1403 CHECK_EQ(IrOpcode::kParameter, r->opcode()); |
| 1404 CHECK_EQ(p0, r); |
| 1405 } |
| 1406 |
| 1407 for (size_t i = 0; i < arraysize(kNumberTypes); i++) { |
| 1408 for (size_t j = 0; j < arraysize(kNumberTypes); j++) { |
| 1409 Type* t0 = kNumberTypes[i]; |
| 1410 Node* p0 = R.Parameter(t0, 0); |
| 1411 Type* t1 = kNumberTypes[j]; |
| 1412 Node* p1 = R.Parameter(t1, 1); |
| 1413 Node* call = R.graph.NewNode(R.javascript.Call(4, NO_CALL_FUNCTION_FLAGS), |
| 1414 fun, R.UndefinedConstant(), p0, p1); |
| 1415 Node* r = R.reduce(call); |
| 1416 |
| 1417 if (t0->Is(Type::Integral32()) && t1->Is(Type::Integral32())) { |
| 1418 CHECK_EQ(IrOpcode::kPhi, r->opcode()); |
| 1419 CHECK(p0 == r->InputAt(0) || p1 == r->InputAt(0)); |
| 1420 CHECK(p1 == r->InputAt(1) || p0 == r->InputAt(1)); |
| 1421 } else { |
| 1422 CHECK_EQ(IrOpcode::kJSCallFunction, r->opcode()); |
| 1423 CHECK_EQ(call, r); |
| 1424 } |
| 1425 } |
| 1426 } |
| 1427 } |
| 1428 |
| 1429 |
1388 TEST(BuiltinMathImul) { | 1430 TEST(BuiltinMathImul) { |
1389 JSTypedLoweringTester R; | 1431 JSTypedLoweringTester R; |
1390 | 1432 |
1391 for (size_t i = 0; i < arraysize(kNumberTypes); i++) { | 1433 for (size_t i = 0; i < arraysize(kNumberTypes); i++) { |
1392 for (size_t j = 0; j < arraysize(kNumberTypes); j++) { | 1434 for (size_t j = 0; j < arraysize(kNumberTypes); j++) { |
1393 Type* t0 = kNumberTypes[i]; | 1435 Type* t0 = kNumberTypes[i]; |
1394 Node* p0 = R.Parameter(t0, 0); | 1436 Node* p0 = R.Parameter(t0, 0); |
1395 Type* t1 = kNumberTypes[j]; | 1437 Type* t1 = kNumberTypes[j]; |
1396 Node* p1 = R.Parameter(t1, 1); | 1438 Node* p1 = R.Parameter(t1, 1); |
1397 Node* fun = R.HeapConstant(handle(R.isolate->context()->math_imul_fun())); | 1439 Node* fun = R.HeapConstant(handle(R.isolate->context()->math_imul_fun())); |
1398 Node* call = R.graph.NewNode(R.javascript.Call(4, NO_CALL_FUNCTION_FLAGS), | 1440 Node* call = R.graph.NewNode(R.javascript.Call(4, NO_CALL_FUNCTION_FLAGS), |
1399 fun, R.UndefinedConstant(), p0, p1); | 1441 fun, R.UndefinedConstant(), p0, p1); |
1400 Node* r = R.reduce(call); | 1442 Node* r = R.reduce(call); |
1401 | 1443 |
1402 if (t0->Is(Type::Integral32()) && t1->Is(Type::Integral32())) { | 1444 if (t0->Is(Type::Integral32()) && t1->Is(Type::Integral32())) { |
1403 R.CheckPureBinop(R.machine.Int32Mul(), r); | 1445 R.CheckPureBinop(R.machine.Int32Mul(), r); |
1404 CHECK_EQ(p0, r->InputAt(0)); | 1446 CHECK_EQ(p0, r->InputAt(0)); |
1405 CHECK_EQ(p1, r->InputAt(1)); | 1447 CHECK_EQ(p1, r->InputAt(1)); |
1406 } else { | 1448 } else { |
1407 CHECK_EQ(IrOpcode::kJSCallFunction, r->opcode()); | 1449 CHECK_EQ(IrOpcode::kJSCallFunction, r->opcode()); |
1408 CHECK_EQ(call, r); | 1450 CHECK_EQ(call, r); |
1409 } | 1451 } |
1410 } | 1452 } |
1411 } | 1453 } |
1412 } | 1454 } |
OLD | NEW |