Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/arm/builtins-arm.cc

Issue 1593553002: [runtime] Throw exception for derived constructors in correct context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: disable regression test for ignition Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ARM 5 #if V8_TARGET_ARCH_ARM
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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); 410 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
411 GenerateTailCallToReturnedCode(masm); 411 GenerateTailCallToReturnedCode(masm);
412 412
413 __ bind(&ok); 413 __ bind(&ok);
414 GenerateTailCallToSharedCode(masm); 414 GenerateTailCallToSharedCode(masm);
415 } 415 }
416 416
417 417
418 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 418 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
419 bool is_api_function, 419 bool is_api_function,
420 bool create_implicit_receiver) { 420 bool create_implicit_receiver,
421 bool check_derived_construct) {
421 // ----------- S t a t e ------------- 422 // ----------- S t a t e -------------
422 // -- r0 : number of arguments 423 // -- r0 : number of arguments
423 // -- r1 : constructor function 424 // -- r1 : constructor function
424 // -- r2 : allocation site or undefined 425 // -- r2 : allocation site or undefined
425 // -- r3 : new target 426 // -- r3 : new target
426 // -- lr : return address 427 // -- lr : return address
427 // -- sp[...]: constructor arguments 428 // -- sp[...]: constructor arguments
428 // ----------------------------------- 429 // -----------------------------------
429 430
430 Isolate* isolate = masm->isolate(); 431 Isolate* isolate = masm->isolate();
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // sp[0]: receiver (newly allocated object) 679 // sp[0]: receiver (newly allocated object)
679 // sp[1]: number of arguments (smi-tagged) 680 // sp[1]: number of arguments (smi-tagged)
680 __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); 681 __ ldr(r1, MemOperand(sp, 1 * kPointerSize));
681 } else { 682 } else {
682 __ ldr(r1, MemOperand(sp)); 683 __ ldr(r1, MemOperand(sp));
683 } 684 }
684 685
685 // Leave construct frame. 686 // Leave construct frame.
686 } 687 }
687 688
689 // ES6 9.2.2. Step 13+
690 // Check that the result is not a Smi, indicating that the constructor result
691 // from a derived class is neither undefined nor an Object.
692 if (check_derived_construct) {
693 Label dont_throw;
694 __ JumpIfNotSmi(r0, &dont_throw);
695 {
696 FrameScope scope(masm, StackFrame::INTERNAL);
697 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject);
698 }
699 __ bind(&dont_throw);
700 }
701
688 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); 702 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1));
689 __ add(sp, sp, Operand(kPointerSize)); 703 __ add(sp, sp, Operand(kPointerSize));
690 if (create_implicit_receiver) { 704 if (create_implicit_receiver) {
691 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); 705 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2);
692 } 706 }
693 __ Jump(lr); 707 __ Jump(lr);
694 } 708 }
695 709
696 710
697 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { 711 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
698 Generate_JSConstructStubHelper(masm, false, true); 712 Generate_JSConstructStubHelper(masm, false, true, false);
699 } 713 }
700 714
701 715
702 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { 716 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
703 Generate_JSConstructStubHelper(masm, true, true); 717 Generate_JSConstructStubHelper(masm, true, true, false);
704 } 718 }
705 719
706 720
707 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { 721 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) {
708 Generate_JSConstructStubHelper(masm, false, false); 722 Generate_JSConstructStubHelper(masm, false, false, false);
709 } 723 }
710 724
711 725
726 void Builtins::Generate_JSBuiltinsConstructStubForDerived(
727 MacroAssembler* masm) {
728 Generate_JSConstructStubHelper(masm, false, false, true);
729 }
730
731
712 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { 732 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
713 FrameScope scope(masm, StackFrame::INTERNAL); 733 FrameScope scope(masm, StackFrame::INTERNAL);
714 __ push(r1); 734 __ push(r1);
715 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); 735 __ CallRuntime(Runtime::kThrowConstructedNonConstructable);
716 } 736 }
717 737
718 738
719 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; 739 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt };
720 740
721 741
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 } 2452 }
2433 } 2453 }
2434 2454
2435 2455
2436 #undef __ 2456 #undef __
2437 2457
2438 } // namespace internal 2458 } // namespace internal
2439 } // namespace v8 2459 } // namespace v8
2440 2460
2441 #endif // V8_TARGET_ARCH_ARM 2461 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698