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 | 5 |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 __ Branch(&ok, hs, sp, Operand(t0)); | 308 __ Branch(&ok, hs, sp, Operand(t0)); |
309 | 309 |
310 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 310 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
311 GenerateTailCallToReturnedCode(masm); | 311 GenerateTailCallToReturnedCode(masm); |
312 | 312 |
313 __ bind(&ok); | 313 __ bind(&ok); |
314 GenerateTailCallToSharedCode(masm); | 314 GenerateTailCallToSharedCode(masm); |
315 } | 315 } |
316 | 316 |
317 | 317 |
| 318 static void Generate_Runtime_NewObject(MacroAssembler* masm, |
| 319 bool create_memento, |
| 320 Register original_constructor, |
| 321 Label* count_incremented, |
| 322 Label* allocated) { |
| 323 if (create_memento) { |
| 324 // Get the cell or allocation site. |
| 325 __ lw(a2, MemOperand(sp, 2 * kPointerSize)); |
| 326 __ push(a2); |
| 327 } |
| 328 |
| 329 __ push(a1); // argument for Runtime_NewObject |
| 330 __ push(original_constructor); // original constructor |
| 331 if (create_memento) { |
| 332 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
| 333 } else { |
| 334 __ CallRuntime(Runtime::kNewObject, 2); |
| 335 } |
| 336 __ mov(t4, v0); |
| 337 |
| 338 // Runtime_NewObjectWithAllocationSite increments allocation count. |
| 339 // Skip the increment. |
| 340 if (create_memento) { |
| 341 __ jmp(count_incremented); |
| 342 } else { |
| 343 __ jmp(allocated); |
| 344 } |
| 345 } |
| 346 |
| 347 |
318 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 348 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
319 bool is_api_function, | 349 bool is_api_function, |
320 bool create_memento) { | 350 bool create_memento) { |
321 // ----------- S t a t e ------------- | 351 // ----------- S t a t e ------------- |
322 // -- a0 : number of arguments | 352 // -- a0 : number of arguments |
323 // -- a1 : constructor function | 353 // -- a1 : constructor function |
324 // -- a2 : allocation site or undefined | 354 // -- a2 : allocation site or undefined |
| 355 // -- a3 : original constructor |
325 // -- ra : return address | 356 // -- ra : return address |
326 // -- sp[...]: constructor arguments | 357 // -- sp[...]: constructor arguments |
327 // ----------------------------------- | 358 // ----------------------------------- |
328 | 359 |
329 // Should never create mementos for api functions. | 360 // Should never create mementos for api functions. |
330 DCHECK(!is_api_function || !create_memento); | 361 DCHECK(!is_api_function || !create_memento); |
331 | 362 |
332 Isolate* isolate = masm->isolate(); | 363 Isolate* isolate = masm->isolate(); |
333 | 364 |
334 // ----------- S t a t e ------------- | 365 // ----------- S t a t e ------------- |
335 // -- a0 : number of arguments | 366 // -- a0 : number of arguments |
336 // -- a1 : constructor function | 367 // -- a1 : constructor function |
337 // -- ra : return address | 368 // -- ra : return address |
338 // -- sp[...]: constructor arguments | 369 // -- sp[...]: constructor arguments |
339 // ----------------------------------- | 370 // ----------------------------------- |
340 | 371 |
341 // Enter a construct frame. | 372 // Enter a construct frame. |
342 { | 373 { |
343 FrameScope scope(masm, StackFrame::CONSTRUCT); | 374 FrameScope scope(masm, StackFrame::CONSTRUCT); |
344 | 375 |
345 if (create_memento) { | 376 if (create_memento) { |
346 __ AssertUndefinedOrAllocationSite(a2, a3); | 377 __ AssertUndefinedOrAllocationSite(a2, t0); |
347 __ push(a2); | 378 __ push(a2); |
348 } | 379 } |
349 | 380 |
350 // Preserve the two incoming parameters on the stack. | 381 // Preserve the two incoming parameters on the stack. |
351 __ sll(a0, a0, kSmiTagSize); // Tag arguments count. | 382 __ sll(a0, a0, kSmiTagSize); // Tag arguments count. |
352 __ MultiPushReversed(a0.bit() | a1.bit()); | 383 __ MultiPushReversed(a0.bit() | a1.bit()); |
353 | 384 |
354 Label rt_call, allocated; | 385 Label rt_call, allocated, normal_new, count_incremented; |
| 386 __ Branch(&normal_new, eq, a1, Operand(a3)); |
| 387 |
| 388 // Original constructor and function are different. |
| 389 Generate_Runtime_NewObject(masm, create_memento, a3, &count_incremented, |
| 390 &allocated); |
| 391 __ bind(&normal_new); |
| 392 |
355 // Try to allocate the object without transitioning into C code. If any of | 393 // Try to allocate the object without transitioning into C code. If any of |
356 // the preconditions is not met, the code bails out to the runtime call. | 394 // the preconditions is not met, the code bails out to the runtime call. |
357 if (FLAG_inline_new) { | 395 if (FLAG_inline_new) { |
358 Label undo_allocation; | 396 Label undo_allocation; |
359 ExternalReference debug_step_in_fp = | 397 ExternalReference debug_step_in_fp = |
360 ExternalReference::debug_step_in_fp_address(isolate); | 398 ExternalReference::debug_step_in_fp_address(isolate); |
361 __ li(a2, Operand(debug_step_in_fp)); | 399 __ li(a2, Operand(debug_step_in_fp)); |
362 __ lw(a2, MemOperand(a2)); | 400 __ lw(a2, MemOperand(a2)); |
363 __ Branch(&rt_call, ne, a2, Operand(zero_reg)); | 401 __ Branch(&rt_call, ne, a2, Operand(zero_reg)); |
364 | 402 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // example, the map's unused properties potentially do not match the | 621 // example, the map's unused properties potentially do not match the |
584 // allocated objects unused properties. | 622 // allocated objects unused properties. |
585 // t4: JSObject (previous new top) | 623 // t4: JSObject (previous new top) |
586 __ bind(&undo_allocation); | 624 __ bind(&undo_allocation); |
587 __ UndoAllocationInNewSpace(t4, t5); | 625 __ UndoAllocationInNewSpace(t4, t5); |
588 } | 626 } |
589 | 627 |
590 // Allocate the new receiver object using the runtime call. | 628 // Allocate the new receiver object using the runtime call. |
591 // a1: constructor function | 629 // a1: constructor function |
592 __ bind(&rt_call); | 630 __ bind(&rt_call); |
593 if (create_memento) { | 631 Generate_Runtime_NewObject(masm, create_memento, a1, &count_incremented, |
594 // Get the cell or allocation site. | 632 &allocated); |
595 __ lw(a2, MemOperand(sp, 2 * kPointerSize)); | |
596 __ push(a2); | |
597 } | |
598 | |
599 __ push(a1); // Argument for Runtime_NewObject. | |
600 if (create_memento) { | |
601 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2); | |
602 } else { | |
603 __ CallRuntime(Runtime::kNewObject, 1); | |
604 } | |
605 __ mov(t4, v0); | |
606 | |
607 // If we ended up using the runtime, and we want a memento, then the | |
608 // runtime call made it for us, and we shouldn't do create count | |
609 // increment. | |
610 Label count_incremented; | |
611 if (create_memento) { | |
612 __ jmp(&count_incremented); | |
613 } | |
614 | 633 |
615 // Receiver for constructor call allocated. | 634 // Receiver for constructor call allocated. |
616 // t4: JSObject | 635 // t4: JSObject |
617 __ bind(&allocated); | 636 __ bind(&allocated); |
618 | 637 |
619 if (create_memento) { | 638 if (create_memento) { |
620 __ lw(a2, MemOperand(sp, kPointerSize * 2)); | 639 __ lw(a2, MemOperand(sp, kPointerSize * 2)); |
621 __ LoadRoot(t5, Heap::kUndefinedValueRootIndex); | 640 __ LoadRoot(t5, Heap::kUndefinedValueRootIndex); |
622 __ Branch(&count_incremented, eq, a2, Operand(t5)); | 641 __ Branch(&count_incremented, eq, a2, Operand(t5)); |
623 // a2 is an AllocationSite. We are creating a memento from it, so we | 642 // a2 is an AllocationSite. We are creating a memento from it, so we |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 __ break_(0xCC); | 1589 __ break_(0xCC); |
1571 } | 1590 } |
1572 } | 1591 } |
1573 | 1592 |
1574 | 1593 |
1575 #undef __ | 1594 #undef __ |
1576 | 1595 |
1577 } } // namespace v8::internal | 1596 } } // namespace v8::internal |
1578 | 1597 |
1579 #endif // V8_TARGET_ARCH_MIPS | 1598 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |