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

Side by Side Diff: src/x87/full-codegen-x87.cc

Issue 912233003: X87: new classes: implement new.target passing to superclass constructor (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 | « src/x87/deoptimizer-x87.cc ('k') | no next file » | 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/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // The stub will rewrite receiver and parameter count if the previous 254 // The stub will rewrite receiver and parameter count if the previous
255 // stack frame was an arguments adapter frame. 255 // stack frame was an arguments adapter frame.
256 ArgumentsAccessStub::Type type; 256 ArgumentsAccessStub::Type type;
257 if (is_strict(language_mode())) { 257 if (is_strict(language_mode())) {
258 type = ArgumentsAccessStub::NEW_STRICT; 258 type = ArgumentsAccessStub::NEW_STRICT;
259 } else if (function()->has_duplicate_parameters()) { 259 } else if (function()->has_duplicate_parameters()) {
260 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 260 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
261 } else { 261 } else {
262 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 262 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
263 } 263 }
264 ArgumentsAccessStub stub(isolate(), type); 264 ArgumentsAccessStub::HasNewTarget has_new_target =
265 IsSubclassConstructor(info->function()->kind())
266 ? ArgumentsAccessStub::HAS_NEW_TARGET
267 : ArgumentsAccessStub::NO_NEW_TARGET;
268 ArgumentsAccessStub stub(isolate(), type, has_new_target);
265 __ CallStub(&stub); 269 __ CallStub(&stub);
266 270
267 SetVar(arguments, eax, ebx, edx); 271 SetVar(arguments, eax, ebx, edx);
268 } 272 }
269 273
270 if (FLAG_trace) { 274 if (FLAG_trace) {
271 __ CallRuntime(Runtime::kTraceEnter, 0); 275 __ CallRuntime(Runtime::kTraceEnter, 0);
272 } 276 }
273 277
274 // Visit the declarations and body unless there is an illegal 278 // Visit the declarations and body unless there is an illegal
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 masm_->bind(&check_exit_codesize); 407 masm_->bind(&check_exit_codesize);
404 #endif 408 #endif
405 SetSourcePosition(function()->end_position() - 1); 409 SetSourcePosition(function()->end_position() - 1);
406 __ RecordJSReturn(); 410 __ RecordJSReturn();
407 // Do not use the leave instruction here because it is too short to 411 // Do not use the leave instruction here because it is too short to
408 // patch with the code required by the debugger. 412 // patch with the code required by the debugger.
409 __ mov(esp, ebp); 413 __ mov(esp, ebp);
410 int no_frame_start = masm_->pc_offset(); 414 int no_frame_start = masm_->pc_offset();
411 __ pop(ebp); 415 __ pop(ebp);
412 416
413 int arguments_bytes = (info_->scope()->num_parameters() + 1) * kPointerSize; 417 int arg_count = info_->scope()->num_parameters() + 1;
418 if (FLAG_experimental_classes &&
419 IsSubclassConstructor(info_->function()->kind())) {
420 arg_count++;
421 }
422 int arguments_bytes = arg_count * kPointerSize;
414 __ Ret(arguments_bytes, ecx); 423 __ Ret(arguments_bytes, ecx);
415 // Check that the size of the code used for returning is large enough 424 // Check that the size of the code used for returning is large enough
416 // for the debugger's requirements. 425 // for the debugger's requirements.
417 DCHECK(Assembler::kJSReturnSequenceLength <= 426 DCHECK(Assembler::kJSReturnSequenceLength <=
418 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); 427 masm_->SizeOfCodeGeneratedSince(&check_exit_codesize));
419 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); 428 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset());
420 } 429 }
421 } 430 }
422 431
423 432
(...skipping 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); 3123 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot())));
3115 3124
3116 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); 3125 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
3117 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3126 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3118 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 3127 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
3119 context()->Plug(eax); 3128 context()->Plug(eax);
3120 } 3129 }
3121 3130
3122 3131
3123 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3132 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3133 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3134 GetVar(eax, new_target_var);
3135 __ push(eax);
3136
3124 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3137 SuperReference* super_ref = expr->expression()->AsSuperReference();
3125 EmitLoadSuperConstructor(super_ref); 3138 EmitLoadSuperConstructor(super_ref);
3126 __ push(result_register()); 3139 __ push(result_register());
3127 3140
3128 Variable* this_var = super_ref->this_var()->var(); 3141 Variable* this_var = super_ref->this_var()->var();
3129 GetVar(eax, this_var); 3142 GetVar(eax, this_var);
3130 __ cmp(eax, isolate()->factory()->the_hole_value()); 3143 __ cmp(eax, isolate()->factory()->the_hole_value());
3131 Label uninitialized_this; 3144 Label uninitialized_this;
3132 __ j(equal, &uninitialized_this); 3145 __ j(equal, &uninitialized_this);
3133 __ push(Immediate(this_var->name())); 3146 __ push(Immediate(this_var->name()));
(...skipping 21 matching lines...) Expand all
3155 /* TODO(dslomov): support pretenuring. 3168 /* TODO(dslomov): support pretenuring.
3156 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); 3169 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot());
3157 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == 3170 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() ==
3158 expr->CallNewFeedbackSlot().ToInt() + 1); 3171 expr->CallNewFeedbackSlot().ToInt() + 1);
3159 */ 3172 */
3160 } 3173 }
3161 3174
3162 __ LoadHeapObject(ebx, FeedbackVector()); 3175 __ LoadHeapObject(ebx, FeedbackVector());
3163 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); 3176 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot())));
3164 3177
3165 // TODO(dslomov): use a different stub and propagate new.target. 3178 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET);
3166 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
3167 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3179 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3168 3180
3181 __ Drop(1);
3182
3169 RecordJSReturnSite(expr); 3183 RecordJSReturnSite(expr);
3170 3184
3171 EmitVariableAssignment(this_var, Token::INIT_CONST); 3185 EmitVariableAssignment(this_var, Token::INIT_CONST);
3172 context()->Plug(eax); 3186 context()->Plug(eax);
3173 } 3187 }
3174 3188
3175 3189
3176 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3190 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3177 ZoneList<Expression*>* args = expr->arguments(); 3191 ZoneList<Expression*>* args = expr->arguments();
3178 DCHECK(args->length() == 1); 3192 DCHECK(args->length() == 1);
(...skipping 2096 matching lines...) Expand 10 before | Expand all | Expand 10 after
5275 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5289 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5276 Assembler::target_address_at(call_target_address, 5290 Assembler::target_address_at(call_target_address,
5277 unoptimized_code)); 5291 unoptimized_code));
5278 return OSR_AFTER_STACK_CHECK; 5292 return OSR_AFTER_STACK_CHECK;
5279 } 5293 }
5280 5294
5281 5295
5282 } } // namespace v8::internal 5296 } } // namespace v8::internal
5283 5297
5284 #endif // V8_TARGET_ARCH_X87 5298 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/deoptimizer-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698