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 |
| 39 using namespace v8::base; |
37 using namespace v8::internal; | 40 using namespace v8::internal; |
38 | 41 |
39 | 42 |
40 // Define these function prototypes to match JSEntryFunction in execution.cc. | 43 // Define these function prototypes to match JSEntryFunction in execution.cc. |
41 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); | 44 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
42 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); | 45 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); |
43 typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4); | 46 typedef Object* (*F3)(void* p0, int p1, int p2, int p3, int p4); |
44 typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4); | 47 typedef Object* (*F4)(void* p0, void* p1, int p2, int p3, int p4); |
45 | 48 |
46 | 49 |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 TEST_SDIV(5, -10, -2); | 1491 TEST_SDIV(5, -10, -2); |
1489 TEST_SDIV(3, -10, -3); | 1492 TEST_SDIV(3, -10, -3); |
1490 USE(dummy); | 1493 USE(dummy); |
1491 } | 1494 } |
1492 } | 1495 } |
1493 | 1496 |
1494 | 1497 |
1495 #undef TEST_SDIV | 1498 #undef TEST_SDIV |
1496 | 1499 |
1497 | 1500 |
| 1501 TEST(smmla) { |
| 1502 CcTest::InitializeVM(); |
| 1503 Isolate* const isolate = CcTest::i_isolate(); |
| 1504 HandleScope scope(isolate); |
| 1505 RandomNumberGenerator* const rng = isolate->random_number_generator(); |
| 1506 Assembler assm(isolate, nullptr, 0); |
| 1507 __ smmla(r1, r1, r2, r3); |
| 1508 __ str(r1, MemOperand(r0)); |
| 1509 __ bx(lr); |
| 1510 CodeDesc desc; |
| 1511 assm.GetCode(&desc); |
| 1512 Handle<Code> code = isolate->factory()->NewCode( |
| 1513 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1514 #ifdef OBJECT_PRINT |
| 1515 code->Print(std::cout); |
| 1516 #endif |
| 1517 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1518 for (size_t i = 0; i < 128; ++i) { |
| 1519 int32_t r, x = rng->NextInt(), y = rng->NextInt(), z = rng->NextInt(); |
| 1520 Object* dummy = CALL_GENERATED_CODE(f, &r, x, y, z, 0); |
| 1521 CHECK_EQ(bits::SignedMulHighAndAdd32(x, y, z), r); |
| 1522 USE(dummy); |
| 1523 } |
| 1524 } |
| 1525 |
| 1526 |
| 1527 TEST(smmls) { |
| 1528 CcTest::InitializeVM(); |
| 1529 Isolate* const isolate = CcTest::i_isolate(); |
| 1530 HandleScope scope(isolate); |
| 1531 RandomNumberGenerator* const rng = isolate->random_number_generator(); |
| 1532 Assembler assm(isolate, nullptr, 0); |
| 1533 __ smmls(r1, r1, r2, r3); |
| 1534 __ str(r1, MemOperand(r0)); |
| 1535 __ bx(lr); |
| 1536 CodeDesc desc; |
| 1537 assm.GetCode(&desc); |
| 1538 Handle<Code> code = isolate->factory()->NewCode( |
| 1539 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1540 #ifdef OBJECT_PRINT |
| 1541 code->Print(std::cout); |
| 1542 #endif |
| 1543 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1544 for (size_t i = 0; i < 128; ++i) { |
| 1545 int32_t r, x = rng->NextInt(), y = rng->NextInt(), z = rng->NextInt(); |
| 1546 Object* dummy = CALL_GENERATED_CODE(f, &r, x, y, z, 0); |
| 1547 CHECK_EQ(bits::SignedMulHighAndSub32(x, y, z), r); |
| 1548 USE(dummy); |
| 1549 } |
| 1550 } |
| 1551 |
| 1552 |
| 1553 TEST(smmul) { |
| 1554 CcTest::InitializeVM(); |
| 1555 Isolate* const isolate = CcTest::i_isolate(); |
| 1556 HandleScope scope(isolate); |
| 1557 RandomNumberGenerator* const rng = isolate->random_number_generator(); |
| 1558 Assembler assm(isolate, nullptr, 0); |
| 1559 __ smmul(r1, r1, r2); |
| 1560 __ str(r1, MemOperand(r0)); |
| 1561 __ bx(lr); |
| 1562 CodeDesc desc; |
| 1563 assm.GetCode(&desc); |
| 1564 Handle<Code> code = isolate->factory()->NewCode( |
| 1565 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1566 #ifdef OBJECT_PRINT |
| 1567 code->Print(std::cout); |
| 1568 #endif |
| 1569 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 1570 for (size_t i = 0; i < 128; ++i) { |
| 1571 int32_t r, x = rng->NextInt(), y = rng->NextInt(); |
| 1572 Object* dummy = CALL_GENERATED_CODE(f, &r, x, y, 0, 0); |
| 1573 CHECK_EQ(bits::SignedMulHigh32(x, y), r); |
| 1574 USE(dummy); |
| 1575 } |
| 1576 } |
| 1577 |
| 1578 |
1498 TEST(code_relative_offset) { | 1579 TEST(code_relative_offset) { |
1499 // Test extracting the offset of a label from the beginning of the code | 1580 // Test extracting the offset of a label from the beginning of the code |
1500 // in a register. | 1581 // in a register. |
1501 CcTest::InitializeVM(); | 1582 CcTest::InitializeVM(); |
1502 Isolate* isolate = CcTest::i_isolate(); | 1583 Isolate* isolate = CcTest::i_isolate(); |
1503 HandleScope scope(isolate); | 1584 HandleScope scope(isolate); |
1504 // Initialize a code object that will contain the code. | 1585 // Initialize a code object that will contain the code. |
1505 Handle<Object> code_object(isolate->heap()->undefined_value(), isolate); | 1586 Handle<Object> code_object(isolate->heap()->undefined_value(), isolate); |
1506 | 1587 |
1507 Assembler assm(isolate, NULL, 0); | 1588 Assembler assm(isolate, NULL, 0); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 assm.GetCode(&desc); | 1640 assm.GetCode(&desc); |
1560 Handle<Code> code = isolate->factory()->NewCode( | 1641 Handle<Code> code = isolate->factory()->NewCode( |
1561 desc, Code::ComputeFlags(Code::STUB), code_object); | 1642 desc, Code::ComputeFlags(Code::STUB), code_object); |
1562 F1 f = FUNCTION_CAST<F1>(code->entry()); | 1643 F1 f = FUNCTION_CAST<F1>(code->entry()); |
1563 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); | 1644 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 21, 0, 0, 0, 0)); |
1564 ::printf("f() = %d\n", res); | 1645 ::printf("f() = %d\n", res); |
1565 CHECK_EQ(42, res); | 1646 CHECK_EQ(42, res); |
1566 } | 1647 } |
1567 | 1648 |
1568 #undef __ | 1649 #undef __ |
OLD | NEW |