| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 // Calls into the V8 runtime are based on this very simple interface. | 1528 // Calls into the V8 runtime are based on this very simple interface. |
| 1529 // Note: To be able to return two values from some calls the code in runtime.cc | 1529 // Note: To be able to return two values from some calls the code in runtime.cc |
| 1530 // uses the ObjectPair which is essentially two 32-bit values stuffed into a | 1530 // uses the ObjectPair which is essentially two 32-bit values stuffed into a |
| 1531 // 64-bit value. With the code below we assume that all runtime calls return | 1531 // 64-bit value. With the code below we assume that all runtime calls return |
| 1532 // 64 bits of result. If they don't, the r1 result register contains a bogus | 1532 // 64 bits of result. If they don't, the r1 result register contains a bogus |
| 1533 // value, which is fine because it is caller-saved. | 1533 // value, which is fine because it is caller-saved. |
| 1534 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, | 1534 typedef int64_t (*SimulatorRuntimeCall)(int32_t arg0, |
| 1535 int32_t arg1, | 1535 int32_t arg1, |
| 1536 int32_t arg2, | 1536 int32_t arg2, |
| 1537 int32_t arg3, | 1537 int32_t arg3, |
| 1538 int32_t arg4); | 1538 int32_t arg4, |
| 1539 int32_t arg5); |
| 1539 typedef double (*SimulatorRuntimeFPCall)(int32_t arg0, | 1540 typedef double (*SimulatorRuntimeFPCall)(int32_t arg0, |
| 1540 int32_t arg1, | 1541 int32_t arg1, |
| 1541 int32_t arg2, | 1542 int32_t arg2, |
| 1542 int32_t arg3); | 1543 int32_t arg3); |
| 1543 | 1544 |
| 1544 // This signature supports direct call in to API function native callback | 1545 // This signature supports direct call in to API function native callback |
| 1545 // (refer to InvocationCallback in v8.h). | 1546 // (refer to InvocationCallback in v8.h). |
| 1546 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1547 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
| 1547 | 1548 |
| 1548 // This signature supports direct call to accessor getter callback. | 1549 // This signature supports direct call to accessor getter callback. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1559 // include information on the function called. | 1560 // include information on the function called. |
| 1560 bool stack_aligned = | 1561 bool stack_aligned = |
| 1561 (get_register(sp) | 1562 (get_register(sp) |
| 1562 & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; | 1563 & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; |
| 1563 Redirection* redirection = Redirection::FromSwiInstruction(instr); | 1564 Redirection* redirection = Redirection::FromSwiInstruction(instr); |
| 1564 int32_t arg0 = get_register(r0); | 1565 int32_t arg0 = get_register(r0); |
| 1565 int32_t arg1 = get_register(r1); | 1566 int32_t arg1 = get_register(r1); |
| 1566 int32_t arg2 = get_register(r2); | 1567 int32_t arg2 = get_register(r2); |
| 1567 int32_t arg3 = get_register(r3); | 1568 int32_t arg3 = get_register(r3); |
| 1568 int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp)); | 1569 int32_t* stack_pointer = reinterpret_cast<int32_t*>(get_register(sp)); |
| 1569 int32_t arg4 = *stack_pointer; | 1570 int32_t arg4 = stack_pointer[0]; |
| 1571 int32_t arg5 = stack_pointer[1]; |
| 1570 // This is dodgy but it works because the C entry stubs are never moved. | 1572 // This is dodgy but it works because the C entry stubs are never moved. |
| 1571 // See comment in codegen-arm.cc and bug 1242173. | 1573 // See comment in codegen-arm.cc and bug 1242173. |
| 1572 int32_t saved_lr = get_register(lr); | 1574 int32_t saved_lr = get_register(lr); |
| 1573 intptr_t external = | 1575 intptr_t external = |
| 1574 reinterpret_cast<intptr_t>(redirection->external_function()); | 1576 reinterpret_cast<intptr_t>(redirection->external_function()); |
| 1575 if (redirection->type() == ExternalReference::FP_RETURN_CALL) { | 1577 if (redirection->type() == ExternalReference::FP_RETURN_CALL) { |
| 1576 SimulatorRuntimeFPCall target = | 1578 SimulatorRuntimeFPCall target = |
| 1577 reinterpret_cast<SimulatorRuntimeFPCall>(external); | 1579 reinterpret_cast<SimulatorRuntimeFPCall>(external); |
| 1578 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1580 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| 1579 double x, y; | 1581 double x, y; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | 1624 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); |
| 1623 } | 1625 } |
| 1624 set_register(r0, (int32_t) *result); | 1626 set_register(r0, (int32_t) *result); |
| 1625 } else { | 1627 } else { |
| 1626 // builtin call. | 1628 // builtin call. |
| 1627 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); | 1629 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); |
| 1628 SimulatorRuntimeCall target = | 1630 SimulatorRuntimeCall target = |
| 1629 reinterpret_cast<SimulatorRuntimeCall>(external); | 1631 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 1630 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1632 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| 1631 PrintF( | 1633 PrintF( |
| 1632 "Call to host function at %p args %08x, %08x, %08x, %08x, %0xc", | 1634 "Call to host function at %p" |
| 1635 "args %08x, %08x, %08x, %08x, %08x, %08x", |
| 1633 FUNCTION_ADDR(target), | 1636 FUNCTION_ADDR(target), |
| 1634 arg0, | 1637 arg0, |
| 1635 arg1, | 1638 arg1, |
| 1636 arg2, | 1639 arg2, |
| 1637 arg3, | 1640 arg3, |
| 1638 arg4); | 1641 arg4, |
| 1642 arg5); |
| 1639 if (!stack_aligned) { | 1643 if (!stack_aligned) { |
| 1640 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1644 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1641 } | 1645 } |
| 1642 PrintF("\n"); | 1646 PrintF("\n"); |
| 1643 } | 1647 } |
| 1644 CHECK(stack_aligned); | 1648 CHECK(stack_aligned); |
| 1645 int64_t result = target(arg0, arg1, arg2, arg3, arg4); | 1649 int64_t result = target(arg0, arg1, arg2, arg3, arg4, arg5); |
| 1646 int32_t lo_res = static_cast<int32_t>(result); | 1650 int32_t lo_res = static_cast<int32_t>(result); |
| 1647 int32_t hi_res = static_cast<int32_t>(result >> 32); | 1651 int32_t hi_res = static_cast<int32_t>(result >> 32); |
| 1648 if (::v8::internal::FLAG_trace_sim) { | 1652 if (::v8::internal::FLAG_trace_sim) { |
| 1649 PrintF("Returned %08x\n", lo_res); | 1653 PrintF("Returned %08x\n", lo_res); |
| 1650 } | 1654 } |
| 1651 set_register(r0, lo_res); | 1655 set_register(r0, lo_res); |
| 1652 set_register(r1, hi_res); | 1656 set_register(r1, hi_res); |
| 1653 } | 1657 } |
| 1654 set_register(lr, saved_lr); | 1658 set_register(lr, saved_lr); |
| 1655 set_pc(get_register(lr)); | 1659 set_pc(get_register(lr)); |
| (...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 uintptr_t address = *stack_slot; | 3162 uintptr_t address = *stack_slot; |
| 3159 set_register(sp, current_sp + sizeof(uintptr_t)); | 3163 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 3160 return address; | 3164 return address; |
| 3161 } | 3165 } |
| 3162 | 3166 |
| 3163 } } // namespace v8::internal | 3167 } } // namespace v8::internal |
| 3164 | 3168 |
| 3165 #endif // USE_SIMULATOR | 3169 #endif // USE_SIMULATOR |
| 3166 | 3170 |
| 3167 #endif // V8_TARGET_ARCH_ARM | 3171 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |