Chromium Code Reviews| Index: src/arm/simulator-arm.cc |
| =================================================================== |
| --- src/arm/simulator-arm.cc (revision 6213) |
| +++ src/arm/simulator-arm.cc (working copy) |
| @@ -48,6 +48,7 @@ |
| using ::v8::internal::OS; |
| using ::v8::internal::ReadLine; |
| using ::v8::internal::DeleteArray; |
| +using ::v8::internal::ExternalReference; |
| // This macro provides a platform independent use of sscanf. The reason for |
| // SScanF not being implemented in a platform independent way through |
| @@ -745,10 +746,10 @@ |
| // offset from the svc instruction so the simulator knows what to call. |
| class Redirection { |
| public: |
| - Redirection(void* external_function, bool fp_return) |
| + Redirection(void* external_function, ExternalReference::Type type) |
| : external_function_(external_function), |
| swi_instruction_((AL << 28) | (0xf << 24) | call_rt_redirected), |
| - fp_return_(fp_return), |
| + type_(type), |
| next_(list_) { |
| Simulator::current()-> |
| FlushICache(reinterpret_cast<void*>(&swi_instruction_), |
| @@ -761,14 +762,15 @@ |
| } |
| void* external_function() { return external_function_; } |
| - bool fp_return() { return fp_return_; } |
| + ExternalReference::Type type() { return type_; } |
| - static Redirection* Get(void* external_function, bool fp_return) { |
| + static Redirection* Get(void* external_function, |
| + ExternalReference::Type type) { |
| Redirection* current; |
| for (current = list_; current != NULL; current = current->next_) { |
| if (current->external_function_ == external_function) return current; |
| } |
| - return new Redirection(external_function, fp_return); |
| + return new Redirection(external_function, type); |
| } |
| static Redirection* FromSwiInstruction(Instr* swi_instruction) { |
| @@ -781,7 +783,7 @@ |
| private: |
| void* external_function_; |
| uint32_t swi_instruction_; |
| - bool fp_return_; |
| + ExternalReference::Type type_; |
| Redirection* next_; |
| static Redirection* list_; |
| }; |
| @@ -791,8 +793,8 @@ |
| void* Simulator::RedirectExternalReference(void* external_function, |
| - bool fp_return) { |
| - Redirection* redirection = Redirection::Get(external_function, fp_return); |
| + ExternalReference::Type type) { |
| + Redirection* redirection = Redirection::Get(external_function, type); |
| return redirection->address_of_swi_instruction(); |
| } |
| @@ -1533,6 +1535,9 @@ |
| int32_t arg2, |
| int32_t arg3); |
| +// This signature supports direct call in to API function native callback |
| +// (refer to InvocationCallback in v8.h). |
| +typedef v8::Handle<v8::Value> (*SimulatorRuntimeApiCall)(int32_t arg0); |
| // Software interrupt instructions are used by the simulator to call into the |
| // C-based V8 runtime. |
| @@ -1555,9 +1560,9 @@ |
| // This is dodgy but it works because the C entry stubs are never moved. |
| // See comment in codegen-arm.cc and bug 1242173. |
| int32_t saved_lr = get_register(lr); |
| - if (redirection->fp_return()) { |
| - intptr_t external = |
| - reinterpret_cast<intptr_t>(redirection->external_function()); |
| + intptr_t external = |
| + reinterpret_cast<intptr_t>(redirection->external_function()); |
| + if (redirection->type() == ExternalReference::FP_RETURN_CALL) { |
| SimulatorRuntimeFPCall target = |
| reinterpret_cast<SimulatorRuntimeFPCall>(external); |
| if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| @@ -1573,9 +1578,28 @@ |
| CHECK(stack_aligned); |
| double result = target(arg0, arg1, arg2, arg3); |
| SetFpResult(result); |
| + } else if (redirection->type() == ExternalReference::DIRECT_CALL) { |
| + SimulatorRuntimeApiCall target = |
| + reinterpret_cast<SimulatorRuntimeApiCall>(external); |
| + if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| + PrintF( |
| + "Call to host function at %p args %08x", |
| + FUNCTION_ADDR(target), |
| + arg0); |
| + if (!stack_aligned) { |
| + PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| + } |
| + PrintF("\n"); |
| + } |
| + CHECK(stack_aligned); |
| + v8::Handle<v8::Value> result = target(arg0); |
| + if (::v8::internal::FLAG_trace_sim) { |
| + PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); |
| + } |
| + set_register(r0, (int32_t) *result); |
| } else { |
| - intptr_t external = |
| - reinterpret_cast<int32_t>(redirection->external_function()); |
| + // builtin/runtime call |
|
antonm
2011/01/26 11:36:38
nit: add a dot please.
v8 style is to end comment
Zaheer
2011/02/02 10:05:59
Done.
|
| + ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); |
| SimulatorRuntimeCall target = |
| reinterpret_cast<SimulatorRuntimeCall>(external); |
| if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |