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 |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 while (bit_vector != 0) { | 1527 while (bit_vector != 0) { |
1528 if ((bit_vector & 1) != 0) { | 1528 if ((bit_vector & 1) != 0) { |
1529 count++; | 1529 count++; |
1530 } | 1530 } |
1531 bit_vector >>= 1; | 1531 bit_vector >>= 1; |
1532 } | 1532 } |
1533 return count; | 1533 return count; |
1534 } | 1534 } |
1535 | 1535 |
1536 | 1536 |
1537 void Simulator::ProcessPUW(Instruction* instr, | 1537 int32_t Simulator::ProcessPU(Instruction* instr, |
1538 int num_regs, | 1538 int num_regs, |
1539 int reg_size, | 1539 int reg_size, |
1540 intptr_t* start_address, | 1540 intptr_t* start_address, |
1541 intptr_t* end_address) { | 1541 intptr_t* end_address) { |
1542 int rn = instr->RnValue(); | 1542 int rn = instr->RnValue(); |
1543 int32_t rn_val = get_register(rn); | 1543 int32_t rn_val = get_register(rn); |
1544 switch (instr->PUField()) { | 1544 switch (instr->PUField()) { |
1545 case da_x: { | 1545 case da_x: { |
1546 UNIMPLEMENTED(); | 1546 UNIMPLEMENTED(); |
1547 break; | 1547 break; |
1548 } | 1548 } |
1549 case ia_x: { | 1549 case ia_x: { |
1550 *start_address = rn_val; | 1550 *start_address = rn_val; |
1551 *end_address = rn_val + (num_regs * reg_size) - reg_size; | 1551 *end_address = rn_val + (num_regs * reg_size) - reg_size; |
(...skipping 10 matching lines...) Expand all Loading... |
1562 *start_address = rn_val + reg_size; | 1562 *start_address = rn_val + reg_size; |
1563 *end_address = rn_val + (num_regs * reg_size); | 1563 *end_address = rn_val + (num_regs * reg_size); |
1564 rn_val = *end_address; | 1564 rn_val = *end_address; |
1565 break; | 1565 break; |
1566 } | 1566 } |
1567 default: { | 1567 default: { |
1568 UNREACHABLE(); | 1568 UNREACHABLE(); |
1569 break; | 1569 break; |
1570 } | 1570 } |
1571 } | 1571 } |
1572 if (instr->HasW()) { | 1572 return rn_val; |
1573 set_register(rn, rn_val); | |
1574 } | |
1575 } | 1573 } |
1576 | 1574 |
1577 | 1575 |
1578 // Addressing Mode 4 - Load and Store Multiple | 1576 // Addressing Mode 4 - Load and Store Multiple |
1579 void Simulator::HandleRList(Instruction* instr, bool load) { | 1577 void Simulator::HandleRList(Instruction* instr, bool load) { |
1580 int rlist = instr->RlistValue(); | 1578 int rlist = instr->RlistValue(); |
1581 int num_regs = count_bits(rlist); | 1579 int num_regs = count_bits(rlist); |
1582 | 1580 |
1583 intptr_t start_address = 0; | 1581 intptr_t start_address = 0; |
1584 intptr_t end_address = 0; | 1582 intptr_t end_address = 0; |
1585 ProcessPUW(instr, num_regs, kPointerSize, &start_address, &end_address); | 1583 int32_t rn_val = |
| 1584 ProcessPU(instr, num_regs, kPointerSize, &start_address, &end_address); |
1586 | 1585 |
1587 intptr_t* address = reinterpret_cast<intptr_t*>(start_address); | 1586 intptr_t* address = reinterpret_cast<intptr_t*>(start_address); |
1588 // Catch null pointers a little earlier. | 1587 // Catch null pointers a little earlier. |
1589 ASSERT(start_address > 8191 || start_address < 0); | 1588 ASSERT(start_address > 8191 || start_address < 0); |
1590 int reg = 0; | 1589 int reg = 0; |
1591 while (rlist != 0) { | 1590 while (rlist != 0) { |
1592 if ((rlist & 1) != 0) { | 1591 if ((rlist & 1) != 0) { |
1593 if (load) { | 1592 if (load) { |
1594 set_register(reg, *address); | 1593 set_register(reg, *address); |
1595 } else { | 1594 } else { |
1596 *address = get_register(reg); | 1595 *address = get_register(reg); |
1597 } | 1596 } |
1598 address += 1; | 1597 address += 1; |
1599 } | 1598 } |
1600 reg++; | 1599 reg++; |
1601 rlist >>= 1; | 1600 rlist >>= 1; |
1602 } | 1601 } |
1603 ASSERT(end_address == ((intptr_t)address) - 4); | 1602 ASSERT(end_address == ((intptr_t)address) - 4); |
| 1603 if (instr->HasW()) { |
| 1604 set_register(instr->RnValue(), rn_val); |
| 1605 } |
1604 } | 1606 } |
1605 | 1607 |
1606 | 1608 |
1607 // Addressing Mode 6 - Load and Store Multiple Coprocessor registers. | 1609 // Addressing Mode 6 - Load and Store Multiple Coprocessor registers. |
1608 void Simulator::HandleVList(Instruction* instr) { | 1610 void Simulator::HandleVList(Instruction* instr) { |
1609 VFPRegPrecision precision = | 1611 VFPRegPrecision precision = |
1610 (instr->SzValue() == 0) ? kSinglePrecision : kDoublePrecision; | 1612 (instr->SzValue() == 0) ? kSinglePrecision : kDoublePrecision; |
1611 int operand_size = (precision == kSinglePrecision) ? 4 : 8; | 1613 int operand_size = (precision == kSinglePrecision) ? 4 : 8; |
1612 | 1614 |
1613 bool load = (instr->VLValue() == 0x1); | 1615 bool load = (instr->VLValue() == 0x1); |
1614 | 1616 |
1615 int vd; | 1617 int vd; |
1616 int num_regs; | 1618 int num_regs; |
1617 vd = instr->VFPDRegValue(precision); | 1619 vd = instr->VFPDRegValue(precision); |
1618 if (precision == kSinglePrecision) { | 1620 if (precision == kSinglePrecision) { |
1619 num_regs = instr->Immed8Value(); | 1621 num_regs = instr->Immed8Value(); |
1620 } else { | 1622 } else { |
1621 num_regs = instr->Immed8Value() / 2; | 1623 num_regs = instr->Immed8Value() / 2; |
1622 } | 1624 } |
1623 | 1625 |
1624 intptr_t start_address = 0; | 1626 intptr_t start_address = 0; |
1625 intptr_t end_address = 0; | 1627 intptr_t end_address = 0; |
1626 ProcessPUW(instr, num_regs, operand_size, &start_address, &end_address); | 1628 int32_t rn_val = |
| 1629 ProcessPU(instr, num_regs, operand_size, &start_address, &end_address); |
1627 | 1630 |
1628 intptr_t* address = reinterpret_cast<intptr_t*>(start_address); | 1631 intptr_t* address = reinterpret_cast<intptr_t*>(start_address); |
1629 for (int reg = vd; reg < vd + num_regs; reg++) { | 1632 for (int reg = vd; reg < vd + num_regs; reg++) { |
1630 if (precision == kSinglePrecision) { | 1633 if (precision == kSinglePrecision) { |
1631 if (load) { | 1634 if (load) { |
1632 set_s_register_from_sinteger( | 1635 set_s_register_from_sinteger( |
1633 reg, ReadW(reinterpret_cast<int32_t>(address), instr)); | 1636 reg, ReadW(reinterpret_cast<int32_t>(address), instr)); |
1634 } else { | 1637 } else { |
1635 WriteW(reinterpret_cast<int32_t>(address), | 1638 WriteW(reinterpret_cast<int32_t>(address), |
1636 get_sinteger_from_s_register(reg), instr); | 1639 get_sinteger_from_s_register(reg), instr); |
(...skipping 12 matching lines...) Expand all Loading... |
1649 int32_t data[2]; | 1652 int32_t data[2]; |
1650 double d = get_double_from_d_register(reg); | 1653 double d = get_double_from_d_register(reg); |
1651 OS::MemCopy(data, &d, 8); | 1654 OS::MemCopy(data, &d, 8); |
1652 WriteW(reinterpret_cast<int32_t>(address), data[0], instr); | 1655 WriteW(reinterpret_cast<int32_t>(address), data[0], instr); |
1653 WriteW(reinterpret_cast<int32_t>(address + 1), data[1], instr); | 1656 WriteW(reinterpret_cast<int32_t>(address + 1), data[1], instr); |
1654 } | 1657 } |
1655 address += 2; | 1658 address += 2; |
1656 } | 1659 } |
1657 } | 1660 } |
1658 ASSERT(reinterpret_cast<intptr_t>(address) - operand_size == end_address); | 1661 ASSERT(reinterpret_cast<intptr_t>(address) - operand_size == end_address); |
| 1662 if (instr->HasW()) { |
| 1663 set_register(instr->RnValue(), rn_val); |
| 1664 } |
1659 } | 1665 } |
1660 | 1666 |
1661 | 1667 |
1662 // Calls into the V8 runtime are based on this very simple interface. | 1668 // Calls into the V8 runtime are based on this very simple interface. |
1663 // Note: To be able to return two values from some calls the code in runtime.cc | 1669 // Note: To be able to return two values from some calls the code in runtime.cc |
1664 // uses the ObjectPair which is essentially two 32-bit values stuffed into a | 1670 // uses the ObjectPair which is essentially two 32-bit values stuffed into a |
1665 // 64-bit value. With the code below we assume that all runtime calls return | 1671 // 64-bit value. With the code below we assume that all runtime calls return |
1666 // 64 bits of result. If they don't, the r1 result register contains a bogus | 1672 // 64 bits of result. If they don't, the r1 result register contains a bogus |
1667 // value, which is fine because it is caller-saved. | 1673 // value, which is fine because it is caller-saved. |
1668 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, | 1674 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, |
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3890 uintptr_t address = *stack_slot; | 3896 uintptr_t address = *stack_slot; |
3891 set_register(sp, current_sp + sizeof(uintptr_t)); | 3897 set_register(sp, current_sp + sizeof(uintptr_t)); |
3892 return address; | 3898 return address; |
3893 } | 3899 } |
3894 | 3900 |
3895 } } // namespace v8::internal | 3901 } } // namespace v8::internal |
3896 | 3902 |
3897 #endif // USE_SIMULATOR | 3903 #endif // USE_SIMULATOR |
3898 | 3904 |
3899 #endif // V8_TARGET_ARCH_ARM | 3905 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |