OLD | NEW |
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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 __ bind(&done); | 1980 __ bind(&done); |
1981 __ Ret(); | 1981 __ Ret(); |
1982 | 1982 |
1983 // Do the runtime call to allocate the arguments object. | 1983 // Do the runtime call to allocate the arguments object. |
1984 __ bind(&runtime); | 1984 __ bind(&runtime); |
1985 __ Push(a1, a3, a2); | 1985 __ Push(a1, a3, a2); |
1986 __ TailCallRuntime(Runtime::kNewStrictArguments); | 1986 __ TailCallRuntime(Runtime::kNewStrictArguments); |
1987 } | 1987 } |
1988 | 1988 |
1989 | 1989 |
1990 void RestParamAccessStub::GenerateNew(MacroAssembler* masm) { | |
1991 // a2 : number of parameters (tagged) | |
1992 // a3 : parameters pointer | |
1993 // a4 : rest parameter index (tagged) | |
1994 // Check if the calling frame is an arguments adaptor frame. | |
1995 | |
1996 Label runtime; | |
1997 __ ld(a0, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | |
1998 __ ld(a5, MemOperand(a0, StandardFrameConstants::kContextOffset)); | |
1999 __ Branch(&runtime, ne, a5, | |
2000 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | |
2001 | |
2002 // Patch the arguments.length and the parameters pointer. | |
2003 __ ld(a2, MemOperand(a0, ArgumentsAdaptorFrameConstants::kLengthOffset)); | |
2004 __ SmiScale(at, a2, kPointerSizeLog2); | |
2005 | |
2006 __ Daddu(a3, a0, Operand(at)); | |
2007 __ Daddu(a3, a3, Operand(StandardFrameConstants::kCallerSPOffset)); | |
2008 | |
2009 // Do the runtime call to allocate the arguments object. | |
2010 __ bind(&runtime); | |
2011 __ Push(a2, a3, a4); | |
2012 __ TailCallRuntime(Runtime::kNewRestParam); | |
2013 } | |
2014 | |
2015 | |
2016 void RegExpExecStub::Generate(MacroAssembler* masm) { | 1990 void RegExpExecStub::Generate(MacroAssembler* masm) { |
2017 // Just jump directly to runtime if native RegExp is not selected at compile | 1991 // Just jump directly to runtime if native RegExp is not selected at compile |
2018 // time or if regexp entry in generated code is turned off runtime switch or | 1992 // time or if regexp entry in generated code is turned off runtime switch or |
2019 // at compilation. | 1993 // at compilation. |
2020 #ifdef V8_INTERPRETED_REGEXP | 1994 #ifdef V8_INTERPRETED_REGEXP |
2021 __ TailCallRuntime(Runtime::kRegExpExec); | 1995 __ TailCallRuntime(Runtime::kRegExpExec); |
2022 #else // V8_INTERPRETED_REGEXP | 1996 #else // V8_INTERPRETED_REGEXP |
2023 | 1997 |
2024 // Stack frame on entry. | 1998 // Stack frame on entry. |
2025 // sp[0]: last_match_info (expected JSArray) | 1999 // sp[0]: last_match_info (expected JSArray) |
(...skipping 3149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5175 | 5149 |
5176 Label fast_elements_case; | 5150 Label fast_elements_case; |
5177 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); | 5151 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); |
5178 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 5152 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
5179 | 5153 |
5180 __ bind(&fast_elements_case); | 5154 __ bind(&fast_elements_case); |
5181 GenerateCase(masm, FAST_ELEMENTS); | 5155 GenerateCase(masm, FAST_ELEMENTS); |
5182 } | 5156 } |
5183 | 5157 |
5184 | 5158 |
| 5159 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
| 5160 // ----------- S t a t e ------------- |
| 5161 // -- a1 : function |
| 5162 // -- cp : context |
| 5163 // -- fp : frame pointer |
| 5164 // -- ra : return address |
| 5165 // ----------------------------------- |
| 5166 __ AssertFunction(a1); |
| 5167 |
| 5168 // For Ignition we need to skip all possible handler/stub frames until |
| 5169 // we reach the JavaScript frame for the function (similar to what the |
| 5170 // runtime fallback implementation does). So make a2 point to that |
| 5171 // JavaScript frame. |
| 5172 { |
| 5173 Label loop, loop_entry; |
| 5174 __ Branch(USE_DELAY_SLOT, &loop_entry); |
| 5175 __ mov(a2, fp); // In delay slot. |
| 5176 __ bind(&loop); |
| 5177 __ ld(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); |
| 5178 __ bind(&loop_entry); |
| 5179 __ ld(a3, MemOperand(a2, StandardFrameConstants::kMarkerOffset)); |
| 5180 __ Branch(&loop, ne, a1, Operand(a3)); |
| 5181 } |
| 5182 |
| 5183 // Check if we have rest parameters (only possible if we have an |
| 5184 // arguments adaptor frame below the function frame). |
| 5185 Label no_rest_parameters; |
| 5186 __ ld(a2, MemOperand(a2, StandardFrameConstants::kCallerFPOffset)); |
| 5187 __ ld(a3, MemOperand(a2, StandardFrameConstants::kContextOffset)); |
| 5188 __ Branch(&no_rest_parameters, ne, a3, |
| 5189 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 5190 |
| 5191 // Check if the arguments adaptor frame contains more arguments than |
| 5192 // specified by the function's internal formal parameter count. |
| 5193 Label rest_parameters; |
| 5194 __ SmiLoadUntag( |
| 5195 a0, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 5196 __ ld(a1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
| 5197 __ lw(a1, |
| 5198 FieldMemOperand(a1, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 5199 __ Dsubu(a0, a0, Operand(a1)); |
| 5200 __ Branch(&rest_parameters, gt, a0, Operand(zero_reg)); |
| 5201 |
| 5202 // Return an empty rest parameter array. |
| 5203 __ bind(&no_rest_parameters); |
| 5204 { |
| 5205 // ----------- S t a t e ------------- |
| 5206 // -- cp : context |
| 5207 // -- ra : return address |
| 5208 // ----------------------------------- |
| 5209 |
| 5210 // Allocate an empty rest parameter array. |
| 5211 Label allocate, done_allocate; |
| 5212 __ Allocate(JSArray::kSize, v0, a0, a1, &allocate, TAG_OBJECT); |
| 5213 __ bind(&done_allocate); |
| 5214 |
| 5215 // Setup the rest parameter array in v0. |
| 5216 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, a1); |
| 5217 __ sd(a1, FieldMemOperand(v0, JSArray::kMapOffset)); |
| 5218 __ LoadRoot(a1, Heap::kEmptyFixedArrayRootIndex); |
| 5219 __ sd(a1, FieldMemOperand(v0, JSArray::kPropertiesOffset)); |
| 5220 __ sd(a1, FieldMemOperand(v0, JSArray::kElementsOffset)); |
| 5221 __ Move(a1, Smi::FromInt(0)); |
| 5222 __ Ret(USE_DELAY_SLOT); |
| 5223 __ sd(a1, FieldMemOperand(v0, JSArray::kLengthOffset)); // In delay slot |
| 5224 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
| 5225 |
| 5226 // Fall back to %AllocateInNewSpace. |
| 5227 __ bind(&allocate); |
| 5228 { |
| 5229 FrameScope scope(masm, StackFrame::INTERNAL); |
| 5230 __ Push(Smi::FromInt(JSArray::kSize)); |
| 5231 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 5232 } |
| 5233 __ jmp(&done_allocate); |
| 5234 } |
| 5235 |
| 5236 __ bind(&rest_parameters); |
| 5237 { |
| 5238 // Compute the pointer to the first rest parameter (skippping the receiver). |
| 5239 __ Dlsa(a2, a2, a0, kPointerSizeLog2); |
| 5240 __ Daddu(a2, a2, Operand(StandardFrameConstants::kCallerSPOffset - |
| 5241 1 * kPointerSize)); |
| 5242 |
| 5243 // ----------- S t a t e ------------- |
| 5244 // -- cp : context |
| 5245 // -- a0 : number of rest parameters |
| 5246 // -- a2 : pointer to first rest parameters |
| 5247 // -- ra : return address |
| 5248 // ----------------------------------- |
| 5249 |
| 5250 // Allocate space for the rest parameter array plus the backing store. |
| 5251 Label allocate, done_allocate; |
| 5252 __ li(a1, Operand(JSArray::kSize + FixedArray::kHeaderSize)); |
| 5253 __ Dlsa(a1, a1, a0, kPointerSizeLog2); |
| 5254 __ Allocate(a1, v0, a3, at, &allocate, TAG_OBJECT); |
| 5255 __ bind(&done_allocate); |
| 5256 |
| 5257 // Compute arguments.length in a4. |
| 5258 __ SmiTag(a4, a0); |
| 5259 |
| 5260 // Setup the elements array in v0. |
| 5261 __ LoadRoot(at, Heap::kFixedArrayMapRootIndex); |
| 5262 __ sd(at, FieldMemOperand(v0, FixedArray::kMapOffset)); |
| 5263 __ sd(a4, FieldMemOperand(v0, FixedArray::kLengthOffset)); |
| 5264 __ Daddu(a3, v0, Operand(FixedArray::kHeaderSize)); |
| 5265 { |
| 5266 Label loop, done_loop; |
| 5267 __ Dlsa(a1, a3, a0, kPointerSizeLog2); |
| 5268 __ bind(&loop); |
| 5269 __ Branch(&done_loop, eq, a1, Operand(a3)); |
| 5270 __ ld(at, MemOperand(a2, 0 * kPointerSize)); |
| 5271 __ sd(at, FieldMemOperand(a3, 0 * kPointerSize)); |
| 5272 __ Dsubu(a2, a2, Operand(1 * kPointerSize)); |
| 5273 __ Daddu(a3, a3, Operand(1 * kPointerSize)); |
| 5274 __ b(&loop); |
| 5275 __ bind(&done_loop); |
| 5276 } |
| 5277 |
| 5278 // Setup the rest parameter array in a3. |
| 5279 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, at); |
| 5280 __ sd(at, FieldMemOperand(a3, JSArray::kMapOffset)); |
| 5281 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); |
| 5282 __ sd(at, FieldMemOperand(a3, JSArray::kPropertiesOffset)); |
| 5283 __ sd(v0, FieldMemOperand(a3, JSArray::kElementsOffset)); |
| 5284 __ sd(a4, FieldMemOperand(a3, JSArray::kLengthOffset)); |
| 5285 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
| 5286 __ Ret(USE_DELAY_SLOT); |
| 5287 __ mov(v0, a3); // In delay slot |
| 5288 |
| 5289 // Fall back to %AllocateInNewSpace. |
| 5290 __ bind(&allocate); |
| 5291 { |
| 5292 FrameScope scope(masm, StackFrame::INTERNAL); |
| 5293 __ SmiTag(a0); |
| 5294 __ SmiTag(a1); |
| 5295 __ Push(a0, a2, a1); |
| 5296 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 5297 __ Pop(a0, a2); |
| 5298 __ SmiUntag(a0); |
| 5299 } |
| 5300 __ jmp(&done_allocate); |
| 5301 } |
| 5302 } |
| 5303 |
| 5304 |
5185 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { | 5305 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
5186 Register context_reg = cp; | 5306 Register context_reg = cp; |
5187 Register slot_reg = a2; | 5307 Register slot_reg = a2; |
5188 Register result_reg = v0; | 5308 Register result_reg = v0; |
5189 Label slow_case; | 5309 Label slow_case; |
5190 | 5310 |
5191 // Go up context chain to the script context. | 5311 // Go up context chain to the script context. |
5192 for (int i = 0; i < depth(); ++i) { | 5312 for (int i = 0; i < depth(); ++i) { |
5193 __ ld(result_reg, ContextMemOperand(context_reg, Context::PREVIOUS_INDEX)); | 5313 __ ld(result_reg, ContextMemOperand(context_reg, Context::PREVIOUS_INDEX)); |
5194 context_reg = result_reg; | 5314 context_reg = result_reg; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5639 return_value_operand, NULL); | 5759 return_value_operand, NULL); |
5640 } | 5760 } |
5641 | 5761 |
5642 | 5762 |
5643 #undef __ | 5763 #undef __ |
5644 | 5764 |
5645 } // namespace internal | 5765 } // namespace internal |
5646 } // namespace v8 | 5766 } // namespace v8 |
5647 | 5767 |
5648 #endif // V8_TARGET_ARCH_MIPS64 | 5768 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |