Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #if defined(TARGET_ARCH_DBC) | 9 #if defined(TARGET_ARCH_DBC) |
| 10 | 10 |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1687 const intptr_t shift_amount = | 1687 const intptr_t shift_amount = |
| 1688 (rhs >= kBitsPerWord) ? (kBitsPerWord - 1) : rhs; | 1688 (rhs >= kBitsPerWord) ? (kBitsPerWord - 1) : rhs; |
| 1689 const intptr_t lhs = reinterpret_cast<intptr_t>(FP[rB]) >> kSmiTagSize; | 1689 const intptr_t lhs = reinterpret_cast<intptr_t>(FP[rB]) >> kSmiTagSize; |
| 1690 *reinterpret_cast<intptr_t*>(&FP[rA]) = | 1690 *reinterpret_cast<intptr_t*>(&FP[rA]) = |
| 1691 (lhs >> shift_amount) << kSmiTagSize; | 1691 (lhs >> shift_amount) << kSmiTagSize; |
| 1692 pc++; | 1692 pc++; |
| 1693 } | 1693 } |
| 1694 DISPATCH(); | 1694 DISPATCH(); |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 #if defined(ARCH_IS_64_BIT) | |
| 1698 { | |
| 1699 BYTECODE(BoxDouble, A_D); | |
|
Vyacheslav Egorov (Google)
2016/07/14 16:26:24
I would call this bytecode WriteIntoDouble or some
zra
2016/07/14 21:12:10
Done.
| |
| 1700 const double value = bit_cast<double, RawObject*>(FP[rD]); | |
| 1701 RawDouble* box = RAW_CAST(Double, *SP--); | |
| 1702 box->ptr()->value_ = value; | |
| 1703 FP[rA] = box; | |
| 1704 DISPATCH(); | |
| 1705 } | |
| 1706 | |
| 1707 { | |
| 1708 BYTECODE(UnboxDouble, A_D); | |
| 1709 const RawDouble* box = RAW_CAST(Double, FP[rD]); | |
| 1710 FP[rA] = bit_cast<RawObject*, double>(box->ptr()->value_); | |
| 1711 DISPATCH(); | |
| 1712 } | |
| 1713 | |
| 1714 { | |
| 1715 BYTECODE(CheckedUnboxDouble, A_D); | |
| 1716 const intptr_t box_cid = SimulatorHelpers::GetClassId(FP[rD]); | |
| 1717 if (box_cid == kSmiCid) { | |
| 1718 const intptr_t value = reinterpret_cast<intptr_t>(FP[rD]) >> kSmiTagSize; | |
| 1719 const double result = static_cast<double>(value); | |
| 1720 FP[rA] = bit_cast<RawObject*, double>(result); | |
| 1721 pc++; | |
| 1722 } else if (box_cid == kDoubleCid) { | |
| 1723 const RawDouble* box = RAW_CAST(Double, FP[rD]); | |
| 1724 FP[rA] = bit_cast<RawObject*, double>(box->ptr()->value_); | |
| 1725 pc++; | |
| 1726 } | |
| 1727 DISPATCH(); | |
| 1728 } | |
| 1729 | |
| 1730 { | |
| 1731 BYTECODE(SmiToDouble, A_D); | |
| 1732 const intptr_t value = reinterpret_cast<intptr_t>(FP[rD]) >> kSmiTagSize; | |
| 1733 const double result = static_cast<double>(value); | |
| 1734 FP[rA] = bit_cast<RawObject*, double>(result); | |
| 1735 DISPATCH(); | |
| 1736 } | |
| 1737 | |
| 1738 { | |
| 1739 BYTECODE(DAdd, A_B_C); | |
| 1740 const double lhs = bit_cast<double, RawObject*>(FP[rB]); | |
| 1741 const double rhs = bit_cast<double, RawObject*>(FP[rC]); | |
| 1742 FP[rA] = bit_cast<RawObject*, double>(lhs + rhs); | |
| 1743 DISPATCH(); | |
| 1744 } | |
| 1745 | |
| 1746 { | |
| 1747 BYTECODE(DSub, A_B_C); | |
| 1748 const double lhs = bit_cast<double, RawObject*>(FP[rB]); | |
| 1749 const double rhs = bit_cast<double, RawObject*>(FP[rC]); | |
| 1750 FP[rA] = bit_cast<RawObject*, double>(lhs - rhs); | |
| 1751 DISPATCH(); | |
| 1752 } | |
| 1753 | |
| 1754 { | |
| 1755 BYTECODE(DMul, A_B_C); | |
| 1756 const double lhs = bit_cast<double, RawObject*>(FP[rB]); | |
| 1757 const double rhs = bit_cast<double, RawObject*>(FP[rC]); | |
| 1758 FP[rA] = bit_cast<RawObject*, double>(lhs * rhs); | |
| 1759 DISPATCH(); | |
| 1760 } | |
| 1761 | |
| 1762 { | |
| 1763 BYTECODE(DDiv, A_B_C); | |
| 1764 const double lhs = bit_cast<double, RawObject*>(FP[rB]); | |
| 1765 const double rhs = bit_cast<double, RawObject*>(FP[rC]); | |
| 1766 const double result = lhs / rhs; | |
| 1767 FP[rA] = bit_cast<RawObject*, double>(result); | |
| 1768 DISPATCH(); | |
| 1769 } | |
| 1770 | |
| 1771 { | |
| 1772 BYTECODE(DNeg, A_D); | |
| 1773 const double value = bit_cast<double, RawObject*>(FP[rD]); | |
| 1774 FP[rA] = bit_cast<RawObject*, double>(-value); | |
| 1775 DISPATCH(); | |
| 1776 } | |
| 1777 #else // defined(ARCH_IS_64_BIT) | |
| 1778 { | |
| 1779 BYTECODE(BoxDouble, A_D); | |
| 1780 UNIMPLEMENTED(); | |
| 1781 DISPATCH(); | |
| 1782 } | |
| 1783 | |
| 1784 { | |
| 1785 BYTECODE(UnboxDouble, A_D); | |
| 1786 UNIMPLEMENTED(); | |
| 1787 DISPATCH(); | |
| 1788 } | |
| 1789 | |
| 1790 { | |
| 1791 BYTECODE(CheckedUnboxDouble, A_D); | |
| 1792 UNIMPLEMENTED(); | |
| 1793 DISPATCH(); | |
| 1794 } | |
| 1795 | |
| 1796 { | |
| 1797 BYTECODE(SmiToDouble, A_D); | |
| 1798 UNIMPLEMENTED(); | |
| 1799 DISPATCH(); | |
| 1800 } | |
| 1801 | |
| 1802 { | |
| 1803 BYTECODE(DAdd, A_B_C); | |
| 1804 UNIMPLEMENTED(); | |
| 1805 DISPATCH(); | |
| 1806 } | |
| 1807 | |
| 1808 { | |
| 1809 BYTECODE(DSub, A_B_C); | |
| 1810 UNIMPLEMENTED(); | |
| 1811 DISPATCH(); | |
| 1812 } | |
| 1813 | |
| 1814 { | |
| 1815 BYTECODE(DMul, A_B_C); | |
| 1816 UNIMPLEMENTED(); | |
| 1817 DISPATCH(); | |
| 1818 } | |
| 1819 | |
| 1820 { | |
| 1821 BYTECODE(DDiv, A_B_C); | |
| 1822 UNIMPLEMENTED(); | |
| 1823 DISPATCH(); | |
| 1824 } | |
| 1825 | |
| 1826 { | |
| 1827 BYTECODE(DNeg, A_D); | |
| 1828 UNIMPLEMENTED(); | |
| 1829 DISPATCH(); | |
| 1830 } | |
| 1831 #endif // defined(ARCH_IS_64_BIT) | |
| 1832 | |
| 1697 // Return and return like instructions (Instrinsic). | 1833 // Return and return like instructions (Instrinsic). |
| 1698 { | 1834 { |
| 1699 RawObject* result; // result to return to the caller. | 1835 RawObject* result; // result to return to the caller. |
| 1700 | 1836 |
| 1701 BYTECODE(Intrinsic, A); | 1837 BYTECODE(Intrinsic, A); |
| 1702 // Try invoking intrinsic handler. If it succeeds (returns true) | 1838 // Try invoking intrinsic handler. If it succeeds (returns true) |
| 1703 // then just return the value it returned to the caller. | 1839 // then just return the value it returned to the caller. |
| 1704 result = null_value; | 1840 result = null_value; |
| 1705 if (!intrinsics_[rA](thread, FP, &result)) { | 1841 if (!intrinsics_[rA](thread, FP, &result)) { |
| 1706 DISPATCH(); | 1842 DISPATCH(); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2082 BYTECODE(CheckSmi, 0); | 2218 BYTECODE(CheckSmi, 0); |
| 2083 intptr_t obj = reinterpret_cast<intptr_t>(FP[rA]); | 2219 intptr_t obj = reinterpret_cast<intptr_t>(FP[rA]); |
| 2084 if ((obj & kSmiTagMask) == kSmiTag) { | 2220 if ((obj & kSmiTagMask) == kSmiTag) { |
| 2085 pc++; | 2221 pc++; |
| 2086 } | 2222 } |
| 2087 DISPATCH(); | 2223 DISPATCH(); |
| 2088 } | 2224 } |
| 2089 | 2225 |
| 2090 { | 2226 { |
| 2091 BYTECODE(CheckClassId, A_D); | 2227 BYTECODE(CheckClassId, A_D); |
| 2092 const intptr_t actual_cid = SimulatorHelpers::GetClassId(FP[rA]); | 2228 const intptr_t actual_cid = |
| 2229 reinterpret_cast<intptr_t>(FP[rA]) >> kSmiTagSize; | |
| 2093 const intptr_t desired_cid = rD; | 2230 const intptr_t desired_cid = rD; |
| 2094 pc += (actual_cid == desired_cid) ? 1 : 0; | 2231 pc += (actual_cid == desired_cid) ? 1 : 0; |
| 2095 DISPATCH(); | 2232 DISPATCH(); |
| 2096 } | 2233 } |
| 2097 | 2234 |
| 2098 { | 2235 { |
| 2099 BYTECODE(CheckDenseSwitch, A_D); | 2236 BYTECODE(CheckDenseSwitch, A_D); |
| 2100 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]); | 2237 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]); |
| 2101 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag); | 2238 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag); |
| 2102 const intptr_t cid_min = Bytecode::DecodeD(*pc); | 2239 const intptr_t cid_min = Bytecode::DecodeD(*pc); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2287 { | 2424 { |
| 2288 BYTECODE(IfUGt, A_D); | 2425 BYTECODE(IfUGt, A_D); |
| 2289 const uintptr_t lhs = reinterpret_cast<uintptr_t>(FP[rA]); | 2426 const uintptr_t lhs = reinterpret_cast<uintptr_t>(FP[rA]); |
| 2290 const uintptr_t rhs = reinterpret_cast<uintptr_t>(FP[rD]); | 2427 const uintptr_t rhs = reinterpret_cast<uintptr_t>(FP[rD]); |
| 2291 if (lhs <= rhs) { | 2428 if (lhs <= rhs) { |
| 2292 pc++; | 2429 pc++; |
| 2293 } | 2430 } |
| 2294 DISPATCH(); | 2431 DISPATCH(); |
| 2295 } | 2432 } |
| 2296 | 2433 |
| 2434 #if defined(ARCH_IS_64_BIT) | |
| 2435 { | |
| 2436 BYTECODE(IfDEq, A_D); | |
| 2437 const double lhs = bit_cast<double, RawObject*>(FP[rA]); | |
| 2438 const double rhs = bit_cast<double, RawObject*>(FP[rD]); | |
| 2439 pc += (lhs == rhs) ? 0 : 1; | |
| 2440 DISPATCH(); | |
| 2441 } | |
| 2442 | |
| 2297 { | 2443 { |
| 2444 BYTECODE(IfDNe, A_D); | |
| 2445 const double lhs = bit_cast<double, RawObject*>(FP[rA]); | |
| 2446 const double rhs = bit_cast<double, RawObject*>(FP[rD]); | |
| 2447 pc += (lhs != rhs) ? 0 : 1; | |
| 2448 DISPATCH(); | |
| 2449 } | |
| 2450 | |
| 2451 { | |
| 2452 BYTECODE(IfDLe, A_D); | |
| 2453 const double lhs = bit_cast<double, RawObject*>(FP[rA]); | |
| 2454 const double rhs = bit_cast<double, RawObject*>(FP[rD]); | |
| 2455 pc += (lhs <= rhs) ? 0 : 1; | |
| 2456 DISPATCH(); | |
| 2457 } | |
| 2458 | |
| 2459 { | |
| 2460 BYTECODE(IfDLt, A_D); | |
| 2461 const double lhs = bit_cast<double, RawObject*>(FP[rA]); | |
| 2462 const double rhs = bit_cast<double, RawObject*>(FP[rD]); | |
| 2463 pc += (lhs < rhs) ? 0 : 1; | |
| 2464 DISPATCH(); | |
| 2465 } | |
| 2466 | |
| 2467 { | |
| 2468 BYTECODE(IfDGe, A_D); | |
| 2469 const double lhs = bit_cast<double, RawObject*>(FP[rA]); | |
| 2470 const double rhs = bit_cast<double, RawObject*>(FP[rD]); | |
| 2471 pc += (lhs >= rhs) ? 0 : 1; | |
| 2472 DISPATCH(); | |
| 2473 } | |
| 2474 | |
| 2475 { | |
| 2476 BYTECODE(IfDGt, A_D); | |
| 2477 const double lhs = bit_cast<double, RawObject*>(FP[rA]); | |
| 2478 const double rhs = bit_cast<double, RawObject*>(FP[rD]); | |
| 2479 pc += (lhs > rhs) ? 0 : 1; | |
| 2480 DISPATCH(); | |
| 2481 } | |
| 2482 #else // defined(ARCH_IS_64_BIT) | |
| 2483 { | |
| 2484 BYTECODE(IfDEq, A_D); | |
| 2485 UNREACHABLE(); | |
| 2486 DISPATCH(); | |
| 2487 } | |
| 2488 | |
| 2489 { | |
| 2490 BYTECODE(IfDNe, A_D); | |
| 2491 UNREACHABLE(); | |
| 2492 DISPATCH(); | |
| 2493 } | |
| 2494 | |
| 2495 { | |
| 2496 BYTECODE(IfDLe, A_D); | |
| 2497 UNREACHABLE(); | |
| 2498 DISPATCH(); | |
| 2499 } | |
| 2500 | |
| 2501 { | |
| 2502 BYTECODE(IfDLt, A_D); | |
| 2503 UNREACHABLE(); | |
| 2504 DISPATCH(); | |
| 2505 } | |
| 2506 | |
| 2507 { | |
| 2508 BYTECODE(IfDGe, A_D); | |
| 2509 UNREACHABLE(); | |
| 2510 DISPATCH(); | |
| 2511 } | |
| 2512 | |
| 2513 { | |
| 2514 BYTECODE(IfDGt, A_D); | |
| 2515 UNREACHABLE(); | |
| 2516 DISPATCH(); | |
| 2517 } | |
| 2518 #endif // defined(ARCH_IS_64_BIT) | |
| 2519 | |
| 2520 { | |
| 2298 BYTECODE(IfEqStrictNum, A_D); | 2521 BYTECODE(IfEqStrictNum, A_D); |
| 2299 RawObject* lhs = FP[rA]; | 2522 RawObject* lhs = FP[rA]; |
| 2300 RawObject* rhs = FP[rD]; | 2523 RawObject* rhs = FP[rD]; |
| 2301 if (!SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) { | 2524 if (!SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) { |
| 2302 pc++; | 2525 pc++; |
| 2303 } | 2526 } |
| 2304 DISPATCH(); | 2527 DISPATCH(); |
| 2305 } | 2528 } |
| 2306 | 2529 |
| 2307 { | 2530 { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2521 // Single dispatch point used by exception handling macros. | 2744 // Single dispatch point used by exception handling macros. |
| 2522 { | 2745 { |
| 2523 DispatchAfterException: | 2746 DispatchAfterException: |
| 2524 DISPATCH(); | 2747 DISPATCH(); |
| 2525 } | 2748 } |
| 2526 | 2749 |
| 2527 UNREACHABLE(); | 2750 UNREACHABLE(); |
| 2528 return 0; | 2751 return 0; |
| 2529 } | 2752 } |
| 2530 | 2753 |
| 2754 | |
| 2531 void Simulator::Longjmp(uword pc, | 2755 void Simulator::Longjmp(uword pc, |
| 2532 uword sp, | 2756 uword sp, |
| 2533 uword fp, | 2757 uword fp, |
| 2534 RawObject* raw_exception, | 2758 RawObject* raw_exception, |
| 2535 RawObject* raw_stacktrace, | 2759 RawObject* raw_stacktrace, |
| 2536 Thread* thread) { | 2760 Thread* thread) { |
| 2537 // Walk over all setjmp buffers (simulated --> C++ transitions) | 2761 // Walk over all setjmp buffers (simulated --> C++ transitions) |
| 2538 // and try to find the setjmp associated with the simulated stack pointer. | 2762 // and try to find the setjmp associated with the simulated stack pointer. |
| 2539 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); | 2763 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); |
| 2540 while ((buf->link() != NULL) && (buf->link()->fp() > fp)) { | 2764 while ((buf->link() != NULL) && (buf->link()->fp() > fp)) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2558 fp_ = reinterpret_cast<RawObject**>(fp); | 2782 fp_ = reinterpret_cast<RawObject**>(fp); |
| 2559 pc_ = pc; | 2783 pc_ = pc; |
| 2560 special_[kExceptionSpecialIndex] = raw_exception; | 2784 special_[kExceptionSpecialIndex] = raw_exception; |
| 2561 special_[kStacktraceSpecialIndex] = raw_stacktrace; | 2785 special_[kStacktraceSpecialIndex] = raw_stacktrace; |
| 2562 buf->Longjmp(); | 2786 buf->Longjmp(); |
| 2563 UNREACHABLE(); | 2787 UNREACHABLE(); |
| 2564 } | 2788 } |
| 2565 | 2789 |
| 2566 } // namespace dart | 2790 } // namespace dart |
| 2567 | 2791 |
| 2568 | |
| 2569 #endif // defined TARGET_ARCH_DBC | 2792 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |