From 8633086fcdb3a596f55d07095b4d3bd2e4cbcf33 Mon Sep 17 00:00:00 2001 From: "dcarney@chromium.org" Date: Tue, 21 May 2013 12:17:04 +0000 Subject: [PATCH] fix arm simulator after 14725 BUG= R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/15484006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14731 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/simulator-arm.cc | 51 ++++++++++++++++++++++++++++++++--------------- src/arm/stub-cache-arm.cc | 14 ++++++++++--- src/assembler.h | 10 +++++++++- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/arm/simulator-arm.cc b/src/arm/simulator-arm.cc index 790b48a..c9db167 100644 --- a/src/arm/simulator-arm.cc +++ b/src/arm/simulator-arm.cc @@ -1628,10 +1628,13 @@ typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); // This signature supports direct call in to API function native callback // (refer to InvocationCallback in v8.h). typedef v8::Handle (*SimulatorRuntimeDirectApiCall)(int32_t arg0); +typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); // This signature supports direct call to accessor getter callback. typedef v8::Handle (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, int32_t arg1); +typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, + int32_t arg1); // Software interrupt instructions are used by the simulator to call into the // C-based V8 runtime. @@ -1770,40 +1773,56 @@ void Simulator::SoftwareInterrupt(Instruction* instr) { break; } } - } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { - SimulatorRuntimeDirectApiCall target = - reinterpret_cast(external); + } else if ( + redirection->type() == ExternalReference::DIRECT_API_CALL || + redirection->type() == ExternalReference::DIRECT_API_CALL_NEW) { if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08x", - FUNCTION_ADDR(target), arg0); + reinterpret_cast(external), arg0); if (!stack_aligned) { PrintF(" with unaligned stack %08x\n", get_register(sp)); } PrintF("\n"); } CHECK(stack_aligned); - v8::Handle result = target(arg0); - if (::v8::internal::FLAG_trace_sim) { - PrintF("Returned %p\n", reinterpret_cast(*result)); + if (redirection->type() == ExternalReference::DIRECT_API_CALL) { + SimulatorRuntimeDirectApiCall target = + reinterpret_cast(external); + v8::Handle result = target(arg0); + if (::v8::internal::FLAG_trace_sim) { + PrintF("Returned %p\n", reinterpret_cast(*result)); + } + set_register(r0, reinterpret_cast(*result)); + } else { + SimulatorRuntimeDirectApiCallNew target = + reinterpret_cast(external); + target(arg0); } - set_register(r0, reinterpret_cast(*result)); - } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { - SimulatorRuntimeDirectGetterCall target = - reinterpret_cast(external); + } else if ( + redirection->type() == ExternalReference::DIRECT_GETTER_CALL || + redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08x %08x", - FUNCTION_ADDR(target), arg0, arg1); + reinterpret_cast(external), arg0, arg1); if (!stack_aligned) { PrintF(" with unaligned stack %08x\n", get_register(sp)); } PrintF("\n"); } CHECK(stack_aligned); - v8::Handle result = target(arg0, arg1); - if (::v8::internal::FLAG_trace_sim) { - PrintF("Returned %p\n", reinterpret_cast(*result)); + if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { + SimulatorRuntimeDirectGetterCall target = + reinterpret_cast(external); + v8::Handle result = target(arg0, arg1); + if (::v8::internal::FLAG_trace_sim) { + PrintF("Returned %p\n", reinterpret_cast(*result)); + } + set_register(r0, reinterpret_cast(*result)); + } else { + SimulatorRuntimeDirectGetterCallNew target = + reinterpret_cast(external); + target(arg0, arg1); } - set_register(r0, reinterpret_cast(*result)); } else { // builtin call. ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index 86eb0db..b0de014 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -937,8 +937,12 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, bool returns_handle = !CallbackTable::ReturnsVoid(masm->isolate(), function_address); ApiFunction fun(function_address); + ExternalReference::Type type = + returns_handle ? + ExternalReference::DIRECT_API_CALL : + ExternalReference::DIRECT_API_CALL_NEW; ExternalReference ref = ExternalReference(&fun, - ExternalReference::DIRECT_API_CALL, + type, masm->isolate()); AllowExternalCallThatCantCauseGC scope(masm); __ CallApiFunctionAndReturn(ref, @@ -1438,8 +1442,12 @@ void BaseLoadStubCompiler::GenerateLoadCallback( bool returns_handle = !CallbackTable::ReturnsVoid(isolate(), getter_address); ApiFunction fun(getter_address); - ExternalReference ref = ExternalReference( - &fun, ExternalReference::DIRECT_GETTER_CALL, isolate()); + ExternalReference::Type type = + returns_handle ? + ExternalReference::DIRECT_GETTER_CALL : + ExternalReference::DIRECT_GETTER_CALL_NEW; + + ExternalReference ref = ExternalReference(&fun, type, isolate()); __ CallApiFunctionAndReturn(ref, kStackUnwindSpace, returns_handle, diff --git a/src/assembler.h b/src/assembler.h index 6abd5c5..2d9e727 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -647,9 +647,17 @@ class ExternalReference BASE_EMBEDDED { // Handle f(v8::Arguments&) DIRECT_API_CALL, + // Direct call to API function callback. + // void f(v8::Arguments&) + DIRECT_API_CALL_NEW, + // Direct call to accessor getter callback. // Handle f(Local property, AccessorInfo& info) - DIRECT_GETTER_CALL + DIRECT_GETTER_CALL, + + // Direct call to accessor getter callback. + // void f(Local property, AccessorInfo& info) + DIRECT_GETTER_CALL_NEW }; static void SetUp(); -- 2.7.4