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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 418 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
419 GenerateTailCallToReturnedCode(masm); | 419 GenerateTailCallToReturnedCode(masm); |
420 | 420 |
421 __ bind(&ok); | 421 __ bind(&ok); |
422 GenerateTailCallToSharedCode(masm); | 422 GenerateTailCallToSharedCode(masm); |
423 } | 423 } |
424 | 424 |
425 | 425 |
426 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 426 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
427 bool is_api_function, | 427 bool is_api_function, |
428 bool create_implicit_receiver) { | 428 bool create_implicit_receiver, |
429 bool check_derived_construct) { | |
429 // ----------- S t a t e ------------- | 430 // ----------- S t a t e ------------- |
430 // -- a0 : number of arguments | 431 // -- a0 : number of arguments |
431 // -- a1 : constructor function | 432 // -- a1 : constructor function |
432 // -- a2 : allocation site or undefined | 433 // -- a2 : allocation site or undefined |
433 // -- a3 : new target | 434 // -- a3 : new target |
434 // -- ra : return address | 435 // -- ra : return address |
435 // -- sp[...]: constructor arguments | 436 // -- sp[...]: constructor arguments |
436 // ----------------------------------- | 437 // ----------------------------------- |
437 | 438 |
438 Isolate* isolate = masm->isolate(); | 439 Isolate* isolate = masm->isolate(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 // sp[0]: receiver (newly allocated object) | 678 // sp[0]: receiver (newly allocated object) |
678 // sp[1]: number of arguments (smi-tagged) | 679 // sp[1]: number of arguments (smi-tagged) |
679 __ lw(a1, MemOperand(sp, 1 * kPointerSize)); | 680 __ lw(a1, MemOperand(sp, 1 * kPointerSize)); |
680 } else { | 681 } else { |
681 __ lw(a1, MemOperand(sp)); | 682 __ lw(a1, MemOperand(sp)); |
682 } | 683 } |
683 | 684 |
684 // Leave construct frame. | 685 // Leave construct frame. |
685 } | 686 } |
686 | 687 |
688 // ES6 9.2.2. Step 13+ | |
689 // Check that the result is not a Smi, indicating that the constructor result | |
690 // from a derived class is neither undefined nor an Object. | |
691 if (check_derived_construct) { | |
692 Label dont_throw; | |
693 __ JumpIfNotSmi(v0, &dont_throw); | |
694 { | |
695 FrameScope scope(masm, StackFrame::INTERNAL); | |
696 __ push(v0); | |
Camillo Bruni
2016/01/15 13:51:47
Sorry, I figured out that I don't have to pass an
balazs.kilvady
2016/01/15 13:59:44
Done.
| |
697 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject); | |
698 } | |
699 __ bind(&dont_throw); | |
700 } | |
701 | |
687 __ sll(t0, a1, kPointerSizeLog2 - 1); | 702 __ sll(t0, a1, kPointerSizeLog2 - 1); |
688 __ Addu(sp, sp, t0); | 703 __ Addu(sp, sp, t0); |
689 __ Addu(sp, sp, kPointerSize); | 704 __ Addu(sp, sp, kPointerSize); |
690 if (create_implicit_receiver) { | 705 if (create_implicit_receiver) { |
691 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); | 706 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); |
692 } | 707 } |
693 __ Ret(); | 708 __ Ret(); |
694 } | 709 } |
695 | 710 |
696 | 711 |
697 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 712 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
698 Generate_JSConstructStubHelper(masm, false, true); | 713 Generate_JSConstructStubHelper(masm, false, true, false); |
699 } | 714 } |
700 | 715 |
701 | 716 |
702 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 717 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
703 Generate_JSConstructStubHelper(masm, true, true); | 718 Generate_JSConstructStubHelper(masm, true, true, false); |
704 } | 719 } |
705 | 720 |
706 | 721 |
707 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 722 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
708 Generate_JSConstructStubHelper(masm, false, false); | 723 Generate_JSConstructStubHelper(masm, false, false, false); |
709 } | 724 } |
710 | 725 |
711 | 726 |
712 void Builtins::Generate_JSBuiltinsConstructStubForDerived( | 727 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
713 MacroAssembler* masm) { | 728 MacroAssembler* masm) { |
714 Generate_JSConstructStubHelper(masm, false, false); | 729 Generate_JSConstructStubHelper(masm, false, false, true); |
715 } | 730 } |
716 | 731 |
717 | 732 |
718 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 733 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
719 FrameScope scope(masm, StackFrame::INTERNAL); | 734 FrameScope scope(masm, StackFrame::INTERNAL); |
720 __ Push(a1); | 735 __ Push(a1); |
721 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); | 736 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
722 } | 737 } |
723 | 738 |
724 | 739 |
(...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2545 } | 2560 } |
2546 } | 2561 } |
2547 | 2562 |
2548 | 2563 |
2549 #undef __ | 2564 #undef __ |
2550 | 2565 |
2551 } // namespace internal | 2566 } // namespace internal |
2552 } // namespace v8 | 2567 } // namespace v8 |
2553 | 2568 |
2554 #endif // V8_TARGET_ARCH_MIPS | 2569 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |