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

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

Issue 803933008: new classes: change semantics of super(...) call and add new.target to construct stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix x64 Created 5 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-object.cc ('k') | src/x64/code-stubs-x64.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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 __ j(above_equal, &ok); 92 __ j(above_equal, &ok);
93 93
94 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); 94 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
95 GenerateTailCallToReturnedCode(masm); 95 GenerateTailCallToReturnedCode(masm);
96 96
97 __ bind(&ok); 97 __ bind(&ok);
98 GenerateTailCallToSharedCode(masm); 98 GenerateTailCallToSharedCode(masm);
99 } 99 }
100 100
101 101
102 static void Generate_Runtime_NewObject(MacroAssembler* masm,
103 bool create_memento,
104 Register original_constructor,
105 Label* count_incremented,
106 Label* allocated) {
107 int offset = 0;
108 if (create_memento) {
109 // Get the cell or allocation site.
110 __ movp(rdi, Operand(rsp, kPointerSize * 2));
111 __ Push(rdi);
112 offset = kPointerSize;
113 }
114
115 // Must restore rsi (context) and rdi (constructor) before calling runtime.
116 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
117 __ movp(rdi, Operand(rsp, offset));
118 __ Push(rdi);
119 __ Push(original_constructor);
120 if (create_memento) {
121 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3);
122 } else {
123 __ CallRuntime(Runtime::kNewObject, 2);
124 }
125 __ movp(rbx, rax); // store result in rbx
126
127 // Runtime_NewObjectWithAllocationSite increments allocation count.
128 // Skip the increment.
129 if (create_memento) {
130 __ jmp(count_incremented);
131 } else {
132 __ jmp(allocated);
133 }
134 }
135
136
102 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 137 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
103 bool is_api_function, 138 bool is_api_function,
104 bool create_memento) { 139 bool create_memento) {
105 // ----------- S t a t e ------------- 140 // ----------- S t a t e -------------
106 // -- rax: number of arguments 141 // -- rax: number of arguments
107 // -- rdi: constructor function 142 // -- rdi: constructor function
108 // -- rbx: allocation site or undefined 143 // -- rbx: allocation site or undefined
144 // -- rdx: original constructor
109 // ----------------------------------- 145 // -----------------------------------
110 146
111 // Should never create mementos for api functions. 147 // Should never create mementos for api functions.
112 DCHECK(!is_api_function || !create_memento); 148 DCHECK(!is_api_function || !create_memento);
113 149
114 // Enter a construct frame. 150 // Enter a construct frame.
115 { 151 {
116 FrameScope scope(masm, StackFrame::CONSTRUCT); 152 FrameScope scope(masm, StackFrame::CONSTRUCT);
117 153
118 if (create_memento) { 154 if (create_memento) {
119 __ AssertUndefinedOrAllocationSite(rbx); 155 __ AssertUndefinedOrAllocationSite(rbx);
120 __ Push(rbx); 156 __ Push(rbx);
121 } 157 }
122 158
123 // Store a smi-tagged arguments count on the stack. 159 // Store a smi-tagged arguments count on the stack.
124 __ Integer32ToSmi(rax, rax); 160 __ Integer32ToSmi(rax, rax);
125 __ Push(rax); 161 __ Push(rax);
126 162
127 // Push the function to invoke on the stack. 163 // Push the function to invoke on the stack.
128 __ Push(rdi); 164 __ Push(rdi);
129 165
166 Label rt_call, normal_new, allocated, count_incremented;
167 __ cmpp(rdx, rdi);
168 __ j(equal, &normal_new);
169
170 Generate_Runtime_NewObject(masm, create_memento, rdx, &count_incremented,
171 &allocated);
172
173 __ bind(&normal_new);
130 // Try to allocate the object without transitioning into C code. If any of 174 // 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. 175 // the preconditions is not met, the code bails out to the runtime call.
132 Label rt_call, allocated;
133 if (FLAG_inline_new) { 176 if (FLAG_inline_new) {
134 Label undo_allocation; 177 Label undo_allocation;
135 178
136 ExternalReference debug_step_in_fp = 179 ExternalReference debug_step_in_fp =
137 ExternalReference::debug_step_in_fp_address(masm->isolate()); 180 ExternalReference::debug_step_in_fp_address(masm->isolate());
138 __ Move(kScratchRegister, debug_step_in_fp); 181 __ Move(kScratchRegister, debug_step_in_fp);
139 __ cmpp(Operand(kScratchRegister, 0), Immediate(0)); 182 __ cmpp(Operand(kScratchRegister, 0), Immediate(0));
140 __ j(not_equal, &rt_call); 183 __ j(not_equal, &rt_call);
141 184
142 // Verified that the constructor is a JSFunction. 185 // Verified that the constructor is a JSFunction.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // example, the map's unused properties potentially do not match the 381 // example, the map's unused properties potentially do not match the
339 // allocated objects unused properties. 382 // allocated objects unused properties.
340 // rbx: JSObject (previous new top) 383 // rbx: JSObject (previous new top)
341 __ bind(&undo_allocation); 384 __ bind(&undo_allocation);
342 __ UndoAllocationInNewSpace(rbx); 385 __ UndoAllocationInNewSpace(rbx);
343 } 386 }
344 387
345 // Allocate the new receiver object using the runtime call. 388 // Allocate the new receiver object using the runtime call.
346 // rdi: function (constructor) 389 // rdi: function (constructor)
347 __ bind(&rt_call); 390 __ bind(&rt_call);
348 int offset = 0; 391 Generate_Runtime_NewObject(masm, create_memento, rdi, &count_incremented,
349 if (create_memento) { 392 &allocated);
350 // Get the cell or allocation site.
351 __ movp(rdi, Operand(rsp, kPointerSize*2));
352 __ Push(rdi);
353 offset = kPointerSize;
354 }
355
356 // Must restore rsi (context) and rdi (constructor) before calling runtime.
357 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
358 __ movp(rdi, Operand(rsp, offset));
359 __ Push(rdi);
360 if (create_memento) {
361 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2);
362 } else {
363 __ CallRuntime(Runtime::kNewObject, 1);
364 }
365 __ movp(rbx, rax); // store result in rbx
366
367 // 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
369 // increment.
370 Label count_incremented;
371 if (create_memento) {
372 __ jmp(&count_incremented);
373 }
374 393
375 // New object allocated. 394 // New object allocated.
376 // rbx: newly allocated object 395 // rbx: newly allocated object
377 __ bind(&allocated); 396 __ bind(&allocated);
378 397
379 if (create_memento) { 398 if (create_memento) {
380 __ movp(rcx, Operand(rsp, kPointerSize*2)); 399 __ movp(rcx, Operand(rsp, kPointerSize*2));
381 __ Cmp(rcx, masm->isolate()->factory()->undefined_value()); 400 __ Cmp(rcx, masm->isolate()->factory()->undefined_value());
382 __ j(equal, &count_incremented); 401 __ j(equal, &count_incremented);
383 // rcx is an AllocationSite. We are creating a memento from it, so we 402 // rcx is an AllocationSite. We are creating a memento from it, so we
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 __ bind(&ok); 1539 __ bind(&ok);
1521 __ ret(0); 1540 __ ret(0);
1522 } 1541 }
1523 1542
1524 1543
1525 #undef __ 1544 #undef __
1526 1545
1527 } } // namespace v8::internal 1546 } } // namespace v8::internal
1528 1547
1529 #endif // V8_TARGET_ARCH_X64 1548 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698