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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 typedef void (*SimulatorRuntimeCall)(NativeArguments arguments); | 966 typedef void (*SimulatorRuntimeCall)(NativeArguments arguments); |
967 | 967 |
968 // Calls to leaf Dart runtime functions are based on this interface. | 968 // Calls to leaf Dart runtime functions are based on this interface. |
969 typedef int32_t (*SimulatorLeafRuntimeCall)( | 969 typedef int32_t (*SimulatorLeafRuntimeCall)( |
970 int32_t r0, int32_t r1, int32_t r2, int32_t r3); | 970 int32_t r0, int32_t r1, int32_t r2, int32_t r3); |
971 | 971 |
972 // Calls to leaf float Dart runtime functions are based on this interface. | 972 // Calls to leaf float Dart runtime functions are based on this interface. |
973 typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, double d1); | 973 typedef double (*SimulatorLeafFloatRuntimeCall)(double d0, double d1); |
974 | 974 |
975 // Calls to native Dart functions are based on this interface. | 975 // Calls to native Dart functions are based on this interface. |
976 typedef void (*SimulatorNativeCall)(NativeArguments* arguments); | 976 typedef void (*SimulatorBootstrapNativeCall)(NativeArguments* arguments); |
| 977 typedef void (*SimulatorNativeCall)(NativeArguments* arguments, uword target); |
977 | 978 |
978 | 979 |
979 void Simulator::DoBreak(Instr *instr) { | 980 void Simulator::DoBreak(Instr *instr) { |
980 ASSERT(instr->OpcodeField() == SPECIAL); | 981 ASSERT(instr->OpcodeField() == SPECIAL); |
981 ASSERT(instr->FunctionField() == BREAK); | 982 ASSERT(instr->FunctionField() == BREAK); |
982 if (instr->BreakCodeField() == Instr::kStopMessageCode) { | 983 if (instr->BreakCodeField() == Instr::kStopMessageCode) { |
983 SimulatorDebugger dbg(this); | 984 SimulatorDebugger dbg(this); |
984 const char* message = *reinterpret_cast<const char**>( | 985 const char* message = *reinterpret_cast<const char**>( |
985 reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize); | 986 reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize); |
986 set_pc(get_pc() + Instr::kInstrSize); | 987 set_pc(get_pc() + Instr::kInstrSize); |
(...skipping 14 matching lines...) Expand all Loading... |
1001 | 1002 |
1002 if (!setjmp(buffer.buffer_)) { | 1003 if (!setjmp(buffer.buffer_)) { |
1003 int32_t saved_ra = get_register(RA); | 1004 int32_t saved_ra = get_register(RA); |
1004 Redirection* redirection = Redirection::FromBreakInstruction(instr); | 1005 Redirection* redirection = Redirection::FromBreakInstruction(instr); |
1005 uword external = redirection->external_function(); | 1006 uword external = redirection->external_function(); |
1006 if (FLAG_trace_sim) { | 1007 if (FLAG_trace_sim) { |
1007 OS::Print("Call to host function at 0x%"Pd"\n", external); | 1008 OS::Print("Call to host function at 0x%"Pd"\n", external); |
1008 } | 1009 } |
1009 | 1010 |
1010 if ((redirection->call_kind() == kRuntimeCall) || | 1011 if ((redirection->call_kind() == kRuntimeCall) || |
| 1012 (redirection->call_kind() == kBootstrapNativeCall) || |
1011 (redirection->call_kind() == kNativeCall)) { | 1013 (redirection->call_kind() == kNativeCall)) { |
1012 // Set the top_exit_frame_info of this simulator to the native stack. | 1014 // Set the top_exit_frame_info of this simulator to the native stack. |
1013 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); | 1015 set_top_exit_frame_info(reinterpret_cast<uword>(&buffer)); |
1014 } | 1016 } |
1015 if (redirection->call_kind() == kRuntimeCall) { | 1017 if (redirection->call_kind() == kRuntimeCall) { |
1016 NativeArguments arguments; | 1018 NativeArguments arguments; |
1017 ASSERT(sizeof(NativeArguments) == 4*kWordSize); | 1019 ASSERT(sizeof(NativeArguments) == 4*kWordSize); |
1018 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); | 1020 arguments.isolate_ = reinterpret_cast<Isolate*>(get_register(A0)); |
1019 arguments.argc_tag_ = get_register(A1); | 1021 arguments.argc_tag_ = get_register(A1); |
1020 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); | 1022 arguments.argv_ = reinterpret_cast<RawObject*(*)[]>(get_register(A2)); |
(...skipping 17 matching lines...) Expand all Loading... |
1038 ASSERT((0 <= redirection->argument_count()) && | 1040 ASSERT((0 <= redirection->argument_count()) && |
1039 (redirection->argument_count() <= 2)); | 1041 (redirection->argument_count() <= 2)); |
1040 // double values are passed and returned in floating point registers. | 1042 // double values are passed and returned in floating point registers. |
1041 SimulatorLeafFloatRuntimeCall target = | 1043 SimulatorLeafFloatRuntimeCall target = |
1042 reinterpret_cast<SimulatorLeafFloatRuntimeCall>(external); | 1044 reinterpret_cast<SimulatorLeafFloatRuntimeCall>(external); |
1043 double d0 = 0.0; | 1045 double d0 = 0.0; |
1044 double d6 = get_fregister_double(F12); | 1046 double d6 = get_fregister_double(F12); |
1045 double d7 = get_fregister_double(F14); | 1047 double d7 = get_fregister_double(F14); |
1046 d0 = target(d6, d7); | 1048 d0 = target(d6, d7); |
1047 set_fregister_double(F0, d0); | 1049 set_fregister_double(F0, d0); |
| 1050 } else if (redirection->call_kind() == kBootstrapNativeCall) { |
| 1051 NativeArguments* arguments; |
| 1052 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); |
| 1053 SimulatorBootstrapNativeCall target = |
| 1054 reinterpret_cast<SimulatorBootstrapNativeCall>(external); |
| 1055 target(arguments); |
| 1056 set_register(V0, icount_); // Zap result register from void function. |
| 1057 set_register(V1, icount_); |
1048 } else { | 1058 } else { |
1049 ASSERT(redirection->call_kind() == kNativeCall); | 1059 ASSERT(redirection->call_kind() == kNativeCall); |
1050 NativeArguments* arguments; | 1060 NativeArguments* arguments; |
1051 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); | 1061 arguments = reinterpret_cast<NativeArguments*>(get_register(A0)); |
| 1062 uword target_func = get_register(A1); |
1052 SimulatorNativeCall target = | 1063 SimulatorNativeCall target = |
1053 reinterpret_cast<SimulatorNativeCall>(external); | 1064 reinterpret_cast<SimulatorNativeCall>(external); |
1054 target(arguments); | 1065 target(arguments, target_func); |
1055 set_register(V0, icount_); // Zap result register from void function. | 1066 set_register(V0, icount_); // Zap result register from void function. |
1056 set_register(V1, icount_); | 1067 set_register(V1, icount_); |
1057 } | 1068 } |
1058 set_top_exit_frame_info(0); | 1069 set_top_exit_frame_info(0); |
1059 | 1070 |
1060 // Zap caller-saved registers, since the actual runtime call could have | 1071 // Zap caller-saved registers, since the actual runtime call could have |
1061 // used them. | 1072 // used them. |
1062 set_register(T0, icount_); | 1073 set_register(T0, icount_); |
1063 set_register(T1, icount_); | 1074 set_register(T1, icount_); |
1064 set_register(T2, icount_); | 1075 set_register(T2, icount_); |
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2245 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
2235 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2246 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
2236 buf->Longjmp(); | 2247 buf->Longjmp(); |
2237 } | 2248 } |
2238 | 2249 |
2239 } // namespace dart | 2250 } // namespace dart |
2240 | 2251 |
2241 #endif // !defined(HOST_ARCH_MIPS) | 2252 #endif // !defined(HOST_ARCH_MIPS) |
2242 | 2253 |
2243 #endif // defined TARGET_ARCH_MIPS | 2254 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |