Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/mips64/simulator-mips64.cc

Issue 2825393003: [sim] Consistent support for C calls with up to 9 args (Closed)
Patch Set: enum -> const variable Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 } 1977 }
1978 1978
1979 1979
1980 // Calls into the V8 runtime are based on this very simple interface. 1980 // Calls into the V8 runtime are based on this very simple interface.
1981 // Note: To be able to return two values from some calls the code in runtime.cc 1981 // Note: To be able to return two values from some calls the code in runtime.cc
1982 // uses the ObjectPair which is essentially two 32-bit values stuffed into a 1982 // uses the ObjectPair which is essentially two 32-bit values stuffed into a
1983 // 64-bit value. With the code below we assume that all runtime calls return 1983 // 64-bit value. With the code below we assume that all runtime calls return
1984 // 64 bits of result. If they don't, the v1 result register contains a bogus 1984 // 64 bits of result. If they don't, the v1 result register contains a bogus
1985 // value, which is fine because it is caller-saved. 1985 // value, which is fine because it is caller-saved.
1986 1986
1987 typedef ObjectPair (*SimulatorRuntimeCall)(int64_t arg0, 1987 typedef ObjectPair (*SimulatorRuntimeCall)(int64_t arg0, int64_t arg1,
1988 int64_t arg1, 1988 int64_t arg2, int64_t arg3,
1989 int64_t arg2, 1989 int64_t arg4, int64_t arg5,
1990 int64_t arg3, 1990 int64_t arg6, int64_t arg7,
1991 int64_t arg4, 1991 int64_t arg8);
1992 int64_t arg5);
1993 1992
1994 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(int64_t arg0, int64_t arg1, 1993 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(int64_t arg0, int64_t arg1,
1995 int64_t arg2, int64_t arg3, 1994 int64_t arg2, int64_t arg3,
1996 int64_t arg4); 1995 int64_t arg4);
1997 1996
1998 // These prototypes handle the four types of FP calls. 1997 // These prototypes handle the four types of FP calls.
1999 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); 1998 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1);
2000 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); 1999 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1);
2001 typedef double (*SimulatorRuntimeFPCall)(double darg0); 2000 typedef double (*SimulatorRuntimeFPCall)(double darg0);
2002 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); 2001 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0);
(...skipping 12 matching lines...) Expand all
2015 // C-based V8 runtime. They are also used for debugging with simulator. 2014 // C-based V8 runtime. They are also used for debugging with simulator.
2016 void Simulator::SoftwareInterrupt() { 2015 void Simulator::SoftwareInterrupt() {
2017 // There are several instructions that could get us here, 2016 // There are several instructions that could get us here,
2018 // the break_ instruction, or several variants of traps. All 2017 // the break_ instruction, or several variants of traps. All
2019 // Are "SPECIAL" class opcode, and are distinuished by function. 2018 // Are "SPECIAL" class opcode, and are distinuished by function.
2020 int32_t func = instr_.FunctionFieldRaw(); 2019 int32_t func = instr_.FunctionFieldRaw();
2021 uint32_t code = (func == BREAK) ? instr_.Bits(25, 6) : -1; 2020 uint32_t code = (func == BREAK) ? instr_.Bits(25, 6) : -1;
2022 // We first check if we met a call_rt_redirected. 2021 // We first check if we met a call_rt_redirected.
2023 if (instr_.InstructionBits() == rtCallRedirInstr) { 2022 if (instr_.InstructionBits() == rtCallRedirInstr) {
2024 Redirection* redirection = Redirection::FromSwiInstruction(instr_.instr()); 2023 Redirection* redirection = Redirection::FromSwiInstruction(instr_.instr());
2024
2025 int64_t* stack_pointer = reinterpret_cast<int64_t*>(get_register(sp));
2026
2025 int64_t arg0 = get_register(a0); 2027 int64_t arg0 = get_register(a0);
2026 int64_t arg1 = get_register(a1); 2028 int64_t arg1 = get_register(a1);
2027 int64_t arg2 = get_register(a2); 2029 int64_t arg2 = get_register(a2);
2028 int64_t arg3 = get_register(a3); 2030 int64_t arg3 = get_register(a3);
2029 int64_t arg4, arg5; 2031 int64_t arg4 = get_register(a4);
2030 2032 int64_t arg5 = get_register(a5);
2031 arg4 = get_register(a4); // Abi n64 register a4. 2033 int64_t arg6 = get_register(a6);
2032 arg5 = get_register(a5); // Abi n64 register a5. 2034 int64_t arg7 = get_register(a7);
2035 int64_t arg8 = stack_pointer[0];
2036 STATIC_ASSERT(kMaxCParameters == 9);
2033 2037
2034 bool fp_call = 2038 bool fp_call =
2035 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || 2039 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) ||
2036 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || 2040 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) ||
2037 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || 2041 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) ||
2038 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); 2042 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL);
2039 2043
2040 if (!IsMipsSoftFloatABI) { 2044 if (!IsMipsSoftFloatABI) {
2041 // With the hard floating point calling convention, double 2045 // With the hard floating point calling convention, double
2042 // arguments are passed in FPU registers. Fetch the arguments 2046 // arguments are passed in FPU registers. Fetch the arguments
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 set_register(v0, arg0); 2221 set_register(v0, arg0);
2218 } else { 2222 } else {
2219 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL || 2223 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL ||
2220 redirection->type() == ExternalReference::BUILTIN_CALL_PAIR); 2224 redirection->type() == ExternalReference::BUILTIN_CALL_PAIR);
2221 SimulatorRuntimeCall target = 2225 SimulatorRuntimeCall target =
2222 reinterpret_cast<SimulatorRuntimeCall>(external); 2226 reinterpret_cast<SimulatorRuntimeCall>(external);
2223 if (::v8::internal::FLAG_trace_sim) { 2227 if (::v8::internal::FLAG_trace_sim) {
2224 PrintF( 2228 PrintF(
2225 "Call to host function at %p " 2229 "Call to host function at %p "
2226 "args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 2230 "args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64
2227 " , %08" PRIx64 " , %08" PRIx64 " \n", 2231 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64
2232 " , %08" PRIx64 " \n",
2228 static_cast<void*>(FUNCTION_ADDR(target)), arg0, arg1, arg2, arg3, 2233 static_cast<void*>(FUNCTION_ADDR(target)), arg0, arg1, arg2, arg3,
2229 arg4, arg5); 2234 arg4, arg5, arg6, arg7, arg8);
2230 } 2235 }
2231 // int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5); 2236 ObjectPair result =
2232 // set_register(v0, static_cast<int32_t>(result)); 2237 target(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
2233 // set_register(v1, static_cast<int32_t>(result >> 32));
2234 ObjectPair result = target(arg0, arg1, arg2, arg3, arg4, arg5);
2235 set_register(v0, (int64_t)(result.x)); 2238 set_register(v0, (int64_t)(result.x));
2236 set_register(v1, (int64_t)(result.y)); 2239 set_register(v1, (int64_t)(result.y));
2237 } 2240 }
2238 if (::v8::internal::FLAG_trace_sim) { 2241 if (::v8::internal::FLAG_trace_sim) {
2239 PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(v1), 2242 PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(v1),
2240 get_register(v0)); 2243 get_register(v0));
2241 } 2244 }
2242 set_register(ra, saved_ra); 2245 set_register(ra, saved_ra);
2243 set_pc(get_register(ra)); 2246 set_pc(get_register(ra));
2244 2247
(...skipping 2898 matching lines...) Expand 10 before | Expand all | Expand 10 after
5143 } 5146 }
5144 5147
5145 5148
5146 #undef UNSUPPORTED 5149 #undef UNSUPPORTED
5147 } // namespace internal 5150 } // namespace internal
5148 } // namespace v8 5151 } // namespace v8
5149 5152
5150 #endif // USE_SIMULATOR 5153 #endif // USE_SIMULATOR
5151 5154
5152 #endif // V8_TARGET_ARCH_MIPS64 5155 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698