Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: src/x64/codegen-x64.cc

Issue 201042: Win64 - Allow returning two values from a runtime function. (Closed)
Patch Set: Fixed typo. Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/x64/codegen-x64.cc
diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc
index 8d313c951cb45678bb106962a31fdd33535c5343..c5f023c840ef689d9de36f4d6f9dbf8208318659 100644
--- a/src/x64/codegen-x64.cc
+++ b/src/x64/codegen-x64.cc
@@ -6829,7 +6829,8 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
// Do the runtime call to allocate the arguments object.
__ bind(&runtime);
- __ TailCallRuntime(ExternalReference(Runtime::kNewArgumentsFast), 3);
+ Runtime::Function* f = Runtime::FunctionForId(Runtime::kNewArgumentsFast);
+ __ TailCallRuntime(ExternalReference(f), 3, f->result_size);
}
@@ -6891,7 +6892,9 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
__ pop(rbx); // Return address.
__ push(rdx);
__ push(rbx);
- __ TailCallRuntime(ExternalReference(Runtime::kGetArgumentsProperty), 1);
+ Runtime::Function* f =
+ Runtime::FunctionForId(Runtime::kGetArgumentsProperty);
+ __ TailCallRuntime(ExternalReference(f), 1, f->result_size);
}
@@ -6915,6 +6918,19 @@ void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) {
}
+int CEntryStub::MinorKey() {
+ ASSERT(result_size_ <= 2);
+#ifdef _WIN64
+ // Simple results returned in rax.
+ // Complex results must be written to address passed as first argument.
+ return (result_size_ < 2) ? 0 : result_size_ * 2;
William Hesse 2009/09/07 14:34:18 Why is the key 4 if the size is 2, and 0 if it is
Lasse Reichstein 2009/09/08 11:51:35 Previously, minor key 0 was used for CEntryStub an
+#else
+ // Results returned in rax or in rax+rdx by default.
Søren Thygesen Gjesse 2009/09/07 12:22:33 Maybe add something about this being compiler spec
Lasse Reichstein 2009/09/08 11:51:35 I'll say something. It's calling convention specif
+ return 0;
+#endif
+}
+
+
void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
// Check that stack should contain next handler, frame pointer, state and
// return address in that order.
@@ -6986,8 +7002,18 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
// Store Arguments object on stack, below the 4 WIN64 ABI parameter slots.
__ movq(Operand(rsp, 4 * kPointerSize), r14); // argc.
__ movq(Operand(rsp, 5 * kPointerSize), r15); // argv.
- // Pass a pointer to the Arguments object as the first argument.
- __ lea(rcx, Operand(rsp, 4 * kPointerSize));
+ if (result_size_ < 2) {
Søren Thygesen Gjesse 2009/09/07 12:22:33 Why not == 1? We only have 1 and 2 right?
Lasse Reichstein 2009/09/08 11:51:35 I was expecting 0 to be allowed too (for a functio
+ // Pass a pointer to the Arguments object as the first argument.
+ // Return result in single register (rax).
+ __ lea(rcx, Operand(rsp, 4 * kPointerSize));
+ } else {
+ ASSERT_EQ(2, result_size_);
+ // Pass a pointer to the result location as the first argument.
+ __ lea(rcx, Operand(rsp, 6 * kPointerSize));
+ // Pass a pointer to the Arguments object as the second argument.
+ __ lea(rdx, Operand(rsp, 4 * kPointerSize));
+ }
+
#else // ! defined(_WIN64)
// GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9.
__ movq(rdi, r14); // argc.
@@ -7010,7 +7036,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
__ j(zero, &failure_returned);
// Exit the JavaScript to C++ exit frame.
- __ LeaveExitFrame(frame_type);
+ __ LeaveExitFrame(frame_type, result_size_);
__ ret(0);
// Handling of failure.
@@ -7146,7 +7172,7 @@ void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) {
StackFrame::EXIT;
// Enter the exit frame that transitions from JavaScript to C++.
- __ EnterExitFrame(frame_type);
+ __ EnterExitFrame(frame_type, result_size_);
// rax: Holds the context at this point, but should not be used.
// On entry to code generated by GenerateCore, it must hold
@@ -7333,7 +7359,8 @@ void StackCheckStub::Generate(MacroAssembler* masm) {
__ push(rax);
// Do tail-call to runtime routine.
- __ TailCallRuntime(ExternalReference(Runtime::kStackGuard), 1);
+ Runtime::Function* f = Runtime::FunctionForId(Runtime::kStackGuard);
+ __ TailCallRuntime(ExternalReference(f), 1, f->result_size);
}

Powered by Google App Engine
This is Rietveld 408576698