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

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

Issue 1239593003: Fix memento initialization when constructing from new call (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 5 years, 5 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/mips64/builtins-mips64.cc ('k') | test/cctest/test-mementos.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // -- rdx: original constructor 109 // -- rdx: original constructor
110 // ----------------------------------- 110 // -----------------------------------
111 111
112 // Should never create mementos for api functions. 112 // Should never create mementos for api functions.
113 DCHECK(!is_api_function || !create_memento); 113 DCHECK(!is_api_function || !create_memento);
114 114
115 // Enter a construct frame. 115 // Enter a construct frame.
116 { 116 {
117 FrameScope scope(masm, StackFrame::CONSTRUCT); 117 FrameScope scope(masm, StackFrame::CONSTRUCT);
118 118
119 if (create_memento) {
120 __ AssertUndefinedOrAllocationSite(rbx);
121 __ Push(rbx);
122 }
123
124 // Preserve the incoming parameters on the stack. 119 // Preserve the incoming parameters on the stack.
120 __ AssertUndefinedOrAllocationSite(rbx);
121 __ Push(rbx);
125 __ Integer32ToSmi(rax, rax); 122 __ Integer32ToSmi(rax, rax);
126 __ Push(rax); 123 __ Push(rax);
127 __ Push(rdi); 124 __ Push(rdi);
128 __ Push(rdx); 125 __ Push(rdx);
129 126
130 // Try to allocate the object without transitioning into C code. If any of 127 // Try to allocate the object without transitioning into C code. If any of
131 // the preconditions is not met, the code bails out to the runtime call. 128 // the preconditions is not met, the code bails out to the runtime call.
132 Label rt_call, allocated; 129 Label rt_call, allocated;
133 if (FLAG_inline_new) { 130 if (FLAG_inline_new) {
134 ExternalReference debug_step_in_fp = 131 ExternalReference debug_step_in_fp =
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 244 }
248 if (create_memento) { 245 if (create_memento) {
249 __ leap(rsi, Operand(rdi, -AllocationMemento::kSize)); 246 __ leap(rsi, Operand(rdi, -AllocationMemento::kSize));
250 __ InitializeFieldsWithFiller(rcx, rsi, rdx); 247 __ InitializeFieldsWithFiller(rcx, rsi, rdx);
251 248
252 // Fill in memento fields if necessary. 249 // Fill in memento fields if necessary.
253 // rsi: points to the allocated but uninitialized memento. 250 // rsi: points to the allocated but uninitialized memento.
254 __ Move(Operand(rsi, AllocationMemento::kMapOffset), 251 __ Move(Operand(rsi, AllocationMemento::kMapOffset),
255 factory->allocation_memento_map()); 252 factory->allocation_memento_map());
256 // Get the cell or undefined. 253 // Get the cell or undefined.
257 __ movp(rdx, Operand(rsp, kPointerSize*2)); 254 __ movp(rdx, Operand(rsp, 3 * kPointerSize));
255 __ AssertUndefinedOrAllocationSite(rdx);
258 __ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset), rdx); 256 __ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset), rdx);
259 } else { 257 } else {
260 __ InitializeFieldsWithFiller(rcx, rdi, rdx); 258 __ InitializeFieldsWithFiller(rcx, rdi, rdx);
261 } 259 }
262 260
263 // Add the object tag to make the JSObject real, so that we can continue 261 // Add the object tag to make the JSObject real, so that we can continue
264 // and jump into the continuation code at any time from now on. 262 // and jump into the continuation code at any time from now on.
265 // rbx: JSObject (untagged) 263 // rbx: JSObject (untagged)
266 __ orp(rbx, Immediate(kHeapObjectTag)); 264 __ orp(rbx, Immediate(kHeapObjectTag));
267 265
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 411 }
414 412
415 413
416 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { 414 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) {
417 // ----------- S t a t e ------------- 415 // ----------- S t a t e -------------
418 // -- rax: number of arguments 416 // -- rax: number of arguments
419 // -- rdi: constructor function 417 // -- rdi: constructor function
420 // -- rbx: allocation site or undefined 418 // -- rbx: allocation site or undefined
421 // -- rdx: original constructor 419 // -- rdx: original constructor
422 // ----------------------------------- 420 // -----------------------------------
423 // TODO(dslomov): support pretenuring
424 CHECK(!FLAG_pretenuring_call_new);
425 421
426 { 422 {
427 FrameScope frame_scope(masm, StackFrame::CONSTRUCT); 423 FrameScope frame_scope(masm, StackFrame::CONSTRUCT);
428 424
425 // Preserve allocation site.
426 __ AssertUndefinedOrAllocationSite(rbx);
427 __ Push(rbx);
428
429 // Store a smi-tagged arguments count on the stack. 429 // Store a smi-tagged arguments count on the stack.
430 __ Integer32ToSmi(rax, rax); 430 __ Integer32ToSmi(rax, rax);
431 __ Push(rax); 431 __ Push(rax);
432 __ SmiToInteger32(rax, rax); 432 __ SmiToInteger32(rax, rax);
433 433
434 // Push new.target 434 // Push new.target
435 __ Push(rdx); 435 __ Push(rdx);
436 436
437 // receiver is the hole. 437 // receiver is the hole.
438 __ Push(masm->isolate()->factory()->the_hole_value()); 438 __ Push(masm->isolate()->factory()->the_hole_value());
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 __ ret(0); 1707 __ ret(0);
1708 } 1708 }
1709 1709
1710 1710
1711 #undef __ 1711 #undef __
1712 1712
1713 } // namespace internal 1713 } // namespace internal
1714 } // namespace v8 1714 } // namespace v8
1715 1715
1716 #endif // V8_TARGET_ARCH_X64 1716 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/mips64/builtins-mips64.cc ('k') | test/cctest/test-mementos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698