| 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_MIPS) | 10 #if defined(TARGET_ARCH_MIPS) |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 // the size specified by the user and the buffer space needed for | 529 // the size specified by the user and the buffer space needed for |
| 530 // handling stack overflow exceptions. To be safe in potential | 530 // handling stack overflow exceptions. To be safe in potential |
| 531 // stack underflows we also add some underflow buffer space. | 531 // stack underflows we also add some underflow buffer space. |
| 532 stack_ = new char[(Isolate::GetSpecifiedStackSize() + | 532 stack_ = new char[(Isolate::GetSpecifiedStackSize() + |
| 533 Isolate::kStackSizeBuffer + | 533 Isolate::kStackSizeBuffer + |
| 534 kSimulatorStackUnderflowSize)]; | 534 kSimulatorStackUnderflowSize)]; |
| 535 icount_ = 0; | 535 icount_ = 0; |
| 536 delay_slot_ = false; | 536 delay_slot_ = false; |
| 537 break_pc_ = NULL; | 537 break_pc_ = NULL; |
| 538 break_instr_ = 0; | 538 break_instr_ = 0; |
| 539 last_setjmp_buffer_ = NULL; |
| 540 top_exit_frame_info_ = 0; |
| 539 | 541 |
| 540 // Setup architecture state. | 542 // Setup architecture state. |
| 541 // All registers are initialized to zero to start with. | 543 // All registers are initialized to zero to start with. |
| 542 for (int i = 0; i < kNumberOfCpuRegisters; i++) { | 544 for (int i = 0; i < kNumberOfCpuRegisters; i++) { |
| 543 registers_[i] = 0; | 545 registers_[i] = 0; |
| 544 } | 546 } |
| 545 pc_ = 0; | 547 pc_ = 0; |
| 546 // The sp is initialized to point to the bottom (high address) of the | 548 // The sp is initialized to point to the bottom (high address) of the |
| 547 // allocated stack area. | 549 // allocated stack area. |
| 548 registers_[SP] = StackTop(); | 550 registers_[SP] = StackTop(); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { | 825 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { |
| 824 SimulatorSetjmpBuffer buffer(this); | 826 SimulatorSetjmpBuffer buffer(this); |
| 825 | 827 |
| 826 if (!setjmp(buffer.buffer_)) { | 828 if (!setjmp(buffer.buffer_)) { |
| 827 int32_t saved_ra = get_register(RA); | 829 int32_t saved_ra = get_register(RA); |
| 828 Redirection* redirection = Redirection::FromBreakInstruction(instr); | 830 Redirection* redirection = Redirection::FromBreakInstruction(instr); |
| 829 uword external = redirection->external_function(); | 831 uword external = redirection->external_function(); |
| 830 if (FLAG_trace_sim) { | 832 if (FLAG_trace_sim) { |
| 831 OS::Print("Call to host function at 0x%"Pd"\n", external); | 833 OS::Print("Call to host function at 0x%"Pd"\n", external); |
| 832 } | 834 } |
| 835 |
| 836 if (redirection->call_kind() != kLeafRuntimeCall) { |
| 837 // The top_exit_frame_info of the current isolate points to the top of |
| 838 // the simulator stack. |
| 839 ASSERT((StackTop() - Isolate::Current()->top_exit_frame_info()) < |
| 840 Isolate::GetSpecifiedStackSize()); |
| 841 // Set the top_exit_frame_info of this simulator to the native stack. |
| 842 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); |
| 843 } |
| 833 if (redirection->call_kind() == kRuntimeCall) { | 844 if (redirection->call_kind() == kRuntimeCall) { |
| 834 NativeArguments arguments; | 845 NativeArguments arguments; |
| 835 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 846 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
| 836 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); | 847 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); |
| 837 arguments.argc_tag_ = get_register(A1); | 848 arguments.argc_tag_ = get_register(A1); |
| 838 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); | 849 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); |
| 839 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); | 850 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); |
| 840 SimulatorRuntimeCall target = | 851 SimulatorRuntimeCall target = |
| 841 reinterpret_cast<SimulatorRuntimeCall>(external); | 852 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 842 target(arguments); | 853 target(arguments); |
| 843 set_register(V0, icount_); // Zap result register from void function. | 854 set_register(V0, icount_); // Zap result register from void function. |
| 844 } else if (redirection->call_kind() == kLeafRuntimeCall) { | 855 } else if (redirection->call_kind() == kLeafRuntimeCall) { |
| 845 int32_t a0 = get_register(A0); | 856 int32_t a0 = get_register(A0); |
| 846 int32_t a1 = get_register(A1); | 857 int32_t a1 = get_register(A1); |
| 847 int32_t a2 = get_register(A2); | 858 int32_t a2 = get_register(A2); |
| 848 int32_t a3 = get_register(A3); | 859 int32_t a3 = get_register(A3); |
| 849 SimulatorLeafRuntimeCall target = | 860 SimulatorLeafRuntimeCall target = |
| 850 reinterpret_cast<SimulatorLeafRuntimeCall>(external); | 861 reinterpret_cast<SimulatorLeafRuntimeCall>(external); |
| 851 a0 = target(a0, a1, a2, a3); | 862 a0 = target(a0, a1, a2, a3); |
| 852 set_register(V0, a0); // Set returned result from function. | 863 set_register(V0, a0); // Set returned result from function. |
| 853 } else { | 864 } else { |
| 854 ASSERT(redirection->call_kind() == kNativeCall); | 865 ASSERT(redirection->call_kind() == kNativeCall); |
| 855 NativeArguments* arguments; | 866 NativeArguments* arguments; |
| 856 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); | 867 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); |
| 857 SimulatorNativeCall target = | 868 SimulatorNativeCall target = |
| 858 reinterpret_cast<SimulatorNativeCall>(external); | 869 reinterpret_cast<SimulatorNativeCall>(external); |
| 859 target(arguments); | 870 target(arguments); |
| 860 set_register(V0, icount_); // Zap result register from void function. | 871 set_register(V0, icount_); // Zap result register from void function. |
| 861 } | 872 } |
| 873 set_top_exit_frame_info(0); |
| 862 | 874 |
| 863 // Zap caller-saved registers, since the actual runtime call could have | 875 // Zap caller-saved registers, since the actual runtime call could have |
| 864 // used them. | 876 // used them. |
| 865 set_register(T0, icount_); | 877 set_register(T0, icount_); |
| 866 set_register(T1, icount_); | 878 set_register(T1, icount_); |
| 867 set_register(T2, icount_); | 879 set_register(T2, icount_); |
| 868 set_register(T3, icount_); | 880 set_register(T3, icount_); |
| 869 set_register(T4, icount_); | 881 set_register(T4, icount_); |
| 870 set_register(T5, icount_); | 882 set_register(T5, icount_); |
| 871 set_register(T6, icount_); | 883 set_register(T6, icount_); |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 // Restore the SP register and return R1:R0. | 1610 // Restore the SP register and return R1:R0. |
| 1599 set_register(SP, sp_before_call); | 1611 set_register(SP, sp_before_call); |
| 1600 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); | 1612 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); |
| 1601 } | 1613 } |
| 1602 | 1614 |
| 1603 } // namespace dart | 1615 } // namespace dart |
| 1604 | 1616 |
| 1605 #endif // !defined(HOST_ARCH_MIPS) | 1617 #endif // !defined(HOST_ARCH_MIPS) |
| 1606 | 1618 |
| 1607 #endif // defined TARGET_ARCH_MIPS | 1619 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |