Commit 2b0b06f3 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[wasm-gc] Improve error message for object allocators

Bug: v8:7748
Change-Id: I4382c73bf089672ab9f054754a87e27b51478b86
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2964602
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75187}
parent d7f30b17
...@@ -3875,7 +3875,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -3875,7 +3875,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
rtt.type.is_bottom() || rtt.type.is_bottom() ||
(rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) { (rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) {
PopTypeError(imm.struct_type->field_count(), rtt, PopTypeError(imm.struct_type->field_count(), rtt,
"rtt for type " + std::to_string(imm.index)); "rtt with depth for type " + std::to_string(imm.index));
return 0; return 0;
} }
ArgVector args = PeekArgs(imm.struct_type, 1); ArgVector args = PeekArgs(imm.struct_type, 1);
...@@ -3912,7 +3912,8 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -3912,7 +3912,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (!VALIDATE( if (!VALIDATE(
rtt.type.is_bottom() || rtt.type.is_bottom() ||
(rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) { (rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) {
PopTypeError(0, rtt, "rtt for type " + std::to_string(imm.index)); PopTypeError(0, rtt,
"rtt with depth for type " + std::to_string(imm.index));
return 0; return 0;
} }
Value value = CreateValue(ValueType::Ref(imm.index, kNonNullable)); Value value = CreateValue(ValueType::Ref(imm.index, kNonNullable));
...@@ -3997,7 +3998,8 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -3997,7 +3998,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (!VALIDATE( if (!VALIDATE(
rtt.type.is_bottom() || rtt.type.is_bottom() ||
(rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) { (rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) {
PopTypeError(2, rtt, "rtt for type " + std::to_string(imm.index)); PopTypeError(2, rtt,
"rtt with depth for type " + std::to_string(imm.index));
return 0; return 0;
} }
Value length = Peek(1, 1, kWasmI32); Value length = Peek(1, 1, kWasmI32);
...@@ -4030,7 +4032,8 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -4030,7 +4032,8 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (!VALIDATE( if (!VALIDATE(
rtt.type.is_bottom() || rtt.type.is_bottom() ||
(rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) { (rtt.type.ref_index() == imm.index && rtt.type.has_depth()))) {
PopTypeError(1, rtt, "rtt for type " + std::to_string(imm.index)); PopTypeError(1, rtt,
"rtt with depth for type " + std::to_string(imm.index));
return 0; return 0;
} }
Value length = Peek(1, 0, kWasmI32); Value length = Peek(1, 0, kWasmI32);
......
...@@ -3924,8 +3924,8 @@ TEST_F(FunctionBodyDecoderTest, GCStruct) { ...@@ -3924,8 +3924,8 @@ TEST_F(FunctionBodyDecoderTest, GCStruct) {
WASM_RTT_CANON(array_type_index)), WASM_RTT_CANON(array_type_index)),
kExprDrop}, kExprDrop},
kAppendEnd, kAppendEnd,
"struct.new_with_rtt[1] expected rtt for type 0, found " "struct.new_with_rtt[1] expected rtt with depth for type 0, "
"rtt.canon of type (rtt 0 1)"); "found rtt.canon of type (rtt 0 1)");
// Out-of-bounds index. // Out-of-bounds index.
ExpectFailure(sigs.v_v(), ExpectFailure(sigs.v_v(),
{WASM_STRUCT_NEW_WITH_RTT(42, WASM_I32V(0), {WASM_STRUCT_NEW_WITH_RTT(42, WASM_I32V(0),
...@@ -4057,8 +4057,8 @@ TEST_F(FunctionBodyDecoderTest, GCArray) { ...@@ -4057,8 +4057,8 @@ TEST_F(FunctionBodyDecoderTest, GCArray) {
array_type_index, WASM_REF_NULL(kFuncRefCode), WASM_I32V(5), array_type_index, WASM_REF_NULL(kFuncRefCode), WASM_I32V(5),
WASM_RTT_CANON(struct_type_index))}, WASM_RTT_CANON(struct_type_index))},
kAppendEnd, kAppendEnd,
"array.new_with_rtt[2] expected rtt for type 0, found " "array.new_with_rtt[2] expected rtt with depth for type 0, "
"rtt.canon of type (rtt 0 1)"); "found rtt.canon of type (rtt 0 1)");
// Wrong type index. // Wrong type index.
ExpectFailure( ExpectFailure(
sigs.v_v(), sigs.v_v(),
......
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