Skip to content

Commit 93aa0db

Browse files
authored
[spec] Update br_on_cast validation (#92)
As described in the overview, relax validation so that the input and output types need only be in the same hierarchy rather than requiring that the output type be a subtype of the input type. In addition to updating the SpecTec source of truth, add notes about what the extra supertypes in the formal rules are achieving. These notes are modeled on the similar note that already exists for ref.cast_desc.
1 parent 4ff66b3 commit 93aa0db

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

document/core/valid/instructions.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ $${rule-prose: Instr_ok/br_on_cast}
235235

236236
$${rule: Instr_ok/br_on_cast}
237237

238+
.. note::
239+
The existence of a common supertype ${:rt_3} means that ${:rt_1} and ${:rt_2} must be in the same heap subtyping hierarchy.
240+
238241

239242
.. _valid-br_on_cast_fail:
240243

@@ -245,6 +248,9 @@ $${rule-prose: Instr_ok/br_on_cast_fail}
245248

246249
$${rule: Instr_ok/br_on_cast_fail}
247250

251+
.. note::
252+
The existence of a common supertype ${:rt_3} means that ${:rt_1} and ${:rt_2} must be in the same heap subtyping hierarchy.
253+
248254

249255
.. _valid-call:
250256

specification/wasm-latest/2.3-validation.instructions.spectec

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,21 @@ rule Instr_ok/br_on_cast:
9898
-- if C.LABELS[l] = t* rt
9999
-- Reftype_ok: C |- rt_1 : OK
100100
-- Reftype_ok: C |- rt_2 : OK
101-
-- Reftype_sub: C |- rt_2 <: rt_1
101+
-- Reftype_ok: C |- rt_3 : OK
102+
----
103+
-- Reftype_sub: C |- rt_1 <: rt_3
104+
-- Reftype_sub: C |- rt_2 <: rt_3
102105
-- Reftype_sub: C |- rt_2 <: rt
103106

104107
rule Instr_ok/br_on_cast_fail:
105108
C |- BR_ON_CAST_FAIL l rt_1 rt_2 : t* rt_1 -> t* rt_2
106109
-- if C.LABELS[l] = t* rt
107110
-- Reftype_ok: C |- rt_1 : OK
108111
-- Reftype_ok: C |- rt_2 : OK
109-
-- Reftype_sub: C |- rt_2 <: rt_1
112+
-- Reftype_ok: C |- rt_3 : OK
113+
----
114+
-- Reftype_sub: C |- rt_1 <: rt_3
115+
-- Reftype_sub: C |- rt_2 <: rt_3
110116
-- Reftype_sub: C |- $diffrt(rt_1, rt_2) <: rt
111117

112118

0 commit comments

Comments
 (0)