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

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

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