Commit e8c919a5 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by V8 LUCI CQ

[wasm][eh] Update 'delegate' behavior in fuzzer

R=clemensb@chromium.org

Bug: v8:8091
Change-Id: I99546c99de2283c1169b299b5ae3cd89298a8a95
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3148134Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76728}
parent cd5f286d
...@@ -232,7 +232,6 @@ class WasmGenerator { ...@@ -232,7 +232,6 @@ class WasmGenerator {
bool is_delegate = num_catch == 0 && !has_catch_all && data->get<bool>(); bool is_delegate = num_catch == 0 && !has_catch_all && data->get<bool>();
// Allow one more target than there are enclosing try blocks, for delegating // Allow one more target than there are enclosing try blocks, for delegating
// to the caller. // to the caller.
uint8_t delegate_target = data->get<uint8_t>() % (try_blocks_.size() + 1);
base::Vector<const ValueType> return_type_vec = base::Vector<const ValueType> return_type_vec =
return_type.kind() == kVoid ? base::Vector<ValueType>{} return_type.kind() == kVoid ? base::Vector<ValueType>{}
...@@ -240,9 +239,7 @@ class WasmGenerator { ...@@ -240,9 +239,7 @@ class WasmGenerator {
BlockScope block_scope(this, kExprTry, {}, return_type_vec, return_type_vec, BlockScope block_scope(this, kExprTry, {}, return_type_vec, return_type_vec,
!is_delegate); !is_delegate);
int control_depth = static_cast<int>(blocks_.size()) - 1; int control_depth = static_cast<int>(blocks_.size()) - 1;
try_blocks_.push_back(control_depth);
Generate(return_type, data); Generate(return_type, data);
try_blocks_.pop_back();
catch_blocks_.push_back(control_depth); catch_blocks_.push_back(control_depth);
for (int i = 0; i < num_catch; ++i) { for (int i = 0; i < num_catch; ++i) {
const FunctionSig* exception_type = const FunctionSig* exception_type =
...@@ -258,12 +255,10 @@ class WasmGenerator { ...@@ -258,12 +255,10 @@ class WasmGenerator {
Generate(return_type, data); Generate(return_type, data);
} }
if (is_delegate) { if (is_delegate) {
DCHECK_GT(blocks_.size(), try_blocks_.size()); // The delegate target depth does not include the current try block,
// If {delegate_target == try_blocks_.size()}, delegate to the caller. // because 'delegate' closes this scope. However it is still in the
int delegate_depth = delegate_target == try_blocks_.size() // {blocks_} list, so remove one to get the correct size.
? static_cast<int>(blocks_.size()) - 2 int delegate_depth = data->get<uint8_t>() % (blocks_.size() - 1);
: static_cast<int>(blocks_.size() - 2 -
try_blocks_[delegate_target]);
builder_->EmitWithU32V(kExprDelegate, delegate_depth); builder_->EmitWithU32V(kExprDelegate, delegate_depth);
} }
catch_blocks_.pop_back(); catch_blocks_.pop_back();
...@@ -1050,7 +1045,6 @@ class WasmGenerator { ...@@ -1050,7 +1045,6 @@ class WasmGenerator {
std::vector<ValueType> globals_; std::vector<ValueType> globals_;
std::vector<uint8_t> mutable_globals_; // indexes into {globals_}. std::vector<uint8_t> mutable_globals_; // indexes into {globals_}.
uint32_t recursion_depth = 0; uint32_t recursion_depth = 0;
std::vector<int> try_blocks_;
std::vector<int> catch_blocks_; std::vector<int> catch_blocks_;
bool has_simd_; bool has_simd_;
uint32_t num_structs_; uint32_t num_structs_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment