| Index: src/compiler/frame-elider.cc
|
| diff --git a/src/compiler/frame-elider.cc b/src/compiler/frame-elider.cc
|
| index 172a724dd8a744dce535f47f96ec9f1342d3d4d1..8b9d20bcb4e88c892f63c3269b106d698797c2f0 100644
|
| --- a/src/compiler/frame-elider.cc
|
| +++ b/src/compiler/frame-elider.cc
|
| @@ -2,8 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "src/base/adapters.h"
|
| #include "src/compiler/frame-elider.h"
|
| +#include "src/base/adapters.h"
|
| +#include "src/compiler/linkage.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
| @@ -11,19 +12,23 @@ namespace compiler {
|
|
|
| FrameElider::FrameElider(InstructionSequence* code) : code_(code) {}
|
|
|
| -void FrameElider::Run() {
|
| +void FrameElider::Run(const CallDescriptor* descriptor) {
|
| MarkBlocks();
|
| PropagateMarks();
|
| MarkDeConstruction();
|
| }
|
|
|
| +bool IsDeoptimize(const Instruction* instr) {
|
| + return instr->arch_opcode() == ArchOpcode::kArchDeoptimize ||
|
| + FlagsModeField::decode(instr->opcode()) == kFlags_deoptimize;
|
| +}
|
|
|
| void FrameElider::MarkBlocks() {
|
| for (InstructionBlock* block : instruction_blocks()) {
|
| if (block->needs_frame()) continue;
|
| for (int i = block->code_start(); i < block->code_end(); ++i) {
|
| - if (InstructionAt(i)->IsCall() ||
|
| - InstructionAt(i)->opcode() == ArchOpcode::kArchDeoptimize) {
|
| + if (InstructionAt(i)->IsCall() || IsDeoptimize(InstructionAt(i)) ||
|
| + InstructionAt(i)->arch_opcode() == ArchOpcode::kArchStackPointer) {
|
| block->mark_needs_frame();
|
| break;
|
| }
|
| @@ -33,7 +38,7 @@ void FrameElider::MarkBlocks() {
|
|
|
|
|
| void FrameElider::PropagateMarks() {
|
| - while (PropagateInOrder() && PropagateReversed()) {
|
| + while (PropagateInOrder() || PropagateReversed()) {
|
| }
|
| }
|
|
|
| @@ -47,10 +52,37 @@ void FrameElider::MarkDeConstruction() {
|
| }
|
| // Find "frame -> no frame" transitions, inserting frame
|
| // deconstructions.
|
| + // TODO(mtrofin): we currently have to deal with deferred blocks
|
| + // that branch to deferred on non-deferred blocks, and when
|
| + // the deferred path continues to need a frame, while the non-deferred
|
| + // one doesn't. To avoid penalizing the non-deferred path with the cost of
|
| + // deconstruction, we deconstruct and reconstruct on the deferred path.
|
| + // This is a bit hacky and inefficient (code size). Alternatively, we
|
| + // should insert a deferred block on the edge between the deferred block
|
| + // and the non-deferred one, so we may insert there the deconstruction.
|
| + bool makes_switch = false;
|
| for (RpoNumber& succ : block->successors()) {
|
| if (!InstructionBlockAt(succ)->needs_frame()) {
|
| - DCHECK_EQ(1U, block->SuccessorCount());
|
| - block->mark_must_deconstruct_frame();
|
| + makes_switch = true;
|
| + break;
|
| + }
|
| + }
|
| + if (!makes_switch) continue;
|
| +
|
| + ArchOpcode last_opcode =
|
| + code_->InstructionAt(block->last_instruction_index())->arch_opcode();
|
| + if (last_opcode == kArchThrowTerminator ||
|
| + IsDeoptimize(code_->InstructionAt(block->last_instruction_index()))) {
|
| + continue;
|
| + }
|
| + block->mark_must_deconstruct_frame();
|
| + if (block->SuccessorCount() > 1) {
|
| + for (RpoNumber& succ : block->successors()) {
|
| + InstructionBlock* succ_block = InstructionBlockAt(succ);
|
| + if (succ_block->needs_frame() && succ_block->IsDeferred()) {
|
| + succ_block->mark_must_construct_frame();
|
| + }
|
| + DCHECK_IMPLIES(!succ_block->IsDeferred(), !succ_block->needs_frame());
|
| }
|
| }
|
| } else {
|
|
|