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

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

Issue 908883002: new classes: implement new.target passing to superclass constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix x64 arithmetic 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/x64/code-stubs-x64.cc ('k') | test/mjsunit/harmony/classes-experimental.js » ('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/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 int num_parameters = info->scope()->num_parameters(); 247 int num_parameters = info->scope()->num_parameters();
248 int offset = num_parameters * kPointerSize; 248 int offset = num_parameters * kPointerSize;
249 __ leap(rdx, 249 __ leap(rdx,
250 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); 250 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset));
251 __ Push(rdx); 251 __ Push(rdx);
252 __ Push(Smi::FromInt(num_parameters)); 252 __ Push(Smi::FromInt(num_parameters));
253 // Arguments to ArgumentsAccessStub: 253 // Arguments to ArgumentsAccessStub:
254 // function, receiver address, parameter count. 254 // function, receiver address, parameter count.
255 // The stub will rewrite receiver and parameter count if the previous 255 // The stub will rewrite receiver and parameter count if the previous
256 // stack frame was an arguments adapter frame. 256 // stack frame was an arguments adapter frame.
257
258 ArgumentsAccessStub::HasNewTarget has_new_target =
259 IsSubclassConstructor(info->function()->kind())
260 ? ArgumentsAccessStub::HAS_NEW_TARGET
261 : ArgumentsAccessStub::NO_NEW_TARGET;
257 ArgumentsAccessStub::Type type; 262 ArgumentsAccessStub::Type type;
258 if (is_strict(language_mode())) { 263 if (is_strict(language_mode())) {
259 type = ArgumentsAccessStub::NEW_STRICT; 264 type = ArgumentsAccessStub::NEW_STRICT;
260 } else if (function()->has_duplicate_parameters()) { 265 } else if (function()->has_duplicate_parameters()) {
261 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 266 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
262 } else { 267 } else {
263 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 268 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
264 } 269 }
265 ArgumentsAccessStub stub(isolate(), type); 270 ArgumentsAccessStub stub(isolate(), type, has_new_target);
266 __ CallStub(&stub); 271 __ CallStub(&stub);
267 272
268 SetVar(arguments, rax, rbx, rdx); 273 SetVar(arguments, rax, rbx, rdx);
269 } 274 }
270 275
271 if (FLAG_trace) { 276 if (FLAG_trace) {
272 __ CallRuntime(Runtime::kTraceEnter, 0); 277 __ CallRuntime(Runtime::kTraceEnter, 0);
273 } 278 }
274 279
275 // Visit the declarations and body unless there is an illegal 280 // Visit the declarations and body unless there is an illegal
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 masm_->bind(&check_exit_codesize); 414 masm_->bind(&check_exit_codesize);
410 #endif 415 #endif
411 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); 416 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
412 __ RecordJSReturn(); 417 __ RecordJSReturn();
413 // Do not use the leave instruction here because it is too short to 418 // Do not use the leave instruction here because it is too short to
414 // patch with the code required by the debugger. 419 // patch with the code required by the debugger.
415 __ movp(rsp, rbp); 420 __ movp(rsp, rbp);
416 __ popq(rbp); 421 __ popq(rbp);
417 int no_frame_start = masm_->pc_offset(); 422 int no_frame_start = masm_->pc_offset();
418 423
419 int arguments_bytes = (info_->scope()->num_parameters() + 1) * kPointerSize; 424 int arg_count = info_->scope()->num_parameters() + 1;
425 if (FLAG_experimental_classes &&
426 IsSubclassConstructor(info_->function()->kind())) {
427 arg_count++;
428 }
429 int arguments_bytes = arg_count * kPointerSize;
420 __ Ret(arguments_bytes, rcx); 430 __ Ret(arguments_bytes, rcx);
421 431
422 // Add padding that will be overwritten by a debugger breakpoint. We 432 // Add padding that will be overwritten by a debugger breakpoint. We
423 // have just generated at least 7 bytes: "movp rsp, rbp; pop rbp; ret k" 433 // have just generated at least 7 bytes: "movp rsp, rbp; pop rbp; ret k"
424 // (3 + 1 + 3) for x64 and at least 6 (2 + 1 + 3) bytes for x32. 434 // (3 + 1 + 3) for x64 and at least 6 (2 + 1 + 3) bytes for x32.
425 const int kPadding = Assembler::kJSReturnSequenceLength - 435 const int kPadding = Assembler::kJSReturnSequenceLength -
426 kPointerSize == kInt64Size ? 7 : 6; 436 kPointerSize == kInt64Size ? 7 : 6;
427 for (int i = 0; i < kPadding; ++i) { 437 for (int i = 0; i < kPadding; ++i) {
428 masm_->int3(); 438 masm_->int3();
429 } 439 }
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after
3135 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot())); 3145 __ Move(rdx, SmiFromSlot(expr->CallNewFeedbackSlot()));
3136 3146
3137 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); 3147 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
3138 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3148 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3139 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 3149 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
3140 context()->Plug(rax); 3150 context()->Plug(rax);
3141 } 3151 }
3142 3152
3143 3153
3144 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3154 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3155 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3156 GetVar(result_register(), new_target_var);
3157 __ Push(result_register());
3158
3145 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3159 SuperReference* super_ref = expr->expression()->AsSuperReference();
3146 EmitLoadSuperConstructor(super_ref); 3160 EmitLoadSuperConstructor(super_ref);
3147 __ Push(result_register()); 3161 __ Push(result_register());
3148 3162
3149 Variable* this_var = super_ref->this_var()->var(); 3163 Variable* this_var = super_ref->this_var()->var();
3150 3164
3151 GetVar(rax, this_var); 3165 GetVar(rax, this_var);
3152 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 3166 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
3153 Label uninitialized_this; 3167 Label uninitialized_this;
3154 __ j(equal, &uninitialized_this); 3168 __ j(equal, &uninitialized_this);
(...skipping 24 matching lines...) Expand all
3179 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); 3193 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot());
3180 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == 3194 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() ==
3181 expr->CallNewFeedbackSlot().ToInt() + 1); 3195 expr->CallNewFeedbackSlot().ToInt() + 1);
3182 */ 3196 */
3183 } 3197 }
3184 3198
3185 __ Move(rbx, FeedbackVector()); 3199 __ Move(rbx, FeedbackVector());
3186 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); 3200 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot()));
3187 3201
3188 // TODO(dslomov): use a different stub and propagate new.target. 3202 // TODO(dslomov): use a different stub and propagate new.target.
3189 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); 3203 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET);
3190 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3204 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3191 3205
3206 __ Drop(1);
3207
3192 RecordJSReturnSite(expr); 3208 RecordJSReturnSite(expr);
3193 3209
3210
3194 EmitVariableAssignment(this_var, Token::INIT_CONST); 3211 EmitVariableAssignment(this_var, Token::INIT_CONST);
3195 context()->Plug(rax); 3212 context()->Plug(rax);
3196 } 3213 }
3197 3214
3198 3215
3199 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3216 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3200 ZoneList<Expression*>* args = expr->arguments(); 3217 ZoneList<Expression*>* args = expr->arguments();
3201 DCHECK(args->length() == 1); 3218 DCHECK(args->length() == 1);
3202 3219
3203 VisitForAccumulatorValue(args->at(0)); 3220 VisitForAccumulatorValue(args->at(0));
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5332 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5316 Assembler::target_address_at(call_target_address, 5333 Assembler::target_address_at(call_target_address,
5317 unoptimized_code)); 5334 unoptimized_code));
5318 return OSR_AFTER_STACK_CHECK; 5335 return OSR_AFTER_STACK_CHECK;
5319 } 5336 }
5320 5337
5321 5338
5322 } } // namespace v8::internal 5339 } } // namespace v8::internal
5323 5340
5324 #endif // V8_TARGET_ARCH_X64 5341 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | test/mjsunit/harmony/classes-experimental.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698