Skip to content

Commit

Permalink
[wasm][liftoff] Update value stack after interface calls
Browse files Browse the repository at this point in the history
This refactors the way the function-body-decoder maintains
its value stack: it now always calls the respective instruction's
interface function before updating its value stack (by dropping
input values and pushing results). The benefit is that interface
functions still see the original values in the decoder.

No change in observable behavior is intended.

Change-Id: I7618d11ff16675ef29ccb246371ac4fc85733955
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2732019
Commit-Queue: Jakob Kummerow <[email protected]>
Reviewed-by: Clemens Backes <[email protected]>
Cr-Commit-Position: refs/heads/master@{#73193}
  • Loading branch information
jakobkummerow authored and Commit Bot committed Mar 4, 2021
1 parent 3dbb84c commit 1b5c7e1
Show file tree
Hide file tree
Showing 4 changed files with 620 additions and 366 deletions.
17 changes: 9 additions & 8 deletions src/wasm/baseline/liftoff-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ class LiftoffCompiler {
__ DeallocateStackSlot(sizeof(int64_t));
}

void DoReturn(FullDecoder* decoder) {
void DoReturn(FullDecoder* decoder, uint32_t /* drop_values */) {
if (FLAG_trace_wasm) TraceFunctionExit(decoder);
size_t num_returns = decoder->sig_->return_count();
if (num_returns > 0) __ MoveToReturnLocations(decoder->sig_, descriptor_);
Expand Down Expand Up @@ -2243,9 +2243,10 @@ class LiftoffCompiler {
__ jmp(target->label.get());
}

void BrOrRet(FullDecoder* decoder, uint32_t depth) {
void BrOrRet(FullDecoder* decoder, uint32_t depth,
uint32_t /* drop_values */) {
if (depth == decoder->control_depth() - 1) {
DoReturn(decoder);
DoReturn(decoder, 0);
} else {
BrImpl(decoder->control_at(depth));
}
Expand Down Expand Up @@ -2279,7 +2280,7 @@ class LiftoffCompiler {
outstanding_op_ = kNoOutstandingOp;
}

BrOrRet(decoder, depth);
BrOrRet(decoder, depth, 0);
__ bind(&cont_false);
}

Expand All @@ -2292,7 +2293,7 @@ class LiftoffCompiler {
__ jmp(label.get());
} else {
__ bind(label.get());
BrOrRet(decoder, br_depth);
BrOrRet(decoder, br_depth, 0);
}
}

Expand Down Expand Up @@ -2944,7 +2945,7 @@ class LiftoffCompiler {
__ emit_cond_jump(kUnequal, &cont_false, ref_object.type.kind(), ref.gp(),
null);

BrOrRet(decoder, depth);
BrOrRet(decoder, depth, 0);
__ bind(&cont_false);
__ PushRegister(kRef, ref);
}
Expand Down Expand Up @@ -4808,7 +4809,7 @@ class LiftoffCompiler {
SubtypeCheck(decoder, obj, rtt, &cont_false, kNullFails);

__ PushRegister(rtt.type.is_bottom() ? kBottom : obj.type.kind(), obj_reg);
BrOrRet(decoder, depth);
BrOrRet(decoder, depth, 0);

__ bind(&cont_false);
// Drop the branch's value, restore original value.
Expand Down Expand Up @@ -4962,7 +4963,7 @@ class LiftoffCompiler {

__ bind(&match);
__ PushRegister(result_kind, obj_reg);
BrOrRet(decoder, br_depth);
BrOrRet(decoder, br_depth, 0);

__ bind(&no_match);
// Drop the branch's value, restore original value.
Expand Down
Loading

0 comments on commit 1b5c7e1

Please sign in to comment.