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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 #else | 1285 #else |
1286 *x = static_cast<int32_t>(*pair); | 1286 *x = static_cast<int32_t>(*pair); |
1287 *y = static_cast<int32_t>(*pair >> 32); | 1287 *y = static_cast<int32_t>(*pair >> 32); |
1288 #endif | 1288 #endif |
1289 } | 1289 } |
1290 #endif | 1290 #endif |
1291 | 1291 |
1292 // Calls into the V8 runtime. | 1292 // Calls into the V8 runtime. |
1293 typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, | 1293 typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, |
1294 intptr_t arg2, intptr_t arg3, | 1294 intptr_t arg2, intptr_t arg3, |
1295 intptr_t arg4, intptr_t arg5); | 1295 intptr_t arg4, intptr_t arg5, |
| 1296 intptr_t arg6, intptr_t arg7, |
| 1297 intptr_t arg8); |
1296 typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, | 1298 typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, |
1297 intptr_t arg2, intptr_t arg3, | 1299 intptr_t arg2, intptr_t arg3, |
1298 intptr_t arg4, intptr_t arg5); | 1300 intptr_t arg4, intptr_t arg5); |
1299 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, | 1301 typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, |
1300 intptr_t arg2, intptr_t arg3, | 1302 intptr_t arg2, intptr_t arg3, |
1301 intptr_t arg4, | 1303 intptr_t arg4, |
1302 intptr_t arg5); | 1304 intptr_t arg5); |
1303 | 1305 |
1304 // These prototypes handle the four types of FP calls. | 1306 // These prototypes handle the four types of FP calls. |
1305 typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1307 typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
(...skipping 16 matching lines...) Expand all Loading... |
1322 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1324 void Simulator::SoftwareInterrupt(Instruction* instr) { |
1323 int svc = instr->SvcValue(); | 1325 int svc = instr->SvcValue(); |
1324 switch (svc) { | 1326 switch (svc) { |
1325 case kCallRtRedirected: { | 1327 case kCallRtRedirected: { |
1326 // Check if stack is aligned. Error if not aligned is reported below to | 1328 // Check if stack is aligned. Error if not aligned is reported below to |
1327 // include information on the function called. | 1329 // include information on the function called. |
1328 bool stack_aligned = | 1330 bool stack_aligned = |
1329 (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == | 1331 (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == |
1330 0; | 1332 0; |
1331 Redirection* redirection = Redirection::FromSwiInstruction(instr); | 1333 Redirection* redirection = Redirection::FromSwiInstruction(instr); |
1332 const int kArgCount = 6; | 1334 const int kArgCount = 9; |
| 1335 const int kRegisterArgCount = 8; |
1333 int arg0_regnum = 3; | 1336 int arg0_regnum = 3; |
1334 intptr_t result_buffer = 0; | 1337 intptr_t result_buffer = 0; |
1335 bool uses_result_buffer = | 1338 bool uses_result_buffer = |
1336 redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || | 1339 redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || |
1337 (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && | 1340 (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && |
1338 !ABI_RETURNS_OBJECT_PAIRS_IN_REGS); | 1341 !ABI_RETURNS_OBJECT_PAIRS_IN_REGS); |
1339 if (uses_result_buffer) { | 1342 if (uses_result_buffer) { |
1340 result_buffer = get_register(r3); | 1343 result_buffer = get_register(r3); |
1341 arg0_regnum++; | 1344 arg0_regnum++; |
1342 } | 1345 } |
1343 intptr_t arg[kArgCount]; | 1346 intptr_t arg[kArgCount]; |
1344 for (int i = 0; i < kArgCount; i++) { | 1347 // First eight arguments in registers r3-r10. |
| 1348 for (int i = 0; i < kRegisterArgCount; i++) { |
1345 arg[i] = get_register(arg0_regnum + i); | 1349 arg[i] = get_register(arg0_regnum + i); |
1346 } | 1350 } |
| 1351 intptr_t* stack_pointer = reinterpret_cast<intptr_t*>(get_register(sp)); |
| 1352 // Remaining argument on stack |
| 1353 arg[kRegisterArgCount] = stack_pointer[kStackFrameExtraParamSlot]; |
| 1354 STATIC_ASSERT(kArgCount == kRegisterArgCount + 1); |
| 1355 STATIC_ASSERT(kMaxCParameters == 9); |
1347 bool fp_call = | 1356 bool fp_call = |
1348 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || | 1357 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || |
1349 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || | 1358 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || |
1350 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || | 1359 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || |
1351 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); | 1360 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); |
1352 // This is dodgy but it works because the C entry stubs are never moved. | 1361 // This is dodgy but it works because the C entry stubs are never moved. |
1353 // See comment in codegen-arm.cc and bug 1242173. | 1362 // See comment in codegen-arm.cc and bug 1242173. |
1354 intptr_t saved_lr = special_reg_lr_; | 1363 intptr_t saved_lr = special_reg_lr_; |
1355 intptr_t external = | 1364 intptr_t external = |
1356 reinterpret_cast<intptr_t>(redirection->external_function()); | 1365 reinterpret_cast<intptr_t>(redirection->external_function()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 } | 1521 } |
1513 target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); | 1522 target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); |
1514 } else { | 1523 } else { |
1515 // builtin call. | 1524 // builtin call. |
1516 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1525 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1517 SimulatorRuntimeCall target = | 1526 SimulatorRuntimeCall target = |
1518 reinterpret_cast<SimulatorRuntimeCall>(external); | 1527 reinterpret_cast<SimulatorRuntimeCall>(external); |
1519 PrintF( | 1528 PrintF( |
1520 "Call to host function at %p,\n" | 1529 "Call to host function at %p,\n" |
1521 "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR | 1530 "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR |
| 1531 ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR |
1522 ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, | 1532 ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, |
1523 static_cast<void*>(FUNCTION_ADDR(target)), arg[0], arg[1], | 1533 static_cast<void*>(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2], |
1524 arg[2], arg[3], arg[4], arg[5]); | 1534 arg[3], arg[4], arg[5], arg[6], arg[7], arg[8]); |
1525 if (!stack_aligned) { | 1535 if (!stack_aligned) { |
1526 PrintF(" with unaligned stack %08" V8PRIxPTR "\n", | 1536 PrintF(" with unaligned stack %08" V8PRIxPTR "\n", |
1527 get_register(sp)); | 1537 get_register(sp)); |
1528 } | 1538 } |
1529 PrintF("\n"); | 1539 PrintF("\n"); |
1530 } | 1540 } |
1531 CHECK(stack_aligned); | 1541 CHECK(stack_aligned); |
1532 if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { | 1542 if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { |
1533 SimulatorRuntimeTripleCall target = | 1543 SimulatorRuntimeTripleCall target = |
1534 reinterpret_cast<SimulatorRuntimeTripleCall>(external); | 1544 reinterpret_cast<SimulatorRuntimeTripleCall>(external); |
(...skipping 26 matching lines...) Expand all Loading... |
1561 set_register(r4, y); | 1571 set_register(r4, y); |
1562 } else { | 1572 } else { |
1563 memcpy(reinterpret_cast<void*>(result_buffer), &result, | 1573 memcpy(reinterpret_cast<void*>(result_buffer), &result, |
1564 sizeof(ObjectPair)); | 1574 sizeof(ObjectPair)); |
1565 set_register(r3, result_buffer); | 1575 set_register(r3, result_buffer); |
1566 } | 1576 } |
1567 } else { | 1577 } else { |
1568 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); | 1578 DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); |
1569 SimulatorRuntimeCall target = | 1579 SimulatorRuntimeCall target = |
1570 reinterpret_cast<SimulatorRuntimeCall>(external); | 1580 reinterpret_cast<SimulatorRuntimeCall>(external); |
1571 intptr_t result = | 1581 intptr_t result = target(arg[0], arg[1], arg[2], arg[3], arg[4], |
1572 target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); | 1582 arg[5], arg[6], arg[7], arg[8]); |
1573 if (::v8::internal::FLAG_trace_sim) { | 1583 if (::v8::internal::FLAG_trace_sim) { |
1574 PrintF("Returned %08" V8PRIxPTR "\n", result); | 1584 PrintF("Returned %08" V8PRIxPTR "\n", result); |
1575 } | 1585 } |
1576 set_register(r3, result); | 1586 set_register(r3, result); |
1577 } | 1587 } |
1578 } | 1588 } |
1579 } | 1589 } |
1580 set_pc(saved_lr); | 1590 set_pc(saved_lr); |
1581 break; | 1591 break; |
1582 } | 1592 } |
(...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4420 } | 4430 } |
4421 processor->prev_ = nullptr; | 4431 processor->prev_ = nullptr; |
4422 processor->next_ = nullptr; | 4432 processor->next_ = nullptr; |
4423 } | 4433 } |
4424 | 4434 |
4425 } // namespace internal | 4435 } // namespace internal |
4426 } // namespace v8 | 4436 } // namespace v8 |
4427 | 4437 |
4428 #endif // USE_SIMULATOR | 4438 #endif // USE_SIMULATOR |
4429 #endif // V8_TARGET_ARCH_PPC | 4439 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |