| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 102 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 103 bool is_api_function, | 103 bool is_api_function, |
| 104 bool create_memento) { | 104 bool create_memento) { |
| 105 // ----------- S t a t e ------------- | 105 // ----------- S t a t e ------------- |
| 106 // -- rax: number of arguments | 106 // -- rax: number of arguments |
| 107 // -- rdi: constructor function | 107 // -- rdi: constructor function |
| 108 // -- rbx: allocation site or undefined | 108 // -- rbx: allocation site or undefined |
| 109 // -- r11: original constructor |
| 109 // ----------------------------------- | 110 // ----------------------------------- |
| 110 | 111 |
| 111 // Should never create mementos for api functions. | 112 // Should never create mementos for api functions. |
| 112 DCHECK(!is_api_function || !create_memento); | 113 DCHECK(!is_api_function || !create_memento); |
| 113 | 114 |
| 114 // Enter a construct frame. | 115 // Enter a construct frame. |
| 115 { | 116 { |
| 116 FrameScope scope(masm, StackFrame::CONSTRUCT); | 117 FrameScope scope(masm, StackFrame::CONSTRUCT); |
| 117 | 118 |
| 118 if (create_memento) { | 119 if (create_memento) { |
| 119 __ AssertUndefinedOrAllocationSite(rbx); | 120 __ AssertUndefinedOrAllocationSite(rbx); |
| 120 __ Push(rbx); | 121 __ Push(rbx); |
| 121 } | 122 } |
| 122 | 123 |
| 123 // Store a smi-tagged arguments count on the stack. | 124 // Store a smi-tagged arguments count on the stack. |
| 124 __ Integer32ToSmi(rax, rax); | 125 __ Integer32ToSmi(rax, rax); |
| 125 __ Push(rax); | 126 __ Push(rax); |
| 126 | 127 |
| 127 // Push the function to invoke on the stack. | 128 // Push the function to invoke on the stack. |
| 128 __ Push(rdi); | 129 __ Push(rdi); |
| 129 | 130 |
| 131 Label rt_call; |
| 132 __ cmpp(r11, rdi); |
| 133 __ j(not_equal, &rt_call); |
| 134 |
| 130 // Try to allocate the object without transitioning into C code. If any of | 135 // 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. | 136 // the preconditions is not met, the code bails out to the runtime call. |
| 132 Label rt_call, allocated; | 137 Label allocated; |
| 133 if (FLAG_inline_new) { | 138 if (FLAG_inline_new) { |
| 134 Label undo_allocation; | 139 Label undo_allocation; |
| 135 | 140 |
| 136 ExternalReference debug_step_in_fp = | 141 ExternalReference debug_step_in_fp = |
| 137 ExternalReference::debug_step_in_fp_address(masm->isolate()); | 142 ExternalReference::debug_step_in_fp_address(masm->isolate()); |
| 138 __ Move(kScratchRegister, debug_step_in_fp); | 143 __ Move(kScratchRegister, debug_step_in_fp); |
| 139 __ cmpp(Operand(kScratchRegister, 0), Immediate(0)); | 144 __ cmpp(Operand(kScratchRegister, 0), Immediate(0)); |
| 140 __ j(not_equal, &rt_call); | 145 __ j(not_equal, &rt_call); |
| 141 | 146 |
| 142 // Verified that the constructor is a JSFunction. | 147 // Verified that the constructor is a JSFunction. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // Get the cell or allocation site. | 355 // Get the cell or allocation site. |
| 351 __ movp(rdi, Operand(rsp, kPointerSize*2)); | 356 __ movp(rdi, Operand(rsp, kPointerSize*2)); |
| 352 __ Push(rdi); | 357 __ Push(rdi); |
| 353 offset = kPointerSize; | 358 offset = kPointerSize; |
| 354 } | 359 } |
| 355 | 360 |
| 356 // Must restore rsi (context) and rdi (constructor) before calling runtime. | 361 // Must restore rsi (context) and rdi (constructor) before calling runtime. |
| 357 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 362 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 358 __ movp(rdi, Operand(rsp, offset)); | 363 __ movp(rdi, Operand(rsp, offset)); |
| 359 __ Push(rdi); | 364 __ Push(rdi); |
| 365 __ Push(r11); |
| 360 if (create_memento) { | 366 if (create_memento) { |
| 361 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2); | 367 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
| 362 } else { | 368 } else { |
| 363 __ CallRuntime(Runtime::kNewObject, 1); | 369 __ CallRuntime(Runtime::kNewObject, 2); |
| 364 } | 370 } |
| 365 __ movp(rbx, rax); // store result in rbx | 371 __ movp(rbx, rax); // store result in rbx |
| 366 | 372 |
| 367 // If we ended up using the runtime, and we want a memento, then the | 373 // If we ended up using the runtime, and we want a memento, then the |
| 368 // runtime call made it for us, and we shouldn't do create count | 374 // runtime call made it for us, and we shouldn't do create count |
| 369 // increment. | 375 // increment. |
| 370 Label count_incremented; | 376 Label count_incremented; |
| 371 if (create_memento) { | 377 if (create_memento) { |
| 372 __ jmp(&count_incremented); | 378 __ jmp(&count_incremented); |
| 373 } | 379 } |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 __ bind(&ok); | 1526 __ bind(&ok); |
| 1521 __ ret(0); | 1527 __ ret(0); |
| 1522 } | 1528 } |
| 1523 | 1529 |
| 1524 | 1530 |
| 1525 #undef __ | 1531 #undef __ |
| 1526 | 1532 |
| 1527 } } // namespace v8::internal | 1533 } } // namespace v8::internal |
| 1528 | 1534 |
| 1529 #endif // V8_TARGET_ARCH_X64 | 1535 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |