Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <iostream> // NOLINT(readability/streams) | |
| 29 | |
| 28 #include "src/v8.h" | 30 #include "src/v8.h" |
| 29 #include "test/cctest/cctest.h" | 31 #include "test/cctest/cctest.h" |
| 30 | 32 |
| 31 #include "src/arm/assembler-arm-inl.h" | 33 #include "src/arm/assembler-arm-inl.h" |
| 32 #include "src/arm/simulator-arm.h" | 34 #include "src/arm/simulator-arm.h" |
| 33 #include "src/disassembler.h" | 35 #include "src/disassembler.h" |
| 34 #include "src/factory.h" | 36 #include "src/factory.h" |
| 35 #include "src/ostreams.h" | 37 #include "src/ostreams.h" |
| 36 | 38 |
| 37 using namespace v8::internal; | 39 using namespace v8::internal; |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1488 TEST_SDIV(5, -10, -2); | 1490 TEST_SDIV(5, -10, -2); |
| 1489 TEST_SDIV(3, -10, -3); | 1491 TEST_SDIV(3, -10, -3); |
| 1490 USE(dummy); | 1492 USE(dummy); |
| 1491 } | 1493 } |
| 1492 } | 1494 } |
| 1493 | 1495 |
| 1494 | 1496 |
| 1495 #undef TEST_SDIV | 1497 #undef TEST_SDIV |
| 1496 | 1498 |
| 1497 | 1499 |
| 1500 #define TEST_SMMUL(f, x, y) \ | |
|
Benedikt Meurer
2014/10/13 18:25:48
Move all the new tests to test/unittests/arm/assem
Benedikt Meurer
2014/10/14 04:49:43
Maybe later...
| |
| 1501 do { \ | |
| 1502 int32_t actual; \ | |
| 1503 Object* dummy = CALL_GENERATED_CODE(f, &actual, x, y, 0, 0); \ | |
| 1504 CHECK_EQ(v8::base::bits::SignedMulHigh32(x, y), actual); \ | |
| 1505 USE(dummy); \ | |
| 1506 } while (0) | |
| 1507 | |
| 1508 | |
| 1509 TEST(19) { | |
| 1510 // Test smmul. | |
| 1511 CcTest::InitializeVM(); | |
| 1512 Isolate* isolate = CcTest::i_isolate(); | |
| 1513 HandleScope scope(isolate); | |
| 1514 | |
| 1515 Assembler assm(isolate, nullptr, 0); | |
| 1516 | |
| 1517 __ smmul(r1, r1, r2); | |
| 1518 __ str(r1, MemOperand(r0)); | |
| 1519 __ bx(lr); | |
| 1520 | |
| 1521 CodeDesc desc; | |
| 1522 assm.GetCode(&desc); | |
| 1523 Handle<Code> code = isolate->factory()->NewCode( | |
| 1524 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 1525 #ifdef DEBUG | |
| 1526 code->Print(std::cout); | |
| 1527 #endif | |
| 1528 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
| 1529 TEST_SMMUL(f, kMinInt, kMinInt); | |
| 1530 TEST_SMMUL(f, kMinInt, -1); | |
| 1531 TEST_SMMUL(f, -1, kMinInt); | |
| 1532 TEST_SMMUL(f, kMinInt, kMaxInt); | |
| 1533 TEST_SMMUL(f, kMaxInt, kMinInt); | |
| 1534 TEST_SMMUL(f, 0, 1); | |
| 1535 TEST_SMMUL(f, 1, 0); | |
| 1536 TEST_SMMUL(f, 42, -1); | |
| 1537 } | |
| 1538 | |
| 1539 | |
| 1540 #undef TEST_SMMUL | |
| 1541 | |
| 1542 | |
| 1543 #define TEST_SMMLA(f, x, y, z) \ | |
| 1544 do { \ | |
| 1545 int32_t actual; \ | |
| 1546 Object* dummy = CALL_GENERATED_CODE(f, &actual, x, y, z, 0); \ | |
| 1547 CHECK_EQ(v8::base::bits::SignedMulHighAndAdd32(x, y, z), actual); \ | |
| 1548 USE(dummy); \ | |
| 1549 } while (0) | |
| 1550 | |
| 1551 | |
| 1552 TEST(20) { | |
| 1553 // Test smmla. | |
| 1554 CcTest::InitializeVM(); | |
| 1555 Isolate* isolate = CcTest::i_isolate(); | |
| 1556 HandleScope scope(isolate); | |
| 1557 | |
| 1558 Assembler assm(isolate, nullptr, 0); | |
| 1559 | |
| 1560 __ smmla(r1, r1, r2, r3); | |
| 1561 __ str(r1, MemOperand(r0)); | |
| 1562 __ bx(lr); | |
| 1563 | |
| 1564 CodeDesc desc; | |
| 1565 assm.GetCode(&desc); | |
| 1566 Handle<Code> code = isolate->factory()->NewCode( | |
| 1567 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 1568 #ifdef DEBUG | |
| 1569 code->Print(std::cout); | |
| 1570 #endif | |
| 1571 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
| 1572 TEST_SMMLA(f, kMinInt, kMinInt, 123456); | |
| 1573 TEST_SMMLA(f, kMinInt, -1, 0); | |
| 1574 TEST_SMMLA(f, -1, kMinInt, -1); | |
| 1575 TEST_SMMLA(f, kMinInt, kMaxInt, 1); | |
| 1576 TEST_SMMLA(f, kMaxInt, kMinInt, 0); | |
| 1577 TEST_SMMLA(f, 0, 1, kMinInt); | |
| 1578 TEST_SMMLA(f, 1, 0, kMaxInt - 1); | |
| 1579 TEST_SMMLA(f, 42, -1, 0); | |
| 1580 } | |
| 1581 | |
| 1582 | |
| 1583 #undef TEST_SMMLA | |
| 1584 | |
| 1585 | |
| 1586 #define TEST_SMMLS(f, x, y, z) \ | |
| 1587 do { \ | |
| 1588 int32_t actual; \ | |
| 1589 Object* dummy = CALL_GENERATED_CODE(f, &actual, x, y, z, 0); \ | |
| 1590 CHECK_EQ(v8::base::bits::SignedMulHighAndSub32(x, y, z), actual); \ | |
| 1591 USE(dummy); \ | |
| 1592 } while (0) | |
| 1593 | |
| 1594 | |
| 1595 TEST(21) { | |
| 1596 // Test smmls. | |
| 1597 CcTest::InitializeVM(); | |
| 1598 Isolate* isolate = CcTest::i_isolate(); | |
| 1599 HandleScope scope(isolate); | |
| 1600 | |
| 1601 Assembler assm(isolate, nullptr, 0); | |
| 1602 | |
| 1603 __ smmls(r1, r1, r2, r3); | |
| 1604 __ str(r1, MemOperand(r0)); | |
| 1605 __ bx(lr); | |
| 1606 | |
| 1607 CodeDesc desc; | |
| 1608 assm.GetCode(&desc); | |
| 1609 Handle<Code> code = isolate->factory()->NewCode( | |
| 1610 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 1611 #ifdef DEBUG | |
| 1612 code->Print(std::cout); | |
| 1613 #endif | |
| 1614 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
| 1615 TEST_SMMLS(f, kMinInt, kMinInt, 123456); | |
| 1616 TEST_SMMLS(f, kMinInt, -1, 0); | |
| 1617 TEST_SMMLS(f, -1, kMinInt, -1); | |
| 1618 TEST_SMMLS(f, kMinInt, kMaxInt, 1); | |
| 1619 TEST_SMMLS(f, kMaxInt, kMinInt, 0); | |
| 1620 TEST_SMMLS(f, 0, 1, kMinInt); | |
| 1621 TEST_SMMLS(f, 1, 0, kMaxInt - 1); | |
| 1622 TEST_SMMLS(f, 42, -1, 0); | |
| 1623 } | |
| 1624 | |
| 1625 | |
| 1626 #undef TEST_SMMLS | |
| 1627 | |
| 1628 | |
| 1498 TEST(code_relative_offset) { | 1629 TEST(code_relative_offset) { |
| 1499 // Test extracting the offset of a label from the beginning of the code | 1630 // Test extracting the offset of a label from the beginning of the code |
| 1500 // in a register. | 1631 // in a register. |
| 1501 CcTest::InitializeVM(); | 1632 CcTest::InitializeVM(); |
| 1502 Isolate* isolate = CcTest::i_isolate(); | 1633 Isolate* isolate = CcTest::i_isolate(); |
| 1503 HandleScope scope(isolate); | 1634 HandleScope scope(isolate); |
| 1504 // Initialize a code object that will contain the code. | 1635 // Initialize a code object that will contain the code. |
| 1505 Handle<Object> code_object(isolate->heap()->undefined_value(), isolate); | 1636 Handle<Object> code_object(isolate->heap()->undefined_value(), isolate); |
| 1506 | 1637 |
| 1507 Assembler assm(isolate, NULL, 0); | 1638 Assembler assm(isolate, NULL, 0); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1559 assm.GetCode(&desc); | 1690 assm.GetCode(&desc); |
| 1560 Handle<Code> code = isolate->factory()->NewCode( | 1691 Handle<Code> code = isolate->factory()->NewCode( |
| 1561 desc, Code::ComputeFlags(Code::STUB), code_object); | 1692 desc, Code::ComputeFlags(Code::STUB), code_object); |
| 1562 F1 f = FUNCTION_CAST<F1>(code->entry()); | 1693 F1 f = FUNCTION_CAST<F1>(code->entry()); |
| 1563 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); | 1694 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); |
| 1564 ::printf("f() = %d\n", res); | 1695 ::printf("f() = %d\n", res); |
| 1565 CHECK_EQ(42, res); | 1696 CHECK_EQ(42, res); |
| 1566 } | 1697 } |
| 1567 | 1698 |
| 1568 #undef __ | 1699 #undef __ |
| OLD | NEW |