OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 411 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
412 GenerateTailCallToReturnedCode(masm); | 412 GenerateTailCallToReturnedCode(masm); |
413 | 413 |
414 __ Bind(&ok); | 414 __ Bind(&ok); |
415 GenerateTailCallToSharedCode(masm); | 415 GenerateTailCallToSharedCode(masm); |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 419 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
420 bool is_api_function, | 420 bool is_api_function, |
421 bool create_implicit_receiver) { | 421 bool create_implicit_receiver, |
| 422 bool check_derived_construct) { |
422 // ----------- S t a t e ------------- | 423 // ----------- S t a t e ------------- |
423 // -- x0 : number of arguments | 424 // -- x0 : number of arguments |
424 // -- x1 : constructor function | 425 // -- x1 : constructor function |
425 // -- x2 : allocation site or undefined | 426 // -- x2 : allocation site or undefined |
426 // -- x3 : new target | 427 // -- x3 : new target |
427 // -- lr : return address | 428 // -- lr : return address |
428 // -- sp[...]: constructor arguments | 429 // -- sp[...]: constructor arguments |
429 // ----------------------------------- | 430 // ----------------------------------- |
430 | 431 |
431 ASM_LOCATION("Builtins::Generate_JSConstructStubHelper"); | 432 ASM_LOCATION("Builtins::Generate_JSConstructStubHelper"); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 // jssp[0]: receiver (newly allocated object) | 691 // jssp[0]: receiver (newly allocated object) |
691 // jssp[1]: number of arguments (smi-tagged) | 692 // jssp[1]: number of arguments (smi-tagged) |
692 __ Peek(x1, 1 * kXRegSize); | 693 __ Peek(x1, 1 * kXRegSize); |
693 } else { | 694 } else { |
694 __ Peek(x1, 0); | 695 __ Peek(x1, 0); |
695 } | 696 } |
696 | 697 |
697 // Leave construct frame. | 698 // Leave construct frame. |
698 } | 699 } |
699 | 700 |
| 701 // ES6 9.2.2. Step 13+ |
| 702 // Check that the result is not a Smi, indicating that the constructor result |
| 703 // from a derived class is neither undefined nor an Object. |
| 704 if (check_derived_construct) { |
| 705 Label dont_throw; |
| 706 __ JumpIfNotSmi(x0, &dont_throw); |
| 707 { |
| 708 FrameScope scope(masm, StackFrame::INTERNAL); |
| 709 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); |
| 710 } |
| 711 __ Bind(&dont_throw); |
| 712 } |
| 713 |
700 __ DropBySMI(x1); | 714 __ DropBySMI(x1); |
701 __ Drop(1); | 715 __ Drop(1); |
702 if (create_implicit_receiver) { | 716 if (create_implicit_receiver) { |
703 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, x1, x2); | 717 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, x1, x2); |
704 } | 718 } |
705 __ Ret(); | 719 __ Ret(); |
706 } | 720 } |
707 | 721 |
708 | 722 |
709 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 723 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
710 Generate_JSConstructStubHelper(masm, false, true); | 724 Generate_JSConstructStubHelper(masm, false, true, false); |
711 } | 725 } |
712 | 726 |
713 | 727 |
714 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 728 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
715 Generate_JSConstructStubHelper(masm, true, true); | 729 Generate_JSConstructStubHelper(masm, true, true, false); |
716 } | 730 } |
717 | 731 |
718 | 732 |
719 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 733 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
720 Generate_JSConstructStubHelper(masm, false, false); | 734 Generate_JSConstructStubHelper(masm, false, false, false); |
721 } | 735 } |
722 | 736 |
723 | 737 |
| 738 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
| 739 MacroAssembler* masm) { |
| 740 Generate_JSConstructStubHelper(masm, false, false, true); |
| 741 } |
| 742 |
| 743 |
724 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 744 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
725 FrameScope scope(masm, StackFrame::INTERNAL); | 745 FrameScope scope(masm, StackFrame::INTERNAL); |
726 __ Push(x1); | 746 __ Push(x1); |
727 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); | 747 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
728 } | 748 } |
729 | 749 |
730 | 750 |
731 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; | 751 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; |
732 | 752 |
733 | 753 |
(...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2579 } | 2599 } |
2580 } | 2600 } |
2581 | 2601 |
2582 | 2602 |
2583 #undef __ | 2603 #undef __ |
2584 | 2604 |
2585 } // namespace internal | 2605 } // namespace internal |
2586 } // namespace v8 | 2606 } // namespace v8 |
2587 | 2607 |
2588 #endif // V8_TARGET_ARCH_ARM | 2608 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |