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

Unified Diff: runtime/vm/stub_code_x64.cc

Issue 11360116: Pass closure object as first implicit argument to closure functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_x64.cc
===================================================================
--- runtime/vm/stub_code_x64.cc (revision 14694)
+++ runtime/vm/stub_code_x64.cc (working copy)
@@ -26,7 +26,6 @@
"Set to true for debugging & verifying the slow paths.");
DECLARE_FLAG(int, optimization_counter_threshold);
-
// Input parameters:
// RSP : points to return address.
// RSP + 8 : address of last argument in argument array.
@@ -38,7 +37,7 @@
void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
ASSERT((R12 != CTX) && (R13 != CTX));
const intptr_t isolate_offset = NativeArguments::isolate_offset();
- const intptr_t argc_offset = NativeArguments::argc_offset();
+ const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
const intptr_t argv_offset = NativeArguments::argv_offset();
const intptr_t retval_offset = NativeArguments::retval_offset();
@@ -65,7 +64,9 @@
// Pass NativeArguments structure by value and call runtime.
__ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs.
- __ movq(Address(RSP, argc_offset), R10); // Set argc in NativeArguments.
+ // There are no runtime calls to closures, so we do not need to set the tag
+ // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
+ __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments.
__ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv.
__ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments.
__ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument.
@@ -115,15 +116,14 @@
// RSP : points to return address.
// RSP + 8 : address of return value.
// RAX : address of first argument in argument array.
-// RAX - 8*R10 + 8 : address of last argument in argument array.
// RBX : address of the native function to call.
-// R10 : number of arguments to the call.
+// R10 : argc_tag including number of arguments and function kind.
void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
const intptr_t native_args_struct_offset = 0;
const intptr_t isolate_offset =
NativeArguments::isolate_offset() + native_args_struct_offset;
- const intptr_t argc_offset =
- NativeArguments::argc_offset() + native_args_struct_offset;
+ const intptr_t argc_tag_offset =
+ NativeArguments::argc_tag_offset() + native_args_struct_offset;
const intptr_t argv_offset =
NativeArguments::argv_offset() + native_args_struct_offset;
const intptr_t retval_offset =
@@ -154,7 +154,7 @@
// Pass NativeArguments structure by value and call native function.
__ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs.
- __ movq(Address(RSP, argc_offset), R10); // Set argc in NativeArguments.
+ __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments.
__ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments.
__ leaq(RAX, Address(RBP, 2 * kWordSize)); // Compute return value addr.
__ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments.
@@ -718,10 +718,10 @@
// Input parameters:
// R10: Arguments descriptor array (num_args is first Smi element, closure
-// object is not included in num_args).
-// Note: The closure object is pushed before the first argument to the function
-// being called, the stub accesses the closure from this location directly
-// when setting up the context and resolving the entry point.
+// object is included in num_args and is first argument).
+// Note: The closure object is the first argument to the function being
+// called, the stub accesses the closure from this location directly
+// when trying to resolve the call.
void StubCode::GenerateCallClosureFunctionStub(Assembler* assembler) {
const Immediate raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
@@ -729,7 +729,7 @@
// Total number of args is the first Smi in args descriptor array (R10).
__ movq(RAX, FieldAddress(R10, Array::data_offset())); // Load num_args.
// Load closure object in R13.
- __ movq(R13, Address(RSP, RAX, TIMES_4, kWordSize)); // RAX is a Smi.
+ __ movq(R13, Address(RSP, RAX, TIMES_4, 0)); // RAX is a Smi.
// Verify that R13 is a closure by checking its class.
Label not_closure;
@@ -787,7 +787,7 @@
// object, passing the non-closure object and its arguments array.
// R13: non-closure object.
// R10: arguments descriptor array (num_args is first Smi element, closure
- // object is not included in num_args).
+ // object is included in num_args).
// Create a stub frame as we are pushing some objects on the stack before
// calling into the runtime.
@@ -798,6 +798,7 @@
// Total number of args is the first Smi in args descriptor array (R10).
__ movq(R13, FieldAddress(R10, Array::data_offset())); // Load num_args.
__ SmiUntag(R13);
+ __ subq(R13, Immediate(1)); // Arguments array length, minus the closure.
// See stack layout below explaining "wordSize * 5" offset.
PushArgumentsArray(assembler, (kWordSize * 5));
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698