| 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 #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 Loading... |
| 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) { | 119 // Always push a potential allocation site to preserve a fixed frame size. |
| 120 __ AssertUndefinedOrAllocationSite(rbx); | 120 __ AssertUndefinedOrAllocationSite(rbx); |
| 121 __ Push(rbx); | 121 __ Push(rbx); |
| 122 } | |
| 123 | 122 |
| 124 // Preserve the incoming parameters on the stack. | 123 // Preserve the incoming parameters on the stack. |
| 125 __ Integer32ToSmi(rax, rax); | 124 __ Integer32ToSmi(rax, rax); |
| 126 __ Push(rax); | 125 __ Push(rax); |
| 127 __ Push(rdi); | 126 __ Push(rdi); |
| 128 __ Push(rdx); | 127 __ Push(rdx); |
| 129 | 128 |
| 130 // Try to allocate the object without transitioning into C code. If any of | 129 // 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. | 130 // the preconditions is not met, the code bails out to the runtime call. |
| 132 Label rt_call, allocated; | 131 Label rt_call, allocated; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 246 } |
| 248 if (create_memento) { | 247 if (create_memento) { |
| 249 __ leap(rsi, Operand(rdi, -AllocationMemento::kSize)); | 248 __ leap(rsi, Operand(rdi, -AllocationMemento::kSize)); |
| 250 __ InitializeFieldsWithFiller(rcx, rsi, rdx); | 249 __ InitializeFieldsWithFiller(rcx, rsi, rdx); |
| 251 | 250 |
| 252 // Fill in memento fields if necessary. | 251 // Fill in memento fields if necessary. |
| 253 // rsi: points to the allocated but uninitialized memento. | 252 // rsi: points to the allocated but uninitialized memento. |
| 254 __ Move(Operand(rsi, AllocationMemento::kMapOffset), | 253 __ Move(Operand(rsi, AllocationMemento::kMapOffset), |
| 255 factory->allocation_memento_map()); | 254 factory->allocation_memento_map()); |
| 256 // Get the cell or undefined. | 255 // Get the cell or undefined. |
| 257 __ movp(rdx, Operand(rsp, kPointerSize*2)); | 256 __ movp(rdx, Operand(rsp, 3 * kPointerSize)); |
| 257 __ AssertUndefinedOrAllocationSite(rdx); |
| 258 __ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset), rdx); | 258 __ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset), rdx); |
| 259 } else { | 259 } else { |
| 260 __ InitializeFieldsWithFiller(rcx, rdi, rdx); | 260 __ InitializeFieldsWithFiller(rcx, rdi, rdx); |
| 261 } | 261 } |
| 262 | 262 |
| 263 // Add the object tag to make the JSObject real, so that we can continue | 263 // 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. | 264 // and jump into the continuation code at any time from now on. |
| 265 // rbx: JSObject (untagged) | 265 // rbx: JSObject (untagged) |
| 266 __ orp(rbx, Immediate(kHeapObjectTag)); | 266 __ orp(rbx, Immediate(kHeapObjectTag)); |
| 267 | 267 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 413 } |
| 414 | 414 |
| 415 | 415 |
| 416 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { | 416 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { |
| 417 // ----------- S t a t e ------------- | 417 // ----------- S t a t e ------------- |
| 418 // -- rax: number of arguments | 418 // -- rax: number of arguments |
| 419 // -- rdi: constructor function | 419 // -- rdi: constructor function |
| 420 // -- rbx: allocation site or undefined | 420 // -- rbx: allocation site or undefined |
| 421 // -- rdx: original constructor | 421 // -- rdx: original constructor |
| 422 // ----------------------------------- | 422 // ----------------------------------- |
| 423 // TODO(dslomov): support pretenuring | |
| 424 CHECK(!FLAG_pretenuring_call_new); | |
| 425 | 423 |
| 426 { | 424 { |
| 427 FrameScope frame_scope(masm, StackFrame::CONSTRUCT); | 425 FrameScope frame_scope(masm, StackFrame::CONSTRUCT); |
| 428 | 426 |
| 427 // Always push a potential allocation site to preserve a fixed frame size. |
| 428 __ AssertUndefinedOrAllocationSite(rbx); |
| 429 __ Push(rbx); |
| 430 |
| 429 // Store a smi-tagged arguments count on the stack. | 431 // Store a smi-tagged arguments count on the stack. |
| 430 __ Integer32ToSmi(rax, rax); | 432 __ Integer32ToSmi(rax, rax); |
| 431 __ Push(rax); | 433 __ Push(rax); |
| 432 __ SmiToInteger32(rax, rax); | 434 __ SmiToInteger32(rax, rax); |
| 433 | 435 |
| 434 // Push new.target | 436 // Push new.target |
| 435 __ Push(rdx); | 437 __ Push(rdx); |
| 436 | 438 |
| 437 // receiver is the hole. | 439 // receiver is the hole. |
| 438 __ Push(masm->isolate()->factory()->the_hole_value()); | 440 __ Push(masm->isolate()->factory()->the_hole_value()); |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 __ ret(0); | 1709 __ ret(0); |
| 1708 } | 1710 } |
| 1709 | 1711 |
| 1710 | 1712 |
| 1711 #undef __ | 1713 #undef __ |
| 1712 | 1714 |
| 1713 } // namespace internal | 1715 } // namespace internal |
| 1714 } // namespace v8 | 1716 } // namespace v8 |
| 1715 | 1717 |
| 1716 #endif // V8_TARGET_ARCH_X64 | 1718 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |