Skip to content

Commit 97b27bd

Browse files
authored
Rename ref.cast_desc to ref.cast_desc_eq (#89)
And similarly for br_on_cast_desc and br_on_cast_desc_fail. This anticipates a future where we may want a ref.cast_desc instruction that performs a normal cast rather than just comparing descriptor pointers, but takes a descriptor as a handle to the target RTT to use for the cast.
1 parent 2a5e895 commit 97b27bd

File tree

15 files changed

+614
-614
lines changed

15 files changed

+614
-614
lines changed

interpreter/binary/decode.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ let rec instr s =
664664
(match opcode with
665665
| 0x18l -> br_on_cast x rt1 rt2
666666
| 0x19l -> br_on_cast_fail x rt1 rt2
667-
| 0x25l -> br_on_cast_desc x rt1 rt2
668-
| 0x26l -> br_on_cast_desc_fail x rt1 rt2
667+
| 0x25l -> br_on_cast_desc_eq x rt1 rt2
668+
| 0x26l -> br_on_cast_desc_eq_fail x rt1 rt2
669669
| _ -> assert false
670670
)
671671

@@ -677,8 +677,8 @@ let rec instr s =
677677
| 0x1el -> i31_get_u
678678

679679
| 0x22l -> let x = at idx s in ref_get_desc x
680-
| 0x23l -> let ht = heaptype s in ref_cast_desc (NoNull, ht)
681-
| 0x24l -> let ht = heaptype s in ref_cast_desc (Null, ht)
680+
| 0x23l -> let ht = heaptype s in ref_cast_desc_eq (NoNull, ht)
681+
| 0x24l -> let ht = heaptype s in ref_cast_desc_eq (Null, ht)
682682

683683
| n -> illegal2 s pos b n
684684
)

interpreter/binary/encode.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,10 @@ struct
277277
| BrOnCastFail (x, (nul1, t1), (nul2, t2)) ->
278278
let flags = bit 0 (nul1 = Null) + bit 1 (nul2 = Null) in
279279
op 0xfb; op 0x19; byte flags; idx x; heaptype t1; heaptype t2
280-
| BrOnCastDesc (x, (nul1, t1), (nul2, t2)) ->
280+
| BrOnCastDescEq (x, (nul1, t1), (nul2, t2)) ->
281281
let flags = bit 0 (nul1 = Null) + bit 1 (nul2 = Null) in
282282
op 0xfb; op 0x25; byte flags; idx x; heaptype t1; heaptype t2
283-
| BrOnCastDescFail (x, (nul1, t1), (nul2, t2)) ->
283+
| BrOnCastDescEqFail (x, (nul1, t1), (nul2, t2)) ->
284284
let flags = bit 0 (nul1 = Null) + bit 1 (nul2 = Null) in
285285
op 0xfb; op 0x26; byte flags; idx x; heaptype t1; heaptype t2
286286
| Return -> op 0x0f
@@ -436,8 +436,8 @@ struct
436436
| RefTest (Null, t) -> op 0xfb; op 0x15; heaptype t
437437
| RefCast (NoNull, t) -> op 0xfb; op 0x16; heaptype t
438438
| RefCast (Null, t) -> op 0xfb; op 0x17; heaptype t
439-
| RefCastDesc (NoNull, t) -> op 0xfb; op 0x23; heaptype t
440-
| RefCastDesc (Null, t) -> op 0xfb; op 0x24; heaptype t
439+
| RefCastDescEq (NoNull, t) -> op 0xfb; op 0x23; heaptype t
440+
| RefCastDescEq (Null, t) -> op 0xfb; op 0x24; heaptype t
441441

442442
| RefGetDesc x -> op 0xfb; op 0x22; idx x
443443

interpreter/exec/eval.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,31 @@ let rec step (c : config) : config =
258258
else
259259
Ref r :: vs', [Plain (Br x) @@ e.at]
260260

261-
| BrOnCastDesc (x, _rt1, _rt2), Ref (NullRef _) :: vs' ->
261+
| BrOnCastDescEq (x, _rt1, _rt2), Ref (NullRef _) :: vs' ->
262262
vs', [Trapping "null descriptor reference" @@ e.at]
263263

