Skip to content

Commit f4f188a

Browse files
committed
Remove code corresponding to an hypothetical core Wasm support
1 parent 5f736b1 commit f4f188a

19 files changed

+247
-3411
lines changed

compiler/lib/wasm/wa_asm_output.ml

Lines changed: 0 additions & 679 deletions
This file was deleted.

compiler/lib/wasm/wa_asm_output.mli

Lines changed: 0 additions & 19 deletions
This file was deleted.

compiler/lib/wasm/wa_ast.ml

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818

1919
type var = Code.Var.t
2020

21-
type symbol =
22-
| V of var
23-
| S of string
24-
2521
type packed_type =
2622
| I8
2723
| I16
@@ -137,23 +133,18 @@ type memarg = int32
137133

138134
type expression =
139135
| Const of (int32, int64, float, float) op
140-
| ConstSym of symbol * int
141136
| UnOp of (int_un_op, int_un_op, float_un_op, float_un_op) op * expression
142137
| BinOp of
143138
(int_bin_op, int_bin_op, float_bin_op, float_bin_op) op * expression * expression
144139
| I32WrapI64 of expression
145140
| I64ExtendI32 of signage * expression
146141
| F32DemoteF64 of expression
147142
| F64PromoteF32 of expression
148-
| Load of (memarg, memarg, memarg, memarg) op * expression
149-
| Load8 of signage * (memarg, memarg, memarg, memarg) op * expression
150143
| LocalGet of var
151144
| LocalTee of var * expression
152-
| GlobalGet of symbol
145+
| GlobalGet of var
153146
| BlockExpr of func_type * instruction list
154-
| Call_indirect of func_type * expression * expression list
155147
| Call of var * expression list
156-
| MemoryGrow of int * expression
157148
| Seq of instruction list * expression
158149
| Pop of value_type
159150
| RefFunc of var
@@ -177,10 +168,8 @@ type expression =
177168

178169
and instruction =
179170
| Drop of expression
180-
| Store of (memarg, memarg, memarg, memarg) op * expression * expression
181-
| Store8 of (memarg, memarg, memarg, memarg) op * expression * expression
182171
| LocalSet of var * expression
183-
| GlobalSet of symbol * expression
172+
| GlobalSet of var * expression
184173
| Loop of func_type * instruction list
185174
| Block of func_type * instruction list
186175
| If of func_type * expression * instruction list * instruction list
@@ -200,7 +189,6 @@ and instruction =
200189
| Rethrow of int
201190
| ArraySet of var * expression * expression * expression
202191
| StructSet of var * int * expression * expression
203-
| Return_call_indirect of func_type * expression * expression list
204192
| Return_call of var * expression list
205193
| Return_call_ref of var * expression * expression list
206194
| Location of Code.loc * instruction
@@ -211,14 +199,6 @@ type import_desc =
211199
| Global of global_type
212200
| Tag of value_type
213201

