OLD | NEW |
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_ARM | 7 #if V8_TARGET_ARCH_ARM |
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 Loading... |
255 int offset = num_parameters * kPointerSize; | 255 int offset = num_parameters * kPointerSize; |
256 __ add(r2, fp, | 256 __ add(r2, fp, |
257 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 257 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
258 __ mov(r1, Operand(Smi::FromInt(num_parameters))); | 258 __ mov(r1, Operand(Smi::FromInt(num_parameters))); |
259 __ Push(r3, r2, r1); | 259 __ Push(r3, r2, r1); |
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 receiever and parameter count if the previous | 263 // The stub will rewrite receiever 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, r0, r1, r2); | 280 SetVar(arguments, r0, r1, r2); |
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 // Visit the declarations and body unless there is an illegal | 287 // Visit the declarations and body unless there is an illegal |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 __ bind(&ok); | 447 __ bind(&ok); |
444 | 448 |
445 #ifdef DEBUG | 449 #ifdef DEBUG |
446 // Add a label for checking the size of the code used for returning. | 450 // Add a label for checking the size of the code used for returning. |
447 Label check_exit_codesize; | 451 Label check_exit_codesize; |
448 __ bind(&check_exit_codesize); | 452 __ bind(&check_exit_codesize); |
449 #endif | 453 #endif |
450 // Make sure that the constant pool is not emitted inside of the return | 454 // Make sure that the constant pool is not emitted inside of the return |
451 // sequence. | 455 // sequence. |
452 { Assembler::BlockConstPoolScope block_const_pool(masm_); | 456 { Assembler::BlockConstPoolScope block_const_pool(masm_); |
453 int32_t sp_delta = (info_->scope()->num_parameters() + 1) * kPointerSize; | 457 int32_t arg_count = info_->scope()->num_parameters() + 1; |
| 458 if (FLAG_experimental_classes && |
| 459 IsSubclassConstructor(info_->function()->kind())) { |
| 460 arg_count++; |
| 461 } |
| 462 int32_t sp_delta = arg_count * kPointerSize; |
454 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); | 463 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
455 // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5! | 464 // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5! |
456 PredictableCodeSizeScope predictable(masm_, -1); | 465 PredictableCodeSizeScope predictable(masm_, -1); |
457 __ RecordJSReturn(); | 466 __ RecordJSReturn(); |
458 int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 467 int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
459 { ConstantPoolUnavailableScope constant_pool_unavailable(masm_); | 468 { ConstantPoolUnavailableScope constant_pool_unavailable(masm_); |
460 __ add(sp, sp, Operand(sp_delta)); | 469 __ add(sp, sp, Operand(sp_delta)); |
461 __ Jump(lr); | 470 __ Jump(lr); |
462 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); | 471 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
463 } | 472 } |
(...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3250 __ mov(r3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3259 __ mov(r3, Operand(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
3251 | 3260 |
3252 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3261 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
3253 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3262 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3254 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3263 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3255 context()->Plug(r0); | 3264 context()->Plug(r0); |
3256 } | 3265 } |
3257 | 3266 |
3258 | 3267 |
3259 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3268 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3269 Comment cmnt(masm_, "[ SuperConstructorCall"); |
| 3270 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
| 3271 GetVar(result_register(), new_target_var); |
| 3272 __ Push(result_register()); |
| 3273 |
3260 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 3274 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
3261 EmitLoadSuperConstructor(super_ref); | 3275 EmitLoadSuperConstructor(super_ref); |
3262 __ push(result_register()); | 3276 __ push(result_register()); |
3263 | 3277 |
3264 Variable* this_var = super_ref->this_var()->var(); | 3278 Variable* this_var = super_ref->this_var()->var(); |
3265 | 3279 |
3266 GetVar(r0, this_var); | 3280 GetVar(r0, this_var); |
3267 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 3281 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
3268 Label uninitialized_this; | 3282 Label uninitialized_this; |
3269 __ b(eq, &uninitialized_this); | 3283 __ b(eq, &uninitialized_this); |
(...skipping 23 matching lines...) Expand all Loading... |
3293 /* TODO(dslomov): support pretenuring. | 3307 /* TODO(dslomov): support pretenuring. |
3294 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 3308 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
3295 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == | 3309 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
3296 expr->CallNewFeedbackSlot().ToInt() + 1); | 3310 expr->CallNewFeedbackSlot().ToInt() + 1); |
3297 */ | 3311 */ |
3298 } | 3312 } |
3299 | 3313 |
3300 __ Move(r2, FeedbackVector()); | 3314 __ Move(r2, FeedbackVector()); |
3301 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); | 3315 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); |
3302 | 3316 |
3303 // TODO(dslomov): use a different stub and propagate new.target. | 3317 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3304 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | |
3305 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3318 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3306 | 3319 |
| 3320 __ Drop(1); |
| 3321 |
3307 RecordJSReturnSite(expr); | 3322 RecordJSReturnSite(expr); |
3308 | 3323 |
3309 EmitVariableAssignment(this_var, Token::INIT_CONST); | 3324 EmitVariableAssignment(this_var, Token::INIT_CONST); |
3310 context()->Plug(r0); | 3325 context()->Plug(r0); |
3311 } | 3326 } |
3312 | 3327 |
3313 | 3328 |
3314 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3329 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3315 ZoneList<Expression*>* args = expr->arguments(); | 3330 ZoneList<Expression*>* args = expr->arguments(); |
3316 DCHECK(args->length() == 1); | 3331 DCHECK(args->length() == 1); |
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5426 | 5441 |
5427 DCHECK(interrupt_address == | 5442 DCHECK(interrupt_address == |
5428 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5443 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5429 return OSR_AFTER_STACK_CHECK; | 5444 return OSR_AFTER_STACK_CHECK; |
5430 } | 5445 } |
5431 | 5446 |
5432 | 5447 |
5433 } } // namespace v8::internal | 5448 } } // namespace v8::internal |
5434 | 5449 |
5435 #endif // V8_TARGET_ARCH_ARM | 5450 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |