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