OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 // Return. | 1961 // Return. |
1962 __ Ret(); | 1962 __ Ret(); |
1963 | 1963 |
1964 // Do the runtime call to allocate the arguments object. | 1964 // Do the runtime call to allocate the arguments object. |
1965 __ bind(&runtime); | 1965 __ bind(&runtime); |
1966 __ Push(r4, r6, r5); | 1966 __ Push(r4, r6, r5); |
1967 __ TailCallRuntime(Runtime::kNewStrictArguments); | 1967 __ TailCallRuntime(Runtime::kNewStrictArguments); |
1968 } | 1968 } |
1969 | 1969 |
1970 | 1970 |
1971 void RestParamAccessStub::GenerateNew(MacroAssembler* masm) { | |
1972 // r5 : number of parameters (tagged) | |
1973 // r6 : parameters pointer | |
1974 // r7 : rest parameter index (tagged) | |
1975 | |
1976 Label runtime; | |
1977 __ LoadP(r8, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | |
1978 __ LoadP(r3, MemOperand(r8, StandardFrameConstants::kContextOffset)); | |
1979 __ CmpSmiLiteral(r3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); | |
1980 __ bne(&runtime); | |
1981 | |
1982 // Patch the arguments.length and the parameters pointer. | |
1983 __ LoadP(r5, MemOperand(r8, ArgumentsAdaptorFrameConstants::kLengthOffset)); | |
1984 __ SmiToPtrArrayOffset(r0, r5); | |
1985 __ add(r6, r8, r0); | |
1986 __ addi(r6, r6, Operand(StandardFrameConstants::kCallerSPOffset)); | |
1987 | |
1988 __ bind(&runtime); | |
1989 __ Push(r5, r6, r7); | |
1990 __ TailCallRuntime(Runtime::kNewRestParam); | |
1991 } | |
1992 | |
1993 | |
1994 void RegExpExecStub::Generate(MacroAssembler* masm) { | 1971 void RegExpExecStub::Generate(MacroAssembler* masm) { |
1995 // Just jump directly to runtime if native RegExp is not selected at compile | 1972 // Just jump directly to runtime if native RegExp is not selected at compile |
1996 // time or if regexp entry in generated code is turned off runtime switch or | 1973 // time or if regexp entry in generated code is turned off runtime switch or |
1997 // at compilation. | 1974 // at compilation. |
1998 #ifdef V8_INTERPRETED_REGEXP | 1975 #ifdef V8_INTERPRETED_REGEXP |
1999 __ TailCallRuntime(Runtime::kRegExpExec); | 1976 __ TailCallRuntime(Runtime::kRegExpExec); |
2000 #else // V8_INTERPRETED_REGEXP | 1977 #else // V8_INTERPRETED_REGEXP |
2001 | 1978 |
2002 // Stack frame on entry. | 1979 // Stack frame on entry. |
2003 // sp[0]: last_match_info (expected JSArray) | 1980 // sp[0]: last_match_info (expected JSArray) |
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5149 | 5126 |
5150 Label fast_elements_case; | 5127 Label fast_elements_case; |
5151 __ cmpi(r6, Operand(FAST_ELEMENTS)); | 5128 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
5152 __ beq(&fast_elements_case); | 5129 __ beq(&fast_elements_case); |
5153 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 5130 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
5154 | 5131 |
5155 __ bind(&fast_elements_case); | 5132 __ bind(&fast_elements_case); |
5156 GenerateCase(masm, FAST_ELEMENTS); | 5133 GenerateCase(masm, FAST_ELEMENTS); |
5157 } | 5134 } |
5158 | 5135 |
| 5136 void FastNewRestParameterStub::Generate(MacroAssembler* masm) { |
| 5137 // ----------- S t a t e ------------- |
| 5138 // -- r4 : function |
| 5139 // -- cp : context |
| 5140 // -- fp : frame pointer |
| 5141 // -- lr : return address |
| 5142 // ----------------------------------- |
| 5143 __ AssertFunction(r4); |
| 5144 |
| 5145 // For Ignition we need to skip all possible handler/stub frames until |
| 5146 // we reach the JavaScript frame for the function (similar to what the |
| 5147 // runtime fallback implementation does). So make r5 point to that |
| 5148 // JavaScript frame. |
| 5149 { |
| 5150 Label loop, loop_entry; |
| 5151 __ mr(r5, fp); |
| 5152 __ b(&loop_entry); |
| 5153 __ bind(&loop); |
| 5154 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); |
| 5155 __ bind(&loop_entry); |
| 5156 __ LoadP(ip, MemOperand(r5, StandardFrameConstants::kMarkerOffset)); |
| 5157 __ cmp(ip, r4); |
| 5158 __ bne(&loop); |
| 5159 } |
| 5160 |
| 5161 // Check if we have rest parameters (only possible if we have an |
| 5162 // arguments adaptor frame below the function frame). |
| 5163 Label no_rest_parameters; |
| 5164 __ LoadP(r5, MemOperand(r5, StandardFrameConstants::kCallerFPOffset)); |
| 5165 __ LoadP(ip, MemOperand(r5, StandardFrameConstants::kContextOffset)); |
| 5166 __ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 5167 __ bne(&no_rest_parameters); |
| 5168 |
| 5169 // Check if the arguments adaptor frame contains more arguments than |
| 5170 // specified by the function's internal formal parameter count. |
| 5171 Label rest_parameters; |
| 5172 __ LoadP(r3, MemOperand(r5, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 5173 __ LoadP(r4, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 5174 __ LoadWordArith( |
| 5175 r4, FieldMemOperand(r4, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 5176 #if V8_TARGET_ARCH_PPC64 |
| 5177 __ SmiTag(r4); |
| 5178 #endif |
| 5179 __ sub(r3, r3, r4, LeaveOE, SetRC); |
| 5180 __ bgt(&rest_parameters, cr0); |
| 5181 |
| 5182 // Return an empty rest parameter array. |
| 5183 __ bind(&no_rest_parameters); |
| 5184 { |
| 5185 // ----------- S t a t e ------------- |
| 5186 // -- cp : context |
| 5187 // -- lr : return address |
| 5188 // ----------------------------------- |
| 5189 |
| 5190 // Allocate an empty rest parameter array. |
| 5191 Label allocate, done_allocate; |
| 5192 __ Allocate(JSArray::kSize, r3, r4, r5, &allocate, TAG_OBJECT); |
| 5193 __ bind(&done_allocate); |
| 5194 |
| 5195 // Setup the rest parameter array in r0. |
| 5196 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r4); |
| 5197 __ StoreP(r4, FieldMemOperand(r3, JSArray::kMapOffset), r0); |
| 5198 __ LoadRoot(r4, Heap::kEmptyFixedArrayRootIndex); |
| 5199 __ StoreP(r4, FieldMemOperand(r3, JSArray::kPropertiesOffset), r0); |
| 5200 __ StoreP(r4, FieldMemOperand(r3, JSArray::kElementsOffset), r0); |
| 5201 __ li(r4, Operand::Zero()); |
| 5202 __ StoreP(r4, FieldMemOperand(r3, JSArray::kLengthOffset), r0); |
| 5203 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
| 5204 __ Ret(); |
| 5205 |
| 5206 // Fall back to %AllocateInNewSpace. |
| 5207 __ bind(&allocate); |
| 5208 { |
| 5209 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 5210 __ Push(Smi::FromInt(JSArray::kSize)); |
| 5211 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 5212 } |
| 5213 __ b(&done_allocate); |
| 5214 } |
| 5215 |
| 5216 __ bind(&rest_parameters); |
| 5217 { |
| 5218 // Compute the pointer to the first rest parameter (skippping the receiver). |
| 5219 __ SmiToPtrArrayOffset(r9, r3); |
| 5220 __ add(r5, r5, r9); |
| 5221 __ addi(r5, r5, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 5222 |
| 5223 // ----------- S t a t e ------------- |
| 5224 // -- cp : context |
| 5225 // -- r3 : number of rest parameters (tagged) |
| 5226 // -- r5 : pointer just past first rest parameters |
| 5227 // -- r9 : size of rest parameters |
| 5228 // -- lr : return address |
| 5229 // ----------------------------------- |
| 5230 |
| 5231 // Allocate space for the rest parameter array plus the backing store. |
| 5232 Label allocate, done_allocate; |
| 5233 __ mov(r4, Operand(JSArray::kSize + FixedArray::kHeaderSize)); |
| 5234 __ add(r4, r4, r9); |
| 5235 __ Allocate(r4, r6, r7, r8, &allocate, TAG_OBJECT); |
| 5236 __ bind(&done_allocate); |
| 5237 |
| 5238 // Setup the elements array in r6. |
| 5239 __ LoadRoot(r4, Heap::kFixedArrayMapRootIndex); |
| 5240 __ StoreP(r4, FieldMemOperand(r6, FixedArray::kMapOffset), r0); |
| 5241 __ StoreP(r3, FieldMemOperand(r6, FixedArray::kLengthOffset), r0); |
| 5242 __ addi(r7, r6, |
| 5243 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); |
| 5244 { |
| 5245 Label loop; |
| 5246 __ SmiUntag(r0, r3); |
| 5247 __ mtctr(r0); |
| 5248 __ bind(&loop); |
| 5249 __ LoadPU(ip, MemOperand(r5, -kPointerSize)); |
| 5250 __ StorePU(ip, MemOperand(r7, kPointerSize)); |
| 5251 __ bdnz(&loop); |
| 5252 __ addi(r7, r7, Operand(kPointerSize)); |
| 5253 } |
| 5254 |
| 5255 // Setup the rest parameter array in r7. |
| 5256 __ LoadNativeContextSlot(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, r4); |
| 5257 __ StoreP(r4, MemOperand(r7, JSArray::kMapOffset)); |
| 5258 __ LoadRoot(r4, Heap::kEmptyFixedArrayRootIndex); |
| 5259 __ StoreP(r4, MemOperand(r7, JSArray::kPropertiesOffset)); |
| 5260 __ StoreP(r6, MemOperand(r7, JSArray::kElementsOffset)); |
| 5261 __ StoreP(r3, MemOperand(r7, JSArray::kLengthOffset)); |
| 5262 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
| 5263 __ addi(r3, r7, Operand(kHeapObjectTag)); |
| 5264 __ Ret(); |
| 5265 |
| 5266 // Fall back to %AllocateInNewSpace. |
| 5267 __ bind(&allocate); |
| 5268 { |
| 5269 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 5270 __ SmiTag(r4); |
| 5271 __ Push(r3, r5, r9, r4); |
| 5272 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 5273 __ mr(r6, r3); |
| 5274 __ Pop(r3, r5, r9); |
| 5275 } |
| 5276 __ b(&done_allocate); |
| 5277 } |
| 5278 } |
5159 | 5279 |
5160 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { | 5280 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
5161 Register context = cp; | 5281 Register context = cp; |
5162 Register result = r3; | 5282 Register result = r3; |
5163 Register slot = r5; | 5283 Register slot = r5; |
5164 | 5284 |
5165 // Go up the context chain to the script context. | 5285 // Go up the context chain to the script context. |
5166 for (int i = 0; i < depth(); ++i) { | 5286 for (int i = 0; i < depth(); ++i) { |
5167 __ LoadP(result, ContextMemOperand(context, Context::PREVIOUS_INDEX)); | 5287 __ LoadP(result, ContextMemOperand(context, Context::PREVIOUS_INDEX)); |
5168 context = result; | 5288 context = result; |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5678 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5798 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5679 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5799 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5680 } | 5800 } |
5681 | 5801 |
5682 | 5802 |
5683 #undef __ | 5803 #undef __ |
5684 } // namespace internal | 5804 } // namespace internal |
5685 } // namespace v8 | 5805 } // namespace v8 |
5686 | 5806 |
5687 #endif // V8_TARGET_ARCH_PPC | 5807 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |