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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 414 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
415 GenerateTailCallToReturnedCode(masm); | 415 GenerateTailCallToReturnedCode(masm); |
416 | 416 |
417 __ bind(&ok); | 417 __ bind(&ok); |
418 GenerateTailCallToSharedCode(masm); | 418 GenerateTailCallToSharedCode(masm); |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 422 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
423 bool is_api_function, | 423 bool is_api_function, |
424 bool create_implicit_receiver) { | 424 bool create_implicit_receiver, |
| 425 bool check_derived_construct) { |
425 // ----------- S t a t e ------------- | 426 // ----------- S t a t e ------------- |
426 // -- r3 : number of arguments | 427 // -- r3 : number of arguments |
427 // -- r4 : constructor function | 428 // -- r4 : constructor function |
428 // -- r5 : allocation site or undefined | 429 // -- r5 : allocation site or undefined |
429 // -- r6 : new target | 430 // -- r6 : new target |
430 // -- lr : return address | 431 // -- lr : return address |
431 // -- sp[...]: constructor arguments | 432 // -- sp[...]: constructor arguments |
432 // ----------------------------------- | 433 // ----------------------------------- |
433 | 434 |
434 Isolate* isolate = masm->isolate(); | 435 Isolate* isolate = masm->isolate(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // sp[0]: receiver (newly allocated object) | 674 // sp[0]: receiver (newly allocated object) |
674 // sp[1]: number of arguments (smi-tagged) | 675 // sp[1]: number of arguments (smi-tagged) |
675 __ LoadP(r4, MemOperand(sp, 1 * kPointerSize)); | 676 __ LoadP(r4, MemOperand(sp, 1 * kPointerSize)); |
676 } else { | 677 } else { |
677 __ LoadP(r4, MemOperand(sp)); | 678 __ LoadP(r4, MemOperand(sp)); |
678 } | 679 } |
679 | 680 |
680 // Leave construct frame. | 681 // Leave construct frame. |
681 } | 682 } |
682 | 683 |
| 684 // ES6 9.2.2. Step 13+ |
| 685 // Check that the result is not a Smi, indicating that the constructor result |
| 686 // from a derived class is neither undefined nor an Object. |
| 687 if (check_derived_construct) { |
| 688 Label dont_throw; |
| 689 __ JumpIfNotSmi(r3, &dont_throw); |
| 690 { |
| 691 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 692 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); |
| 693 } |
| 694 __ bind(&dont_throw); |
| 695 } |
| 696 |
683 __ SmiToPtrArrayOffset(r4, r4); | 697 __ SmiToPtrArrayOffset(r4, r4); |
684 __ add(sp, sp, r4); | 698 __ add(sp, sp, r4); |
685 __ addi(sp, sp, Operand(kPointerSize)); | 699 __ addi(sp, sp, Operand(kPointerSize)); |
686 if (create_implicit_receiver) { | 700 if (create_implicit_receiver) { |
687 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r4, r5); | 701 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r4, r5); |
688 } | 702 } |
689 __ blr(); | 703 __ blr(); |
690 } | 704 } |
691 | 705 |
692 | 706 |
693 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 707 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
694 Generate_JSConstructStubHelper(masm, false, true); | 708 Generate_JSConstructStubHelper(masm, false, true, false); |
695 } | 709 } |
696 | 710 |
697 | 711 |
698 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 712 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
699 Generate_JSConstructStubHelper(masm, true, true); | 713 Generate_JSConstructStubHelper(masm, true, true, false); |
700 } | 714 } |
701 | 715 |
702 | 716 |
703 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 717 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
704 Generate_JSConstructStubHelper(masm, false, false); | 718 Generate_JSConstructStubHelper(masm, false, false, false); |
705 } | 719 } |
706 | 720 |
707 | 721 |
708 void Builtins::Generate_JSBuiltinsConstructStubForDerived( | 722 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
709 MacroAssembler* masm) { | 723 MacroAssembler* masm) { |
710 Generate_JSConstructStubHelper(masm, false, false); | 724 Generate_JSConstructStubHelper(masm, false, false, true); |
711 } | 725 } |
712 | 726 |
713 | 727 |
714 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 728 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
715 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 729 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
716 __ push(r4); | 730 __ push(r4); |
717 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); | 731 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
718 } | 732 } |
719 | 733 |
720 | 734 |
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 __ bkpt(0); | 2519 __ bkpt(0); |
2506 } | 2520 } |
2507 } | 2521 } |
2508 | 2522 |
2509 | 2523 |
2510 #undef __ | 2524 #undef __ |
2511 } // namespace internal | 2525 } // namespace internal |
2512 } // namespace v8 | 2526 } // namespace v8 |
2513 | 2527 |
2514 #endif // V8_TARGET_ARCH_PPC | 2528 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |