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

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

Issue 900423002: X87: 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: Created 5 years, 10 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 | « no previous file | src/x87/code-stubs-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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 __ j(above_equal, &ok, Label::kNear); 93 __ j(above_equal, &ok, Label::kNear);
94 94
95 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); 95 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
96 GenerateTailCallToReturnedCode(masm); 96 GenerateTailCallToReturnedCode(masm);
97 97
98 __ bind(&ok); 98 __ bind(&ok);
99 GenerateTailCallToSharedCode(masm); 99 GenerateTailCallToSharedCode(masm);
100 } 100 }
101 101
102 102
103 static void Generate_Runtime_NewObject(MacroAssembler* masm,
104 bool create_memento,
105 Register original_constructor,
106 Label* count_incremented,
107 Label* allocated) {
108 int offset = 0;
109 if (create_memento) {
110 // Get the cell or allocation site.
111 __ mov(edi, Operand(esp, kPointerSize * 2));
112 __ push(edi);
113 offset = kPointerSize;
114 }
115
116 // Must restore esi (context) and edi (constructor) before calling
117 // runtime.
118 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
119 __ mov(edi, Operand(esp, offset));
120 __ push(edi);
121 __ push(original_constructor);
122 if (create_memento) {
123 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3);
124 } else {
125 __ CallRuntime(Runtime::kNewObject, 2);
126 }
127 __ mov(ebx, eax); // store result in ebx
128
129 // Runtime_NewObjectWithAllocationSite increments allocation count.
130 // Skip the increment.
131 if (create_memento) {
132 __ jmp(count_incremented);
133 } else {
134 __ jmp(allocated);
135 }
136 }
137
138
103 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 139 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
104 bool is_api_function, 140 bool is_api_function,
105 bool create_memento) { 141 bool create_memento) {
106 // ----------- S t a t e ------------- 142 // ----------- S t a t e -------------
107 // -- eax: number of arguments 143 // -- eax: number of arguments
108 // -- edi: constructor function 144 // -- edi: constructor function
109 // -- ebx: allocation site or undefined 145 // -- ebx: allocation site or undefined
146 // -- edx: original constructor
110 // ----------------------------------- 147 // -----------------------------------
111 148
112 // Should never create mementos for api functions. 149 // Should never create mementos for api functions.
113 DCHECK(!is_api_function || !create_memento); 150 DCHECK(!is_api_function || !create_memento);
114 151
115 // Enter a construct frame. 152 // Enter a construct frame.
116 { 153 {
117 FrameScope scope(masm, StackFrame::CONSTRUCT); 154 FrameScope scope(masm, StackFrame::CONSTRUCT);
118 155
119 if (create_memento) { 156 if (create_memento) {
120 __ AssertUndefinedOrAllocationSite(ebx); 157 __ AssertUndefinedOrAllocationSite(ebx);
121 __ push(ebx); 158 __ push(ebx);
122 } 159 }
123 160
124 // Store a smi-tagged arguments count on the stack. 161 // Store a smi-tagged arguments count on the stack.
125 __ SmiTag(eax); 162 __ SmiTag(eax);
126 __ push(eax); 163 __ push(eax);
127 164
128 // Push the function to invoke on the stack. 165 // Push the function to invoke on the stack.
129 __ push(edi); 166 __ push(edi);
130 167
168 __ cmp(edx, edi);
169 Label normal_new;
170 Label count_incremented;
171 Label allocated;
172 __ j(equal, &normal_new);
173
174 // Original constructor and function are different.
175 Generate_Runtime_NewObject(masm, create_memento, edx, &count_incremented,
176 &allocated);
177 __ bind(&normal_new);
178
131 // Try to allocate the object without transitioning into C code. If any of 179 // Try to allocate the object without transitioning into C code. If any of
132 // the preconditions is not met, the code bails out to the runtime call. 180 // the preconditions is not met, the code bails out to the runtime call.
133 Label rt_call, allocated; 181 Label rt_call;
134 if (FLAG_inline_new) { 182 if (FLAG_inline_new) {
135 Label undo_allocation; 183 Label undo_allocation;
136 ExternalReference debug_step_in_fp = 184 ExternalReference debug_step_in_fp =
137 ExternalReference::debug_step_in_fp_address(masm->isolate()); 185 ExternalReference::debug_step_in_fp_address(masm->isolate());
138 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); 186 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0));
139 __ j(not_equal, &rt_call); 187 __ j(not_equal, &rt_call);
140 188
141 // Verified that the constructor is a JSFunction. 189 // Verified that the constructor is a JSFunction.
142 // Load the initial map and verify that it is in fact a map. 190 // Load the initial map and verify that it is in fact a map.
143 // edi: constructor 191 // edi: constructor
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Undo the setting of the new top so that the heap is verifiable. For 385 // Undo the setting of the new top so that the heap is verifiable. For
338 // example, the map's unused properties potentially do not match the 386 // example, the map's unused properties potentially do not match the
339 // allocated objects unused properties. 387 // allocated objects unused properties.
340 // ebx: JSObject (previous new top) 388 // ebx: JSObject (previous new top)
341 __ bind(&undo_allocation); 389 __ bind(&undo_allocation);
342 __ UndoAllocationInNewSpace(ebx); 390 __ UndoAllocationInNewSpace(ebx);
343 } 391 }
344 392
345 // Allocate the new receiver object using the runtime call. 393 // Allocate the new receiver object using the runtime call.
346 __ bind(&rt_call); 394 __ bind(&rt_call);
347 int offset = 0; 395 Generate_Runtime_NewObject(masm, create_memento, edi, &count_incremented,
348 if (create_memento) { 396 &allocated);
349 // Get the cell or allocation site.
350 __ mov(edi, Operand(esp, kPointerSize * 2));
351 __ push(edi);
352 offset = kPointerSize;
353 }
354
355 // Must restore esi (context) and edi (constructor) before calling runtime.
356 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
357 __ mov(edi, Operand(esp, offset));
358 // edi: function (constructor)
359 __ push(edi);
360 if (create_memento) {
361 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2);
362 } else {
363 __ CallRuntime(Runtime::kNewObject, 1);
364 }
365 __ mov(ebx, eax); // store result in ebx
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
375 // New object allocated. 397 // New object allocated.
376 // ebx: newly allocated object 398 // ebx: newly allocated object
377 __ bind(&allocated); 399 __ bind(&allocated);
378 400
379 if (create_memento) { 401 if (create_memento) {
380 __ mov(ecx, Operand(esp, kPointerSize * 2)); 402 __ mov(ecx, Operand(esp, kPointerSize * 2));
381 __ cmp(ecx, masm->isolate()->factory()->undefined_value()); 403 __ cmp(ecx, masm->isolate()->factory()->undefined_value());
382 __ j(equal, &count_incremented); 404 __ j(equal, &count_incremented);
383 // ecx is an AllocationSite. We are creating a memento from it, so we 405 // ecx is an AllocationSite. We are creating a memento from it, so we
384 // need to increment the memento create count. 406 // need to increment the memento create count.
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 1474
1453 __ bind(&ok); 1475 __ bind(&ok);
1454 __ ret(0); 1476 __ ret(0);
1455 } 1477 }
1456 1478
1457 #undef __ 1479 #undef __
1458 } 1480 }
1459 } // namespace v8::internal 1481 } // namespace v8::internal
1460 1482
1461 #endif // V8_TARGET_ARCH_X87 1483 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/x87/code-stubs-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698