| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_PPC | 9 #if V8_TARGET_ARCH_PPC |
| 10 | 10 |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 #if V8_TARGET_BIG_ENDIAN | 1181 #if V8_TARGET_BIG_ENDIAN |
| 1182 *x = static_cast<int32_t>(*pair >> 32); | 1182 *x = static_cast<int32_t>(*pair >> 32); |
| 1183 *y = static_cast<int32_t>(*pair); | 1183 *y = static_cast<int32_t>(*pair); |
| 1184 #else | 1184 #else |
| 1185 *x = static_cast<int32_t>(*pair); | 1185 *x = static_cast<int32_t>(*pair); |
| 1186 *y = static_cast<int32_t>(*pair >> 32); | 1186 *y = static_cast<int32_t>(*pair >> 32); |
| 1187 #endif | 1187 #endif |
| 1188 } | 1188 } |
| 1189 #endif | 1189 #endif |
| 1190 | 1190 |
| 1191 // Calls into the V8 runtime are based on this very simple interface. | 1191 // Calls into the V8 runtime. |
| 1192 // Note: To be able to return two values from some calls the code in | 1192 typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, |
| 1193 // runtime.cc uses the ObjectPair which is essentially two pointer | 1193 intptr_t arg2, intptr_t arg3, |
| 1194 // values stuffed into a structure. With the code below we assume that | 1194 intptr_t arg4, intptr_t arg5); |
| 1195 // all runtime calls return this pair. If they don't, the r4 result | 1195 typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, |
| 1196 // register contains a bogus value, which is fine because it is | 1196 intptr_t arg2, intptr_t arg3, |
| 1197 // caller-saved. | 1197 intptr_t arg4, intptr_t arg5); |
| 1198 typedef ObjectPair (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, | |
| 1199 intptr_t arg2, intptr_t arg3, | |
| 1200 intptr_t arg4, intptr_t arg5); | |
| 1201 | |
| 1202 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, | 1198 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, |
| 1203 intptr_t arg2, intptr_t arg3, | 1199 intptr_t arg2, intptr_t arg3, |
| 1204 intptr_t arg4, | 1200 intptr_t arg4, |
| 1205 intptr_t arg5); | 1201 intptr_t arg5); |
| 1206 | 1202 |
| 1207 // These prototypes handle the four types of FP calls. | 1203 // These prototypes handle the four types of FP calls. |
| 1208 typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1204 typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
| 1209 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1205 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
| 1210 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1206 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
| 1211 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, intptr_t arg0); | 1207 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, intptr_t arg0); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1229 // Check if stack is aligned. Error if not aligned is reported below to | 1225 // Check if stack is aligned. Error if not aligned is reported below to |
| 1230 // include information on the function called. | 1226 // include information on the function called. |
| 1231 bool stack_aligned = | 1227 bool stack_aligned = |
| 1232 (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == | 1228 (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == |
| 1233 0; | 1229 0; |
| 1234 Redirection* redirection = Redirection::FromSwiInstruction(instr); | 1230 Redirection* redirection = Redirection::FromSwiInstruction(instr); |
| 1235 const int kArgCount = 6; | 1231 const int kArgCount = 6; |
| 1236 int arg0_regnum = 3; | 1232 int arg0_regnum = 3; |
| 1237 intptr_t result_buffer = 0; | 1233 intptr_t result_buffer = 0; |
| 1238 bool uses_result_buffer = | 1234 bool uses_result_buffer = |
| 1239 redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE; | 1235 redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || |
| 1236 (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && |
| 1237 !ABI_RETURNS_OBJECT_PAIRS_IN_REGS); |
| 1240 if (uses_result_buffer) { | 1238 if (uses_result_buffer) { |
| 1241 result_buffer = get_register(r3); | 1239 result_buffer = get_register(r3); |
| 1242 arg0_regnum++; | 1240 arg0_regnum++; |
| 1243 } | 1241 } |
| 1244 intptr_t arg[kArgCount]; | 1242 intptr_t arg[kArgCount]; |
| 1245 for (int i = 0; i < kArgCount; i++) { | 1243 for (int i = 0; i < kArgCount; i++) { |
| 1246 arg[i] = get_register(arg0_regnum + i); | 1244 arg[i] = get_register(arg0_regnum + i); |
| 1247 } | 1245 } |
| 1248 bool fp_call = | 1246 bool fp_call = |
| 1249 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || | 1247 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR | 1434 PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR |
| 1437 "}\n", | 1435 "}\n", |
| 1438 reinterpret_cast<intptr_t>(result.x), | 1436 reinterpret_cast<intptr_t>(result.x), |
| 1439 reinterpret_cast<intptr_t>(result.y), | 1437 reinterpret_cast<intptr_t>(result.y), |
| 1440 reinterpret_cast<intptr_t>(result.z)); | 1438 reinterpret_cast<intptr_t>(result.z)); |
| 1441 } | 1439 } |
| 1442 memcpy(reinterpret_cast<void*>(result_buffer), &result, | 1440 memcpy(reinterpret_cast<void*>(result_buffer), &result, |
| 1443 sizeof(ObjectTriple)); | 1441 sizeof(ObjectTriple)); |
| 1444 set_register(r3, result_buffer); | 1442 set_register(r3, result_buffer); |
| 1445 } else { | 1443 } else { |
| 1446 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); | 1444 if (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR) { |
| 1447 SimulatorRuntimeCall target = | 1445 SimulatorRuntimePairCall target = |
| 1448 reinterpret_cast<SimulatorRuntimeCall>(external); | 1446 reinterpret_cast<SimulatorRuntimePairCall>(external); |
| 1449 ObjectPair result = | 1447 ObjectPair result = |
| 1450 target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); | 1448 target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); |
| 1451 intptr_t x; | 1449 intptr_t x; |
| 1452 intptr_t y; | 1450 intptr_t y; |
| 1453 decodeObjectPair(&result, &x, &y); | 1451 decodeObjectPair(&result, &x, &y); |
| 1454 if (::v8::internal::FLAG_trace_sim) { | 1452 if (::v8::internal::FLAG_trace_sim) { |
| 1455 PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", x, y); | 1453 PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", x, y); |
| 1454 } |
| 1455 if (ABI_RETURNS_OBJECT_PAIRS_IN_REGS) { |
| 1456 set_register(r3, x); |
| 1457 set_register(r4, y); |
| 1458 } else { |
| 1459 memcpy(reinterpret_cast<void*>(result_buffer), &result, |
| 1460 sizeof(ObjectPair)); |
| 1461 set_register(r3, result_buffer); |
| 1462 } |
| 1463 } else { |
| 1464 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); |
| 1465 SimulatorRuntimeCall target = |
| 1466 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 1467 intptr_t result = |
| 1468 target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); |
| 1469 if (::v8::internal::FLAG_trace_sim) { |
| 1470 PrintF("Returned %08" V8PRIxPTR "\n", result); |
| 1471 } |
| 1472 set_register(r3, result); |
| 1456 } | 1473 } |
| 1457 set_register(r3, x); | |
| 1458 set_register(r4, y); | |
| 1459 } | 1474 } |
| 1460 } | 1475 } |
| 1461 set_pc(saved_lr); | 1476 set_pc(saved_lr); |
| 1462 break; | 1477 break; |
| 1463 } | 1478 } |
| 1464 case kBreakpoint: { | 1479 case kBreakpoint: { |
| 1465 PPCDebugger dbg(this); | 1480 PPCDebugger dbg(this); |
| 1466 dbg.Debug(); | 1481 dbg.Debug(); |
| 1467 break; | 1482 break; |
| 1468 } | 1483 } |
| (...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 4069 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
| 4055 uintptr_t address = *stack_slot; | 4070 uintptr_t address = *stack_slot; |
| 4056 set_register(sp, current_sp + sizeof(uintptr_t)); | 4071 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 4057 return address; | 4072 return address; |
| 4058 } | 4073 } |
| 4059 } // namespace internal | 4074 } // namespace internal |
| 4060 } // namespace v8 | 4075 } // namespace v8 |
| 4061 | 4076 |
| 4062 #endif // USE_SIMULATOR | 4077 #endif // USE_SIMULATOR |
| 4063 #endif // V8_TARGET_ARCH_PPC | 4078 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |