Commit ea122ef8 authored by palfia@homejinni.com's avatar palfia@homejinni.com

MIPS: fix arm simulator after 14725

Port r14731 (046b5d8d)

BUG=

Review URL: https://codereview.chromium.org/15606002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14737 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b2729b1b
...@@ -3980,10 +3980,6 @@ void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, ...@@ -3980,10 +3980,6 @@ void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function,
PopSafepointRegisters(); PopSafepointRegisters();
} }
// As mentioned above, on MIPS a pointer is returned - we need to dereference
// it to get the actual return value (which is also a pointer).
lw(v0, MemOperand(v0));
Label promote_scheduled_exception; Label promote_scheduled_exception;
Label delete_allocated_handles; Label delete_allocated_handles;
Label leave_exit_frame; Label leave_exit_frame;
...@@ -3991,11 +3987,15 @@ void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, ...@@ -3991,11 +3987,15 @@ void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function,
if (returns_handle) { if (returns_handle) {
Label load_return_value; Label load_return_value;
// As mentioned above, on MIPS a pointer is returned - we need to
// dereference it to get the actual return value (which is also a pointer).
lw(v0, MemOperand(v0));
Branch(&load_return_value, eq, v0, Operand(zero_reg)); Branch(&load_return_value, eq, v0, Operand(zero_reg));
// Dereference returned value. // Dereference returned value.
lw(v0, MemOperand(v0)); lw(v0, MemOperand(v0));
b(&return_value_loaded); Branch(&return_value_loaded);
nop();
bind(&load_return_value); bind(&load_return_value);
} }
// Load value from ReturnValue. // Load value from ReturnValue.
......
...@@ -1388,10 +1388,13 @@ typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); ...@@ -1388,10 +1388,13 @@ typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0);
// This signature supports direct call in to API function native callback // This signature supports direct call in to API function native callback
// (refer to InvocationCallback in v8.h). // (refer to InvocationCallback in v8.h).
typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0);
typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0);
// This signature supports direct call to accessor getter callback. // This signature supports direct call to accessor getter callback.
typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0,
int32_t arg1); int32_t arg1);
typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0,
int32_t arg1);
// Software interrupt instructions are used by the simulator to call into the // Software interrupt instructions are used by the simulator to call into the
// C-based V8 runtime. They are also used for debugging with simulator. // C-based V8 runtime. They are also used for debugging with simulator.
...@@ -1536,28 +1539,44 @@ void Simulator::SoftwareInterrupt(Instruction* instr) { ...@@ -1536,28 +1539,44 @@ void Simulator::SoftwareInterrupt(Instruction* instr) {
break; break;
} }
} }
} else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { } else if (
redirection->type() == ExternalReference::DIRECT_API_CALL ||
redirection->type() == ExternalReference::DIRECT_API_CALL_NEW) {
// See DirectCEntryStub::GenerateCall for explanation of register usage. // See DirectCEntryStub::GenerateCall for explanation of register usage.
SimulatorRuntimeDirectApiCall target =
reinterpret_cast<SimulatorRuntimeDirectApiCall>(external);
if (::v8::internal::FLAG_trace_sim) { if (::v8::internal::FLAG_trace_sim) {
PrintF("Call to host function at %p args %08x\n", PrintF("Call to host function at %p args %08x\n",
FUNCTION_ADDR(target), arg1); reinterpret_cast<void*>(external), arg1);
} }
v8::Handle<v8::Value> result = target(arg1); if (redirection->type() == ExternalReference::DIRECT_API_CALL) {
*(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result); SimulatorRuntimeDirectApiCall target =
set_register(v0, arg0); reinterpret_cast<SimulatorRuntimeDirectApiCall>(external);
} else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { v8::Handle<v8::Value> result = target(arg1);
*(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result);
set_register(v0, arg0);
} else {
SimulatorRuntimeDirectApiCallNew target =
reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external);
target(arg1);
}
} else if (
redirection->type() == ExternalReference::DIRECT_GETTER_CALL ||
redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) {
// See DirectCEntryStub::GenerateCall for explanation of register usage. // See DirectCEntryStub::GenerateCall for explanation of register usage.
SimulatorRuntimeDirectGetterCall target =
reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external);
if (::v8::internal::FLAG_trace_sim) { if (::v8::internal::FLAG_trace_sim) {
PrintF("Call to host function at %p args %08x %08x\n", PrintF("Call to host function at %p args %08x %08x\n",
FUNCTION_ADDR(target), arg1, arg2); reinterpret_cast<void*>(external), arg1, arg2);
}
if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) {
SimulatorRuntimeDirectGetterCall target =
reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external);
v8::Handle<v8::Value> result = target(arg1, arg2);
*(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result);
set_register(v0, arg0);
} else {
SimulatorRuntimeDirectGetterCallNew target =
reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external);
target(arg1, arg2);
} }
v8::Handle<v8::Value> result = target(arg1, arg2);
*(reinterpret_cast<int*>(arg0)) = reinterpret_cast<int32_t>(*result);
set_register(v0, arg0);
} else { } else {
SimulatorRuntimeCall target = SimulatorRuntimeCall target =
reinterpret_cast<SimulatorRuntimeCall>(external); reinterpret_cast<SimulatorRuntimeCall>(external);
......
...@@ -935,9 +935,13 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -935,9 +935,13 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
bool returns_handle = bool returns_handle =
!CallbackTable::ReturnsVoid(masm->isolate(), function_address); !CallbackTable::ReturnsVoid(masm->isolate(), function_address);
ApiFunction fun(function_address); ApiFunction fun(function_address);
ExternalReference::Type type =
returns_handle ?
ExternalReference::DIRECT_API_CALL :
ExternalReference::DIRECT_API_CALL_NEW;
ExternalReference ref = ExternalReference ref =
ExternalReference(&fun, ExternalReference(&fun,
ExternalReference::DIRECT_API_CALL, type,
masm->isolate()); masm->isolate());
AllowExternalCallThatCantCauseGC scope(masm); AllowExternalCallThatCantCauseGC scope(masm);
__ CallApiFunctionAndReturn(ref, __ CallApiFunctionAndReturn(ref,
...@@ -1450,8 +1454,12 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1450,8 +1454,12 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
bool returns_handle = bool returns_handle =
!CallbackTable::ReturnsVoid(isolate(), getter_address); !CallbackTable::ReturnsVoid(isolate(), getter_address);
ApiFunction fun(getter_address); ApiFunction fun(getter_address);
ExternalReference ref = ExternalReference( ExternalReference::Type type =
&fun, ExternalReference::DIRECT_GETTER_CALL, isolate()); returns_handle ?
ExternalReference::DIRECT_GETTER_CALL :
ExternalReference::DIRECT_GETTER_CALL_NEW;
ExternalReference ref = ExternalReference(&fun, type, isolate());
__ CallApiFunctionAndReturn(ref, __ CallApiFunctionAndReturn(ref,
kStackUnwindSpace, kStackUnwindSpace,
returns_handle, returns_handle,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment