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

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 174522: Use stack frame marker constants to mark arguments adaptor frame. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 __ test(edi, Immediate(kSmiTagMask)); 2132 __ test(edi, Immediate(kSmiTagMask));
2133 build_args.Branch(zero); 2133 build_args.Branch(zero);
2134 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2134 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2135 build_args.Branch(not_equal); 2135 build_args.Branch(not_equal);
2136 2136
2137 // Copy the arguments to this function possibly from the 2137 // Copy the arguments to this function possibly from the
2138 // adaptor frame below it. 2138 // adaptor frame below it.
2139 Label invoke, adapted; 2139 Label invoke, adapted;
2140 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 2140 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2141 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); 2141 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
2142 __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); 2142 __ cmp(Operand(ecx),
2143 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
2143 __ j(equal, &adapted); 2144 __ j(equal, &adapted);
2144 2145
2145 // No arguments adaptor frame. Copy fixed number of arguments. 2146 // No arguments adaptor frame. Copy fixed number of arguments.
2146 __ mov(eax, Immediate(scope_->num_parameters())); 2147 __ mov(eax, Immediate(scope_->num_parameters()));
2147 for (int i = 0; i < scope_->num_parameters(); i++) { 2148 for (int i = 0; i < scope_->num_parameters(); i++) {
2148 __ push(frame_->ParameterAt(i)); 2149 __ push(frame_->ParameterAt(i));
2149 } 2150 }
2150 __ jmp(&invoke); 2151 __ jmp(&invoke);
2151 2152
2152 // Arguments adaptor frame present. Copy arguments from there, but 2153 // Arguments adaptor frame present. Copy arguments from there, but
(...skipping 2752 matching lines...) Expand 10 before | Expand all | Expand 10 after
4905 void CodeGenerator::GenerateIsConstructCall(ZoneList<Expression*>* args) { 4906 void CodeGenerator::GenerateIsConstructCall(ZoneList<Expression*>* args) {
4906 ASSERT(args->length() == 0); 4907 ASSERT(args->length() == 0);
4907 4908
4908 // Get the frame pointer for the calling frame. 4909 // Get the frame pointer for the calling frame.
4909 Result fp = allocator()->Allocate(); 4910 Result fp = allocator()->Allocate();
4910 __ mov(fp.reg(), Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 4911 __ mov(fp.reg(), Operand(ebp, StandardFrameConstants::kCallerFPOffset));
4911 4912
4912 // Skip the arguments adaptor frame if it exists. 4913 // Skip the arguments adaptor frame if it exists.
4913 Label check_frame_marker; 4914 Label check_frame_marker;
4914 __ cmp(Operand(fp.reg(), StandardFrameConstants::kContextOffset), 4915 __ cmp(Operand(fp.reg(), StandardFrameConstants::kContextOffset),
4915 Immediate(ArgumentsAdaptorFrame::SENTINEL)); 4916 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
4916 __ j(not_equal, &check_frame_marker); 4917 __ j(not_equal, &check_frame_marker);
4917 __ mov(fp.reg(), Operand(fp.reg(), StandardFrameConstants::kCallerFPOffset)); 4918 __ mov(fp.reg(), Operand(fp.reg(), StandardFrameConstants::kCallerFPOffset));
4918 4919
4919 // Check the marker in the calling frame. 4920 // Check the marker in the calling frame.
4920 __ bind(&check_frame_marker); 4921 __ bind(&check_frame_marker);
4921 __ cmp(Operand(fp.reg(), StandardFrameConstants::kMarkerOffset), 4922 __ cmp(Operand(fp.reg(), StandardFrameConstants::kMarkerOffset),
4922 Immediate(Smi::FromInt(StackFrame::CONSTRUCT))); 4923 Immediate(Smi::FromInt(StackFrame::CONSTRUCT)));
4923 fp.Unuse(); 4924 fp.Unuse();
4924 destination()->Split(equal); 4925 destination()->Split(equal);
4925 } 4926 }
(...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after
7102 7103
7103 __ StubReturn(1); 7104 __ StubReturn(1);
7104 } 7105 }
7105 7106
7106 7107
7107 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) { 7108 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) {
7108 // Check if the calling frame is an arguments adaptor frame. 7109 // Check if the calling frame is an arguments adaptor frame.
7109 Label adaptor; 7110 Label adaptor;
7110 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 7111 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
7111 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); 7112 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
7112 __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); 7113 __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
7113 __ j(equal, &adaptor); 7114 __ j(equal, &adaptor);
7114 7115
7115 // Nothing to do: The formal number of parameters has already been 7116 // Nothing to do: The formal number of parameters has already been
7116 // passed in register eax by calling function. Just return it. 7117 // passed in register eax by calling function. Just return it.
7117 __ ret(0); 7118 __ ret(0);
7118 7119
7119 // Arguments adaptor case: Read the arguments length from the 7120 // Arguments adaptor case: Read the arguments length from the
7120 // adaptor frame and return it. 7121 // adaptor frame and return it.
7121 __ bind(&adaptor); 7122 __ bind(&adaptor);
7122 __ mov(eax, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); 7123 __ mov(eax, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
(...skipping 11 matching lines...) Expand all
7134 7135
7135 // Check that the key is a smi. 7136 // Check that the key is a smi.
7136 Label slow; 7137 Label slow;
7137 __ test(edx, Immediate(kSmiTagMask)); 7138 __ test(edx, Immediate(kSmiTagMask));
7138 __ j(not_zero, &slow, not_taken); 7139 __ j(not_zero, &slow, not_taken);
7139 7140
7140 // Check if the calling frame is an arguments adaptor frame. 7141 // Check if the calling frame is an arguments adaptor frame.
7141 Label adaptor; 7142 Label adaptor;
7142 __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 7143 __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
7143 __ mov(ecx, Operand(ebx, StandardFrameConstants::kContextOffset)); 7144 __ mov(ecx, Operand(ebx, StandardFrameConstants::kContextOffset));
7144 __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); 7145 __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
7145 __ j(equal, &adaptor); 7146 __ j(equal, &adaptor);
7146 7147
7147 // Check index against formal parameters count limit passed in 7148 // Check index against formal parameters count limit passed in
7148 // through register eax. Use unsigned comparison to get negative 7149 // through register eax. Use unsigned comparison to get negative
7149 // check for free. 7150 // check for free.
7150 __ cmp(edx, Operand(eax)); 7151 __ cmp(edx, Operand(eax));
7151 __ j(above_equal, &slow, not_taken); 7152 __ j(above_equal, &slow, not_taken);
7152 7153
7153 // Read the argument from the stack and return it. 7154 // Read the argument from the stack and return it.
7154 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this 7155 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this
(...skipping 30 matching lines...) Expand all
7185 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { 7186 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
7186 // The displacement is used for skipping the return address and the 7187 // The displacement is used for skipping the return address and the
7187 // frame pointer on the stack. It is the offset of the last 7188 // frame pointer on the stack. It is the offset of the last
7188 // parameter (if any) relative to the frame pointer. 7189 // parameter (if any) relative to the frame pointer.
7189 static const int kDisplacement = 2 * kPointerSize; 7190 static const int kDisplacement = 2 * kPointerSize;
7190 7191
7191 // Check if the calling frame is an arguments adaptor frame. 7192 // Check if the calling frame is an arguments adaptor frame.
7192 Label runtime; 7193 Label runtime;
7193 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 7194 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
7194 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); 7195 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
7195 __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); 7196 __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
7196 __ j(not_equal, &runtime); 7197 __ j(not_equal, &runtime);
7197 7198
7198 // Patch the arguments.length and the parameters pointer. 7199 // Patch the arguments.length and the parameters pointer.
7199 __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); 7200 __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
7200 __ mov(Operand(esp, 1 * kPointerSize), ecx); 7201 __ mov(Operand(esp, 1 * kPointerSize), ecx);
7201 __ lea(edx, Operand(edx, ecx, times_2, kDisplacement)); 7202 __ lea(edx, Operand(edx, ecx, times_2, kDisplacement));
7202 __ mov(Operand(esp, 2 * kPointerSize), edx); 7203 __ mov(Operand(esp, 2 * kPointerSize), edx);
7203 7204
7204 // Do the runtime call to allocate the arguments object. 7205 // Do the runtime call to allocate the arguments object.
7205 __ bind(&runtime); 7206 __ bind(&runtime);
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
7717 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { 7718 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
7718 Label invoke, exit; 7719 Label invoke, exit;
7719 #ifdef ENABLE_LOGGING_AND_PROFILING 7720 #ifdef ENABLE_LOGGING_AND_PROFILING
7720 Label not_outermost_js, not_outermost_js_2; 7721 Label not_outermost_js, not_outermost_js_2;
7721 #endif 7722 #endif
7722 7723
7723 // Setup frame. 7724 // Setup frame.
7724 __ push(ebp); 7725 __ push(ebp);
7725 __ mov(ebp, Operand(esp)); 7726 __ mov(ebp, Operand(esp));
7726 7727
7728 // Push marker in two places.
7729 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY;
7730 __ push(Immediate(Smi::FromInt(marker))); // context slot
7731 __ push(Immediate(Smi::FromInt(marker))); // function slot
7727 // Save callee-saved registers (C calling conventions). 7732 // Save callee-saved registers (C calling conventions).
7728 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY;
7729 // Push something that is not an arguments adaptor.
7730 __ push(Immediate(~ArgumentsAdaptorFrame::SENTINEL));
7731 __ push(Immediate(Smi::FromInt(marker))); // @ function offset
7732 __ push(edi); 7733 __ push(edi);
7733 __ push(esi); 7734 __ push(esi);
7734 __ push(ebx); 7735 __ push(ebx);
7735 7736
7736 // Save copies of the top frame descriptor on the stack. 7737 // Save copies of the top frame descriptor on the stack.
7737 ExternalReference c_entry_fp(Top::k_c_entry_fp_address); 7738 ExternalReference c_entry_fp(Top::k_c_entry_fp_address);
7738 __ push(Operand::StaticVariable(c_entry_fp)); 7739 __ push(Operand::StaticVariable(c_entry_fp));
7739 7740
7740 #ifdef ENABLE_LOGGING_AND_PROFILING 7741 #ifdef ENABLE_LOGGING_AND_PROFILING
7741 // If this is the outermost JS call, set js_entry_sp value. 7742 // If this is the outermost JS call, set js_entry_sp value.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
7872 7873
7873 int CompareStub::MinorKey() { 7874 int CompareStub::MinorKey() {
7874 // Encode the two parameters in a unique 16 bit value. 7875 // Encode the two parameters in a unique 16 bit value.
7875 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 7876 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
7876 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 7877 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
7877 } 7878 }
7878 7879
7879 #undef __ 7880 #undef __
7880 7881
7881 } } // namespace v8::internal 7882 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698