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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 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 | 1391 // struct from the function (which is currently the case). This means we pass |
1392 // the first argument in a1 instead of a0. | 1392 // the first argument in a1 instead of a0. |
1393 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 | 1394 // Here, we pass the first argument in a0, because this function |
1395 // does not return a struct. | 1395 // does not return a struct. |
1396 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); | 1396 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); |
1397 typedef v8::Handle<v8::Value> (*SimulatorRuntimeProfilingApiCall)( | |
1398 int32_t arg0, int32_t arg1); | |
1399 typedef void (*SimulatorRuntimeProfilingApiCallNew)(int32_t arg0, int32_t arg1); | |
1400 | 1397 |
1401 // This signature supports direct call to accessor getter callback. | 1398 // This signature supports direct call to accessor getter callback. |
1402 // See comment at SimulatorRuntimeDirectApiCall. | 1399 // See comment at SimulatorRuntimeDirectApiCall. |
1403 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, | 1400 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, |
1404 int32_t arg1); | 1401 int32_t arg1); |
1405 // See comment at SimulatorRuntimeDirectApiCallNew. | 1402 // See comment at SimulatorRuntimeDirectApiCallNew. |
1406 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, | 1403 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, |
1407 int32_t arg1); | 1404 int32_t arg1); |
1408 typedef v8::Handle<v8::Value> (*SimulatorRuntimeProfilingGetterCall)( | |
1409 int32_t arg0, int32_t arg1, int32_t arg2); | |
1410 typedef void (*SimulatorRuntimeProfilingGetterCallNew)( | |
1411 int32_t arg0, int32_t arg1, int32_t arg2); | |
1412 | 1405 |
1413 // 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 |
1414 // 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. |
1415 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1408 void Simulator::SoftwareInterrupt(Instruction* instr) { |
1416 // There are several instructions that could get us here, | 1409 // There are several instructions that could get us here, |
1417 // the break_ instruction, or several variants of traps. All | 1410 // the break_ instruction, or several variants of traps. All |
1418 // Are "SPECIAL" class opcode, and are distinuished by function. | 1411 // Are "SPECIAL" class opcode, and are distinuished by function. |
1419 int32_t func = instr->FunctionFieldRaw(); | 1412 int32_t func = instr->FunctionFieldRaw(); |
1420 uint32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; | 1413 uint32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; |
1421 | 1414 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 } else { | 1564 } else { |
1572 if (::v8::internal::FLAG_trace_sim) { | 1565 if (::v8::internal::FLAG_trace_sim) { |
1573 PrintF("Call to host function at %p args %08x\n", | 1566 PrintF("Call to host function at %p args %08x\n", |
1574 reinterpret_cast<void*>(external), arg0); | 1567 reinterpret_cast<void*>(external), arg0); |
1575 } | 1568 } |
1576 SimulatorRuntimeDirectApiCallNew target = | 1569 SimulatorRuntimeDirectApiCallNew target = |
1577 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); | 1570 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); |
1578 target(arg0); | 1571 target(arg0); |
1579 } | 1572 } |
1580 } else if ( | 1573 } else if ( |
1581 redirection->type() == ExternalReference::PROFILING_API_CALL || | |
1582 redirection->type() == ExternalReference::PROFILING_API_CALL_NEW) { | |
1583 if (redirection->type() == ExternalReference::PROFILING_API_CALL) { | |
1584 // See comment at type definition of SimulatorRuntimeDirectApiCall | |
1585 // for explanation of register usage. | |
1586 if (::v8::internal::FLAG_trace_sim) { | |
1587 PrintF("Call to host function at %p args %08x %08x\n", | |
1588 reinterpret_cast<void*>(external), arg1, arg2); | |
1589 } | |
1590 SimulatorRuntimeProfilingApiCall target = | |
1591 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); | |
1592 v8::Handle<v8::Value> result = target(arg1, arg2); | |
1593 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); | |
1594 set_register(v0, arg0); | |
1595 } else { | |
1596 if (::v8::internal::FLAG_trace_sim) { | |
1597 PrintF("Call to host function at %p args %08x %08x\n", | |
1598 reinterpret_cast<void*>(external), arg0, arg1); | |
1599 } | |
1600 SimulatorRuntimeProfilingApiCallNew target = | |
1601 reinterpret_cast<SimulatorRuntimeProfilingApiCallNew>(external); | |
1602 target(arg0, arg1); | |
1603 } | |
1604 } else if ( | |
1605 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || | 1574 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || |
1606 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { | 1575 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { |
1607 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { | 1576 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { |
1608 // See comment at type definition of SimulatorRuntimeDirectGetterCall | 1577 // See comment at type definition of SimulatorRuntimeDirectGetterCall |
1609 // for explanation of register usage. | 1578 // for explanation of register usage. |
1610 if (::v8::internal::FLAG_trace_sim) { | 1579 if (::v8::internal::FLAG_trace_sim) { |
1611 PrintF("Call to host function at %p args %08x %08x\n", | 1580 PrintF("Call to host function at %p args %08x %08x\n", |
1612 reinterpret_cast<void*>(external), arg1, arg2); | 1581 reinterpret_cast<void*>(external), arg1, arg2); |
1613 } | 1582 } |
1614 SimulatorRuntimeDirectGetterCall target = | 1583 SimulatorRuntimeDirectGetterCall target = |
1615 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | 1584 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
1616 v8::Handle<v8::Value> result = target(arg1, arg2); | 1585 v8::Handle<v8::Value> result = target(arg1, arg2); |
1617 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); | 1586 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); |
1618 set_register(v0, arg0); | 1587 set_register(v0, arg0); |
1619 } else { | 1588 } else { |
1620 if (::v8::internal::FLAG_trace_sim) { | 1589 if (::v8::internal::FLAG_trace_sim) { |
1621 PrintF("Call to host function at %p args %08x %08x\n", | 1590 PrintF("Call to host function at %p args %08x %08x\n", |
1622 reinterpret_cast<void*>(external), arg0, arg1); | 1591 reinterpret_cast<void*>(external), arg0, arg1); |
1623 } | 1592 } |
1624 SimulatorRuntimeDirectGetterCallNew target = | 1593 SimulatorRuntimeDirectGetterCallNew target = |
1625 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); | 1594 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); |
1626 target(arg0, arg1); | 1595 target(arg0, arg1); |
1627 } | 1596 } |
1628 } else if ( | |
1629 redirection->type() == ExternalReference::PROFILING_GETTER_CALL || | |
1630 redirection->type() == ExternalReference::PROFILING_GETTER_CALL_NEW) { | |
1631 if (redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { | |
1632 // See comment at type definition of SimulatorRuntimeProfilingGetterCall | |
1633 // for explanation of register usage. | |
1634 if (::v8::internal::FLAG_trace_sim) { | |
1635 PrintF("Call to host function at %p args %08x %08x %08x\n", | |
1636 reinterpret_cast<void*>(external), arg1, arg2, arg3); | |
1637 } | |
1638 SimulatorRuntimeProfilingGetterCall target = | |
1639 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); | |
1640 v8::Handle<v8::Value> result = target(arg1, arg2, arg3); | |
1641 *(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); | |
1642 set_register(v0, arg0); | |
1643 } else { | |
1644 if (::v8::internal::FLAG_trace_sim) { | |
1645 PrintF("Call to host function at %p args %08x %08x %08x\n", | |
1646 reinterpret_cast<void*>(external), arg0, arg1, arg2); | |
1647 } | |
1648 SimulatorRuntimeProfilingGetterCallNew target = | |
1649 reinterpret_cast<SimulatorRuntimeProfilingGetterCallNew>(external); | |
1650 target(arg0, arg1, arg2); | |
1651 } | |
1652 } else { | 1597 } else { |
1653 SimulatorRuntimeCall target = | 1598 SimulatorRuntimeCall target = |
1654 reinterpret_cast<SimulatorRuntimeCall>(external); | 1599 reinterpret_cast<SimulatorRuntimeCall>(external); |
1655 if (::v8::internal::FLAG_trace_sim) { | 1600 if (::v8::internal::FLAG_trace_sim) { |
1656 PrintF( | 1601 PrintF( |
1657 "Call to host function at %p " | 1602 "Call to host function at %p " |
1658 "args %08x, %08x, %08x, %08x, %08x, %08x\n", | 1603 "args %08x, %08x, %08x, %08x, %08x, %08x\n", |
1659 FUNCTION_ADDR(target), | 1604 FUNCTION_ADDR(target), |
1660 arg0, | 1605 arg0, |
1661 arg1, | 1606 arg1, |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 } | 2938 } |
2994 | 2939 |
2995 | 2940 |
2996 #undef UNSUPPORTED | 2941 #undef UNSUPPORTED |
2997 | 2942 |
2998 } } // namespace v8::internal | 2943 } } // namespace v8::internal |
2999 | 2944 |
3000 #endif // USE_SIMULATOR | 2945 #endif // USE_SIMULATOR |
3001 | 2946 |
3002 #endif // V8_TARGET_ARCH_MIPS | 2947 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |