Reviewers: Michael Starzinger,
Message:
ptal
this is in no way a hack!
Description:
add context save for GenerateFastApiCall
[email protected]
BUG=
Please review this at https://chromiumcodereview.appspot.com/23461039/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+19, -8 lines):
M src/x64/macro-assembler-x64.h
M src/x64/macro-assembler-x64.cc
M src/x64/stub-cache-x64.cc
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index
0c605d826dd1f80fa4db3dec59fed95477c350c2..e8f1332b15e934f526953c8976e531efd3efb4e2
100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -694,7 +694,8 @@ void MacroAssembler::CallApiFunctionAndReturn(Address
function_address,
Address thunk_address,
Register thunk_last_arg,
int stack_space,
- int return_value_offset) {
+ int return_value_offset,
+ bool restore_context) {
Label prologue;
Label promote_scheduled_exception;
Label delete_allocated_handles;
@@ -819,7 +820,12 @@ void MacroAssembler::CallApiFunctionAndReturn(Address
function_address,
#endif
LeaveApiExitFrame();
- ret(stack_space * kPointerSize);
+ if (restore_context) {
+ movq(rsi, Operand(rsp, (stack_space + 1) * kPointerSize));
+ ret((stack_space + 2) * kPointerSize);
+ } else {
+ ret(stack_space * kPointerSize);
+ }
bind(&promote_scheduled_exception);
TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
Index: src/x64/macro-assembler-x64.h
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h
index
8e30981833acff2e6caac0b8ddf2b0276d51c9de..c265f125452d3dbefdb9b997441273e1c1046ff4
100644
--- a/src/x64/macro-assembler-x64.h
+++ b/src/x64/macro-assembler-x64.h
@@ -1260,7 +1260,8 @@ class MacroAssembler: public Assembler {
Address thunk_address,
Register thunk_last_arg,
int stack_space,
- int return_value_offset_from_rbp);
+ int return_value_offset_from_rbp,
+ bool restore_context = false);
// Before calling a C-function from generated code, align arguments on
stack.
// After aligning the frame, arguments must be stored in rsp[0], rsp[8],
Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index
31f60be565e2de24697de08cca2a78ded9ec27c2..8c8e5f8cd109297a6abd2125b6d2b2368a6049cd
100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -443,7 +443,8 @@ static void FreeSpaceForFastApiCall(MacroAssembler*
masm, Register scratch) {
// Generates call to API function.
static void GenerateFastApiCall(MacroAssembler* masm,
const CallOptimization& optimization,
- int argc) {
+ int argc,
+ bool restore_context = false) {
// ----------- S t a t e -------------
// -- rsp[0] : return address
// -- rsp[8] : object passing the type check
@@ -506,7 +507,7 @@ static void GenerateFastApiCall(MacroAssembler* masm,
// it's not controlled by GC.
const int kApiStackSpace = 4;
- __ PrepareCallApiFunction(kApiStackSpace);
+ __ PrepareCallApiFunction(kApiStackSpace + (restore_context ? 2 : 0));
__ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_.
__ addq(rbx, Immediate(argc * kPointerSize));
@@ -524,7 +525,8 @@ static void GenerateFastApiCall(MacroAssembler* masm,
thunk_address,
callback_arg,
api_call_argc + 1,
- kFastApiCallArguments + 1);
+ kFastApiCallArguments + 1,
+ restore_context);
}
@@ -542,7 +544,9 @@ static void GenerateFastApiCall(MacroAssembler* masm,
// Copy return value.
__ movq(scratch, Operand(rsp, 0));
// Assign stack space for the call arguments.
- __ subq(rsp, Immediate(stack_space * kPointerSize));
+ __ subq(rsp, Immediate((stack_space + 2) * kPointerSize));
+ // Save context
+ __ movq(Operand(rsp, (stack_space + 1) * kPointerSize), rsi);
// Move the return address on top of the stack.
__ movq(Operand(rsp, 0), scratch);
// Write holder to stack frame.
@@ -557,7 +561,7 @@ static void GenerateFastApiCall(MacroAssembler* masm,
__ movq(Operand(rsp, index-- * kPointerSize), values[i]);
}
- GenerateFastApiCall(masm, optimization, argc);
+ GenerateFastApiCall(masm, optimization, argc, true);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.