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

Side by Side Diff: src/x64/builtins-x64.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 | « src/runtime/runtime-internal.cc ('k') | src/x87/builtins-x87.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_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); 110 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
111 GenerateTailCallToReturnedCode(masm); 111 GenerateTailCallToReturnedCode(masm);
112 112
113 __ bind(&ok); 113 __ bind(&ok);
114 GenerateTailCallToSharedCode(masm); 114 GenerateTailCallToSharedCode(masm);
115 } 115 }
116 116
117 117
118 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 118 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
119 bool is_api_function, 119 bool is_api_function,
120 bool create_implicit_receiver) { 120 bool create_implicit_receiver,
121 bool check_derived_construct) {
121 // ----------- S t a t e ------------- 122 // ----------- S t a t e -------------
122 // -- rax: number of arguments 123 // -- rax: number of arguments
123 // -- rdi: constructor function 124 // -- rdi: constructor function
124 // -- rbx: allocation site or undefined 125 // -- rbx: allocation site or undefined
125 // -- rdx: new target 126 // -- rdx: new target
126 // ----------------------------------- 127 // -----------------------------------
127 128
128 // Enter a construct frame. 129 // Enter a construct frame.
129 { 130 {
130 FrameScope scope(masm, StackFrame::CONSTRUCT); 131 FrameScope scope(masm, StackFrame::CONSTRUCT);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // arguments count is stored below the receiver. 351 // arguments count is stored below the receiver.
351 __ bind(&exit); 352 __ bind(&exit);
352 __ movp(rbx, Operand(rsp, 1 * kPointerSize)); 353 __ movp(rbx, Operand(rsp, 1 * kPointerSize));
353 } else { 354 } else {
354 __ movp(rbx, Operand(rsp, 0)); 355 __ movp(rbx, Operand(rsp, 0));
355 } 356 }
356 357
357 // Leave construct frame. 358 // Leave construct frame.
358 } 359 }
359 360
361 // ES6 9.2.2. Step 13+
362 // Check that the result is not a Smi, indicating that the constructor result
363 // from a derived class is neither undefined nor an Object.
364 if (check_derived_construct) {
365 Label dont_throw;
366 __ JumpIfNotSmi(rax, &dont_throw);
367 {
368 FrameScope scope(masm, StackFrame::INTERNAL);
369 __ CallRuntime(Runtime::kThrowDerivedConstructorReturnedNonObject);
370 }
371 __ bind(&dont_throw);
372 }
373
360 // Remove caller arguments from the stack and return. 374 // Remove caller arguments from the stack and return.
361 __ PopReturnAddressTo(rcx); 375 __ PopReturnAddressTo(rcx);
362 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); 376 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2);
363 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); 377 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize));
364 __ PushReturnAddressFrom(rcx); 378 __ PushReturnAddressFrom(rcx);
365 if (create_implicit_receiver) { 379 if (create_implicit_receiver) {
366 Counters* counters = masm->isolate()->counters(); 380 Counters* counters = masm->isolate()->counters();
367 __ IncrementCounter(counters->constructed_objects(), 1); 381 __ IncrementCounter(counters->constructed_objects(), 1);
368 } 382 }
369 __ ret(0); 383 __ ret(0);
370 } 384 }
371 385
372 386
373 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { 387 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
374 Generate_JSConstructStubHelper(masm, false, true); 388 Generate_JSConstructStubHelper(masm, false, true, false);
375 } 389 }
376 390
377 391
378 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { 392 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
379 Generate_JSConstructStubHelper(masm, true, true); 393 Generate_JSConstructStubHelper(masm, true, true, false);
380 } 394 }
381 395
382 396
383 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { 397 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) {
384 Generate_JSConstructStubHelper(masm, false, false); 398 Generate_JSConstructStubHelper(masm, false, false, false);
385 } 399 }
386 400
387 401
402 void Builtins::Generate_JSBuiltinsConstructStubForDerived(
403 MacroAssembler* masm) {
404 Generate_JSConstructStubHelper(masm, false, false, true);
405 }
406
407
388 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { 408 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
389 FrameScope scope(masm, StackFrame::INTERNAL); 409 FrameScope scope(masm, StackFrame::INTERNAL);
390 __ Push(rdi); 410 __ Push(rdi);
391 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); 411 __ CallRuntime(Runtime::kThrowConstructedNonConstructable);
392 } 412 }
393 413
394 414
395 enum IsTagged { kRaxIsSmiTagged, kRaxIsUntaggedInt }; 415 enum IsTagged { kRaxIsSmiTagged, kRaxIsUntaggedInt };
396 416
397 417
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 __ ret(0); 2604 __ ret(0);
2585 } 2605 }
2586 2606
2587 2607
2588 #undef __ 2608 #undef __
2589 2609
2590 } // namespace internal 2610 } // namespace internal
2591 } // namespace v8 2611 } // namespace v8
2592 2612
2593 #endif // V8_TARGET_ARCH_X64 2613 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698