Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: runtime/vm/simulator_dbc.cc

Issue 2120703002: DBC: Enables unboxed doubles (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rename BoxDouble -> WriteIntoDouble Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | tools/build.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(WriteIntoDouble, A_D);
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(WriteIntoDouble, 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 { 2217 {
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 {
2227 BYTECODE(CheckEitherNonSmi, A_D);
2228 const intptr_t obj1 = reinterpret_cast<intptr_t>(FP[rA]);
2229 const intptr_t obj2 = reinterpret_cast<intptr_t>(FP[rD]);
2230 const intptr_t tag = (obj1 | obj2) & kSmiTagMask;
2231 if (tag != kSmiTag) {
2232 pc++;
2233 }
2234 DISPATCH();
2235 }
2236
2237 {
2091 BYTECODE(CheckClassId, A_D); 2238 BYTECODE(CheckClassId, A_D);
2092 const intptr_t actual_cid = SimulatorHelpers::GetClassId(FP[rA]); 2239 const intptr_t actual_cid =
2240 reinterpret_cast<intptr_t>(FP[rA]) >> kSmiTagSize;
2093 const intptr_t desired_cid = rD; 2241 const intptr_t desired_cid = rD;
2094 pc += (actual_cid == desired_cid) ? 1 : 0; 2242 pc += (actual_cid == desired_cid) ? 1 : 0;
2095 DISPATCH(); 2243 DISPATCH();
2096 } 2244 }
2097 2245
2098 { 2246 {
2099 BYTECODE(CheckDenseSwitch, A_D); 2247 BYTECODE(CheckDenseSwitch, A_D);
2100 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]); 2248 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
2101 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag); 2249 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
2102 const intptr_t cid_min = Bytecode::DecodeD(*pc); 2250 const intptr_t cid_min = Bytecode::DecodeD(*pc);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 { 2435 {
2288 BYTECODE(IfUGt, A_D); 2436 BYTECODE(IfUGt, A_D);
2289 const uintptr_t lhs = reinterpret_cast<uintptr_t>(FP[rA]); 2437 const uintptr_t lhs = reinterpret_cast<uintptr_t>(FP[rA]);
2290 const uintptr_t rhs = reinterpret_cast<uintptr_t>(FP[rD]); 2438 const uintptr_t rhs = reinterpret_cast<uintptr_t>(FP[rD]);
2291 if (lhs <= rhs) { 2439 if (lhs <= rhs) {
2292 pc++; 2440 pc++;
2293 } 2441 }
2294 DISPATCH(); 2442 DISPATCH();
2295 } 2443 }
2296 2444
2445 #if defined(ARCH_IS_64_BIT)
2446 {
2447 BYTECODE(IfDEq, A_D);
2448 const double lhs = bit_cast<double, RawObject*>(FP[rA]);
2449 const double rhs = bit_cast<double, RawObject*>(FP[rD]);
2450 pc += (lhs == rhs) ? 0 : 1;
2451 DISPATCH();
2452 }
2453
2297 { 2454 {
2455 BYTECODE(IfDNe, A_D);
2456 const double lhs = bit_cast<double, RawObject*>(FP[rA]);
2457 const double rhs = bit_cast<double, RawObject*>(FP[rD]);
2458 pc += (lhs != rhs) ? 0 : 1;
2459 DISPATCH();
2460 }
2461
2462 {
2463 BYTECODE(IfDLe, A_D);
2464 const double lhs = bit_cast<double, RawObject*>(FP[rA]);
2465 const double rhs = bit_cast<double, RawObject*>(FP[rD]);
2466 pc += (lhs <= rhs) ? 0 : 1;
2467 DISPATCH();
2468 }
2469
2470 {
2471 BYTECODE(IfDLt, A_D);
2472 const double lhs = bit_cast<double, RawObject*>(FP[rA]);
2473 const double rhs = bit_cast<double, RawObject*>(FP[rD]);
2474 pc += (lhs < rhs) ? 0 : 1;
2475 DISPATCH();
2476 }
2477
2478 {
2479 BYTECODE(IfDGe, A_D);
2480 const double lhs = bit_cast<double, RawObject*>(FP[rA]);
2481 const double rhs = bit_cast<double, RawObject*>(FP[rD]);
2482 pc += (lhs >= rhs) ? 0 : 1;
2483 DISPATCH();
2484 }
2485
2486 {
2487 BYTECODE(IfDGt, A_D);
2488 const double lhs = bit_cast<double, RawObject*>(FP[rA]);
2489 const double rhs = bit_cast<double, RawObject*>(FP[rD]);
2490 pc += (lhs > rhs) ? 0 : 1;
2491 DISPATCH();
2492 }
2493 #else // defined(ARCH_IS_64_BIT)
2494 {
2495 BYTECODE(IfDEq, A_D);
2496 UNREACHABLE();
2497 DISPATCH();
2498 }
2499
2500 {
2501 BYTECODE(IfDNe, A_D);
2502 UNREACHABLE();
2503 DISPATCH();
2504 }
2505
2506 {
2507 BYTECODE(IfDLe, A_D);
2508 UNREACHABLE();
2509 DISPATCH();
2510 }
2511
2512 {
2513 BYTECODE(IfDLt, A_D);
2514 UNREACHABLE();
2515 DISPATCH();
2516 }
2517
2518 {
2519 BYTECODE(IfDGe, A_D);
2520 UNREACHABLE();
2521 DISPATCH();
2522 }
2523
2524 {
2525 BYTECODE(IfDGt, A_D);
2526 UNREACHABLE();
2527 DISPATCH();
2528 }
2529 #endif // defined(ARCH_IS_64_BIT)
2530
2531 {
2298 BYTECODE(IfEqStrictNum, A_D); 2532 BYTECODE(IfEqStrictNum, A_D);
2299 RawObject* lhs = FP[rA]; 2533 RawObject* lhs = FP[rA];
2300 RawObject* rhs = FP[rD]; 2534 RawObject* rhs = FP[rD];
2301 if (!SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) { 2535 if (!SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) {
2302 pc++; 2536 pc++;
2303 } 2537 }
2304 DISPATCH(); 2538 DISPATCH();
2305 } 2539 }
2306 2540
2307 { 2541 {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 // Single dispatch point used by exception handling macros. 2755 // Single dispatch point used by exception handling macros.
2522 { 2756 {
2523 DispatchAfterException: 2757 DispatchAfterException:
2524 DISPATCH(); 2758 DISPATCH();
2525 } 2759 }
2526 2760
2527 UNREACHABLE(); 2761 UNREACHABLE();
2528 return 0; 2762 return 0;
2529 } 2763 }
2530 2764
2765
2531 void Simulator::Longjmp(uword pc, 2766 void Simulator::Longjmp(uword pc,
2532 uword sp, 2767 uword sp,
2533 uword fp, 2768 uword fp,
2534 RawObject* raw_exception, 2769 RawObject* raw_exception,
2535 RawObject* raw_stacktrace, 2770 RawObject* raw_stacktrace,
2536 Thread* thread) { 2771 Thread* thread) {
2537 // Walk over all setjmp buffers (simulated --> C++ transitions) 2772 // Walk over all setjmp buffers (simulated --> C++ transitions)
2538 // and try to find the setjmp associated with the simulated stack pointer. 2773 // and try to find the setjmp associated with the simulated stack pointer.
2539 SimulatorSetjmpBuffer* buf = last_setjmp_buffer(); 2774 SimulatorSetjmpBuffer* buf = last_setjmp_buffer();
2540 while ((buf->link() != NULL) && (buf->link()->fp() > fp)) { 2775 while ((buf->link() != NULL) && (buf->link()->fp() > fp)) {
(...skipping 17 matching lines...) Expand all
2558 fp_ = reinterpret_cast<RawObject**>(fp); 2793 fp_ = reinterpret_cast<RawObject**>(fp);
2559 pc_ = pc; 2794 pc_ = pc;
2560 special_[kExceptionSpecialIndex] = raw_exception; 2795 special_[kExceptionSpecialIndex] = raw_exception;
2561 special_[kStacktraceSpecialIndex] = raw_stacktrace; 2796 special_[kStacktraceSpecialIndex] = raw_stacktrace;
2562 buf->Longjmp(); 2797 buf->Longjmp();
2563 UNREACHABLE(); 2798 UNREACHABLE();
2564 } 2799 }
2565 2800
2566 } // namespace dart 2801 } // namespace dart
2567 2802
2568
2569 #endif // defined TARGET_ARCH_DBC 2803 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | tools/build.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698