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_S390 | 5 #if V8_TARGET_ARCH_S390 |
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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); | 437 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); |
438 | 438 |
439 __ bind(&ok); | 439 __ bind(&ok); |
440 GenerateTailCallToSharedCode(masm); | 440 GenerateTailCallToSharedCode(masm); |
441 } | 441 } |
442 | 442 |
443 namespace { | 443 namespace { |
444 | 444 |
445 void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, | 445 void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, |
446 bool create_implicit_receiver, | 446 bool create_implicit_receiver, |
447 bool check_derived_construct) { | 447 bool disallow_non_object_return) { |
448 Label post_instantiation_deopt_entry; | 448 Label post_instantiation_deopt_entry; |
449 // ----------- S t a t e ------------- | 449 // ----------- S t a t e ------------- |
450 // -- r2 : number of arguments | 450 // -- r2 : number of arguments |
451 // -- r3 : constructor function | 451 // -- r3 : constructor function |
452 // -- r5 : new target | 452 // -- r5 : new target |
453 // -- cp : context | 453 // -- cp : context |
454 // -- lr : return address | 454 // -- lr : return address |
455 // -- sp[...]: constructor arguments | 455 // -- sp[...]: constructor arguments |
456 // ----------------------------------- | 456 // ----------------------------------- |
457 | 457 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // Call the function. | 526 // Call the function. |
527 // r2: number of arguments | 527 // r2: number of arguments |
528 // r3: constructor function | 528 // r3: constructor function |
529 // r5: new target | 529 // r5: new target |
530 | 530 |
531 ParameterCount actual(r2); | 531 ParameterCount actual(r2); |
532 __ InvokeFunction(r3, r5, actual, CALL_FUNCTION, | 532 __ InvokeFunction(r3, r5, actual, CALL_FUNCTION, |
533 CheckDebugStepCallWrapper()); | 533 CheckDebugStepCallWrapper()); |
534 | 534 |
535 // Store offset of return address for deoptimizer. | 535 // Store offset of return address for deoptimizer. |
536 if (create_implicit_receiver && !is_api_function) { | 536 if (create_implicit_receiver && !disallow_non_object_return && |
| 537 !is_api_function) { |
537 masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( | 538 masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( |
538 masm->pc_offset()); | 539 masm->pc_offset()); |
539 } | 540 } |
540 | 541 |
541 // Restore context from the frame. | 542 // Restore context from the frame. |
542 // r2: result | 543 // r2: result |
543 // sp[0]: receiver | 544 // sp[0]: receiver |
544 // sp[1]: number of arguments (smi-tagged) | 545 // sp[1]: number of arguments (smi-tagged) |
545 __ LoadP(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); | 546 __ LoadP(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); |
546 | 547 |
547 if (create_implicit_receiver) { | 548 if (create_implicit_receiver) { |
548 // If the result is an object (in the ECMA sense), we should get rid | 549 // If the result is an object (in the ECMA sense), we should get rid |
549 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 | 550 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
550 // on page 74. | 551 // on page 74. |
551 Label use_receiver, exit; | 552 Label use_receiver, return_value, do_throw; |
552 | 553 |
553 // If the result is a smi, it is *not* an object in the ECMA sense. | 554 // If the result is a smi, it is *not* an object in the ECMA sense. |
554 // r2: result | 555 // r2: result |
555 // sp[0]: receiver | 556 // sp[0]: receiver |
556 // sp[1]: new.target | 557 // sp[1]: new.target |
557 // sp[2]: number of arguments (smi-tagged) | 558 // sp[2]: number of arguments (smi-tagged) |
558 __ JumpIfSmi(r2, &use_receiver); | 559 // If the result is undefined, we jump out to using the implicit |
| 560 // receiver, otherwise we do a smi check and fall through to |
| 561 // check if the return value is a valid receiver. |
| 562 if (disallow_non_object_return) { |
| 563 __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); |
| 564 __ beq(&use_receiver); |
| 565 __ JumpIfSmi(r2, &do_throw); |
| 566 } else { |
| 567 __ JumpIfSmi(r2, &use_receiver); |
| 568 } |
559 | 569 |
560 // If the type of the result (stored in its map) is less than | 570 // If the type of the result (stored in its map) is less than |
561 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. | 571 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. |
562 __ CompareObjectType(r2, r3, r5, FIRST_JS_RECEIVER_TYPE); | 572 __ CompareObjectType(r2, r3, r5, FIRST_JS_RECEIVER_TYPE); |
563 __ bge(&exit); | 573 __ bge(&return_value); |
| 574 |
| 575 if (disallow_non_object_return) { |
| 576 __ bind(&do_throw); |
| 577 __ CallRuntime(Runtime::kThrowConstructorReturnedNonObject); |
| 578 } |
564 | 579 |
565 // Throw away the result of the constructor invocation and use the | 580 // Throw away the result of the constructor invocation and use the |
566 // on-stack receiver as the result. | 581 // on-stack receiver as the result. |
567 __ bind(&use_receiver); | 582 __ bind(&use_receiver); |
568 __ LoadP(r2, MemOperand(sp)); | 583 __ LoadP(r2, MemOperand(sp)); |
569 | 584 |
570 // Remove receiver from the stack, remove caller arguments, and | 585 // Remove receiver from the stack, remove caller arguments, and |
571 // return. | 586 // return. |
572 __ bind(&exit); | 587 __ bind(&return_value); |
573 // r2: result | 588 // r2: result |
574 // sp[0]: receiver (newly allocated object) | 589 // sp[0]: receiver (newly allocated object) |
575 // sp[1]: number of arguments (smi-tagged) | 590 // sp[1]: number of arguments (smi-tagged) |
576 __ LoadP(r3, MemOperand(sp, 1 * kPointerSize)); | 591 __ LoadP(r3, MemOperand(sp, 1 * kPointerSize)); |
577 } else { | 592 } else { |
578 __ LoadP(r3, MemOperand(sp)); | 593 __ LoadP(r3, MemOperand(sp)); |
579 } | 594 } |
580 | 595 |
581 // Leave construct frame. | 596 // Leave construct frame. |
582 } | 597 } |
583 | 598 |
584 // ES6 9.2.2. Step 13+ | 599 // ES6 9.2.2. Step 13+ |
585 // Check that the result is not a Smi, indicating that the constructor result | 600 // For derived class constructors, throw a TypeError here if the result |
586 // from a derived class is neither undefined nor an Object. | 601 // is not a JSReceiver. For the base constructor, we've already checked |
587 if (check_derived_construct) { | 602 // the result, so we omit the check. |
| 603 if (disallow_non_object_return && !create_implicit_receiver) { |
588 Label do_throw, dont_throw; | 604 Label do_throw, dont_throw; |
589 __ JumpIfSmi(r2, &do_throw); | 605 __ JumpIfSmi(r2, &do_throw); |
590 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | 606 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
591 __ CompareObjectType(r2, r5, r5, FIRST_JS_RECEIVER_TYPE); | 607 __ CompareObjectType(r2, r5, r5, FIRST_JS_RECEIVER_TYPE); |
592 __ bge(&dont_throw); | 608 __ bge(&dont_throw); |
593 __ bind(&do_throw); | 609 __ bind(&do_throw); |
594 { | 610 { |
595 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 611 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
596 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); | 612 __ CallRuntime(Runtime::kThrowConstructorReturnedNonObject); |
597 } | 613 } |
598 __ bind(&dont_throw); | 614 __ bind(&dont_throw); |
599 } | 615 } |
600 | 616 |
601 __ SmiToPtrArrayOffset(r3, r3); | 617 __ SmiToPtrArrayOffset(r3, r3); |
602 __ AddP(sp, sp, r3); | 618 __ AddP(sp, sp, r3); |
603 __ AddP(sp, sp, Operand(kPointerSize)); | 619 __ AddP(sp, sp, Operand(kPointerSize)); |
604 if (create_implicit_receiver) { | 620 if (create_implicit_receiver) { |
605 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r3, r4); | 621 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r3, r4); |
606 } | 622 } |
607 __ Ret(); | 623 __ Ret(); |
608 | 624 |
609 // Store offset of trampoline address for deoptimizer. This is the bailout | 625 // Store offset of trampoline address for deoptimizer. This is the bailout |
610 // point after the receiver instantiation but before the function invocation. | 626 // point after the receiver instantiation but before the function invocation. |
611 // We need to restore some registers in order to continue the above code. | 627 // We need to restore some registers in order to continue the above code. |
612 if (create_implicit_receiver && !is_api_function) { | 628 if (create_implicit_receiver && !disallow_non_object_return && |
| 629 !is_api_function) { |
613 masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( | 630 masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( |
614 masm->pc_offset()); | 631 masm->pc_offset()); |
615 | 632 |
616 // ----------- S t a t e ------------- | 633 // ----------- S t a t e ------------- |
617 // -- r2 : newly allocated object | 634 // -- r2 : newly allocated object |
618 // -- sp[0] : constructor function | 635 // -- sp[0] : constructor function |
619 // ----------------------------------- | 636 // ----------------------------------- |
620 | 637 |
621 __ pop(r3); | 638 __ pop(r3); |
622 __ Push(r2, r2); | 639 __ Push(r2, r2); |
(...skipping 20 matching lines...) Expand all Loading... |
643 } | 660 } |
644 | 661 |
645 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 662 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
646 Generate_JSConstructStubHelper(masm, true, false, false); | 663 Generate_JSConstructStubHelper(masm, true, false, false); |
647 } | 664 } |
648 | 665 |
649 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 666 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
650 Generate_JSConstructStubHelper(masm, false, false, false); | 667 Generate_JSConstructStubHelper(masm, false, false, false); |
651 } | 668 } |
652 | 669 |
| 670 void Builtins::Generate_JSBuiltinsConstructStubForBase(MacroAssembler* masm) { |
| 671 Generate_JSConstructStubHelper(masm, false, true, true); |
| 672 } |
| 673 |
653 void Builtins::Generate_JSBuiltinsConstructStubForDerived( | 674 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
654 MacroAssembler* masm) { | 675 MacroAssembler* masm) { |
655 Generate_JSConstructStubHelper(masm, false, false, true); | 676 Generate_JSConstructStubHelper(masm, false, false, true); |
656 } | 677 } |
657 | 678 |
658 // static | 679 // static |
659 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { | 680 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { |
660 // ----------- S t a t e ------------- | 681 // ----------- S t a t e ------------- |
661 // -- r2 : the value to pass to the generator | 682 // -- r2 : the value to pass to the generator |
662 // -- r3 : the JSGeneratorObject to resume | 683 // -- r3 : the JSGeneratorObject to resume |
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3101 // Now jump to the instructions of the returned code object. | 3122 // Now jump to the instructions of the returned code object. |
3102 __ Jump(ip); | 3123 __ Jump(ip); |
3103 } | 3124 } |
3104 | 3125 |
3105 #undef __ | 3126 #undef __ |
3106 | 3127 |
3107 } // namespace internal | 3128 } // namespace internal |
3108 } // namespace v8 | 3129 } // namespace v8 |
3109 | 3130 |
3110 #endif // V8_TARGET_ARCH_S390 | 3131 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |