OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
6 #include <setjmp.h> | 6 #include <setjmp.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 NativeArguments arguments; | 1520 NativeArguments arguments; |
1521 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 1521 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
1522 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(R0)); | 1522 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(R0)); |
1523 arguments.argc_tag_ = get_register(R1); | 1523 arguments.argc_tag_ = get_register(R1); |
1524 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2)); | 1524 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2)); |
1525 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(R3)); | 1525 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(R3)); |
1526 SimulatorRuntimeCall target = | 1526 SimulatorRuntimeCall target = |
1527 reinterpret_cast<SimulatorRuntimeCall>(external); | 1527 reinterpret_cast<SimulatorRuntimeCall>(external); |
1528 target(arguments); | 1528 target(arguments); |
1529 set_register(R0, icount_); // Zap result register from void function. | 1529 set_register(R0, icount_); // Zap result register from void function. |
| 1530 set_register(R1, icount_); |
1530 } else if (redirection->call_kind() == kLeafRuntimeCall) { | 1531 } else if (redirection->call_kind() == kLeafRuntimeCall) { |
1531 ASSERT((0 <= redirection->argument_count()) && | 1532 ASSERT((0 <= redirection->argument_count()) && |
1532 (redirection->argument_count() <= 4)); | 1533 (redirection->argument_count() <= 4)); |
1533 int32_t r0 = get_register(R0); | 1534 int32_t r0 = get_register(R0); |
1534 int32_t r1 = get_register(R1); | 1535 int32_t r1 = get_register(R1); |
1535 int32_t r2 = get_register(R2); | 1536 int32_t r2 = get_register(R2); |
1536 int32_t r3 = get_register(R3); | 1537 int32_t r3 = get_register(R3); |
1537 SimulatorLeafRuntimeCall target = | 1538 SimulatorLeafRuntimeCall target = |
1538 reinterpret_cast<SimulatorLeafRuntimeCall>(external); | 1539 reinterpret_cast<SimulatorLeafRuntimeCall>(external); |
1539 r0 = target(r0, r1, r2, r3); | 1540 r0 = target(r0, r1, r2, r3); |
1540 set_register(R0, r0); // Set returned result from function. | 1541 set_register(R0, r0); // Set returned result from function. |
| 1542 set_register(R1, icount_); // Zap unused result register. |
1541 } else if (redirection->call_kind() == kLeafFloatRuntimeCall) { | 1543 } else if (redirection->call_kind() == kLeafFloatRuntimeCall) { |
1542 ASSERT((0 <= redirection->argument_count()) && | 1544 ASSERT((0 <= redirection->argument_count()) && |
1543 (redirection->argument_count() <= 2)); | 1545 (redirection->argument_count() <= 2)); |
1544 // We currently use 'hardfp' ('gnueabihf') rather than 'softfp' | |
1545 // ('gnueabi') float ABI for leaf runtime calls, i.e. double values | |
1546 // are passed and returned in vfp registers rather than in integer | |
1547 // register pairs. | |
1548 SimulatorLeafFloatRuntimeCall target = | 1546 SimulatorLeafFloatRuntimeCall target = |
1549 reinterpret_cast<SimulatorLeafFloatRuntimeCall>(external); | 1547 reinterpret_cast<SimulatorLeafFloatRuntimeCall>(external); |
| 1548 #if defined(ARM_FLOAT_ABI_HARD) |
| 1549 // If we're doing "hardfp", the double arguments are already in the |
| 1550 // floating point registers. |
1550 double d0 = get_dregister(D0); | 1551 double d0 = get_dregister(D0); |
1551 double d1 = get_dregister(D1); | 1552 double d1 = get_dregister(D1); |
1552 d0 = target(d0, d1); | 1553 d0 = target(d0, d1); |
1553 set_dregister(D0, d0); | 1554 set_dregister(D0, d0); |
| 1555 #else |
| 1556 // If we're not doing "hardfp", we must be doing "soft" or "softfp", |
| 1557 // So take the double arguments from the integer registers. |
| 1558 uint32_t r0 = get_register(R0); |
| 1559 int32_t r1 = get_register(R1); |
| 1560 uint32_t r2 = get_register(R2); |
| 1561 int32_t r3 = get_register(R3); |
| 1562 int64_t a0 = Utils::LowHighTo64Bits(r0, r1); |
| 1563 int64_t a1 = Utils::LowHighTo64Bits(r2, r3); |
| 1564 double d0 = bit_cast<double, int64_t>(a0); |
| 1565 double d1 = bit_cast<double, int64_t>(a1); |
| 1566 d0 = target(d0, d1); |
| 1567 a0 = bit_cast<int64_t, double>(d0); |
| 1568 r0 = Utils::Low32Bits(a0); |
| 1569 r1 = Utils::High32Bits(a0); |
| 1570 set_register(R0, r0); |
| 1571 set_register(R1, r1); |
| 1572 #endif |
1554 } else if (redirection->call_kind() == kBootstrapNativeCall) { | 1573 } else if (redirection->call_kind() == kBootstrapNativeCall) { |
1555 NativeArguments* arguments; | 1574 NativeArguments* arguments; |
1556 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); | 1575 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); |
1557 SimulatorBootstrapNativeCall target = | 1576 SimulatorBootstrapNativeCall target = |
1558 reinterpret_cast<SimulatorBootstrapNativeCall>(external); | 1577 reinterpret_cast<SimulatorBootstrapNativeCall>(external); |
1559 target(arguments); | 1578 target(arguments); |
1560 set_register(R0, icount_); // Zap result register from void function. | 1579 set_register(R0, icount_); // Zap result register from void function. |
1561 } else { | 1580 } else { |
1562 ASSERT(redirection->call_kind() == kNativeCall); | 1581 ASSERT(redirection->call_kind() == kNativeCall); |
1563 NativeArguments* arguments; | 1582 NativeArguments* arguments; |
1564 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); | 1583 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); |
1565 uword target_func = get_register(R1); | 1584 uword target_func = get_register(R1); |
1566 SimulatorNativeCall target = | 1585 SimulatorNativeCall target = |
1567 reinterpret_cast<SimulatorNativeCall>(external); | 1586 reinterpret_cast<SimulatorNativeCall>(external); |
1568 target(arguments, target_func); | 1587 target(arguments, target_func); |
1569 set_register(R0, icount_); // Zap result register from void function. | 1588 set_register(R0, icount_); // Zap result register from void function. |
| 1589 set_register(R1, icount_); |
1570 } | 1590 } |
1571 set_top_exit_frame_info(0); | 1591 set_top_exit_frame_info(0); |
1572 | 1592 |
1573 // Zap caller-saved registers, since the actual runtime call could have | 1593 // Zap caller-saved registers, since the actual runtime call could have |
1574 // used them. | 1594 // used them. |
1575 set_register(R1, icount_); | |
1576 set_register(R2, icount_); | 1595 set_register(R2, icount_); |
1577 set_register(R3, icount_); | 1596 set_register(R3, icount_); |
1578 set_register(IP, icount_); | 1597 set_register(IP, icount_); |
1579 set_register(LR, icount_); | 1598 set_register(LR, icount_); |
1580 double zap_dvalue = static_cast<double>(icount_); | 1599 double zap_dvalue = static_cast<double>(icount_); |
1581 // Do not zap D0, as it may contain a float result. | 1600 // Do not zap D0, as it may contain a float result. |
1582 for (int i = D1; i <= D7; i++) { | 1601 for (int i = D1; i <= D7; i++) { |
1583 set_dregister(static_cast<DRegister>(i), zap_dvalue); | 1602 set_dregister(static_cast<DRegister>(i), zap_dvalue); |
1584 } | 1603 } |
1585 // The above loop also zaps overlapping registers S2-S15. | 1604 // The above loop also zaps overlapping registers S2-S15. |
(...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3705 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 3724 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
3706 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3725 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
3707 buf->Longjmp(); | 3726 buf->Longjmp(); |
3708 } | 3727 } |
3709 | 3728 |
3710 } // namespace dart | 3729 } // namespace dart |
3711 | 3730 |
3712 #endif // !defined(HOST_ARCH_ARM) | 3731 #endif // !defined(HOST_ARCH_ARM) |
3713 | 3732 |
3714 #endif // defined TARGET_ARCH_ARM | 3733 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |