Index: src/full-codegen/ppc/full-codegen-ppc.cc |
diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc |
index 0ce982204da664cc030e3a77a20d60462fb633fa..b049b289e5b365aed77dfcee3842fdbac7745aa3 100644 |
--- a/src/full-codegen/ppc/full-codegen-ppc.cc |
+++ b/src/full-codegen/ppc/full-codegen-ppc.cc |
@@ -411,6 +411,31 @@ 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() + kCodeSizeMultiplier / 2; |
+ weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier)); |
+ } |
+ EmitProfilingCounterDecrement(weight); |
+ Label ok; |
+ __ cmpi(r6, Operand::Zero()); |
+ __ bge(&ok); |
+ // Don't need to save result register if we are going to do a tail call. |
+ if (!is_tail_call) { |
+ __ push(r3); |
+ } |
+ __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
+ if (!is_tail_call) { |
+ __ pop(r3); |
+ } |
+ EmitProfilingCounterReset(); |
+ __ bind(&ok); |
+} |
void FullCodeGenerator::EmitReturnSequence() { |
Comment cmnt(masm_, "[ Return sequence"); |
@@ -424,23 +449,7 @@ void FullCodeGenerator::EmitReturnSequence() { |
__ push(r3); |
__ 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() + kCodeSizeMultiplier / 2; |
- weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier)); |
- } |
- EmitProfilingCounterDecrement(weight); |
- Label ok; |
- __ cmpi(r6, Operand::Zero()); |
- __ bge(&ok); |
- __ push(r3); |
- __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
- __ pop(r3); |
- EmitProfilingCounterReset(); |
- __ bind(&ok); |
+ EmitProfilingCounterHandlingForReturnSequence(false); |
// Make sure that the constant pool is not emitted inside of the return |
// sequence. |
@@ -2741,6 +2750,14 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
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(); |