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/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // Run the native code for the Array function called as a normal function. | 134 // Run the native code for the Array function called as a normal function. |
135 // Tail call a stub. | 135 // Tail call a stub. |
136 __ mov(a3, a1); | 136 __ mov(a3, a1); |
137 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 137 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
138 ArrayConstructorStub stub(masm->isolate()); | 138 ArrayConstructorStub stub(masm->isolate()); |
139 __ TailCallStub(&stub); | 139 __ TailCallStub(&stub); |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 // static | 143 // static |
| 144 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
| 145 // ----------- S t a t e ------------- |
| 146 // -- a0 : number of arguments |
| 147 // -- a1 : constructor function |
| 148 // -- ra : return address |
| 149 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
| 150 // -- sp[argc * 8] : receiver |
| 151 // ----------------------------------- |
| 152 |
| 153 // 1. Load the first argument into a0 and get rid of the rest (including the |
| 154 // receiver). |
| 155 Label no_arguments; |
| 156 { |
| 157 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
| 158 __ Dsubu(a0, a0, Operand(1)); |
| 159 __ dsll(a0, a0, kPointerSizeLog2); |
| 160 __ Daddu(sp, a0, sp); |
| 161 __ ld(a0, MemOperand(sp)); |
| 162 __ Drop(2); |
| 163 } |
| 164 |
| 165 // 2a. Convert first argument to number. |
| 166 ToNumberStub stub(masm->isolate()); |
| 167 __ TailCallStub(&stub); |
| 168 |
| 169 // 2b. No arguments, return +0. |
| 170 __ bind(&no_arguments); |
| 171 __ Move(v0, Smi::FromInt(0)); |
| 172 __ DropAndRet(1); |
| 173 } |
| 174 |
| 175 |
| 176 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
| 177 // ----------- S t a t e ------------- |
| 178 // -- a0 : number of arguments |
| 179 // -- a1 : constructor function |
| 180 // -- a3 : new target |
| 181 // -- ra : return address |
| 182 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
| 183 // -- sp[argc * 8] : receiver |
| 184 // ----------------------------------- |
| 185 |
| 186 // 1. Make sure we operate in the context of the called function. |
| 187 __ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 188 |
| 189 // 2. Load the first argument into a0 and get rid of the rest (including the |
| 190 // receiver). |
| 191 { |
| 192 Label no_arguments, done; |
| 193 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
| 194 __ Dsubu(a0, a0, Operand(1)); |
| 195 __ dsll(a0, a0, kPointerSizeLog2); |
| 196 __ Daddu(sp, a0, sp); |
| 197 __ ld(a0, MemOperand(sp)); |
| 198 __ Drop(2); |
| 199 __ jmp(&done); |
| 200 __ bind(&no_arguments); |
| 201 __ Move(a0, Smi::FromInt(0)); |
| 202 __ Drop(1); |
| 203 __ bind(&done); |
| 204 } |
| 205 |
| 206 // 3. Make sure a0 is a number. |
| 207 { |
| 208 Label done_convert; |
| 209 __ JumpIfSmi(a0, &done_convert); |
| 210 __ GetObjectType(a0, a2, a2); |
| 211 __ Branch(&done_convert, eq, t0, Operand(HEAP_NUMBER_TYPE)); |
| 212 { |
| 213 FrameScope scope(masm, StackFrame::INTERNAL); |
| 214 __ Push(a1, a3); |
| 215 ToNumberStub stub(masm->isolate()); |
| 216 __ CallStub(&stub); |
| 217 __ Move(a0, v0); |
| 218 __ Pop(a1, a3); |
| 219 } |
| 220 __ bind(&done_convert); |
| 221 } |
| 222 |
| 223 // 4. Check if new target and constructor differ. |
| 224 Label new_object; |
| 225 __ Branch(&new_object, ne, a1, Operand(a3)); |
| 226 |
| 227 // 5. Allocate a JSValue wrapper for the number. |
| 228 __ AllocateJSValue(v0, a1, a0, a2, t0, &new_object); |
| 229 __ Ret(); |
| 230 |
| 231 // 6. Fallback to the runtime to create new object. |
| 232 __ bind(&new_object); |
| 233 { |
| 234 FrameScope scope(masm, StackFrame::INTERNAL); |
| 235 __ Push(a0, a1, a3); // first argument, constructor, new target |
| 236 __ CallRuntime(Runtime::kNewObject); |
| 237 __ Pop(a0); |
| 238 } |
| 239 __ Ret(USE_DELAY_SLOT); |
| 240 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); // In delay slot. |
| 241 } |
| 242 |
| 243 |
| 244 // static |
144 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { | 245 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { |
145 // ----------- S t a t e ------------- | 246 // ----------- S t a t e ------------- |
146 // -- a0 : number of arguments | 247 // -- a0 : number of arguments |
147 // -- a1 : constructor function | 248 // -- a1 : constructor function |
148 // -- ra : return address | 249 // -- ra : return address |
149 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 250 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
150 // -- sp[argc * 8] : receiver | 251 // -- sp[argc * 8] : receiver |
151 // ----------------------------------- | 252 // ----------------------------------- |
152 | 253 |
153 // 1. Load the first argument into a0 and get rid of the rest (including the | 254 // 1. Load the first argument into a0 and get rid of the rest (including the |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { | 303 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
203 // ----------- S t a t e ------------- | 304 // ----------- S t a t e ------------- |
204 // -- a0 : number of arguments | 305 // -- a0 : number of arguments |
205 // -- a1 : constructor function | 306 // -- a1 : constructor function |
206 // -- a3 : new target | 307 // -- a3 : new target |
207 // -- ra : return address | 308 // -- ra : return address |
208 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 309 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
209 // -- sp[argc * 8] : receiver | 310 // -- sp[argc * 8] : receiver |
210 // ----------------------------------- | 311 // ----------------------------------- |
211 | 312 |
212 // 1. Load the first argument into a0 and get rid of the rest (including the | 313 // 1. Make sure we operate in the context of the called function. |
| 314 __ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 315 |
| 316 // 2. Load the first argument into a0 and get rid of the rest (including the |
213 // receiver). | 317 // receiver). |
214 { | 318 { |
215 Label no_arguments, done; | 319 Label no_arguments, done; |
216 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); | 320 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
217 __ Dsubu(a0, a0, Operand(1)); | 321 __ Dsubu(a0, a0, Operand(1)); |
218 __ dsll(a0, a0, kPointerSizeLog2); | 322 __ dsll(a0, a0, kPointerSizeLog2); |
219 __ Daddu(sp, a0, sp); | 323 __ Daddu(sp, a0, sp); |
220 __ ld(a0, MemOperand(sp)); | 324 __ ld(a0, MemOperand(sp)); |
221 __ Drop(2); | 325 __ Drop(2); |
222 __ jmp(&done); | 326 __ jmp(&done); |
223 __ bind(&no_arguments); | 327 __ bind(&no_arguments); |
224 __ LoadRoot(a0, Heap::kempty_stringRootIndex); | 328 __ LoadRoot(a0, Heap::kempty_stringRootIndex); |
225 __ Drop(1); | 329 __ Drop(1); |
226 __ bind(&done); | 330 __ bind(&done); |
227 } | 331 } |
228 | 332 |
229 // 2. Make sure a0 is a string. | 333 // 3. Make sure a0 is a string. |
230 { | 334 { |
231 Label convert, done_convert; | 335 Label convert, done_convert; |
232 __ JumpIfSmi(a0, &convert); | 336 __ JumpIfSmi(a0, &convert); |
233 __ GetObjectType(a0, a2, a2); | 337 __ GetObjectType(a0, a2, a2); |
234 __ And(t0, a2, Operand(kIsNotStringMask)); | 338 __ And(t0, a2, Operand(kIsNotStringMask)); |
235 __ Branch(&done_convert, eq, t0, Operand(zero_reg)); | 339 __ Branch(&done_convert, eq, t0, Operand(zero_reg)); |
236 __ bind(&convert); | 340 __ bind(&convert); |
237 { | 341 { |
238 FrameScope scope(masm, StackFrame::INTERNAL); | 342 FrameScope scope(masm, StackFrame::INTERNAL); |
239 ToStringStub stub(masm->isolate()); | 343 ToStringStub stub(masm->isolate()); |
240 __ Push(a1, a3); | 344 __ Push(a1, a3); |
241 __ CallStub(&stub); | 345 __ CallStub(&stub); |
242 __ Move(a0, v0); | 346 __ Move(a0, v0); |
243 __ Pop(a1, a3); | 347 __ Pop(a1, a3); |
244 } | 348 } |
245 __ bind(&done_convert); | 349 __ bind(&done_convert); |
246 } | 350 } |
247 | 351 |
248 // 3. Check if new target and constructor differ. | 352 // 4. Check if new target and constructor differ. |
249 Label new_object; | 353 Label new_object; |
250 __ Branch(&new_object, ne, a1, Operand(a3)); | 354 __ Branch(&new_object, ne, a1, Operand(a3)); |
251 | 355 |
252 // 4. Allocate a JSValue wrapper for the string. | 356 // 5. Allocate a JSValue wrapper for the string. |
253 { | 357 __ AllocateJSValue(v0, a1, a0, a2, t0, &new_object); |
254 // ----------- S t a t e ------------- | 358 __ Ret(); |
255 // -- a0 : the first argument | |
256 // -- a1 : constructor function | |
257 // -- a3 : new target | |
258 // -- ra : return address | |
259 // ----------------------------------- | |
260 __ Allocate(JSValue::kSize, v0, a2, t0, &new_object, TAG_OBJECT); | |
261 | 359 |
262 // Initialize the JSValue in eax. | 360 // 6. Fallback to the runtime to create new object. |
263 __ LoadGlobalFunctionInitialMap(a1, a2, a3); | |
264 __ sd(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); | |
265 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); | |
266 __ sd(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); | |
267 __ sd(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); | |
268 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); | |
269 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | |
270 __ Ret(); | |
271 } | |
272 | |
273 // 5. Fallback to the runtime to create new object. | |
274 __ bind(&new_object); | 361 __ bind(&new_object); |
275 { | 362 { |
276 FrameScope scope(masm, StackFrame::INTERNAL); | 363 FrameScope scope(masm, StackFrame::INTERNAL); |
277 __ Push(a0, a1, a3); // first argument, constructor, new target | 364 __ Push(a0, a1, a3); // first argument, constructor, new target |
278 __ CallRuntime(Runtime::kNewObject); | 365 __ CallRuntime(Runtime::kNewObject); |
279 __ Pop(a0); | 366 __ Pop(a0); |
280 } | 367 } |
281 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); | 368 __ Ret(USE_DELAY_SLOT); |
282 __ Ret(); | 369 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); // In delay slot. |
283 } | 370 } |
284 | 371 |
285 | 372 |
286 static void CallRuntimePassFunction( | 373 static void CallRuntimePassFunction( |
287 MacroAssembler* masm, Runtime::FunctionId function_id) { | 374 MacroAssembler* masm, Runtime::FunctionId function_id) { |
288 // ----------- S t a t e ------------- | 375 // ----------- S t a t e ------------- |
289 // -- a1 : target function (preserved for callee) | 376 // -- a1 : target function (preserved for callee) |
290 // -- a3 : new target (preserved for callee) | 377 // -- a3 : new target (preserved for callee) |
291 // ----------------------------------- | 378 // ----------------------------------- |
292 | 379 |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 } | 2527 } |
2441 } | 2528 } |
2442 | 2529 |
2443 | 2530 |
2444 #undef __ | 2531 #undef __ |
2445 | 2532 |
2446 } // namespace internal | 2533 } // namespace internal |
2447 } // namespace v8 | 2534 } // namespace v8 |
2448 | 2535 |
2449 #endif // V8_TARGET_ARCH_MIPS64 | 2536 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |