| 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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 322 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
| 323 GenerateTailCallToReturnedCode(masm); | 323 GenerateTailCallToReturnedCode(masm); |
| 324 | 324 |
| 325 __ bind(&ok); | 325 __ bind(&ok); |
| 326 GenerateTailCallToSharedCode(masm); | 326 GenerateTailCallToSharedCode(masm); |
| 327 } | 327 } |
| 328 | 328 |
| 329 | 329 |
| 330 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 330 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 331 bool is_api_function, | 331 bool is_api_function) { |
| 332 bool create_memento) { | |
| 333 // ----------- S t a t e ------------- | 332 // ----------- S t a t e ------------- |
| 334 // -- a0 : number of arguments | 333 // -- a0 : number of arguments |
| 335 // -- a1 : constructor function | 334 // -- a1 : constructor function |
| 336 // -- a2 : allocation site or undefined | 335 // -- a2 : allocation site or undefined |
| 337 // -- a3 : original constructor | 336 // -- a3 : original constructor |
| 338 // -- ra : return address | 337 // -- ra : return address |
| 339 // -- sp[...]: constructor arguments | 338 // -- sp[...]: constructor arguments |
| 340 // ----------------------------------- | 339 // ----------------------------------- |
| 341 | 340 |
| 342 // Should never create mementos for api functions. | |
| 343 DCHECK(!is_api_function || !create_memento); | |
| 344 | |
| 345 Isolate* isolate = masm->isolate(); | 341 Isolate* isolate = masm->isolate(); |
| 346 | 342 |
| 347 // Enter a construct frame. | 343 // Enter a construct frame. |
| 348 { | 344 { |
| 349 FrameScope scope(masm, StackFrame::CONSTRUCT); | 345 FrameScope scope(masm, StackFrame::CONSTRUCT); |
| 350 | 346 |
| 351 // Preserve the incoming parameters on the stack. | 347 // Preserve the incoming parameters on the stack. |
| 352 __ AssertUndefinedOrAllocationSite(a2, t0); | 348 __ AssertUndefinedOrAllocationSite(a2, t0); |
| 353 __ SmiTag(a0); | 349 __ SmiTag(a0); |
| 354 __ Push(a2, a0, a1, a3); | 350 __ Push(a2, a0, a1, a3); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 __ li(t2, Operand(Map::kSlackTrackingCounterEnd - 1)); | 397 __ li(t2, Operand(Map::kSlackTrackingCounterEnd - 1)); |
| 402 | 398 |
| 403 __ bind(&allocate); | 399 __ bind(&allocate); |
| 404 } | 400 } |
| 405 | 401 |
| 406 // Now allocate the JSObject on the heap. | 402 // Now allocate the JSObject on the heap. |
| 407 // a1: constructor function | 403 // a1: constructor function |
| 408 // a2: initial map | 404 // a2: initial map |
| 409 Label rt_call_reload_new_target; | 405 Label rt_call_reload_new_target; |
| 410 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); | 406 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); |
| 411 if (create_memento) { | |
| 412 __ Addu(a3, a3, Operand(AllocationMemento::kSize / kPointerSize)); | |
| 413 } | |
| 414 | 407 |
| 415 __ Allocate(a3, t4, t5, t6, &rt_call_reload_new_target, SIZE_IN_WORDS); | 408 __ Allocate(a3, t4, t5, t6, &rt_call_reload_new_target, SIZE_IN_WORDS); |
| 416 | 409 |
| 417 // Allocated the JSObject, now initialize the fields. Map is set to | 410 // Allocated the JSObject, now initialize the fields. Map is set to |
| 418 // initial map and properties and elements are set to empty fixed array. | 411 // initial map and properties and elements are set to empty fixed array. |
| 419 // a1: constructor function | 412 // a1: constructor function |
| 420 // a2: initial map | 413 // a2: initial map |
| 421 // a3: object size (including memento if create_memento) | 414 // a3: object size |
| 422 // t4: JSObject (not tagged) | 415 // t4: JSObject (not tagged) |
| 423 __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex); | 416 __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex); |
| 424 __ mov(t5, t4); | 417 __ mov(t5, t4); |
| 425 __ sw(a2, MemOperand(t5, JSObject::kMapOffset)); | 418 __ sw(a2, MemOperand(t5, JSObject::kMapOffset)); |
| 426 __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset)); | 419 __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset)); |
| 427 __ sw(t6, MemOperand(t5, JSObject::kElementsOffset)); | 420 __ sw(t6, MemOperand(t5, JSObject::kElementsOffset)); |
| 428 __ Addu(t5, t5, Operand(3*kPointerSize)); | 421 __ Addu(t5, t5, Operand(3*kPointerSize)); |
| 429 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); | 422 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); |
| 430 DCHECK_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); | 423 DCHECK_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); |
| 431 DCHECK_EQ(2 * kPointerSize, JSObject::kElementsOffset); | 424 DCHECK_EQ(2 * kPointerSize, JSObject::kElementsOffset); |
| 432 | 425 |
| 433 // Fill all the in-object properties with appropriate filler. | 426 // Fill all the in-object properties with appropriate filler. |
| 434 // a1: constructor function | 427 // a1: constructor function |
| 435 // a2: initial map | 428 // a2: initial map |
| 436 // a3: object size (in words, including memento if create_memento) | 429 // a3: object size (in words) |
| 437 // t4: JSObject (not tagged) | 430 // t4: JSObject (not tagged) |
| 438 // t5: First in-object property of JSObject (not tagged) | 431 // t5: First in-object property of JSObject (not tagged) |
| 439 // t2: slack tracking counter (non-API function case) | 432 // t2: slack tracking counter (non-API function case) |
| 440 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); | 433 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
| 441 | 434 |
| 442 // Use t7 to hold undefined, which is used in several places below. | 435 // Use t7 to hold undefined, which is used in several places below. |
| 443 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); | 436 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); |
| 444 | 437 |
| 445 if (!is_api_function) { | 438 if (!is_api_function) { |
| 446 Label no_inobject_slack_tracking; | 439 Label no_inobject_slack_tracking; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 466 a0, Operand(t6)); | 459 a0, Operand(t6)); |
| 467 } | 460 } |
| 468 __ InitializeFieldsWithFiller(t5, a0, t7); | 461 __ InitializeFieldsWithFiller(t5, a0, t7); |
| 469 // To allow for truncation. | 462 // To allow for truncation. |
| 470 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); | 463 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); |
| 471 // Fill the remaining fields with one pointer filler map. | 464 // Fill the remaining fields with one pointer filler map. |
| 472 | 465 |
| 473 __ bind(&no_inobject_slack_tracking); | 466 __ bind(&no_inobject_slack_tracking); |
| 474 } | 467 } |
| 475 | 468 |
| 476 if (create_memento) { | 469 __ sll(at, a3, kPointerSizeLog2); |
| 477 __ Subu(a0, a3, Operand(AllocationMemento::kSize / kPointerSize)); | 470 __ Addu(a0, t4, Operand(at)); // End of object. |
| 478 __ sll(a0, a0, kPointerSizeLog2); | 471 __ InitializeFieldsWithFiller(t5, a0, t7); |
| 479 __ Addu(a0, t4, Operand(a0)); // End of object. | |
| 480 __ InitializeFieldsWithFiller(t5, a0, t7); | |
| 481 | |
| 482 // Fill in memento fields. | |
| 483 // t5: points to the allocated but uninitialized memento. | |
| 484 __ LoadRoot(t7, Heap::kAllocationMementoMapRootIndex); | |
| 485 DCHECK_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); | |
| 486 __ sw(t7, MemOperand(t5)); | |
| 487 __ Addu(t5, t5, kPointerSize); | |
| 488 // Load the AllocationSite. | |
| 489 __ lw(t7, MemOperand(sp, 3 * kPointerSize)); | |
| 490 __ AssertUndefinedOrAllocationSite(a2, t0); | |
| 491 DCHECK_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); | |
| 492 __ sw(t7, MemOperand(t5)); | |
| 493 __ Addu(t5, t5, kPointerSize); | |
| 494 } else { | |
| 495 __ sll(at, a3, kPointerSizeLog2); | |
| 496 __ Addu(a0, t4, Operand(at)); // End of object. | |
| 497 __ InitializeFieldsWithFiller(t5, a0, t7); | |
| 498 } | |
| 499 | 472 |
| 500 // Add the object tag to make the JSObject real, so that we can continue | 473 // Add the object tag to make the JSObject real, so that we can continue |
| 501 // and jump into the continuation code at any time from now on. | 474 // and jump into the continuation code at any time from now on. |
| 502 __ Addu(t4, t4, Operand(kHeapObjectTag)); | 475 __ Addu(t4, t4, Operand(kHeapObjectTag)); |
| 503 | 476 |
| 504 // Continue with JSObject being successfully allocated. | 477 // Continue with JSObject being successfully allocated. |
| 505 // t4: JSObject | 478 // t4: JSObject |
| 506 __ jmp(&allocated); | 479 __ jmp(&allocated); |
| 507 | 480 |
| 508 // Reload the original constructor and fall-through. | 481 // Reload the original constructor and fall-through. |
| 509 __ bind(&rt_call_reload_new_target); | 482 __ bind(&rt_call_reload_new_target); |
| 510 __ lw(a3, MemOperand(sp, 0 * kPointerSize)); | 483 __ lw(a3, MemOperand(sp, 0 * kPointerSize)); |
| 511 } | 484 } |
| 512 | 485 |
| 513 // Allocate the new receiver object using the runtime call. | 486 // Allocate the new receiver object using the runtime call. |
| 514 // a1: constructor function | 487 // a1: constructor function |
| 515 // a3: original constructor | 488 // a3: original constructor |
| 516 __ bind(&rt_call); | 489 __ bind(&rt_call); |
| 517 if (create_memento) { | |
| 518 // Get the cell or allocation site. | |
| 519 __ lw(a2, MemOperand(sp, 3 * kPointerSize)); | |
| 520 __ push(a2); // argument 1: allocation site | |
| 521 } | |
| 522 | 490 |
| 523 __ Push(a1, a3); // arguments 2-3 / 1-2 | 491 __ Push(a1, a3); // arguments 2-3 / 1-2 |
| 524 if (create_memento) { | 492 __ CallRuntime(Runtime::kNewObject, 2); |
| 525 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); | |
| 526 } else { | |
| 527 __ CallRuntime(Runtime::kNewObject, 2); | |
| 528 } | |
| 529 __ mov(t4, v0); | 493 __ mov(t4, v0); |
| 530 | 494 |
| 531 // Runtime_NewObjectWithAllocationSite increments allocation count. | |
| 532 // Skip the increment. | |
| 533 Label count_incremented; | |
| 534 if (create_memento) { | |
| 535 __ jmp(&count_incremented); | |
| 536 } | |
| 537 | |
| 538 // Receiver for constructor call allocated. | 495 // Receiver for constructor call allocated. |
| 539 // t4: JSObject | 496 // t4: JSObject |
| 540 __ bind(&allocated); | 497 __ bind(&allocated); |
| 541 | 498 |
| 542 if (create_memento) { | |
| 543 __ lw(a2, MemOperand(sp, 3 * kPointerSize)); | |
| 544 __ LoadRoot(t5, Heap::kUndefinedValueRootIndex); | |
| 545 __ Branch(&count_incremented, eq, a2, Operand(t5)); | |
| 546 // a2 is an AllocationSite. We are creating a memento from it, so we | |
| 547 // need to increment the memento create count. | |
| 548 __ lw(a3, FieldMemOperand(a2, | |
| 549 AllocationSite::kPretenureCreateCountOffset)); | |
| 550 __ Addu(a3, a3, Operand(Smi::FromInt(1))); | |
| 551 __ sw(a3, FieldMemOperand(a2, | |
| 552 AllocationSite::kPretenureCreateCountOffset)); | |
| 553 __ bind(&count_incremented); | |
| 554 } | |
| 555 | |
| 556 // Restore the parameters. | 499 // Restore the parameters. |
| 557 __ Pop(a3); // new.target | 500 __ Pop(a3); // new.target |
| 558 __ Pop(a1); | 501 __ Pop(a1); |
| 559 | 502 |
| 560 // Retrieve smi-tagged arguments count from the stack. | 503 // Retrieve smi-tagged arguments count from the stack. |
| 561 __ lw(a0, MemOperand(sp)); | 504 __ lw(a0, MemOperand(sp)); |
| 562 __ SmiUntag(a0); | 505 __ SmiUntag(a0); |
| 563 | 506 |
| 564 __ Push(a3, t4, t4); | 507 __ Push(a3, t4, t4); |
| 565 | 508 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 587 |
| 645 __ sll(t0, a1, kPointerSizeLog2 - 1); | 588 __ sll(t0, a1, kPointerSizeLog2 - 1); |
| 646 __ Addu(sp, sp, t0); | 589 __ Addu(sp, sp, t0); |
| 647 __ Addu(sp, sp, kPointerSize); | 590 __ Addu(sp, sp, kPointerSize); |
| 648 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); | 591 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); |
| 649 __ Ret(); | 592 __ Ret(); |
| 650 } | 593 } |
| 651 | 594 |
| 652 | 595 |
| 653 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 596 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 654 Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new); | 597 Generate_JSConstructStubHelper(masm, false); |
| 655 } | 598 } |
| 656 | 599 |
| 657 | 600 |
| 658 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 601 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| 659 Generate_JSConstructStubHelper(masm, true, false); | 602 Generate_JSConstructStubHelper(masm, true); |
| 660 } | 603 } |
| 661 | 604 |
| 662 | 605 |
| 663 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { | 606 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { |
| 664 // ----------- S t a t e ------------- | 607 // ----------- S t a t e ------------- |
| 665 // -- a0 : number of arguments | 608 // -- a0 : number of arguments |
| 666 // -- a1 : constructor function | 609 // -- a1 : constructor function |
| 667 // -- a2 : allocation site or undefined | 610 // -- a2 : allocation site or undefined |
| 668 // -- a3 : original constructor | 611 // -- a3 : original constructor |
| 669 // -- ra : return address | 612 // -- ra : return address |
| (...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 } | 1810 } |
| 1868 } | 1811 } |
| 1869 | 1812 |
| 1870 | 1813 |
| 1871 #undef __ | 1814 #undef __ |
| 1872 | 1815 |
| 1873 } // namespace internal | 1816 } // namespace internal |
| 1874 } // namespace v8 | 1817 } // namespace v8 |
| 1875 | 1818 |
| 1876 #endif // V8_TARGET_ARCH_MIPS | 1819 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |