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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 1676883002: [runtime] Optimize and unify rest parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 __ bind(&done); 1975 __ bind(&done);
1976 __ Ret(); 1976 __ Ret();
1977 1977
1978 // Do the runtime call to allocate the arguments object. 1978 // Do the runtime call to allocate the arguments object.
1979 __ bind(&runtime); 1979 __ bind(&runtime);
1980 __ Push(a1, a3, a2); 1980 __ Push(a1, a3, a2);
1981 __ TailCallRuntime(Runtime::kNewStrictArguments); 1981 __ TailCallRuntime(Runtime::kNewStrictArguments);
1982 } 1982 }
1983 1983
1984 1984
1985 void RestParamAccessStub::GenerateNew(MacroAssembler* masm) {
1986 // a2 : number of parameters (tagged)
1987 // a3 : parameters pointer
1988 // a1 : rest parameter index (tagged)
1989 // Check if the calling frame is an arguments adaptor frame.
1990
1991 Label runtime;
1992 __ lw(t0, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
1993 __ lw(t1, MemOperand(t0, StandardFrameConstants::kContextOffset));
1994 __ Branch(&runtime, ne, t1,
1995 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
1996
1997 // Patch the arguments.length and the parameters pointer.
1998 __ lw(a2, MemOperand(t0, ArgumentsAdaptorFrameConstants::kLengthOffset));
1999 __ Lsa(a3, t0, a2, kPointerSizeLog2 - kSmiTagSize);
2000 __ Addu(a3, a3, Operand(StandardFrameConstants::kCallerSPOffset));
2001
2002 // Do the runtime call to allocate the arguments object.
2003 __ bind(&runtime);
2004 __ Push(a2, a3, a1);
2005 __ TailCallRuntime(Runtime::kNewRestParam);
2006 }
2007
2008
2009 void RegExpExecStub::Generate(MacroAssembler* masm) { 1985 void RegExpExecStub::Generate(MacroAssembler* masm) {
2010 // Just jump directly to runtime if native RegExp is not selected at compile 1986 // Just jump directly to runtime if native RegExp is not selected at compile
2011 // time or if regexp entry in generated code is turned off runtime switch or 1987 // time or if regexp entry in generated code is turned off runtime switch or
2012 // at compilation. 1988 // at compilation.
2013 #ifdef V8_INTERPRETED_REGEXP 1989 #ifdef V8_INTERPRETED_REGEXP
2014 __ TailCallRuntime(Runtime::kRegExpExec); 1990 __ TailCallRuntime(Runtime::kRegExpExec);
2015 #else // V8_INTERPRETED_REGEXP 1991 #else // V8_INTERPRETED_REGEXP
2016 1992
2017 // Stack frame on entry. 1993 // Stack frame on entry.
2018 // sp[0]: last_match_info (expected JSArray) 1994 // sp[0]: last_match_info (expected JSArray)
(...skipping 3139 matching lines...) Expand 10 before | Expand all | Expand 10 after
5158 5134
5159 Label fast_elements_case; 5135 Label fast_elements_case;
5160 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); 5136 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS));
5161 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5137 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5162 5138
5163 __ bind(&fast_elements_case); 5139 __ bind(&fast_elements_case);
5164 GenerateCase(masm, FAST_ELEMENTS); 5140 GenerateCase(masm, FAST_ELEMENTS);
5165 } 5141 }
5166 5142
5167 5143
5144 void FastNewRestParameterStub::Generate(MacroAssembler* masm) {
5145 // ----------- S t a t e -------------
5146 // -- a1 : function
5147 // -- cp : context
5148 // -- fp : frame pointer
5149 // -- ra : return address
5150 // -----------------------------------
5151 __ AssertFunction(a1);
5152
5153 // For Ignition we need to skip all possible handler/stub frames until
5154 // we reach the JavaScript frame for the function (similar to what the
5155 // runtime fallback implementation does). So make a2 point to that
5156 // JavaScript frame.
5157 {
5158 Label loop, loop_entry;
5159 __ Branch(USE_DELAY_SLOT, &loop_entry);
5160 __ mov(a2, fp); // In delay slot.
5161 __ bind(&loop);
5162 __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset));
5163 __ bind(&loop_entry);
5164 __ lw(a3, MemOperand(a2, StandardFrameConstants::kMarkerOffset));
5165 __ Branch(&loop, ne, a1, Operand(a3));
5166 }
5167
5168 // Check if we have rest parameters (only possible if we have an
5169 // arguments adaptor frame below the function frame).
5170 Label no_rest_parameters;
5171 __ lw(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset));
5172 __ lw(a3, MemOperand(a2, StandardFrameConstants::kContextOffset));
5173 __ Branch(&no_rest_parameters, ne, a3,
5174 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
5175
5176 // Check if the arguments adaptor frame contains more arguments than
5177 // specified by the function's internal formal parameter count.
5178 Label rest_parameters;
5179 __ lw(a0, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset));
5180 __ lw(a1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
5181 __ lw(a1,
5182 FieldMemOperand(a1, SharedFunctionInfo::kFormalParameterCountOffset));
5183 __ Subu(a0, a0, Operand(a1));
5184 __ Branch(&rest_parameters, gt, a0, Operand(zero_reg));
5185
5186 // Return an empty rest parameter array.
5187 __ bind(&no_rest_parameters);
5188 {
5189 // ----------- S t a t e -------------
5190 // -- cp : context
5191 // -- ra : return address
5192 // -----------------------------------
5193
5194 // Allocate an empty rest parameter array.
5195 Label allocate, done_allocate;
5196 __ Allocate(JSArray::kSize, v0, a0, a1, &allocate, TAG_OBJECT);
5197 __ bind(&done_allocate);
5198
5199 // Setup the rest parameter array in v0.
5200 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, a1);
5201 __ sw(a1, FieldMemOperand(v0, JSArray::kMapOffset));
5202 __ LoadRoot(a1, Heap::kEmptyFixedArrayRootIndex);
5203 __ sw(a1, FieldMemOperand(v0, JSArray::kPropertiesOffset));
5204 __ sw(a1, FieldMemOperand(v0, JSArray::kElementsOffset));
5205 __ Move(a1, Smi::FromInt(0));
5206 __ Ret(USE_DELAY_SLOT);
5207 __ sw(a1, FieldMemOperand(v0, JSArray::kLengthOffset)); // In delay slot
5208 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
5209
5210 // Fall back to %AllocateInNewSpace.
5211 __ bind(&allocate);
5212 {
5213 FrameScope scope(masm, StackFrame::INTERNAL);
5214 __ Push(Smi::FromInt(JSArray::kSize));
5215 __ CallRuntime(Runtime::kAllocateInNewSpace);
5216 }
5217 __ jmp(&done_allocate);
5218 }
5219
5220 __ bind(&rest_parameters);
5221 {
5222 // Compute the pointer to the first rest parameter (skippping the receiver).
5223 __ Lsa(a2, a2, a0, kPointerSizeLog2 - 1);
5224 __ Addu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset -
5225 1 * kPointerSize));
5226
5227 // ----------- S t a t e -------------
5228 // -- cp : context
5229 // -- a0 : number of rest parameters (tagged)
5230 // -- a2 : pointer to first rest parameters
5231 // -- ra : return address
5232 // -----------------------------------
5233
5234 // Allocate space for the rest parameter array plus the backing store.
5235 Label allocate, done_allocate;
5236 __ li(a1, Operand(JSArray::kSize + FixedArray::kHeaderSize));
5237 __ Lsa(a1, a1, a0, kPointerSizeLog2 - 1);
5238 __ Allocate(a1, v0, a3, at, &allocate, TAG_OBJECT);
5239 __ bind(&done_allocate);
5240
5241 // Setup the elements array in v0.
5242 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex);
5243 __ sw(at, FieldMemOperand(v0, FixedArray::kMapOffset));
5244 __ sw(a0, FieldMemOperand(v0, FixedArray::kLengthOffset));
5245 __ Addu(a3, v0, Operand(FixedArray::kHeaderSize));
5246 {
5247 Label loop, done_loop;
5248 __ sll(at, a0, kPointerSizeLog2 - 1);
5249 __ Addu(a1, a3, at);
5250 __ bind(&loop);
5251 __ Branch(&done_loop, eq, a1, Operand(a3));
5252 __ lw(at, MemOperand(a2, 0 * kPointerSize));
5253 __ sw(at, FieldMemOperand(a3, 0 * kPointerSize));
5254 __ Subu(a2, a2, Operand(1 * kPointerSize));
5255 __ Addu(a3, a3, Operand(1 * kPointerSize));
5256 __ b(&loop);
5257 __ bind(&done_loop);
5258 }
5259
5260 // Setup the rest parameter array in a3.
5261 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, at);
5262 __ sw(at, FieldMemOperand(a3, JSArray::kMapOffset));
5263 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex);
5264 __ sw(at, FieldMemOperand(a3, JSArray::kPropertiesOffset));
5265 __ sw(v0, FieldMemOperand(a3, JSArray::kElementsOffset));
5266 __ sw(a0, FieldMemOperand(a3, JSArray::kLengthOffset));
5267 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize);
5268 __ Ret(USE_DELAY_SLOT);
5269 __ mov(v0, a3); // In delay slot
5270
5271 // Fall back to %AllocateInNewSpace.
5272 __ bind(&allocate);
5273 {
5274 FrameScope scope(masm, StackFrame::INTERNAL);
5275 __ SmiTag(a1);
5276 __ Push(a0, a2, a1);
5277 __ CallRuntime(Runtime::kAllocateInNewSpace);
5278 __ Pop(a0, a2);
5279 }
5280 __ jmp(&done_allocate);
5281 }
5282 }
5283
5284
5168 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { 5285 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
5169 Register context_reg = cp; 5286 Register context_reg = cp;
5170 Register slot_reg = a2; 5287 Register slot_reg = a2;
5171 Register result_reg = v0; 5288 Register result_reg = v0;
5172 Label slow_case; 5289 Label slow_case;
5173 5290
5174 // Go up context chain to the script context. 5291 // Go up context chain to the script context.
5175 for (int i = 0; i < depth(); ++i) { 5292 for (int i = 0; i < depth(); ++i) {
5176 __ lw(result_reg, ContextMemOperand(context_reg, Context::PREVIOUS_INDEX)); 5293 __ lw(result_reg, ContextMemOperand(context_reg, Context::PREVIOUS_INDEX));
5177 context_reg = result_reg; 5294 context_reg = result_reg;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
5616 return_value_operand, NULL); 5733 return_value_operand, NULL);
5617 } 5734 }
5618 5735
5619 5736
5620 #undef __ 5737 #undef __
5621 5738
5622 } // namespace internal 5739 } // namespace internal
5623 } // namespace v8 5740 } // namespace v8
5624 5741
5625 #endif // V8_TARGET_ARCH_MIPS 5742 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698