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 |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1640 // uses the ObjectPair which is essentially two 32-bit values stuffed into a | 1640 // uses the ObjectPair which is essentially two 32-bit values stuffed into a |
| 1641 // 64-bit value. With the code below we assume that all runtime calls return | 1641 // 64-bit value. With the code below we assume that all runtime calls return |
| 1642 // 64 bits of result. If they don't, the r1 result register contains a bogus | 1642 // 64 bits of result. If they don't, the r1 result register contains a bogus |
| 1643 // value, which is fine because it is caller-saved. | 1643 // value, which is fine because it is caller-saved. |
| 1644 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, | 1644 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, |
| 1645 int32_t arg1, | 1645 int32_t arg1, |
| 1646 int32_t arg2, | 1646 int32_t arg2, |
| 1647 int32_t arg3, | 1647 int32_t arg3, |
| 1648 int32_t arg4, | 1648 int32_t arg4, |
| 1649 int32_t arg5); | 1649 int32_t arg5); |
| 1650 #if defined(V8_ARM_ON_X86_64) | |
| 1651 // This prototype will handle calls with up to two double args | |
| 1652 // and up to four integer args in any order. Note that arguments | |
| 1653 // on x86_64 are passed in registers. With this prototype the | |
| 1654 // six cited argument registers are loaded. Note that the callee | |
| 1655 // will simply ignore any arguments it doesn't actually need. | |
| 1656 // This prototype will fail for structures passed by value. | |
| 1657 typedef double (*SimulatorRuntimeFPCall)(double darg0, | |
| 1658 double darg1, | |
| 1659 int32_t arg0, | |
| 1660 int32_t arg1, | |
| 1661 int32_t arg2, | |
| 1662 int32_t arg3); | |
| 1663 #else | |
| 1650 typedef double (*SimulatorRuntimeFPCall)(int32_t arg0, | 1664 typedef double (*SimulatorRuntimeFPCall)(int32_t arg0, |
| 1651 int32_t arg1, | 1665 int32_t arg1, |
| 1652 int32_t arg2, | 1666 int32_t arg2, |
| 1653 int32_t arg3); | 1667 int32_t arg3); |
| 1668 #endif | |
| 1654 | 1669 |
| 1655 // This signature supports direct call in to API function native callback | 1670 // This signature supports direct call in to API function native callback |
| 1656 // (refer to InvocationCallback in v8.h). | 1671 // (refer to InvocationCallback in v8.h). |
| 1657 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1672 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
| 1658 | 1673 |
| 1659 // This signature supports direct call to accessor getter callback. | 1674 // This signature supports direct call to accessor getter callback. |
| 1660 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, | 1675 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, |
| 1661 int32_t arg1); | 1676 int32_t arg1); |
| 1662 | 1677 |
| 1678 | |
| 1679 #if defined(V8_ARM_ON_X86_64) | |
| 1680 static double ArgAsDouble(uint32_t lo, uint32_t hi) { | |
| 1681 union { uint64_t i64; double d; } darg; | |
| 1682 darg.i64 = hi; | |
| 1683 darg.i64 = (darg.i64 << 32) | lo; | |
| 1684 return darg.d; | |
| 1685 } | |
| 1686 #endif | |
| 1687 | |
| 1663 // Software interrupt instructions are used by the simulator to call into the | 1688 // Software interrupt instructions are used by the simulator to call into the |
| 1664 // C-based V8 runtime. | 1689 // C-based V8 runtime. |
| 1665 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1690 void Simulator::SoftwareInterrupt(Instruction* instr) { |
| 1666 int svc = instr->SvcValue(); | 1691 int svc = instr->SvcValue(); |
| 1667 switch (svc) { | 1692 switch (svc) { |
| 1668 case kCallRtRedirected: { | 1693 case kCallRtRedirected: { |
| 1669 // Check if stack is aligned. Error if not aligned is reported below to | 1694 // Check if stack is aligned. Error if not aligned is reported below to |
| 1670 // include information on the function called. | 1695 // include information on the function called. |
| 1671 bool stack_aligned = | 1696 bool stack_aligned = |
| 1672 (get_register(sp) | 1697 (get_register(sp) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1732 GetFpArgs(&dval0); | 1757 GetFpArgs(&dval0); |
| 1733 PrintF("Call to host function at %p with arg %f", | 1758 PrintF("Call to host function at %p with arg %f", |
| 1734 FUNCTION_ADDR(target), dval0); | 1759 FUNCTION_ADDR(target), dval0); |
| 1735 break; | 1760 break; |
| 1736 case ExternalReference::BUILTIN_FP_INT_CALL: | 1761 case ExternalReference::BUILTIN_FP_INT_CALL: |
| 1737 GetFpArgs(&dval0, &ival); | 1762 GetFpArgs(&dval0, &ival); |
| 1738 PrintF("Call to host function at %p with args %f, %d", | 1763 PrintF("Call to host function at %p with args %f, %d", |
| 1739 FUNCTION_ADDR(target), dval0, ival); | 1764 FUNCTION_ADDR(target), dval0, ival); |
| 1740 break; | 1765 break; |
| 1741 default: | 1766 default: |
| 1742 UNREACHABLE(); | 1767 UNREACHABLE(); |
|
ulan
2013/04/04 16:38:17
Yes, I think so because of this line.
| |
| 1743 break; | 1768 break; |
| 1744 } | 1769 } |
| 1745 if (!stack_aligned) { | 1770 if (!stack_aligned) { |
| 1746 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1771 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1747 } | 1772 } |
| 1748 PrintF("\n"); | 1773 PrintF("\n"); |
| 1749 } | 1774 } |
| 1750 CHECK(stack_aligned); | 1775 CHECK(stack_aligned); |
| 1751 if (redirection->type() != ExternalReference::BUILTIN_COMPARE_CALL) { | 1776 if (redirection->type() != ExternalReference::BUILTIN_COMPARE_CALL) { |
| 1752 SimulatorRuntimeFPCall target = | 1777 SimulatorRuntimeFPCall target = |
| 1753 reinterpret_cast<SimulatorRuntimeFPCall>(external); | 1778 reinterpret_cast<SimulatorRuntimeFPCall>(external); |
| 1779 #if defined(V8_ARM_ON_X86_64) | |
| 1780 double result = target(ArgAsDouble(arg0, arg1), | |
| 1781 ArgAsDouble(arg2, arg3), | |
| 1782 arg0, arg1, arg2, arg3); | |
| 1783 #else | |
| 1754 double result = target(arg0, arg1, arg2, arg3); | 1784 double result = target(arg0, arg1, arg2, arg3); |
| 1785 #endif | |
| 1755 SetFpResult(result); | 1786 SetFpResult(result); |
| 1756 } else { | 1787 } else { |
| 1757 SimulatorRuntimeCall target = | 1788 SimulatorRuntimeCall target = |
| 1758 reinterpret_cast<SimulatorRuntimeCall>(external); | 1789 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 1759 int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5); | 1790 int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5); |
| 1760 int32_t lo_res = static_cast<int32_t>(result); | 1791 int32_t lo_res = static_cast<int32_t>(result); |
| 1761 int32_t hi_res = static_cast<int32_t>(result >> 32); | 1792 int32_t hi_res = static_cast<int32_t>(result >> 32); |
| 1762 if (::v8::internal::FLAG_trace_sim) { | 1793 if (::v8::internal::FLAG_trace_sim) { |
| 1763 PrintF("Returned %08x\n", lo_res); | 1794 PrintF("Returned %08x\n", lo_res); |
| 1764 } | 1795 } |
| (...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3466 uintptr_t address = *stack_slot; | 3497 uintptr_t address = *stack_slot; |
| 3467 set_register(sp, current_sp + sizeof(uintptr_t)); | 3498 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 3468 return address; | 3499 return address; |
| 3469 } | 3500 } |
| 3470 | 3501 |
| 3471 } } // namespace v8::internal | 3502 } } // namespace v8::internal |
| 3472 | 3503 |
| 3473 #endif // USE_SIMULATOR | 3504 #endif // USE_SIMULATOR |
| 3474 | 3505 |
| 3475 #endif // V8_TARGET_ARCH_ARM | 3506 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |