| Index: src/full-codegen/arm64/full-codegen-arm64.cc
|
| diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc
|
| index 9e664bb500e9599606a9e2cbc9f2f2912fe06ac2..742fd47c70b3b4b570dfa8b63e0fb02517d85025 100644
|
| --- a/src/full-codegen/arm64/full-codegen-arm64.cc
|
| +++ b/src/full-codegen/arm64/full-codegen-arm64.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() + kCodeSizeMultiplier / 2;
|
| + weight = Min(kMaxBackEdgeWeight, Max(1, distance / kCodeSizeMultiplier));
|
| + }
|
| + EmitProfilingCounterDecrement(weight);
|
| + Label ok;
|
| + __ B(pl, &ok);
|
| + // Don't need to save result register if we are going to do a tail call.
|
| + if (!is_tail_call) {
|
| + __ Push(x0);
|
| + }
|
| + __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET);
|
| + if (!is_tail_call) {
|
| + __ Pop(x0);
|
| + }
|
| + EmitProfilingCounterReset();
|
| + __ Bind(&ok);
|
| +}
|
|
|
| void FullCodeGenerator::EmitReturnSequence() {
|
| Comment cmnt(masm_, "[ Return sequence");
|
| @@ -430,24 +454,7 @@ void FullCodeGenerator::EmitReturnSequence() {
|
| __ CallRuntime(Runtime::kTraceExit);
|
| DCHECK(x0.Is(result_register()));
|
| }
|
| - // 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;
|
| - __ B(pl, &ok);
|
| - __ Push(x0);
|
| - __ Call(isolate()->builtins()->InterruptCheck(),
|
| - RelocInfo::CODE_TARGET);
|
| - __ Pop(x0);
|
| - EmitProfilingCounterReset();
|
| - __ Bind(&ok);
|
| + EmitProfilingCounterHandlingForReturnSequence(false);
|
|
|
| SetReturnPosition(literal());
|
| const Register& current_sp = __ StackPointer();
|
| @@ -2560,7 +2567,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();
|
|
|