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_MIPS64 | 10 #if V8_TARGET_ARCH_MIPS64 |
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/mips64/constants-mips64.h" | 16 #include "src/mips64/constants-mips64.h" |
17 #include "src/mips64/simulator-mips64.h" | 17 #include "src/mips64/simulator-mips64.h" |
18 #include "src/ostreams.h" | 18 #include "src/ostreams.h" |
| 19 #include "src/runtime/runtime-utils.h" |
19 | 20 |
20 // Only build the simulator if not compiling for real MIPS hardware. | 21 // Only build the simulator if not compiling for real MIPS hardware. |
21 #if defined(USE_SIMULATOR) | 22 #if defined(USE_SIMULATOR) |
22 | 23 |
23 namespace v8 { | 24 namespace v8 { |
24 namespace internal { | 25 namespace internal { |
25 | 26 |
26 // Utils functions. | 27 // Utils functions. |
27 bool HaveSameSign(int64_t a, int64_t b) { | 28 bool HaveSameSign(int64_t a, int64_t b) { |
28 return ((a ^ b) >= 0); | 29 return ((a ^ b) >= 0); |
(...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 } | 1958 } |
1958 | 1959 |
1959 | 1960 |
1960 // Calls into the V8 runtime are based on this very simple interface. | 1961 // Calls into the V8 runtime are based on this very simple interface. |
1961 // Note: To be able to return two values from some calls the code in runtime.cc | 1962 // Note: To be able to return two values from some calls the code in runtime.cc |
1962 // uses the ObjectPair which is essentially two 32-bit values stuffed into a | 1963 // uses the ObjectPair which is essentially two 32-bit values stuffed into a |
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 | 1967 |
1967 struct ObjectPair { | |
1968 Object* x; | |
1969 Object* y; | |
1970 }; | |
1971 | |
1972 typedef ObjectPair (*SimulatorRuntimeCall)(int64_t arg0, | 1968 typedef ObjectPair (*SimulatorRuntimeCall)(int64_t arg0, |
1973 int64_t arg1, | 1969 int64_t arg1, |
1974 int64_t arg2, | 1970 int64_t arg2, |
1975 int64_t arg3, | 1971 int64_t arg3, |
1976 int64_t arg4, | 1972 int64_t arg4, |
1977 int64_t arg5); | 1973 int64_t arg5); |
1978 | 1974 |
| 1975 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(int64_t arg0, int64_t arg1, |
| 1976 int64_t arg2, int64_t arg3, |
| 1977 int64_t arg4); |
1979 | 1978 |
1980 // These prototypes handle the four types of FP calls. | 1979 // These prototypes handle the four types of FP calls. |
1981 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1980 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
1982 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1981 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
1983 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1982 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
1984 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1983 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
1985 | 1984 |
1986 // This signature supports direct call in to API function native callback | 1985 // This signature supports direct call in to API function native callback |
1987 // (refer to InvocationCallback in v8.h). | 1986 // (refer to InvocationCallback in v8.h). |
1988 typedef void (*SimulatorRuntimeDirectApiCall)(int64_t arg0); | 1987 typedef void (*SimulatorRuntimeDirectApiCall)(int64_t arg0); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 target(arg0, arg1); | 2167 target(arg0, arg1); |
2169 } else if ( | 2168 } else if ( |
2170 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { | 2169 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { |
2171 if (::v8::internal::FLAG_trace_sim) { | 2170 if (::v8::internal::FLAG_trace_sim) { |
2172 PrintF("Call to host function at %p args %08lx %08lx %08lx\n", | 2171 PrintF("Call to host function at %p args %08lx %08lx %08lx\n", |
2173 reinterpret_cast<void*>(external), arg0, arg1, arg2); | 2172 reinterpret_cast<void*>(external), arg0, arg1, arg2); |
2174 } | 2173 } |
2175 SimulatorRuntimeProfilingGetterCall target = | 2174 SimulatorRuntimeProfilingGetterCall target = |
2176 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); | 2175 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); |
2177 target(arg0, arg1, Redirection::ReverseRedirection(arg2)); | 2176 target(arg0, arg1, Redirection::ReverseRedirection(arg2)); |
| 2177 } else if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { |
| 2178 // builtin call returning ObjectTriple. |
| 2179 SimulatorRuntimeTripleCall target = |
| 2180 reinterpret_cast<SimulatorRuntimeTripleCall>(external); |
| 2181 if (::v8::internal::FLAG_trace_sim) { |
| 2182 PrintF( |
| 2183 "Call to host triple returning runtime function %p " |
| 2184 "args %016" PRIx64 ", %016" PRIx64 ", %016" PRIx64 ", %016" PRIx64 |
| 2185 ", %016" PRIx64 "\n", |
| 2186 FUNCTION_ADDR(target), arg1, arg2, arg3, arg4, arg5); |
| 2187 } |
| 2188 // arg0 is a hidden argument pointing to the return location, so don't |
| 2189 // pass it to the target function. |
| 2190 ObjectTriple result = target(arg1, arg2, arg3, arg4, arg5); |
| 2191 if (::v8::internal::FLAG_trace_sim) { |
| 2192 PrintF("Returned { %p, %p, %p }\n", result.x, result.y, result.z); |
| 2193 } |
| 2194 // Return is passed back in address pointed to by hidden first argument. |
| 2195 ObjectTriple* sim_result = reinterpret_cast<ObjectTriple*>(arg0); |
| 2196 *sim_result = result; |
| 2197 set_register(v0, arg0); |
2178 } else { | 2198 } else { |
2179 SimulatorRuntimeCall target = | 2199 SimulatorRuntimeCall target = |
2180 reinterpret_cast<SimulatorRuntimeCall>(external); | 2200 reinterpret_cast<SimulatorRuntimeCall>(external); |
2181 if (::v8::internal::FLAG_trace_sim) { | 2201 if (::v8::internal::FLAG_trace_sim) { |
2182 PrintF( | 2202 PrintF( |
2183 "Call to host function at %p " | 2203 "Call to host function at %p " |
2184 "args %08lx, %08lx, %08lx, %08lx, %08lx, %08lx\n", | 2204 "args %08lx, %08lx, %08lx, %08lx, %08lx, %08lx\n", |
2185 FUNCTION_ADDR(target), | 2205 FUNCTION_ADDR(target), |
2186 arg0, | 2206 arg0, |
2187 arg1, | 2207 arg1, |
(...skipping 2681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4869 } | 4889 } |
4870 | 4890 |
4871 | 4891 |
4872 #undef UNSUPPORTED | 4892 #undef UNSUPPORTED |
4873 } // namespace internal | 4893 } // namespace internal |
4874 } // namespace v8 | 4894 } // namespace v8 |
4875 | 4895 |
4876 #endif // USE_SIMULATOR | 4896 #endif // USE_SIMULATOR |
4877 | 4897 |
4878 #endif // V8_TARGET_ARCH_MIPS64 | 4898 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |