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

Side by Side Diff: src/arm64/full-codegen-arm64.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/arm64/code-stubs-arm64.cc ('k') | src/ast-value-factory.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 7 #if V8_TARGET_ARCH_ARM64
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 int num_parameters = info->scope()->num_parameters(); 255 int num_parameters = info->scope()->num_parameters();
256 int offset = num_parameters * kPointerSize; 256 int offset = num_parameters * kPointerSize;
257 __ Add(x2, fp, StandardFrameConstants::kCallerSPOffset + offset); 257 __ Add(x2, fp, StandardFrameConstants::kCallerSPOffset + offset);
258 __ Mov(x1, Smi::FromInt(num_parameters)); 258 __ Mov(x1, Smi::FromInt(num_parameters));
259 __ Push(x3, x2, x1); 259 __ Push(x3, x2, x1);
260 260
261 // Arguments to ArgumentsAccessStub: 261 // Arguments to ArgumentsAccessStub:
262 // function, receiver address, parameter count. 262 // function, receiver address, parameter count.
263 // The stub will rewrite receiver and parameter count if the previous 263 // The stub will rewrite receiver and parameter count if the previous
264 // stack frame was an arguments adapter frame. 264 // stack frame was an arguments adapter frame.
265 ArgumentsAccessStub::HasNewTarget has_new_target =
266 IsSubclassConstructor(info->function()->kind())
267 ? ArgumentsAccessStub::HAS_NEW_TARGET
268 : ArgumentsAccessStub::NO_NEW_TARGET;
265 ArgumentsAccessStub::Type type; 269 ArgumentsAccessStub::Type type;
266 if (is_strict(language_mode())) { 270 if (is_strict(language_mode())) {
267 type = ArgumentsAccessStub::NEW_STRICT; 271 type = ArgumentsAccessStub::NEW_STRICT;
268 } else if (function()->has_duplicate_parameters()) { 272 } else if (function()->has_duplicate_parameters()) {
269 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 273 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
270 } else { 274 } else {
271 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 275 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
272 } 276 }
273 ArgumentsAccessStub stub(isolate(), type); 277 ArgumentsAccessStub stub(isolate(), type, has_new_target);
274 __ CallStub(&stub); 278 __ CallStub(&stub);
275 279
276 SetVar(arguments, x0, x1, x2); 280 SetVar(arguments, x0, x1, x2);
277 } 281 }
278 282
279 if (FLAG_trace) { 283 if (FLAG_trace) {
280 __ CallRuntime(Runtime::kTraceEnter, 0); 284 __ CallRuntime(Runtime::kTraceEnter, 0);
281 } 285 }
282 286
283 287
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 __ mov(current_sp, fp); 452 __ mov(current_sp, fp);
449 int no_frame_start = masm_->pc_offset(); 453 int no_frame_start = masm_->pc_offset();
450 __ ldp(fp, lr, MemOperand(current_sp, 2 * kXRegSize, PostIndex)); 454 __ ldp(fp, lr, MemOperand(current_sp, 2 * kXRegSize, PostIndex));
451 // Drop the arguments and receiver and return. 455 // Drop the arguments and receiver and return.
452 // TODO(all): This implementation is overkill as it supports 2**31+1 456 // TODO(all): This implementation is overkill as it supports 2**31+1
453 // arguments, consider how to improve it without creating a security 457 // arguments, consider how to improve it without creating a security
454 // hole. 458 // hole.
455 __ ldr_pcrel(ip0, (3 * kInstructionSize) >> kLoadLiteralScaleLog2); 459 __ ldr_pcrel(ip0, (3 * kInstructionSize) >> kLoadLiteralScaleLog2);
456 __ add(current_sp, current_sp, ip0); 460 __ add(current_sp, current_sp, ip0);
457 __ ret(); 461 __ ret();
458 __ dc64(kXRegSize * (info_->scope()->num_parameters() + 1)); 462 int32_t arg_count = info_->scope()->num_parameters() + 1;
463 if (FLAG_experimental_classes &&
464 IsSubclassConstructor(info_->function()->kind())) {
465 arg_count++;
466 }
467 __ dc64(kXRegSize * arg_count);
459 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); 468 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset());
460 } 469 }
461 } 470 }
462 } 471 }
463 472
464 473
465 void FullCodeGenerator::EffectContext::Plug(Variable* var) const { 474 void FullCodeGenerator::EffectContext::Plug(Variable* var) const {
466 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 475 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
467 } 476 }
468 477
(...skipping 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2939 __ Mov(x3, SmiFromSlot(expr->CallNewFeedbackSlot())); 2948 __ Mov(x3, SmiFromSlot(expr->CallNewFeedbackSlot()));
2940 2949
2941 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); 2950 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
2942 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 2951 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
2943 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 2952 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
2944 context()->Plug(x0); 2953 context()->Plug(x0);
2945 } 2954 }
2946 2955
2947 2956
2948 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 2957 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
2958 Comment cmnt(masm_, "[ SuperConstructorCall");
2959 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
2960 GetVar(result_register(), new_target_var);
2961 __ Push(result_register());
2962
2949 SuperReference* super_ref = expr->expression()->AsSuperReference(); 2963 SuperReference* super_ref = expr->expression()->AsSuperReference();
2950 EmitLoadSuperConstructor(super_ref); 2964 EmitLoadSuperConstructor(super_ref);
2951 __ push(result_register()); 2965 __ push(result_register());
2952 2966
2953 Variable* this_var = super_ref->this_var()->var(); 2967 Variable* this_var = super_ref->this_var()->var();
2954 2968
2955 GetVar(x0, this_var); 2969 GetVar(x0, this_var);
2956 Label uninitialized_this; 2970 Label uninitialized_this;
2957 __ JumpIfRoot(x0, Heap::kTheHoleValueRootIndex, &uninitialized_this); 2971 __ JumpIfRoot(x0, Heap::kTheHoleValueRootIndex, &uninitialized_this);
2958 __ Mov(x0, Operand(this_var->name())); 2972 __ Mov(x0, Operand(this_var->name()));
(...skipping 22 matching lines...) Expand all
2981 /* TODO(dslomov): support pretenuring. 2995 /* TODO(dslomov): support pretenuring.
2982 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); 2996 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot());
2983 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == 2997 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() ==
2984 expr->CallNewFeedbackSlot().ToInt() + 1); 2998 expr->CallNewFeedbackSlot().ToInt() + 1);
2985 */ 2999 */
2986 } 3000 }
2987 3001
2988 __ LoadObject(x2, FeedbackVector()); 3002 __ LoadObject(x2, FeedbackVector());
2989 __ Mov(x3, SmiFromSlot(expr->CallFeedbackSlot())); 3003 __ Mov(x3, SmiFromSlot(expr->CallFeedbackSlot()));
2990 3004
2991 // TODO(dslomov): use a different stub and propagate new.target. 3005 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET);
2992 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
2993 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3006 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
2994 3007
3008 __ Drop(1);
3009
2995 RecordJSReturnSite(expr); 3010 RecordJSReturnSite(expr);
2996 3011
2997 EmitVariableAssignment(this_var, Token::INIT_CONST); 3012 EmitVariableAssignment(this_var, Token::INIT_CONST);
2998 context()->Plug(x0); 3013 context()->Plug(x0);
2999 } 3014 }
3000 3015
3001 3016
3002 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3017 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3003 ZoneList<Expression*>* args = expr->arguments(); 3018 ZoneList<Expression*>* args = expr->arguments();
3004 DCHECK(args->length() == 1); 3019 DCHECK(args->length() == 1);
(...skipping 2400 matching lines...) Expand 10 before | Expand all | Expand 10 after
5405 return previous_; 5420 return previous_;
5406 } 5421 }
5407 5422
5408 5423
5409 #undef __ 5424 #undef __
5410 5425
5411 5426
5412 } } // namespace v8::internal 5427 } } // namespace v8::internal
5413 5428
5414 #endif // V8_TARGET_ARCH_ARM64 5429 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm64/code-stubs-arm64.cc ('k') | src/ast-value-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698