214-
type data =
215-
| DataI8 of int
216-
| DataI32 of int32
217-
| DataI64 of int64
218-
| DataBytes of string
219-
| DataSym of symbol * int
220-
| DataSpace of int
221-
222202
type type_field =
223203
{ name : var
224204
; typ : str_type
@@ -237,12 +217,10 @@ type module_field =
237217
}
238218
| Data of
239219
{ name : var
240-
; active : bool
241-
; read_only : bool
242-
; contents : data list
220+
; contents : string
243221
}
244222
| Global of
245-
{ name : symbol
223+
{ name : var
246224
; exported_name : string option
247225
; typ : global_type
248226
; init : expression

compiler/lib/wasm/wa_code_generation.ml

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type constant_global =
3838

3939
type context =
4040
{ constants : (Var.t, W.expression) Hashtbl.t
41-
; mutable data_segments : (bool * W.data list) Var.Map.t
41+
; mutable data_segments : string Var.Map.t
4242
; mutable constant_globals : constant_global Var.Map.t
4343
; mutable other_fields : W.module_field list
4444
; mutable imports : (Var.t * Wa_ast.import_desc) StringMap.t StringMap.t
@@ -119,12 +119,10 @@ let expression_list f l =
119119
in
120120
loop [] l
121121

122-
let register_data_segment x ~active v st =
123-
st.context.data_segments <- Var.Map.add x (active, v) st.context.data_segments;
122+
let register_data_segment x v st =
123+
st.context.data_segments <- Var.Map.add x v st.context.data_segments;
124124
(), st
125125

126-
let get_data_segment x st = Var.Map.find x st.context.data_segments, st
127-
128126
let get_context st = st.context, st
129127

130128
let register_constant x e st =
@@ -180,16 +178,13 @@ let heap_type_sub (ty : W.heap_type) (ty' : W.heap_type) st =
180178
let register_global name ?exported_name ?(constant = false) typ init st =
181179
st.context.other_fields <-
182180
W.Global { name; exported_name; typ; init } :: st.context.other_fields;
183-
(match name with
184-
| S _ -> ()
185-
| V name ->
186-
st.context.constant_globals <-
187-
Var.Map.add
188-
name
189-
{ init = (if not typ.mut then Some init else None)
190-
; constant = (not typ.mut) || constant
191-
}
192-
st.context.constant_globals);
181+
st.context.constant_globals <-
182+
Var.Map.add
183+
name
184+
{ init = (if not typ.mut then Some init else None)
185+
; constant = (not typ.mut) || constant
186+
}
187+
st.context.constant_globals;
193188
(), st
194189

195190
let global_is_registered name =
@@ -331,8 +326,6 @@ module Arith = struct
331326
| W.Const (I32 n), W.Const (I32 n') -> W.Const (I32 (Int32.add n n'))
332327
| W.Const (I32 0l), _ -> e'
333328
| _, W.Const (I32 0l) -> e
334-
| W.ConstSym (sym, offset), W.Const (I32 n) ->
335-
W.ConstSym (sym, offset + Int32.to_int n)
336329
| W.Const _, _ -> W.BinOp (I32 Add, e', e)
337330
| _ -> W.BinOp (I32 Add, e, e'))
338331

@@ -407,8 +400,8 @@ end
407400

408401
let is_small_constant e =
409402
match e with
410-
| W.ConstSym _ | W.Const _ | W.RefI31 (W.Const _) | W.RefFunc _ -> return true
411-
| W.GlobalGet (V name) -> global_is_constant name
403+
| W.Const _ | W.RefI31 (W.Const _) | W.RefFunc _ -> return true
404+
| W.GlobalGet name -> global_is_constant name
412405
| _ -> return false
413406

414407
let un_op_is_smi op =
@@ -430,21 +423,16 @@ let rec is_smi e =
430423
| I31Get (S, _) -> true
431424
| I31Get (U, _)
432425
| Const (I64 _ | F32 _ | F64 _)
433-
| ConstSym _
434426
| UnOp ((F32 _ | F64 _), _)
435427
| I32WrapI64 _
436428
| I64ExtendI32 _
437429
| F32DemoteF64 _
438430
| F64PromoteF32 _
439-
| Load _
440-
| Load8 _
441431
| LocalGet _
442432
| LocalTee _
443433
| GlobalGet _
444434
| BlockExpr _
445-
| Call_indirect _
446435
| Call _
447-
| MemoryGrow _
448436
| Seq _
449437
| Pop _
450438
| RefFunc _
@@ -526,12 +514,12 @@ let rec store ?(always = false) ?typ x e =
526514
else
527515
register_global
528516
~constant:true
529-
(V x)
517+
x
530518
{ mut = true; typ }
531519
(W.RefI31 (Const (I32 0l)))
532520
in
533-
let* () = register_constant x (W.GlobalGet (V x)) in
534-
instr (GlobalSet (V x, e))
521+
let* () = register_constant x (W.GlobalGet x) in
522+
instr (GlobalSet (x, e))
535523
else
536524
let* i = add_var ?typ x in
537525
instr (LocalSet (i, e))

compiler/lib/wasm/wa_code_generation.mli

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type constant_global
2222

2323
type context =
2424
{ constants : (Code.Var.t, Wa_ast.expression) Hashtbl.t
25-
; mutable data_segments : (bool * Wa_ast.data list) Code.Var.Map.t
25+
; mutable data_segments : string Code.Var.Map.t
2626
; mutable constant_globals : constant_global Code.Var.Map.t
2727
; mutable other_fields : Wa_ast.module_field list
2828
; mutable imports : (Code.Var.t * Wa_ast.import_desc) StringMap.t StringMap.t
@@ -154,7 +154,7 @@ val register_import :
154154
?import_module:string -> name:string -> Wa_ast.import_desc -> Wa_ast.var t
155155

156156
val register_global :
157-
Wa_ast.symbol
157+
Wa_ast.var
158158
-> ?exported_name:string
159159
-> ?constant:bool
160160
-> Wa_ast.global_type
@@ -163,9 +163,7 @@ val register_global :
163163

164164
val get_global : Code.Var.t -> Wa_ast.expression option t
165165

166-
val register_data_segment : Code.Var.t -> active:bool -> Wa_ast.data list -> unit t
167-
168-
val get_data_segment : Code.Var.t -> (bool * Wa_ast.data list) t
166+
val register_data_segment : Code.Var.t -> string -> unit t
169167

170168
val register_init_code : unit t -> unit t
171169

0 commit comments

Comments
 (0)