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

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

Issue 1670133002: [es6] Further fixing of tail Calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tail call tracing added Created 4 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 | « no previous file | src/full-codegen/arm64/full-codegen-arm64.cc » ('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 #if V8_TARGET_ARCH_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 EmitProfilingCounterReset(); 416 EmitProfilingCounterReset();
417 417
418 __ bind(&ok); 418 __ bind(&ok);
419 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); 419 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
420 // Record a mapping of the OSR id to this PC. This is used if the OSR 420 // Record a mapping of the OSR id to this PC. This is used if the OSR
421 // entry becomes the target of a bailout. We don't expect it to be, but 421 // entry becomes the target of a bailout. We don't expect it to be, but
422 // we want it to work if it is. 422 // we want it to work if it is.
423 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); 423 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS);
424 } 424 }
425 425
426 void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence(
427 bool is_tail_call) {
428 // Pretend that the exit is a backwards jump to the entry.
429 int weight = 1;
430 if (info_->ShouldSelfOptimize()) {
431 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
432 } else {
433 int distance = masm_->pc_offset();
434 weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
435 }
436 EmitProfilingCounterDecrement(weight);
437 Label ok;
438 __ b(pl, &ok);
439 // Don't need to save result register if we are going to do a tail call.
440 if (!is_tail_call) {
441 __ push(r0);
442 }
443 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET);
444 if (!is_tail_call) {
445 __ pop(r0);
446 }
447 EmitProfilingCounterReset();
448 __ bind(&ok);
449 }
426 450
427 void FullCodeGenerator::EmitReturnSequence() { 451 void FullCodeGenerator::EmitReturnSequence() {
428 Comment cmnt(masm_, "[ Return sequence"); 452 Comment cmnt(masm_, "[ Return sequence");
429 if (return_label_.is_bound()) { 453 if (return_label_.is_bound()) {
430 __ b(&return_label_); 454 __ b(&return_label_);
431 } else { 455 } else {
432 __ bind(&return_label_); 456 __ bind(&return_label_);
433 if (FLAG_trace) { 457 if (FLAG_trace) {
434 // Push the return value on the stack as the parameter. 458 // Push the return value on the stack as the parameter.
435 // Runtime::TraceExit returns its parameter in r0. 459 // Runtime::TraceExit returns its parameter in r0.
436 __ push(r0); 460 __ push(r0);
437 __ CallRuntime(Runtime::kTraceExit); 461 __ CallRuntime(Runtime::kTraceExit);
438 } 462 }
439 // Pretend that the exit is a backwards jump to the entry. 463 EmitProfilingCounterHandlingForReturnSequence(false);
440 int weight = 1;
441 if (info_->ShouldSelfOptimize()) {
442 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
443 } else {
444 int distance = masm_->pc_offset();
445 weight = Min(kMaxBackEdgeWeight,
446 Max(1, distance / kCodeSizeMultiplier));
447 }
448 EmitProfilingCounterDecrement(weight);
449 Label ok;
450 __ b(pl, &ok);
451 __ push(r0);
452 __ Call(isolate()->builtins()->InterruptCheck(),
453 RelocInfo::CODE_TARGET);
454 __ pop(r0);
455 EmitProfilingCounterReset();
456 __ bind(&ok);
457 464
458 // Make sure that the constant pool is not emitted inside of the return 465 // Make sure that the constant pool is not emitted inside of the return
459 // sequence. 466 // sequence.
460 { Assembler::BlockConstPoolScope block_const_pool(masm_); 467 { Assembler::BlockConstPoolScope block_const_pool(masm_);
461 int32_t arg_count = info_->scope()->num_parameters() + 1; 468 int32_t arg_count = info_->scope()->num_parameters() + 1;
462 int32_t sp_delta = arg_count * kPointerSize; 469 int32_t sp_delta = arg_count * kPointerSize;
463 SetReturnPosition(literal()); 470 SetReturnPosition(literal());
464 // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5! 471 // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5!
465 PredictableCodeSizeScope predictable(masm_, -1); 472 PredictableCodeSizeScope predictable(masm_, -1);
466 __ LeaveFrame(StackFrame::JAVA_SCRIPT); 473 __ LeaveFrame(StackFrame::JAVA_SCRIPT);
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { 2755 void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) {
2749 // Load the arguments. 2756 // Load the arguments.
2750 ZoneList<Expression*>* args = expr->arguments(); 2757 ZoneList<Expression*>* args = expr->arguments();
2751 int arg_count = args->length(); 2758 int arg_count = args->length();
2752 for (int i = 0; i < arg_count; i++) { 2759 for (int i = 0; i < arg_count; i++) {
2753 VisitForStackValue(args->at(i)); 2760 VisitForStackValue(args->at(i));
2754 } 2761 }
2755 2762
2756 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); 2763 PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
2757 SetCallPosition(expr); 2764 SetCallPosition(expr);
2765 if (expr->tail_call_mode() == TailCallMode::kAllow) {
2766 if (FLAG_trace) {
2767 __ CallRuntime(Runtime::kTraceTailCall);
2768 }
2769 // Update profiling counters before the tail call since we will
2770 // not return to this function.
2771 EmitProfilingCounterHandlingForReturnSequence(true);
2772 }
2758 Handle<Code> ic = 2773 Handle<Code> ic =
2759 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) 2774 CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode())
2760 .code(); 2775 .code();
2761 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot()))); 2776 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackICSlot())));
2762 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); 2777 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
2763 // Don't assign a type feedback id to the IC, since type feedback is provided 2778 // Don't assign a type feedback id to the IC, since type feedback is provided
2764 // by the vector above. 2779 // by the vector above.
2765 CallIC(ic); 2780 CallIC(ic);
2766 2781
2767 RecordJSReturnSite(expr); 2782 RecordJSReturnSite(expr);
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after
4728 DCHECK(interrupt_address == 4743 DCHECK(interrupt_address ==
4729 isolate->builtins()->OsrAfterStackCheck()->entry()); 4744 isolate->builtins()->OsrAfterStackCheck()->entry());
4730 return OSR_AFTER_STACK_CHECK; 4745 return OSR_AFTER_STACK_CHECK;
4731 } 4746 }
4732 4747
4733 4748
4734 } // namespace internal 4749 } // namespace internal
4735 } // namespace v8 4750 } // namespace v8
4736 4751
4737 #endif // V8_TARGET_ARCH_ARM 4752 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698