| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; | 539 last_setjmp_buffer_ = NULL; |
| 540 top_exit_frame_info_ = 0; |
| 540 | 541 |
| 541 // Setup architecture state. | 542 // Setup architecture state. |
| 542 // All registers are initialized to zero to start with. | 543 // All registers are initialized to zero to start with. |
| 543 for (int i = 0; i < kNumberOfCpuRegisters; i++) { | 544 for (int i = 0; i < kNumberOfCpuRegisters; i++) { |
| 544 registers_[i] = 0; | 545 registers_[i] = 0; |
| 545 } | 546 } |
| 546 pc_ = 0; | 547 pc_ = 0; |
| 547 // 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 |
| 548 // allocated stack area. | 549 // allocated stack area. |
| 549 registers_[SP] = StackTop(); | 550 registers_[SP] = StackTop(); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { | 831 } else if (instr->BreakCodeField() == Instr::kRedirectCode) { |
| 831 SimulatorSetjmpBuffer buffer(this); | 832 SimulatorSetjmpBuffer buffer(this); |
| 832 | 833 |
| 833 if (!setjmp(buffer.buffer_)) { | 834 if (!setjmp(buffer.buffer_)) { |
| 834 int32_t saved_ra = get_register(RA); | 835 int32_t saved_ra = get_register(RA); |
| 835 Redirection* redirection = Redirection::FromBreakInstruction(instr); | 836 Redirection* redirection = Redirection::FromBreakInstruction(instr); |
| 836 uword external = redirection->external_function(); | 837 uword external = redirection->external_function(); |
| 837 if (FLAG_trace_sim) { | 838 if (FLAG_trace_sim) { |
| 838 OS::Print("Call to host function at 0x%"Pd"\n", external); | 839 OS::Print("Call to host function at 0x%"Pd"\n", external); |
| 839 } | 840 } |
| 841 |
| 842 if (redirection->call_kind() != kLeafRuntimeCall) { |
| 843 // The top_exit_frame_info of the current isolate points to the top of |
| 844 // the simulator stack. |
| 845 ASSERT((StackTop() - Isolate::Current()->top_exit_frame_info()) < |
| 846 Isolate::GetSpecifiedStackSize()); |
| 847 // Set the top_exit_frame_info of this simulator to the native stack. |
| 848 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); |
| 849 } |
| 840 if (redirection->call_kind() == kRuntimeCall) { | 850 if (redirection->call_kind() == kRuntimeCall) { |
| 841 NativeArguments arguments; | 851 NativeArguments arguments; |
| 842 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 852 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
| 843 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); | 853 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); |
| 844 arguments.argc_tag_ = get_register(A1); | 854 arguments.argc_tag_ = get_register(A1); |
| 845 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); | 855 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); |
| 846 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); | 856 arguments.retval_ = reinterpret_cast<RawObject**>(get_register(A3)); |
| 847 SimulatorRuntimeCall target = | 857 SimulatorRuntimeCall target = |
| 848 reinterpret_cast<SimulatorRuntimeCall>(external); | 858 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 849 target(arguments); | 859 target(arguments); |
| 850 set_register(V0, icount_); // Zap result register from void function. | 860 set_register(V0, icount_); // Zap result register from void function. |
| 851 } else if (redirection->call_kind() == kLeafRuntimeCall) { | 861 } else if (redirection->call_kind() == kLeafRuntimeCall) { |
| 852 int32_t a0 = get_register(A0); | 862 int32_t a0 = get_register(A0); |
| 853 int32_t a1 = get_register(A1); | 863 int32_t a1 = get_register(A1); |
| 854 int32_t a2 = get_register(A2); | 864 int32_t a2 = get_register(A2); |
| 855 int32_t a3 = get_register(A3); | 865 int32_t a3 = get_register(A3); |
| 856 SimulatorLeafRuntimeCall target = | 866 SimulatorLeafRuntimeCall target = |
| 857 reinterpret_cast<SimulatorLeafRuntimeCall>(external); | 867 reinterpret_cast<SimulatorLeafRuntimeCall>(external); |
| 858 a0 = target(a0, a1, a2, a3); | 868 a0 = target(a0, a1, a2, a3); |
| 859 set_register(V0, a0); // Set returned result from function. | 869 set_register(V0, a0); // Set returned result from function. |
| 860 } else { | 870 } else { |
| 861 ASSERT(redirection->call_kind() == kNativeCall); | 871 ASSERT(redirection->call_kind() == kNativeCall); |
| 862 NativeArguments* arguments; | 872 NativeArguments* arguments; |
| 863 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); | 873 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); |
| 864 SimulatorNativeCall target = | 874 SimulatorNativeCall target = |
| 865 reinterpret_cast<SimulatorNativeCall>(external); | 875 reinterpret_cast<SimulatorNativeCall>(external); |
| 866 target(arguments); | 876 target(arguments); |
| 867 set_register(V0, icount_); // Zap result register from void function. | 877 set_register(V0, icount_); // Zap result register from void function. |
| 868 } | 878 } |
| 879 set_top_exit_frame_info(0); |
| 869 | 880 |
| 870 // Zap caller-saved registers, since the actual runtime call could have | 881 // Zap caller-saved registers, since the actual runtime call could have |
| 871 // used them. | 882 // used them. |
| 872 set_register(T0, icount_); | 883 set_register(T0, icount_); |
| 873 set_register(T1, icount_); | 884 set_register(T1, icount_); |
| 874 set_register(T2, icount_); | 885 set_register(T2, icount_); |
| 875 set_register(T3, icount_); | 886 set_register(T3, icount_); |
| 876 set_register(T4, icount_); | 887 set_register(T4, icount_); |
| 877 set_register(T5, icount_); | 888 set_register(T5, icount_); |
| 878 set_register(T6, icount_); | 889 set_register(T6, icount_); |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 // Restore the SP register and return R1:R0. | 1622 // Restore the SP register and return R1:R0. |
| 1612 set_register(SP, sp_before_call); | 1623 set_register(SP, sp_before_call); |
| 1613 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); | 1624 return Utils::LowHighTo64Bits(get_register(V0), get_register(V1)); |
| 1614 } | 1625 } |
| 1615 | 1626 |
| 1616 } // namespace dart | 1627 } // namespace dart |
| 1617 | 1628 |
| 1618 #endif // !defined(HOST_ARCH_MIPS) | 1629 #endif // !defined(HOST_ARCH_MIPS) |
| 1619 | 1630 |
| 1620 #endif // defined TARGET_ARCH_MIPS | 1631 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |