OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 int32_t arg5); | 1380 int32_t arg5); |
1381 | 1381 |
1382 // These prototypes handle the four types of FP calls. | 1382 // These prototypes handle the four types of FP calls. |
1383 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1383 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
1384 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1384 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
1385 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1385 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
1386 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1386 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
1387 | 1387 |
1388 // This signature supports direct call in to API function native callback | 1388 // This signature supports direct call in to API function native callback |
1389 // (refer to InvocationCallback in v8.h). | 1389 // (refer to InvocationCallback in v8.h). |
| 1390 // NOTE: the O32 abi requires a0 to hold a special pointer when returning a |
| 1391 // struct from the function (which is currently the case). This means we pass |
| 1392 // the first argument in a1 instead of a0. |
1390 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1393 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
| 1394 // Here, we pass the first argument in a0, because this function |
| 1395 // does not return a struct. |
1391 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); | 1396 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); |
1392 | 1397 |
1393 // This signature supports direct call to accessor getter callback. | 1398 // This signature supports direct call to accessor getter callback. |
| 1399 // See comment at SimulatorRuntimeDirectApiCall. |
1394 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, | 1400 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, |
1395 int32_t arg1); | 1401 int32_t arg1); |
| 1402 // See comment at SimulatorRuntimeDirectApiCallNew. |
1396 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, | 1403 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, |
1397 int32_t arg1); | 1404 int32_t arg1); |
1398 | 1405 |
1399 // Software interrupt instructions are used by the simulator to call into the | 1406 // Software interrupt instructions are used by the simulator to call into the |
1400 // C-based V8 runtime. They are also used for debugging with simulator. | 1407 // C-based V8 runtime. They are also used for debugging with simulator. |
1401 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1408 void Simulator::SoftwareInterrupt(Instruction* instr) { |
1402 // There are several instructions that could get us here, | 1409 // There are several instructions that could get us here, |
1403 // the break_ instruction, or several variants of traps. All | 1410 // the break_ instruction, or several variants of traps. All |
1404 // Are "SPECIAL" class opcode, and are distinuished by function. | 1411 // Are "SPECIAL" class opcode, and are distinuished by function. |
1405 int32_t func = instr->FunctionFieldRaw(); | 1412 int32_t func = instr->FunctionFieldRaw(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 PrintF("Returned %f\n", dresult); | 1542 PrintF("Returned %f\n", dresult); |
1536 break; | 1543 break; |
1537 default: | 1544 default: |
1538 UNREACHABLE(); | 1545 UNREACHABLE(); |
1539 break; | 1546 break; |
1540 } | 1547 } |
1541 } | 1548 } |
1542 } else if ( | 1549 } else if ( |
1543 redirection->type() == ExternalReference::DIRECT_API_CALL || | 1550 redirection->type() == ExternalReference::DIRECT_API_CALL || |
1544 redirection->type() == ExternalReference::DIRECT_API_CALL_NEW) { | 1551 redirection->type() == ExternalReference::DIRECT_API_CALL_NEW) { |
1545 // See DirectCEntryStub::GenerateCall for explanation of register usage. | |
1546 if (::v8::internal::FLAG_trace_sim) { | |
1547 PrintF("Call to host function at %p args %08x\n", | |
1548 reinterpret_cast<void*>(external), arg1); | |
1549 } | |
1550 if (redirection->type() == ExternalReference::DIRECT_API_CALL) { | 1552 if (redirection->type() == ExternalReference::DIRECT_API_CALL) { |
| 1553 // See comment at type definition of SimulatorRuntimeDirectApiCall |
| 1554 // for explanation of register usage. |
| 1555 if (::v8::internal::FLAG_trace_sim) { |
| 1556 PrintF("Call to host function at %p args %08x\n", |
| 1557 reinterpret_cast<void*>(external), arg1); |
| 1558 } |
1551 SimulatorRuntimeDirectApiCall target = | 1559 SimulatorRuntimeDirectApiCall target = |
1552 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); | 1560 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); |
1553 v8::Handle<v8::Value> result = target(arg1); | 1561 v8::Handle<v8::Value> result = target(arg1); |
1554 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); | 1562 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); |
1555 set_register(v0, arg0); | 1563 set_register(v0, arg0); |
1556 } else { | 1564 } else { |
| 1565 if (::v8::internal::FLAG_trace_sim) { |
| 1566 PrintF("Call to host function at %p args %08x\n", |
| 1567 reinterpret_cast<void*>(external), arg0); |
| 1568 } |
1557 SimulatorRuntimeDirectApiCallNew target = | 1569 SimulatorRuntimeDirectApiCallNew target = |
1558 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); | 1570 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); |
1559 target(arg1); | 1571 target(arg0); |
1560 } | 1572 } |
1561 } else if ( | 1573 } else if ( |
1562 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || | 1574 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || |
1563 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { | 1575 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { |
1564 // See DirectCEntryStub::GenerateCall for explanation of register usage. | |
1565 if (::v8::internal::FLAG_trace_sim) { | |
1566 PrintF("Call to host function at %p args %08x %08x\n", | |
1567 reinterpret_cast<void*>(external), arg1, arg2); | |
1568 } | |
1569 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { | 1576 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { |
| 1577 // See comment at type definition of SimulatorRuntimeDirectGetterCall |
| 1578 // for explanation of register usage. |
| 1579 if (::v8::internal::FLAG_trace_sim) { |
| 1580 PrintF("Call to host function at %p args %08x %08x\n", |
| 1581 reinterpret_cast<void*>(external), arg1, arg2); |
| 1582 } |
1570 SimulatorRuntimeDirectGetterCall target = | 1583 SimulatorRuntimeDirectGetterCall target = |
1571 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | 1584 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
1572 v8::Handle<v8::Value> result = target(arg1, arg2); | 1585 v8::Handle<v8::Value> result = target(arg1, arg2); |
1573 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); | 1586 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); |
1574 set_register(v0, arg0); | 1587 set_register(v0, arg0); |
1575 } else { | 1588 } else { |
| 1589 if (::v8::internal::FLAG_trace_sim) { |
| 1590 PrintF("Call to host function at %p args %08x %08x\n", |
| 1591 reinterpret_cast<void*>(external), arg0, arg1); |
| 1592 } |
1576 SimulatorRuntimeDirectGetterCallNew target = | 1593 SimulatorRuntimeDirectGetterCallNew target = |
1577 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); | 1594 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); |
1578 target(arg1, arg2); | 1595 target(arg0, arg1); |
1579 } | 1596 } |
1580 } else { | 1597 } else { |
1581 SimulatorRuntimeCall target = | 1598 SimulatorRuntimeCall target = |
1582 reinterpret_cast<SimulatorRuntimeCall>(external); | 1599 reinterpret_cast<SimulatorRuntimeCall>(external); |
1583 if (::v8::internal::FLAG_trace_sim) { | 1600 if (::v8::internal::FLAG_trace_sim) { |
1584 PrintF( | 1601 PrintF( |
1585 "Call to host function at %p " | 1602 "Call to host function at %p " |
1586 "args %08x, %08x, %08x, %08x, %08x, %08x\n", | 1603 "args %08x, %08x, %08x, %08x, %08x, %08x\n", |
1587 FUNCTION_ADDR(target), | 1604 FUNCTION_ADDR(target), |
1588 arg0, | 1605 arg0, |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 } | 2938 } |
2922 | 2939 |
2923 | 2940 |
2924 #undef UNSUPPORTED | 2941 #undef UNSUPPORTED |
2925 | 2942 |
2926 } } // namespace v8::internal | 2943 } } // namespace v8::internal |
2927 | 2944 |
2928 #endif // USE_SIMULATOR | 2945 #endif // USE_SIMULATOR |
2929 | 2946 |
2930 #endif // V8_TARGET_ARCH_MIPS | 2947 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |