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 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 typedef void (*SimulatorRuntimeCall)(NativeArguments arguments); | 1484 typedef void (*SimulatorRuntimeCall)(NativeArguments arguments); |
1485 | 1485 |
1486 // Calls to leaf Dart runtime functions are based on this interface. | 1486 // Calls to leaf Dart runtime functions are based on this interface. |
1487 typedef int32_t (*SimulatorLeafRuntimeCall)( | 1487 typedef int32_t (*SimulatorLeafRuntimeCall)( |
1488 int32_t r0, int32_t r1, int32_t r2, int32_t r3); | 1488 int32_t r0, int32_t r1, int32_t r2, int32_t r3); |
1489 | 1489 |
1490 // Calls to leaf float Dart runtime functions are based on this interface. | 1490 // Calls to leaf float Dart runtime functions are based on this interface. |
1491 typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, double d1); | 1491 typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, double d1); |
1492 | 1492 |
1493 // Calls to native Dart functions are based on this interface. | 1493 // Calls to native Dart functions are based on this interface. |
1494 typedef void (*SimulatorNativeCall)(NativeArguments* arguments); | 1494 typedef void (*SimulatorBootstrapNativeCall)(NativeArguments* arguments); |
| 1495 typedef void (*SimulatorNativeCall)(NativeArguments* arguments, uword target); |
1495 | 1496 |
1496 | 1497 |
1497 void Simulator::SupervisorCall(Instr* instr) { | 1498 void Simulator::SupervisorCall(Instr* instr) { |
1498 int svc = instr->SvcField(); | 1499 int svc = instr->SvcField(); |
1499 switch (svc) { | 1500 switch (svc) { |
1500 case kRedirectionSvcCode: { | 1501 case kRedirectionSvcCode: { |
1501 SimulatorSetjmpBuffer buffer(this); | 1502 SimulatorSetjmpBuffer buffer(this); |
1502 | 1503 |
1503 if (!setjmp(buffer.buffer_)) { | 1504 if (!setjmp(buffer.buffer_)) { |
1504 int32_t saved_lr = get_register(LR); | 1505 int32_t saved_lr = get_register(LR); |
1505 Redirection* redirection = Redirection::FromSvcInstruction(instr); | 1506 Redirection* redirection = Redirection::FromSvcInstruction(instr); |
1506 uword external = redirection->external_function(); | 1507 uword external = redirection->external_function(); |
1507 if (FLAG_trace_sim) { | 1508 if (FLAG_trace_sim) { |
1508 OS::Print("Call to host function at 0x%"Pd"\n", external); | 1509 OS::Print("Call to host function at 0x%"Pd"\n", external); |
1509 } | 1510 } |
1510 | 1511 |
1511 if ((redirection->call_kind() == kRuntimeCall) || | 1512 if ((redirection->call_kind() == kRuntimeCall) || |
| 1513 (redirection->call_kind() == kBootstrapNativeCall) || |
1512 (redirection->call_kind() == kNativeCall)) { | 1514 (redirection->call_kind() == kNativeCall)) { |
1513 // Set the top_exit_frame_info of this simulator to the native stack. | 1515 // Set the top_exit_frame_info of this simulator to the native stack. |
1514 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); | 1516 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); |
1515 } | 1517 } |
1516 if (redirection->call_kind() == kRuntimeCall) { | 1518 if (redirection->call_kind() == kRuntimeCall) { |
1517 NativeArguments arguments; | 1519 NativeArguments arguments; |
1518 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 1520 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
1519 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(R0)); | 1521 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(R0)); |
1520 arguments.argc_tag_ = get_register(R1); | 1522 arguments.argc_tag_ = get_register(R1); |
1521 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2)); | 1523 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(R2)); |
(...skipping 19 matching lines...) Expand all Loading... |
1541 // We currently use 'hardfp' ('gnueabihf') rather than 'softfp' | 1543 // We currently use 'hardfp' ('gnueabihf') rather than 'softfp' |
1542 // ('gnueabi') float ABI for leaf runtime calls, i.e. double values | 1544 // ('gnueabi') float ABI for leaf runtime calls, i.e. double values |
1543 // are passed and returned in vfp registers rather than in integer | 1545 // are passed and returned in vfp registers rather than in integer |
1544 // register pairs. | 1546 // register pairs. |
1545 SimulatorLeafFloatRuntimeCall target = | 1547 SimulatorLeafFloatRuntimeCall target = |
1546 reinterpret_cast<SimulatorLeafFloatRuntimeCall>(external); | 1548 reinterpret_cast<SimulatorLeafFloatRuntimeCall>(external); |
1547 double d0 = get_dregister(D0); | 1549 double d0 = get_dregister(D0); |
1548 double d1 = get_dregister(D1); | 1550 double d1 = get_dregister(D1); |
1549 d0 = target(d0, d1); | 1551 d0 = target(d0, d1); |
1550 set_dregister(D0, d0); | 1552 set_dregister(D0, d0); |
| 1553 } else if (redirection->call_kind() == kBootstrapNativeCall) { |
| 1554 NativeArguments* arguments; |
| 1555 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); |
| 1556 SimulatorBootstrapNativeCall target = |
| 1557 reinterpret_cast<SimulatorBootstrapNativeCall>(external); |
| 1558 target(arguments); |
| 1559 set_register(R0, icount_); // Zap result register from void function. |
1551 } else { | 1560 } else { |
1552 ASSERT(redirection->call_kind() == kNativeCall); | 1561 ASSERT(redirection->call_kind() == kNativeCall); |
1553 NativeArguments* arguments; | 1562 NativeArguments* arguments; |
1554 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); | 1563 arguments = reinterpret_cast<NativeArguments*>(get_register(R0)); |
| 1564 uword target_func = get_register(R1); |
1555 SimulatorNativeCall target = | 1565 SimulatorNativeCall target = |
1556 reinterpret_cast<SimulatorNativeCall>(external); | 1566 reinterpret_cast<SimulatorNativeCall>(external); |
1557 target(arguments); | 1567 target(arguments, target_func); |
1558 set_register(R0, icount_); // Zap result register from void function. | 1568 set_register(R0, icount_); // Zap result register from void function. |
1559 } | 1569 } |
1560 set_top_exit_frame_info(0); | 1570 set_top_exit_frame_info(0); |
1561 | 1571 |
1562 // Zap caller-saved registers, since the actual runtime call could have | 1572 // Zap caller-saved registers, since the actual runtime call could have |
1563 // used them. | 1573 // used them. |
1564 set_register(R1, icount_); | 1574 set_register(R1, icount_); |
1565 set_register(R2, icount_); | 1575 set_register(R2, icount_); |
1566 set_register(R3, icount_); | 1576 set_register(R3, icount_); |
1567 set_register(IP, icount_); | 1577 set_register(IP, icount_); |
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3657 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 3667 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
3658 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3668 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
3659 buf->Longjmp(); | 3669 buf->Longjmp(); |
3660 } | 3670 } |
3661 | 3671 |
3662 } // namespace dart | 3672 } // namespace dart |
3663 | 3673 |
3664 #endif // !defined(HOST_ARCH_ARM) | 3674 #endif // !defined(HOST_ARCH_ARM) |
3665 | 3675 |
3666 #endif // defined TARGET_ARCH_ARM | 3676 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |