Skip to content

Commit

Permalink
[vm/bytecode/compiler] Remove excessive stack overflow checks when in…
Browse files Browse the repository at this point in the history
…lining

Megamorphic benchmark in bytecode/JIT-only mode:

Before:
MegaNeverOverridden(RunTime): 1847.3550369344412 us.
MegaNeverOverriddenIndirect(RunTime): 2054.2040605749485 us.
MegaOnlyOverriddenOnceIndirect(RunTime): 3444.1204027538724 us.
MegaFieldIndirect(RunTime): 2334.6812497082847 us.
MegaFieldHasGetterOnceIndirect(RunTime): 3212.210929373997 us.

After:
MegaNeverOverridden(RunTime): 1393.4616984679665 us.
MegaNeverOverriddenIndirect(RunTime): 1363.8226980231766 us.
MegaOnlyOverriddenOnceIndirect(RunTime): 2814.319476793249 us.
MegaFieldIndirect(RunTime): 1893.1759697256387 us.
MegaFieldHasGetterOnceIndirect(RunTime): 2782.111602225313 us.


dart-lang/sdk#36342

Change-Id: Ibb73c1339f5b8f859531c8ed29aca4054d733ce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97843
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
  • Loading branch information
alexmarkov authored and commit-bot@chromium.org committed Mar 27, 2019
1 parent 9ea9612 commit 994f535
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
11 changes: 11 additions & 0 deletions runtime/vm/compiler/frontend/base_flow_graph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ Fragment BaseFlowGraphBuilder::CheckStackOverflow(TokenPosition position,
new (Z) CheckStackOverflowInstr(position, loop_depth, GetNextDeoptId()));
}

Fragment BaseFlowGraphBuilder::CheckStackOverflowInPrologue(
TokenPosition position) {
if (IsInlining()) {
// If we are inlining don't actually attach the stack check. We must still
// create the stack check in order to allocate a deopt id.
CheckStackOverflow(position, 0);
return Fragment();
}
return CheckStackOverflow(position, 0);
}

Fragment BaseFlowGraphBuilder::Constant(const Object& value) {
ASSERT(value.IsNotTemporaryScopedHandle());
ConstantInstr* constant = new (Z) ConstantInstr(value);
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/compiler/frontend/base_flow_graph_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class BaseFlowGraphBuilder {
TargetEntryInstr** otherwise_entry);
Fragment Return(TokenPosition position);
Fragment CheckStackOverflow(TokenPosition position, intptr_t loop_depth);
Fragment CheckStackOverflowInPrologue(TokenPosition position);
Fragment ThrowException(TokenPosition position);
Fragment TailCall(const Code& code);

Expand Down
7 changes: 6 additions & 1 deletion runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,12 @@ void BytecodeFlowGraphBuilder::BuildCheckStack() {
if (is_generating_interpreter()) {
UNIMPLEMENTED(); // TODO(alexmarkov): interpreter
}
code_ += B->CheckStackOverflow(position_, DecodeOperandA().value());
const intptr_t loop_depth = DecodeOperandA().value();
if (loop_depth == 0) {
code_ += B->CheckStackOverflowInPrologue(position_);
} else {
code_ += B->CheckStackOverflow(position_, loop_depth);
}
ASSERT(B->stack_ == nullptr);
}

Expand Down
9 changes: 2 additions & 7 deletions runtime/vm/compiler/frontend/kernel_to_il.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,8 @@ Fragment FlowGraphBuilder::TryCatch(int try_handler_index) {

Fragment FlowGraphBuilder::CheckStackOverflowInPrologue(
TokenPosition position) {
if (IsInlining()) {
// If we are inlining don't actually attach the stack check. We must still
// create the stack check in order to allocate a deopt id.
CheckStackOverflow(position, loop_depth_);
return Fragment();
}
return CheckStackOverflow(position, loop_depth_);
ASSERT(loop_depth_ == 0);
return BaseFlowGraphBuilder::CheckStackOverflowInPrologue(position);
}

Fragment FlowGraphBuilder::CloneContext(
Expand Down

0 comments on commit 994f535

Please sign in to comment.