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

Unified Diff: src/x64/stub-cache-x64.cc

Issue 19857006: Introduce StackOperandForArgument for X64 to access stack argument (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: One more place Created 7 years, 5 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
« src/x64/builtins-x64.cc ('K') | « src/x64/ic-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index 542018fddd084c20fb9fc1f024a4d8a92e41cccd..c12af91d746abad1a328cdaecafcfa6f05050352 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -415,7 +415,7 @@ static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) {
__ movq(Operand(rsp, 0), scratch);
__ Move(scratch, Smi::FromInt(0));
for (int i = 1; i <= kFastApiCallArguments; i++) {
- __ movq(Operand(rsp, i * kPointerSize), scratch);
+ __ movq(Operand(rsp, kPCOnStackSize + (i - 1) * kPointerSize), scratch);
}
}
@@ -423,13 +423,13 @@ static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) {
// Undoes the effects of ReserveSpaceForFastApiCall.
static void FreeSpaceForFastApiCall(MacroAssembler* masm, Register scratch) {
// ----------- S t a t e -------------
- // -- rsp[0] : return address.
- // -- rsp[8] : last fast api call extra argument.
+ // -- rsp[0] : return address.
+ // -- rsp[8] : last fast api call extra argument.
// -- ...
- // -- rsp[kFastApiCallArguments * 8] : first fast api call extra
+ // -- rsp[kFastApiCallArguments * 8] : first fast api call extra
// argument.
- // -- rsp[kFastApiCallArguments * 8 + 8] : last argument in the internal
- // frame.
+ // -- rsp[kFastApiCallArguments * 8 + kPCOnStackSize] : last argument
+ // in the internal frame.
// -----------------------------------
__ movq(scratch, Operand(rsp, 0));
__ movq(Operand(rsp, kFastApiCallArguments * kPointerSize), scratch);
@@ -464,22 +464,22 @@ static void GenerateFastApiCall(MacroAssembler* masm,
__ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
// Pass the additional arguments.
- __ movq(Operand(rsp, 2 * kPointerSize), rdi);
+ __ movq(Operand(rsp, kPCOnStackSize + 1 * kPointerSize), rdi);
Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
Handle<Object> call_data(api_call_info->data(), masm->isolate());
if (masm->isolate()->heap()->InNewSpace(*call_data)) {
__ Move(rcx, api_call_info);
__ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset));
- __ movq(Operand(rsp, 3 * kPointerSize), rbx);
+ __ movq(Operand(rsp, kPCOnStackSize + 2 * kPointerSize), rbx);
} else {
- __ Move(Operand(rsp, 3 * kPointerSize), call_data);
+ __ Move(Operand(rsp, kPCOnStackSize + 2 * kPointerSize), call_data);
}
__ movq(kScratchRegister,
ExternalReference::isolate_address(masm->isolate()));
- __ movq(Operand(rsp, 4 * kPointerSize), kScratchRegister);
+ __ movq(Operand(rsp, kPCOnStackSize + 3 * kPointerSize), kScratchRegister);
__ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
- __ movq(Operand(rsp, 5 * kPointerSize), kScratchRegister);
- __ movq(Operand(rsp, 6 * kPointerSize), kScratchRegister);
+ __ movq(Operand(rsp, kPCOnStackSize + 4 * kPointerSize), kScratchRegister);
+ __ movq(Operand(rsp, kPCOnStackSize + 5 * kPointerSize), kScratchRegister);
// Prepare arguments.
STATIC_ASSERT(kFastApiCallArguments == 6);
@@ -1074,7 +1074,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
int depth = 0;
if (save_at_depth == depth) {
- __ movq(Operand(rsp, kPointerSize), object_reg);
+ __ movq(Operand(rsp, kPCOnStackSize), object_reg);
}
// Check the maps in the prototype chain.
@@ -1134,7 +1134,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
}
if (save_at_depth == depth) {
- __ movq(Operand(rsp, kPointerSize), reg);
+ __ movq(Operand(rsp, kPCOnStackSize), reg);
}
// Go to the next object in the prototype chain.
@@ -1473,7 +1473,7 @@ void CallStubCompiler::GenerateGlobalReceiverCheck(Handle<JSObject> object,
const int argc = arguments().immediate();
// Get the receiver from the stack.
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the maps haven't changed.
@@ -1525,13 +1525,13 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
PropertyIndex index,
Handle<Name> name) {
// ----------- S t a t e -------------
- // rcx : function name
- // rsp[0] : return address
- // rsp[8] : argument argc
- // rsp[16] : argument argc - 1
+ // rcx : function name
+ // rsp[0] : return address
+ // rsp[8] : argument argc
+ // rsp[16] : argument argc - 1
// ...
- // rsp[argc * 8] : argument 1
- // rsp[(argc + 1) * 8] : argument 0 = receiver
+ // rsp[argc * 8] : argument 1
+ // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver
// -----------------------------------
Label miss;
@@ -1539,7 +1539,7 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
// Get the receiver from the stack.
const int argc = arguments().immediate();
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the receiver isn't a smi.
__ JumpIfSmi(rdx, &miss);
@@ -1560,7 +1560,7 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
// necessary.
if (object->IsGlobalObject()) {
__ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
- __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx);
+ __ movq(Operand(rsp, kPCOnStackSize + argc * kPointerSize), rdx);
}
// Invoke the function.
@@ -1594,7 +1594,7 @@ Handle<Code> CallStubCompiler::CompileArrayCodeCall(
if (cell.is_null()) {
// Get the receiver from the stack.
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the receiver isn't a smi.
__ JumpIfSmi(rdx, &miss);
@@ -1633,11 +1633,11 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
Handle<String> name,
Code::StubType type) {
// ----------- S t a t e -------------
- // -- rcx : name
- // -- rsp[0] : return address
- // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
+ // -- rcx : name
+ // -- rsp[0] : return address
+ // -- rsp[(argc - n - 1) * 8 + kPCOnStackSize] : arg[n] (zero-based)
// -- ...
- // -- rsp[(argc + 1) * 8] : receiver
+ // -- rsp[argc * 8 + kPCOnStackSize] : receiver
// -----------------------------------
// If object is not an array, bail out to regular call.
@@ -1648,7 +1648,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
// Get the receiver from the stack.
const int argc = arguments().immediate();
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the receiver isn't a smi.
__ JumpIfSmi(rdx, &miss);
@@ -1687,7 +1687,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
__ j(greater, &attempt_to_grow_elements);
// Check if value is a smi.
- __ movq(rcx, Operand(rsp, argc * kPointerSize));
+ __ movq(rcx, Operand(rsp, kPCOnStackSize + (argc - 1) * kPointerSize));
__ JumpIfNotSmi(rcx, &with_write_barrier);
// Save new length.
@@ -1722,7 +1722,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
__ cmpl(rax, rcx);
__ j(greater, &call_builtin);
- __ movq(rcx, Operand(rsp, argc * kPointerSize));
+ __ movq(rcx, Operand(rsp, kPCOnStackSize + (argc - 1) * kPointerSize));
__ StoreNumberToDoubleElements(
rcx, rdi, rax, xmm0, &call_builtin, argc * kDoubleSize);
@@ -1799,7 +1799,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
__ jmp(&call_builtin);
}
- __ movq(rbx, Operand(rsp, argc * kPointerSize));
+ __ movq(rbx, Operand(rsp, kPCOnStackSize + (argc - 1) * kPointerSize));
// Growing elements that are SMI-only requires special handling in case
// the new element is non-Smi. For now, delegate to the builtin.
Label no_fast_elements_check;
@@ -1848,7 +1848,7 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
__ RecordWrite(rdi, rdx, rbx, kDontSaveFPRegs, OMIT_REMEMBERED_SET);
// Restore receiver to rdx as finish sequence assumes it's here.
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Increment element's and array's sizes.
__ SmiAddConstant(FieldOperand(rdi, FixedArray::kLengthOffset),
@@ -1884,11 +1884,11 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
Handle<String> name,
Code::StubType type) {
// ----------- S t a t e -------------
- // -- rcx : name
- // -- rsp[0] : return address
- // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
+ // -- rcx : name
+ // -- rsp[0] : return address
+ // -- rsp[(argc - n - 1) * 8 + kPCOnStackSize] : arg[n] (zero-based)
// -- ...
- // -- rsp[(argc + 1) * 8] : receiver
+ // -- rsp[argc * 8 + kPCOnStackSize] : receiver
// -----------------------------------
// If object is not an array, bail out to regular call.
@@ -1899,7 +1899,7 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
// Get the receiver from the stack.
const int argc = arguments().immediate();
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the receiver isn't a smi.
__ JumpIfSmi(rdx, &miss);
@@ -1966,11 +1966,11 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
Handle<String> name,
Code::StubType type) {
// ----------- S t a t e -------------
- // -- rcx : function name
- // -- rsp[0] : return address
- // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
+ // -- rcx : function name
+ // -- rsp[0] : return address
+ // -- rsp[(argc - n - 1) * 8 + kPCOnStackSize] : arg[n] (zero-based)
// -- ...
- // -- rsp[(argc + 1) * 8] : receiver
+ // -- rsp[argc * 8 + kPCOnStackSize] : receiver
// -----------------------------------
// If object is not a string, bail out to regular call.
@@ -2002,9 +2002,9 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
Register receiver = rbx;
Register index = rdi;
Register result = rax;
- __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(receiver, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
if (argc > 0) {
- __ movq(index, Operand(rsp, (argc - 0) * kPointerSize));
+ __ movq(index, Operand(rsp, kPCOnStackSize + (argc - 1) * kPointerSize));
} else {
__ LoadRoot(index, Heap::kUndefinedValueRootIndex);
}
@@ -2047,11 +2047,11 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
Handle<String> name,
Code::StubType type) {
// ----------- S t a t e -------------
- // -- rcx : function name
- // -- rsp[0] : return address
- // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
+ // -- rcx : function name
+ // -- rsp[0] : return address
+ // -- rsp[(argc - n - 1) * 8 + kPCOnStackSize] : arg[n] (zero-based)
// -- ...
- // -- rsp[(argc + 1) * 8] : receiver
+ // -- rsp[argc * 8 + kPCOnStackSize] : receiver
// -----------------------------------
// If object is not a string, bail out to regular call.
@@ -2083,9 +2083,9 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
Register index = rdi;
Register scratch = rdx;
Register result = rax;
- __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(receiver, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
if (argc > 0) {
- __ movq(index, Operand(rsp, (argc - 0) * kPointerSize));
+ __ movq(index, Operand(rsp, kPCOnStackSize + (argc - 1) * kPointerSize));
} else {
__ LoadRoot(index, Heap::kUndefinedValueRootIndex);
}
@@ -2128,11 +2128,11 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
Handle<String> name,
Code::StubType type) {
// ----------- S t a t e -------------
- // -- rcx : function name
- // -- rsp[0] : return address
- // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
+ // -- rcx : function name
+ // -- rsp[0] : return address
+ // -- rsp[(argc - n - 1) * 8 + kPCOnStackSize] : arg[n] (zero-based)
// -- ...
- // -- rsp[(argc + 1) * 8] : receiver
+ // -- rsp[argc * 8 + kPCOnStackSize] : receiver
// -----------------------------------
// If the object is not a JSObject or we got an unexpected number of
@@ -2144,7 +2144,7 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
GenerateNameCheck(name, &miss);
if (cell.is_null()) {
- __ movq(rdx, Operand(rsp, 2 * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + 1 * kPointerSize));
__ JumpIfSmi(rdx, &miss);
CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi,
name, &miss);
@@ -2157,7 +2157,7 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
// Load the char code argument.
Register code = rbx;
- __ movq(code, Operand(rsp, 1 * kPointerSize));
+ __ movq(code, Operand(rsp, kPCOnStackSize));
// Check the code is a smi.
Label slow;
@@ -2212,11 +2212,11 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
Handle<String> name,
Code::StubType type) {
// ----------- S t a t e -------------
- // -- rcx : function name
- // -- rsp[0] : return address
- // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
+ // -- rcx : function name
+ // -- rsp[0] : return address
+ // -- rsp[(argc - n - 1) * 8 + kPCOnStackSize] : arg[n] (zero-based)
// -- ...
- // -- rsp[(argc + 1) * 8] : receiver
+ // -- rsp[argc * 8 + kPCOnStackSize] : receiver
// -----------------------------------
// If the object is not a JSObject or we got an unexpected number of
@@ -2228,7 +2228,7 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
GenerateNameCheck(name, &miss);
if (cell.is_null()) {
- __ movq(rdx, Operand(rsp, 2 * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + 1 * kPointerSize));
__ JumpIfSmi(rdx, &miss);
CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi,
name, &miss);
@@ -2239,7 +2239,7 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
GenerateLoadFunctionFromCell(cell, function, &miss);
}
// Load the (only) argument into rax.
- __ movq(rax, Operand(rsp, 1 * kPointerSize));
+ __ movq(rax, Operand(rsp, kPCOnStackSize));
// Check if the argument is a smi.
Label not_smi;
@@ -2332,7 +2332,7 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
// Get the receiver from the stack.
const int argc = arguments().immediate();
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the receiver isn't a smi.
__ JumpIfSmi(rdx, &miss_before_stack_reserved);
@@ -2372,20 +2372,20 @@ void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
CheckType check,
Label* success) {
// ----------- S t a t e -------------
- // rcx : function name
- // rsp[0] : return address
- // rsp[8] : argument argc
- // rsp[16] : argument argc - 1
+ // rcx : function name
+ // rsp[0] : return address
+ // rsp[8] : argument argc
+ // rsp[16] : argument argc - 1
// ...
- // rsp[argc * 8] : argument 1
- // rsp[(argc + 1) * 8] : argument 0 = receiver
+ // rsp[argc * 8] : argument 1
+ // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver
// -----------------------------------
Label miss;
GenerateNameCheck(name, &miss);
// Get the receiver from the stack.
const int argc = arguments().immediate();
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the receiver isn't a smi.
if (check != NUMBER_CHECK) {
@@ -2409,7 +2409,7 @@ void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object,
// necessary.
if (object->IsGlobalObject()) {
__ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
- __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx);
+ __ movq(Operand(rsp, kPCOnStackSize + argc * kPointerSize), rdx);
}
break;
@@ -2518,13 +2518,13 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
Handle<JSObject> holder,
Handle<Name> name) {
// ----------- S t a t e -------------
- // rcx : function name
- // rsp[0] : return address
- // rsp[8] : argument argc
- // rsp[16] : argument argc - 1
+ // rcx : function name
+ // rsp[0] : return address
+ // rsp[8] : argument argc
+ // rsp[16] : argument argc - 1
// ...
- // rsp[argc * 8] : argument 1
- // rsp[(argc + 1) * 8] : argument 0 = receiver
+ // rsp[argc * 8] : argument 1
+ // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver
// -----------------------------------
Label miss;
GenerateNameCheck(name, &miss);
@@ -2536,14 +2536,14 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
LookupPostInterceptor(holder, name, &lookup);
// Get the receiver from the stack.
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
CallInterceptorCompiler compiler(this, arguments(), rcx, extra_state_);
compiler.Compile(masm(), object, holder, name, &lookup, rdx, rbx, rdi, rax,
&miss);
// Restore receiver.
- __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
+ __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize));
// Check that the function really is a function.
__ JumpIfSmi(rax, &miss);
@@ -2554,7 +2554,7 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
// necessary.
if (object->IsGlobalObject()) {
__ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
- __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx);
+ __ movq(Operand(rsp, kPCOnStackSize + argc * kPointerSize), rdx);
}
// Invoke the function.
@@ -2581,13 +2581,13 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
Handle<JSFunction> function,
Handle<Name> name) {
// ----------- S t a t e -------------
- // rcx : function name
- // rsp[0] : return address
- // rsp[8] : argument argc
- // rsp[16] : argument argc - 1
+ // rcx : function name
+ // rsp[0] : return address
+ // rsp[8] : argument argc
+ // rsp[16] : argument argc - 1
// ...
- // rsp[argc * 8] : argument 1
- // rsp[(argc + 1) * 8] : argument 0 = receiver
+ // rsp[argc * 8] : argument 1
+ // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver
// -----------------------------------
if (HasCustomCallGenerator(function)) {
@@ -2609,7 +2609,7 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
// Patch the receiver on the stack with the global proxy.
if (object->IsGlobalObject()) {
__ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
- __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx);
+ __ movq(Operand(rsp, kPCOnStackSize + argc * kPointerSize), rdx);
}
// Set up the context (function already in rdi).
« src/x64/builtins-x64.cc ('K') | « src/x64/ic-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698