Index: src/full-codegen/mips64/full-codegen-mips64.cc |
diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc |
index bbe9f7ffe4ceea6e6136a816b8fd4a4eda34ea0c..a3380a3310b7c8ef569b76aadc8cd1eba26b7ffe 100644 |
--- a/src/full-codegen/mips64/full-codegen-mips64.cc |
+++ b/src/full-codegen/mips64/full-codegen-mips64.cc |
@@ -414,6 +414,30 @@ void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, |
PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); |
} |
+void FullCodeGenerator::EmitProfilingCounterHandlingForReturnSequence( |
+ bool is_tail_call) { |
+ // Pretend that the exit is a backwards jump to the entry. |
+ int weight = 1; |
+ if (info_->ShouldSelfOptimize()) { |
+ weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
+ } else { |
+ int distance = masm_->pc_offset(); |
+ weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier)); |
+ } |
+ EmitProfilingCounterDecrement(weight); |
+ Label ok; |
+ __ Branch(&ok, ge, a3, Operand(zero_reg)); |
+ // Don't need to save result register if we are going to do a tail call. |
+ if (!is_tail_call) { |
+ __ push(v0); |
+ } |
+ __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
+ if (!is_tail_call) { |
+ __ pop(v0); |
+ } |
+ EmitProfilingCounterReset(); |
+ __ bind(&ok); |
+} |
void FullCodeGenerator::EmitReturnSequence() { |
Comment cmnt(masm_, "[ Return sequence"); |
@@ -427,24 +451,7 @@ void FullCodeGenerator::EmitReturnSequence() { |
__ push(v0); |
__ CallRuntime(Runtime::kTraceExit); |
} |
- // Pretend that the exit is a backwards jump to the entry. |
- int weight = 1; |
- if (info_->ShouldSelfOptimize()) { |
- weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
- } else { |
- int distance = masm_->pc_offset(); |
- weight = Min(kMaxBackEdgeWeight, |
- Max(1, distance / kCodeSizeMultiplier)); |
- } |
- EmitProfilingCounterDecrement(weight); |
- Label ok; |
- __ Branch(&ok, ge, a3, Operand(zero_reg)); |
- __ push(v0); |
- __ Call(isolate()->builtins()->InterruptCheck(), |
- RelocInfo::CODE_TARGET); |
- __ pop(v0); |
- EmitProfilingCounterReset(); |
- __ bind(&ok); |
+ EmitProfilingCounterHandlingForReturnSequence(false); |
// Make sure that the constant pool is not emitted inside of the return |
// sequence. |
@@ -2752,6 +2759,14 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
// Record source position of the IC call. |
SetCallPosition(expr); |
+ if (expr->tail_call_mode() == TailCallMode::kAllow) { |
+ if (FLAG_trace) { |
+ __ CallRuntime(Runtime::kTraceTailCall); |
+ } |
+ // Update profiling counters before the tail call since we will |
+ // not return to this function. |
+ EmitProfilingCounterHandlingForReturnSequence(true); |
+ } |
Handle<Code> ic = |
CodeFactory::CallIC(isolate(), arg_count, mode, expr->tail_call_mode()) |
.code(); |