264-
| BrOnCastDesc (x, _rt1, (Null, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
264+
| BrOnCastDescEq (x, _rt1, (Null, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
265265
Ref r :: vs', [Plain (Br x) @@ e.at]
266266

267-
| BrOnCastDesc (x, _rt1, (NoNull, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
267+
| BrOnCastDescEq (x, _rt1, (NoNull, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
268268
Ref r :: vs', []
269269

270-
| BrOnCastDesc (x, _rt1, _rt2), Ref desc :: Ref r :: vs' ->
270+
| BrOnCastDescEq (x, _rt1, _rt2), Ref desc :: Ref r :: vs' ->
271271
(match Aggr.read_desc r with
272272
| Some desc' when eq_ref desc desc' -> Ref r :: vs', [Plain (Br x) @@ e.at]
273273
| _ -> Ref r :: vs', []
274274
)
275275

276-
| BrOnCastDescFail (x, _rt1, _rt2), Ref (NullRef _) :: vs' ->
276+
| BrOnCastDescEqFail (x, _rt1, _rt2), Ref (NullRef _) :: vs' ->
277277
vs', [Trapping "null descriptor reference" @@ e.at]
278278

279-
| BrOnCastDescFail (x, _rt1, (Null, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
279+
| BrOnCastDescEqFail (x, _rt1, (Null, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
280280
Ref r :: vs', []
281281

282-
| BrOnCastDescFail (x, _rt1, (NoNull, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
282+
| BrOnCastDescEqFail (x, _rt1, (NoNull, _)), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
283283
Ref r :: vs', [Plain (Br x) @@ e.at]
284284

285-
| BrOnCastDescFail (x, _rt1, _rt2), Ref desc :: Ref r :: vs' ->
285+
| BrOnCastDescEqFail (x, _rt1, _rt2), Ref desc :: Ref r :: vs' ->
286286
(match Aggr.read_desc r with
287287
| Some desc' when eq_ref desc desc' -> Ref r :: vs', []
288288
| _ -> Ref r :: vs', [Plain (Br x) @@ e.at]
@@ -689,16 +689,16 @@ let rec step (c : config) : config =
689689
string_of_reftype rt ^ " but got " ^
690690
string_of_reftype (type_of_ref r)) @@ e.at]
691691

692-
| RefCastDesc _rt, Ref (NullRef _) :: vs' ->
692+
| RefCastDescEq _rt, Ref (NullRef _) :: vs' ->
693693
vs', [Trapping "null descriptor reference" @@ e.at]
694694

695-
| RefCastDesc (NoNull, _), Ref _desc :: Ref (NullRef _) :: vs' ->
695+
| RefCastDescEq (NoNull, _), Ref _desc :: Ref (NullRef _) :: vs' ->
696696
vs', [Trapping "descriptor cast failure" @@ e.at]
697697

698-
| RefCastDesc (Null, _), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
698+
| RefCastDescEq (Null, _), Ref _desc :: Ref ((NullRef _) as r) :: vs' ->
699699
Ref r :: vs', []
700700

701-
| RefCastDesc rt, Ref desc :: Ref r :: vs' ->
701+
| RefCastDescEq rt, Ref desc :: Ref r :: vs' ->
702702
(match Aggr.read_desc r with
703703
| Some desc' when eq_ref desc desc' -> Ref r :: vs', []
704704
| _ -> vs', [Trapping "descriptor cast failure" @@ e.at]

interpreter/syntax/ast.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ and instr' =
182182
| BrOnNonNull of labelidx (* break on type inverted *)
183183
| BrOnCast of labelidx * reftype * reftype (* break on type *)
184184
| BrOnCastFail of labelidx * reftype * reftype (* break on type inverted *)
185-
| BrOnCastDesc of labelidx * reftype * reftype (* break on descriptor cast *)
186-
| BrOnCastDescFail of labelidx * reftype * reftype (* break on descriptor cast inverted *)
185+
| BrOnCastDescEq of labelidx * reftype * reftype (* break on descriptor cast *)
186+
| BrOnCastDescEqFail of labelidx * reftype * reftype (* break on descriptor cast inverted *)
187187
| Return (* break from function body *)
188188
| Call of funcidx (* call function *)
189189
| CallRef of typeidx (* call function through reference *)
@@ -225,7 +225,7 @@ and instr' =
225225
| RefAsNonNull (* type cast *)
226226
| RefTest of reftype (* type test *)
227227
| RefCast of reftype (* type cast *)
228-
| RefCastDesc of reftype (* descriptor type cast *)
228+
| RefCastDescEq of reftype (* descriptor type cast *)
229229
| RefGetDesc of typeidx (* read descriptor *)
230230
| RefEq (* reference equality *)
231231
| RefI31 (* scalar reference *)

interpreter/syntax/free.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ let rec instr (e : instr) =
143143
| If (bt, es1, es2) -> blocktype bt ++ block es1 ++ block es2
144144
| Br x | BrIf x | BrOnNull x | BrOnNonNull x -> labels (idx x)
145145
| BrOnCast (x, t1, t2) | BrOnCastFail (x, t1, t2)
146-
| BrOnCastDesc (x, t1, t2) | BrOnCastDescFail (x, t1, t2) ->
146+
| BrOnCastDescEq (x, t1, t2) | BrOnCastDescEqFail (x, t1, t2) ->
147147
labels (idx x) ++ reftype t1 ++ reftype t2
148148
| BrTable (xs, x) -> list (fun x -> labels (idx x)) (x::xs)
149149
| Return -> empty
@@ -169,7 +169,7 @@ let rec instr (e : instr) =
169169
| MemoryInit (x, y) -> memories (idx x) ++ datas (idx y)
170170
| DataDrop x -> datas (idx x)
171171
| RefIsNull | RefAsNonNull -> empty
172-
| RefTest t | RefCast t | RefCastDesc t -> reftype t
172+
| RefTest t | RefCast t | RefCastDescEq t -> reftype t
173173
| RefGetDesc x -> types (idx x)
174174
| RefEq -> empty
175175
| RefNull t -> heaptype t

interpreter/syntax/mnemonics.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ let br_on_null x = BrOnNull x
3535
let br_on_non_null x = BrOnNonNull x
3636
let br_on_cast x t1 t2 = BrOnCast (x, t1, t2)
3737
let br_on_cast_fail x t1 t2 = BrOnCastFail (x, t1, t2)
38-
let br_on_cast_desc x t1 t2 = BrOnCastDesc (x, t1, t2)
39-
let br_on_cast_desc_fail x t1 t2 = BrOnCastDescFail (x, t1, t2)
38+
let br_on_cast_desc_eq x t1 t2 = BrOnCastDescEq (x, t1, t2)
39+
let br_on_cast_desc_eq_fail x t1 t2 = BrOnCastDescEqFail (x, t1, t2)
4040

4141
let catch x1 x2 = Catch (x1, x2)
4242
let catch_ref x1 x2 = CatchRef (x1, x2)
@@ -175,7 +175,7 @@ let ref_is_null = RefIsNull
175175
let ref_as_non_null = RefAsNonNull
176176
let ref_test t = RefTest t
177177
let ref_cast t = RefCast t
178-
let ref_cast_desc t = RefCastDesc t
178+
let ref_cast_desc_eq t = RefCastDescEq t
179179
let ref_get_desc x = RefGetDesc x
180180
let ref_eq = RefEq
181181

interpreter/text/arrange.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,10 @@ let rec instr e =
521521
"br_on_cast " ^ idx x, [Atom (reftype t1); Atom (reftype t2)]
522522
| BrOnCastFail (x, t1, t2) ->
523523
"br_on_cast_fail " ^ idx x, [Atom (reftype t1); Atom (reftype t2)]
524-
| BrOnCastDesc (x, t1, t2) ->
525-
"br_on_cast_desc " ^ idx x, [Atom (reftype t1); Atom (reftype t2)]
526-
| BrOnCastDescFail (x, t1, t2) ->
527-
"br_on_cast_desc_fail " ^ idx x, [Atom (reftype t1); Atom (reftype t2)]
524+
| BrOnCastDescEq (x, t1, t2) ->
525+
"br_on_cast_desc_eq " ^ idx x, [Atom (reftype t1); Atom (reftype t2)]
526+
| BrOnCastDescEqFail (x, t1, t2) ->
527+
"br_on_cast_desc_eq_fail " ^ idx x, [Atom (reftype t1); Atom (reftype t2)]
528528
| Return -> "return", []
529529
| Call x -> "call " ^ idx x, []
530530
| CallRef x -> "call_ref " ^ idx x, []
@@ -569,7 +569,7 @@ let rec instr e =
569569
| RefAsNonNull -> "ref.as_non_null", []
570570
| RefTest t -> "ref.test", [Atom (reftype t)]
571571
| RefCast t -> "ref.cast", [Atom (reftype t)]
572-
| RefCastDesc t -> "ref.cast_desc", [Atom (reftype t)]
572+
| RefCastDescEq t -> "ref.cast_desc_eq", [Atom (reftype t)]
573573
| RefGetDesc x -> "ref.get_desc " ^ idx x, []
574574
| RefEq -> "ref.eq", []
575575
| RefI31 -> "ref.i31", []

interpreter/text/lexer.mll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ rule token = parse
204204
| "br_on_non_null" -> BR_ON_NULL br_on_non_null
205205
| "br_on_cast" -> BR_ON_CAST br_on_cast
206206
| "br_on_cast_fail" -> BR_ON_CAST br_on_cast_fail
207-
| "br_on_cast_desc" -> BR_ON_CAST br_on_cast_desc
208-
| "br_on_cast_desc_fail" -> BR_ON_CAST br_on_cast_desc_fail
207+
| "br_on_cast_desc_eq" -> BR_ON_CAST br_on_cast_desc_eq
208+
| "br_on_cast_desc_eq_fail" -> BR_ON_CAST br_on_cast_desc_eq_fail
209209
| "return" -> RETURN
210210
| "if" -> IF
211211
| "then" -> THEN
@@ -340,7 +340,7 @@ rule token = parse
340340
| "ref.as_non_null" -> REF_AS_NON_NULL
341341
| "ref.test" -> REF_TEST
342342
| "ref.cast" -> REF_CAST
343-
| "ref.cast_desc" -> REF_CAST_DESC
343+
| "ref.cast_desc_eq" -> REF_CAST_DESC
344344
| "ref.get_desc" -> REF_GET_DESC
345345
| "ref.eq" -> REF_EQ
346346

interpreter/text/parser.mly

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ plaininstr :
640640
| REF_AS_NON_NULL { fun c -> ref_as_non_null }
641641
| REF_TEST reftype { fun c -> ref_test ($2 c) }
642642
| REF_CAST reftype { fun c -> ref_cast ($2 c) }
643-
| REF_CAST_DESC reftype { fun c -> ref_cast_desc ($2 c) }
643+
| REF_CAST_DESC reftype { fun c -> ref_cast_desc_eq ($2 c) }
644644
| REF_GET_DESC idx { fun c -> ref_get_desc ($2 c type_) }
645645
| REF_EQ { fun c -> ref_eq }
646646
| REF_I31 { fun c -> ref_i31 }

interpreter/valid/valid.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_resulttype) : infer_ins
591591
" but label has " ^ string_of_resulttype (label c x));
592592
(ts0 @ [RefT rt1]) --> (ts0 @ [RefT rt2]), []
593593

594-
| BrOnCastDesc (x, rt1, rt2) ->
594+
| BrOnCastDescEq (x, rt1, rt2) ->
595595
check_reftype c rt1 e.at;
596596
check_reftype c rt2 e.at;
597597
let (_, ht1), (_, ht2) = rt1, rt2 in
@@ -609,7 +609,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_resulttype) : infer_ins
609609
let rt = desc_cast_ref c rt2 e.at in
610610
(ts0 @ [RefT rt1; RefT rt]) --> (ts0 @ [RefT (diff_reftype rt1 rt2)]), []
611611

612-
| BrOnCastDescFail (x, rt1, rt2) ->
612+
| BrOnCastDescEqFail (x, rt1, rt2) ->
613613
check_reftype c rt1 e.at;
614614
check_reftype c rt2 e.at;
615615
let rt1' = diff_reftype rt1 rt2 in
@@ -847,7 +847,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_resulttype) : infer_ins
847847
check_reftype c rt e.at;
848848
[RefT (Null, top_of_heaptype c.types ht)] --> [RefT (nul, ht)], []
849849

850-
| RefCastDesc rt ->
850+
| RefCastDescEq rt ->
851851
let (nul, ht) = rt in
852852
check_reftype c rt e.at;
853853
let rt' = desc_cast_ref c rt e.at in

0 commit comments

Comments
 (0)