From 48d1e49262a700430a4a2b9a6253026147ee5191 Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Thu, 27 Aug 2009 07:44:37 +0000 Subject: [PATCH] Use stack frame marker constants to mark arguments adaptor frame. Review URL: http://codereview.chromium.org/174522 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2770 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/builtins-arm.cc | 2 +- src/arm/codegen-arm.cc | 12 ++++++------ src/frames-inl.h | 5 +++-- src/frames.h | 9 --------- src/ia32/builtins-ia32.cc | 2 +- src/ia32/codegen-ia32.cc | 19 ++++++++++--------- src/x64/builtins-x64.cc | 2 +- src/x64/codegen-x64.cc | 16 ++++++++-------- src/x64/frames-x64.h | 2 ++ 9 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc index 5745a06e8..daf2378eb 100644 --- a/src/arm/builtins-arm.cc +++ b/src/arm/builtins-arm.cc @@ -573,7 +573,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { __ mov(r0, Operand(r0, LSL, kSmiTagSize)); - __ mov(r4, Operand(ArgumentsAdaptorFrame::SENTINEL)); + __ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | fp.bit() | lr.bit()); __ add(fp, sp, Operand(3 * kPointerSize)); } diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index f98458b9b..5c8b77700 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -3324,7 +3324,7 @@ void CodeGenerator::GenerateIsConstructCall(ZoneList* args) { // Skip the arguments adaptor frame if it exists. Label check_frame_marker; __ ldr(r1, MemOperand(r2, StandardFrameConstants::kContextOffset)); - __ cmp(r1, Operand(ArgumentsAdaptorFrame::SENTINEL)); + __ cmp(r1, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ b(ne, &check_frame_marker); __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset)); @@ -5980,9 +5980,9 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { // r2: receiver // r3: argc // r4: argv - int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; __ mov(r8, Operand(-1)); // Push a bad frame pointer to fail if it is used. - __ mov(r7, Operand(~ArgumentsAdaptorFrame::SENTINEL)); + int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; + __ mov(r7, Operand(Smi::FromInt(marker))); __ mov(r6, Operand(Smi::FromInt(marker))); __ mov(r5, Operand(ExternalReference(Top::k_c_entry_fp_address))); __ ldr(r5, MemOperand(r5)); @@ -6139,7 +6139,7 @@ void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) { Label adaptor; __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); - __ cmp(r3, Operand(ArgumentsAdaptorFrame::SENTINEL)); + __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ b(eq, &adaptor); // Nothing to do: The formal number of parameters has already been @@ -6168,7 +6168,7 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { Label adaptor; __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); - __ cmp(r3, Operand(ArgumentsAdaptorFrame::SENTINEL)); + __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ b(eq, &adaptor); // Check index against formal parameters count limit passed in @@ -6210,7 +6210,7 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { Label runtime; __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); - __ cmp(r3, Operand(ArgumentsAdaptorFrame::SENTINEL)); + __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ b(ne, &runtime); // Patch the arguments.length and the parameters pointer. diff --git a/src/frames-inl.h b/src/frames-inl.h index b04cf506d..c5f2f1a33 100644 --- a/src/frames-inl.h +++ b/src/frames-inl.h @@ -128,8 +128,9 @@ inline Address StandardFrame::ComputePCAddress(Address fp) { inline bool StandardFrame::IsArgumentsAdaptorFrame(Address fp) { - int context = Memory::int_at(fp + StandardFrameConstants::kContextOffset); - return context == ArgumentsAdaptorFrame::SENTINEL; + Object* marker = + Memory::Object_at(fp + StandardFrameConstants::kContextOffset); + return marker == Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR); } diff --git a/src/frames.h b/src/frames.h index f002e1216..768196d3c 100644 --- a/src/frames.h +++ b/src/frames.h @@ -434,15 +434,6 @@ class JavaScriptFrame: public StandardFrame { // match the formal number of parameters. class ArgumentsAdaptorFrame: public JavaScriptFrame { public: - // This sentinel value is temporarily used to distinguish arguments - // adaptor frames from ordinary JavaScript frames. If a frame has - // the sentinel as its context, it is an arguments adaptor frame. It - // must be tagged as a small integer to avoid GC issues. Crud. - enum { - SENTINEL = (1 << kSmiTagSize) | kSmiTag, - NON_SENTINEL = ~SENTINEL - }; - virtual Type type() const { return ARGUMENTS_ADAPTOR; } // Determine the code for the frame. diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc index e679d855c..ad83fe454 100644 --- a/src/ia32/builtins-ia32.cc +++ b/src/ia32/builtins-ia32.cc @@ -669,7 +669,7 @@ static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { __ mov(ebp, Operand(esp)); // Store the arguments adaptor context sentinel. - __ push(Immediate(ArgumentsAdaptorFrame::SENTINEL)); + __ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); // Push the function on the stack. __ push(edi); diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index bf1f81b13..8ce84fb1b 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -2139,7 +2139,8 @@ void CodeGenerator::CallApplyLazy(Property* apply, Label invoke, adapted; __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); - __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); + __ cmp(Operand(ecx), + Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(equal, &adapted); // No arguments adaptor frame. Copy fixed number of arguments. @@ -4912,7 +4913,7 @@ void CodeGenerator::GenerateIsConstructCall(ZoneList* args) { // Skip the arguments adaptor frame if it exists. Label check_frame_marker; __ cmp(Operand(fp.reg(), StandardFrameConstants::kContextOffset), - Immediate(ArgumentsAdaptorFrame::SENTINEL)); + Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(not_equal, &check_frame_marker); __ mov(fp.reg(), Operand(fp.reg(), StandardFrameConstants::kCallerFPOffset)); @@ -7109,7 +7110,7 @@ void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) { Label adaptor; __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); - __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); + __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(equal, &adaptor); // Nothing to do: The formal number of parameters has already been @@ -7141,7 +7142,7 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { Label adaptor; __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); __ mov(ecx, Operand(ebx, StandardFrameConstants::kContextOffset)); - __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); + __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(equal, &adaptor); // Check index against formal parameters count limit passed in @@ -7192,7 +7193,7 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { Label runtime; __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); - __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); + __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(not_equal, &runtime); // Patch the arguments.length and the parameters pointer. @@ -7724,11 +7725,11 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { __ push(ebp); __ mov(ebp, Operand(esp)); - // Save callee-saved registers (C calling conventions). + // Push marker in two places. int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; - // Push something that is not an arguments adaptor. - __ push(Immediate(~ArgumentsAdaptorFrame::SENTINEL)); - __ push(Immediate(Smi::FromInt(marker))); // @ function offset + __ push(Immediate(Smi::FromInt(marker))); // context slot + __ push(Immediate(Smi::FromInt(marker))); // function slot + // Save callee-saved registers (C calling conventions). __ push(edi); __ push(esi); __ push(ebx); diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 52791546d..6d10ee59c 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -53,7 +53,7 @@ static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { __ movq(rbp, rsp); // Store the arguments adaptor context sentinel. - __ push(Immediate(ArgumentsAdaptorFrame::SENTINEL)); + __ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); // Push the function on the stack. __ push(rdi); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index e59237be6..67667c11e 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -3473,7 +3473,7 @@ void CodeGenerator::GenerateIsConstructCall(ZoneList* args) { // Skip the arguments adaptor frame if it exists. Label check_frame_marker; __ cmpq(Operand(fp.reg(), StandardFrameConstants::kContextOffset), - Immediate(ArgumentsAdaptorFrame::SENTINEL)); + Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(not_equal, &check_frame_marker); __ movq(fp.reg(), Operand(fp.reg(), StandardFrameConstants::kCallerFPOffset)); @@ -6618,7 +6618,7 @@ void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { Label runtime; __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); __ movq(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); - __ cmpq(rcx, Immediate(ArgumentsAdaptorFrame::SENTINEL)); + __ cmpq(rcx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(not_equal, &runtime); // Value in rcx is Smi encoded. @@ -6651,7 +6651,7 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { Label adaptor; __ movq(rbx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); __ movq(rcx, Operand(rbx, StandardFrameConstants::kContextOffset)); - __ cmpq(rcx, Immediate(ArgumentsAdaptorFrame::SENTINEL)); + __ cmpq(rcx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(equal, &adaptor); // Check index against formal parameters count limit passed in @@ -6701,7 +6701,7 @@ void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) { Label adaptor; __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); __ movq(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); - __ cmpq(rcx, Immediate(ArgumentsAdaptorFrame::SENTINEL)); + __ cmpq(rcx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); __ j(equal, &adaptor); // Nothing to do: The formal number of parameters has already been @@ -7015,11 +7015,11 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { __ push(rbp); __ movq(rbp, rsp); - // Save callee-saved registers (X64 calling conventions). + // Push the stack frame type marker twice. int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; - // Push something that is not an arguments adaptor. - __ push(Immediate(ArgumentsAdaptorFrame::NON_SENTINEL)); - __ push(Immediate(Smi::FromInt(marker))); // @ function offset + __ push(Immediate(Smi::FromInt(marker))); // context slot + __ push(Immediate(Smi::FromInt(marker))); // function slot + // Save callee-saved registers (X64 calling conventions). __ push(r12); __ push(r13); __ push(r14); diff --git a/src/x64/frames-x64.h b/src/x64/frames-x64.h index 0ec667d29..d1e9c148c 100644 --- a/src/x64/frames-x64.h +++ b/src/x64/frames-x64.h @@ -92,10 +92,12 @@ class StandardFrameConstants : public AllStatic { class JavaScriptFrameConstants : public AllStatic { public: + // FP-relative. static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; static const int kSavedRegistersOffset = +2 * kPointerSize; static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; + // Caller SP-relative. static const int kParam0Offset = -2 * kPointerSize; static const int kReceiverOffset = -1 * kPointerSize; }; -- 2.34.1