OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #if V8_TARGET_ARCH_MIPS | 10 #if V8_TARGET_ARCH_MIPS |
11 | 11 |
12 #include "src/assembler.h" | 12 #include "src/assembler.h" |
13 #include "src/base/bits.h" | 13 #include "src/base/bits.h" |
14 #include "src/codegen.h" | 14 #include "src/codegen.h" |
15 #include "src/disasm.h" | 15 #include "src/disasm.h" |
16 #include "src/mips/constants-mips.h" | 16 #include "src/mips/constants-mips.h" |
17 #include "src/mips/simulator-mips.h" | 17 #include "src/mips/simulator-mips.h" |
18 #include "src/ostreams.h" | 18 #include "src/ostreams.h" |
| 19 #include "src/runtime/runtime-utils.h" |
19 | 20 |
20 | 21 |
21 // Only build the simulator if not compiling for real MIPS hardware. | 22 // Only build the simulator if not compiling for real MIPS hardware. |
22 #if defined(USE_SIMULATOR) | 23 #if defined(USE_SIMULATOR) |
23 | 24 |
24 namespace v8 { | 25 namespace v8 { |
25 namespace internal { | 26 namespace internal { |
26 | 27 |
27 // Utils functions. | 28 // Utils functions. |
28 bool HaveSameSign(int32_t a, int32_t b) { | 29 bool HaveSameSign(int32_t a, int32_t b) { |
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 // 64-bit value. With the code below we assume that all runtime calls return | 1964 // 64-bit value. With the code below we assume that all runtime calls return |
1964 // 64 bits of result. If they don't, the v1 result register contains a bogus | 1965 // 64 bits of result. If they don't, the v1 result register contains a bogus |
1965 // value, which is fine because it is caller-saved. | 1966 // value, which is fine because it is caller-saved. |
1966 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, | 1967 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, |
1967 int32_t arg1, | 1968 int32_t arg1, |
1968 int32_t arg2, | 1969 int32_t arg2, |
1969 int32_t arg3, | 1970 int32_t arg3, |
1970 int32_t arg4, | 1971 int32_t arg4, |
1971 int32_t arg5); | 1972 int32_t arg5); |
1972 | 1973 |
| 1974 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(int32_t arg0, int32_t arg1, |
| 1975 int32_t arg2, int32_t arg3, |
| 1976 int32_t arg4); |
| 1977 |
1973 // These prototypes handle the four types of FP calls. | 1978 // These prototypes handle the four types of FP calls. |
1974 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1979 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
1975 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1980 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
1976 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1981 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
1977 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1982 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
1978 | 1983 |
1979 // This signature supports direct call in to API function native callback | 1984 // This signature supports direct call in to API function native callback |
1980 // (refer to InvocationCallback in v8.h). | 1985 // (refer to InvocationCallback in v8.h). |
1981 typedef void (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1986 typedef void (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
1982 typedef void (*SimulatorRuntimeProfilingApiCall)(int32_t arg0, void* arg1); | 1987 typedef void (*SimulatorRuntimeProfilingApiCall)(int32_t arg0, void* arg1); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 target(arg0, arg1); | 2179 target(arg0, arg1); |
2175 } else if ( | 2180 } else if ( |
2176 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { | 2181 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { |
2177 if (::v8::internal::FLAG_trace_sim) { | 2182 if (::v8::internal::FLAG_trace_sim) { |
2178 PrintF("Call to host function at %p args %08x %08x %08x\n", | 2183 PrintF("Call to host function at %p args %08x %08x %08x\n", |
2179 reinterpret_cast<void*>(external), arg0, arg1, arg2); | 2184 reinterpret_cast<void*>(external), arg0, arg1, arg2); |
2180 } | 2185 } |
2181 SimulatorRuntimeProfilingGetterCall target = | 2186 SimulatorRuntimeProfilingGetterCall target = |
2182 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); | 2187 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); |
2183 target(arg0, arg1, Redirection::ReverseRedirection(arg2)); | 2188 target(arg0, arg1, Redirection::ReverseRedirection(arg2)); |
| 2189 } else if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { |
| 2190 // builtin call returning ObjectTriple. |
| 2191 SimulatorRuntimeTripleCall target = |
| 2192 reinterpret_cast<SimulatorRuntimeTripleCall>(external); |
| 2193 if (::v8::internal::FLAG_trace_sim) { |
| 2194 PrintF( |
| 2195 "Call to host triple returning runtime function %p " |
| 2196 "args %08x, %08x, %08x, %08x, %08x\n", |
| 2197 FUNCTION_ADDR(target), arg1, arg2, arg3, arg4, arg5); |
| 2198 } |
| 2199 // arg0 is a hidden argument pointing to the return location, so don't |
| 2200 // pass it to the target function. |
| 2201 ObjectTriple result = target(arg1, arg2, arg3, arg4, arg5); |
| 2202 if (::v8::internal::FLAG_trace_sim) { |
| 2203 PrintF("Returned { %p, %p, %p }\n", result.x, result.y, result.z); |
| 2204 } |
| 2205 // Return is passed back in address pointed to by hidden first argument. |
| 2206 ObjectTriple* sim_result = reinterpret_cast<ObjectTriple*>(arg0); |
| 2207 *sim_result = result; |
| 2208 set_register(v0, arg0); |
2184 } else { | 2209 } else { |
2185 SimulatorRuntimeCall target = | 2210 SimulatorRuntimeCall target = |
2186 reinterpret_cast<SimulatorRuntimeCall>(external); | 2211 reinterpret_cast<SimulatorRuntimeCall>(external); |
2187 if (::v8::internal::FLAG_trace_sim) { | 2212 if (::v8::internal::FLAG_trace_sim) { |
2188 PrintF( | 2213 PrintF( |
2189 "Call to host function at %p " | 2214 "Call to host function at %p " |
2190 "args %08x, %08x, %08x, %08x, %08x, %08x\n", | 2215 "args %08x, %08x, %08x, %08x, %08x, %08x\n", |
2191 FUNCTION_ADDR(target), | 2216 FUNCTION_ADDR(target), |
2192 arg0, | 2217 arg0, |
2193 arg1, | 2218 arg1, |
(...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4588 | 4613 |
4589 | 4614 |
4590 #undef UNSUPPORTED | 4615 #undef UNSUPPORTED |
4591 | 4616 |
4592 } // namespace internal | 4617 } // namespace internal |
4593 } // namespace v8 | 4618 } // namespace v8 |
4594 | 4619 |
4595 #endif // USE_SIMULATOR | 4620 #endif // USE_SIMULATOR |
4596 | 4621 |
4597 #endif // V8_TARGET_ARCH_MIPS | 4622 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |