| 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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 return new Redirection(external_function, type); | 965 return new Redirection(external_function, type); |
| 966 } | 966 } |
| 967 | 967 |
| 968 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { | 968 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { |
| 969 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); | 969 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); |
| 970 char* addr_of_redirection = | 970 char* addr_of_redirection = |
| 971 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); | 971 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); |
| 972 return reinterpret_cast<Redirection*>(addr_of_redirection); | 972 return reinterpret_cast<Redirection*>(addr_of_redirection); |
| 973 } | 973 } |
| 974 | 974 |
| 975 static void* ReverseRedirection(int32_t reg) { |
| 976 Redirection* redirection = FromSwiInstruction( |
| 977 reinterpret_cast<Instruction*>(reinterpret_cast<void*>(reg))); |
| 978 return redirection->external_function(); |
| 979 } |
| 980 |
| 975 private: | 981 private: |
| 976 void* external_function_; | 982 void* external_function_; |
| 977 uint32_t swi_instruction_; | 983 uint32_t swi_instruction_; |
| 978 ExternalReference::Type type_; | 984 ExternalReference::Type type_; |
| 979 Redirection* next_; | 985 Redirection* next_; |
| 980 }; | 986 }; |
| 981 | 987 |
| 982 | 988 |
| 983 void* Simulator::RedirectExternalReference(void* external_function, | 989 void* Simulator::RedirectExternalReference(void* external_function, |
| 984 ExternalReference::Type type) { | 990 ExternalReference::Type type) { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 | 1388 |
| 1383 // These prototypes handle the four types of FP calls. | 1389 // These prototypes handle the four types of FP calls. |
| 1384 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1390 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
| 1385 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1391 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
| 1386 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1392 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
| 1387 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1393 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
| 1388 | 1394 |
| 1389 // This signature supports direct call in to API function native callback | 1395 // This signature supports direct call in to API function native callback |
| 1390 // (refer to InvocationCallback in v8.h). | 1396 // (refer to InvocationCallback in v8.h). |
| 1391 typedef void (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1397 typedef void (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
| 1392 typedef void (*SimulatorRuntimeProfilingApiCall)(int32_t arg0, int32_t arg1); | 1398 typedef void (*SimulatorRuntimeProfilingApiCall)(int32_t arg0, void* arg1); |
| 1393 | 1399 |
| 1394 // This signature supports direct call to accessor getter callback. | 1400 // This signature supports direct call to accessor getter callback. |
| 1395 typedef void (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, int32_t arg1); | 1401 typedef void (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, int32_t arg1); |
| 1396 typedef void (*SimulatorRuntimeProfilingGetterCall)( | 1402 typedef void (*SimulatorRuntimeProfilingGetterCall)( |
| 1397 int32_t arg0, int32_t arg1, int32_t arg2); | 1403 int32_t arg0, int32_t arg1, void* arg2); |
| 1398 | 1404 |
| 1399 // Software interrupt instructions are used by the simulator to call into the | 1405 // 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. | 1406 // C-based V8 runtime. They are also used for debugging with simulator. |
| 1401 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1407 void Simulator::SoftwareInterrupt(Instruction* instr) { |
| 1402 // There are several instructions that could get us here, | 1408 // There are several instructions that could get us here, |
| 1403 // the break_ instruction, or several variants of traps. All | 1409 // the break_ instruction, or several variants of traps. All |
| 1404 // Are "SPECIAL" class opcode, and are distinuished by function. | 1410 // Are "SPECIAL" class opcode, and are distinuished by function. |
| 1405 int32_t func = instr->FunctionFieldRaw(); | 1411 int32_t func = instr->FunctionFieldRaw(); |
| 1406 uint32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; | 1412 uint32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; |
| 1407 | 1413 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); | 1554 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); |
| 1549 target(arg0); | 1555 target(arg0); |
| 1550 } else if ( | 1556 } else if ( |
| 1551 redirection->type() == ExternalReference::PROFILING_API_CALL) { | 1557 redirection->type() == ExternalReference::PROFILING_API_CALL) { |
| 1552 if (::v8::internal::FLAG_trace_sim) { | 1558 if (::v8::internal::FLAG_trace_sim) { |
| 1553 PrintF("Call to host function at %p args %08x %08x\n", | 1559 PrintF("Call to host function at %p args %08x %08x\n", |
| 1554 reinterpret_cast<void*>(external), arg0, arg1); | 1560 reinterpret_cast<void*>(external), arg0, arg1); |
| 1555 } | 1561 } |
| 1556 SimulatorRuntimeProfilingApiCall target = | 1562 SimulatorRuntimeProfilingApiCall target = |
| 1557 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); | 1563 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); |
| 1558 target(arg0, arg1); | 1564 target(arg0, Redirection::ReverseRedirection(arg1)); |
| 1559 } else if ( | 1565 } else if ( |
| 1560 redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { | 1566 redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { |
| 1561 if (::v8::internal::FLAG_trace_sim) { | 1567 if (::v8::internal::FLAG_trace_sim) { |
| 1562 PrintF("Call to host function at %p args %08x %08x\n", | 1568 PrintF("Call to host function at %p args %08x %08x\n", |
| 1563 reinterpret_cast<void*>(external), arg0, arg1); | 1569 reinterpret_cast<void*>(external), arg0, arg1); |
| 1564 } | 1570 } |
| 1565 SimulatorRuntimeDirectGetterCall target = | 1571 SimulatorRuntimeDirectGetterCall target = |
| 1566 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | 1572 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
| 1567 target(arg0, arg1); | 1573 target(arg0, arg1); |
| 1568 } else if ( | 1574 } else if ( |
| 1569 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { | 1575 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { |
| 1570 if (::v8::internal::FLAG_trace_sim) { | 1576 if (::v8::internal::FLAG_trace_sim) { |
| 1571 PrintF("Call to host function at %p args %08x %08x %08x\n", | 1577 PrintF("Call to host function at %p args %08x %08x %08x\n", |
| 1572 reinterpret_cast<void*>(external), arg0, arg1, arg2); | 1578 reinterpret_cast<void*>(external), arg0, arg1, arg2); |
| 1573 } | 1579 } |
| 1574 SimulatorRuntimeProfilingGetterCall target = | 1580 SimulatorRuntimeProfilingGetterCall target = |
| 1575 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); | 1581 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); |
| 1576 target(arg0, arg1, arg2); | 1582 target(arg0, arg1, Redirection::ReverseRedirection(arg2)); |
| 1577 } else { | 1583 } else { |
| 1578 SimulatorRuntimeCall target = | 1584 SimulatorRuntimeCall target = |
| 1579 reinterpret_cast<SimulatorRuntimeCall>(external); | 1585 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 1580 if (::v8::internal::FLAG_trace_sim) { | 1586 if (::v8::internal::FLAG_trace_sim) { |
| 1581 PrintF( | 1587 PrintF( |
| 1582 "Call to host function at %p " | 1588 "Call to host function at %p " |
| 1583 "args %08x, %08x, %08x, %08x, %08x, %08x\n", | 1589 "args %08x, %08x, %08x, %08x, %08x, %08x\n", |
| 1584 FUNCTION_ADDR(target), | 1590 FUNCTION_ADDR(target), |
| 1585 arg0, | 1591 arg0, |
| 1586 arg1, | 1592 arg1, |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2928 } | 2934 } |
| 2929 | 2935 |
| 2930 | 2936 |
| 2931 #undef UNSUPPORTED | 2937 #undef UNSUPPORTED |
| 2932 | 2938 |
| 2933 } } // namespace v8::internal | 2939 } } // namespace v8::internal |
| 2934 | 2940 |
| 2935 #endif // USE_SIMULATOR | 2941 #endif // USE_SIMULATOR |
| 2936 | 2942 |
| 2937 #endif // V8_TARGET_ARCH_MIPS | 2943 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |