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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 415 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
416 GenerateTailCallToReturnedCode(masm); | 416 GenerateTailCallToReturnedCode(masm); |
417 | 417 |
418 __ bind(&ok); | 418 __ bind(&ok); |
419 GenerateTailCallToSharedCode(masm); | 419 GenerateTailCallToSharedCode(masm); |
420 } | 420 } |
421 | 421 |
422 | 422 |
423 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 423 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
424 bool is_api_function, | 424 bool is_api_function, |
425 bool create_implicit_receiver) { | 425 bool create_implicit_receiver, |
426 bool check_derived_construct) { | |
426 // ----------- S t a t e ------------- | 427 // ----------- S t a t e ------------- |
427 // -- a0 : number of arguments | 428 // -- a0 : number of arguments |
428 // -- a1 : constructor function | 429 // -- a1 : constructor function |
429 // -- a2 : allocation site or undefined | 430 // -- a2 : allocation site or undefined |
430 // -- a3 : new target | 431 // -- a3 : new target |
431 // -- ra : return address | 432 // -- ra : return address |
432 // -- sp[...]: constructor arguments | 433 // -- sp[...]: constructor arguments |
433 // ----------------------------------- | 434 // ----------------------------------- |
434 | 435 |
435 Isolate* isolate = masm->isolate(); | 436 Isolate* isolate = masm->isolate(); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 // sp[0]: receiver (newly allocated object) | 671 // sp[0]: receiver (newly allocated object) |
671 // sp[1]: number of arguments (smi-tagged) | 672 // sp[1]: number of arguments (smi-tagged) |
672 __ ld(a1, MemOperand(sp, 1 * kPointerSize)); | 673 __ ld(a1, MemOperand(sp, 1 * kPointerSize)); |
673 } else { | 674 } else { |
674 __ ld(a1, MemOperand(sp)); | 675 __ ld(a1, MemOperand(sp)); |
675 } | 676 } |
676 | 677 |
677 // Leave construct frame. | 678 // Leave construct frame. |
678 } | 679 } |
679 | 680 |
681 // ES6 9.2.2. Step 13+ | |
682 // Check that the result is not a Smi, indicating that the constructor result | |
683 // from a derived class is neither undefined nor an Object. | |
684 if (check_derived_construct) { | |
685 Label dont_throw; | |
686 __ JumpIfNotSmi(v0, &dont_throw); | |
687 { | |
688 FrameScope scope(masm, StackFrame::INTERNAL); | |
689 __ push(v0); | |
Camillo Bruni
2016/01/15 13:51:47
same here ;)
balazs.kilvady
2016/01/15 13:59:44
Done.
| |
690 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); | |
691 } | |
692 __ bind(&dont_throw); | |
693 } | |
694 | |
680 __ SmiScale(a4, a1, kPointerSizeLog2); | 695 __ SmiScale(a4, a1, kPointerSizeLog2); |
681 __ Daddu(sp, sp, a4); | 696 __ Daddu(sp, sp, a4); |
682 __ Daddu(sp, sp, kPointerSize); | 697 __ Daddu(sp, sp, kPointerSize); |
683 if (create_implicit_receiver) { | 698 if (create_implicit_receiver) { |
684 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); | 699 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); |
685 } | 700 } |
686 __ Ret(); | 701 __ Ret(); |
687 } | 702 } |
688 | 703 |
689 | 704 |
690 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 705 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
691 Generate_JSConstructStubHelper(masm, false, true); | 706 Generate_JSConstructStubHelper(masm, false, true, false); |
692 } | 707 } |
693 | 708 |
694 | 709 |
695 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 710 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
696 Generate_JSConstructStubHelper(masm, true, true); | 711 Generate_JSConstructStubHelper(masm, true, true, false); |
697 } | 712 } |
698 | 713 |
699 | 714 |
700 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 715 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
701 Generate_JSConstructStubHelper(masm, false, false); | 716 Generate_JSConstructStubHelper(masm, false, false, false); |
702 } | 717 } |
703 | 718 |
704 | 719 |
705 void Builtins::Generate_JSBuiltinsConstructStubForDerived( | 720 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
706 MacroAssembler* masm) { | 721 MacroAssembler* masm) { |
707 Generate_JSConstructStubHelper(masm, false, false); | 722 Generate_JSConstructStubHelper(masm, false, false, true); |
708 } | 723 } |
709 | 724 |
710 | 725 |
711 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 726 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
712 FrameScope scope(masm, StackFrame::INTERNAL); | 727 FrameScope scope(masm, StackFrame::INTERNAL); |
713 __ Push(a1); | 728 __ Push(a1); |
714 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); | 729 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
715 } | 730 } |
716 | 731 |
717 | 732 |
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2534 } | 2549 } |
2535 } | 2550 } |
2536 | 2551 |
2537 | 2552 |
2538 #undef __ | 2553 #undef __ |
2539 | 2554 |
2540 } // namespace internal | 2555 } // namespace internal |
2541 } // namespace v8 | 2556 } // namespace v8 |
2542 | 2557 |
2543 #endif // V8_TARGET_ARCH_MIPS64 | 2558 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |