@@ -49,9 +49,6 @@ let float_binop_aux (l : constant list) (f : float -> float -> 'a) : 'a option =
4949 let args =
5050 match l with
5151 | [ Float i; Float j ] -> Some (i, j)
52- | [ Int i; Int j ] -> Some (Targetint. to_float i, Targetint. to_float j)
53- | [ Int i; Float j ] -> Some (Targetint. to_float i, j)
54- | [ Float i; Int j ] -> Some (i, Targetint. to_float j)
5552 | _ -> None
5653 in
5754 match args with
@@ -66,7 +63,6 @@ let float_binop (l : constant list) (f : float -> float -> float) : constant opt
6663let float_unop (l : constant list ) (f : float -> float ) : constant option =
6764 match l with
6865 | [ Float i ] -> Some (Float (f i))
69- | [ Int i ] -> Some (Float (f (Targetint. to_float i)))
7066 | _ -> None
7167
7268let bool' b = Int Targetint. (if b then one else zero)
@@ -76,18 +72,14 @@ let bool b = Some (bool' b)
7672let float_unop_bool (l : constant list ) (f : float -> bool ) =
7773 match l with
7874 | [ Float i ] -> bool (f i)
79- | [ Int i ] -> bool (f (Targetint. to_float i))
8075 | _ -> None
8176
8277let float_binop_bool l f =
8378 match float_binop_aux l f with
8479 | Some b -> bool b
8580 | None -> None
8681
87- let int32 i =
88- match Config. target () with
89- | `JavaScript -> Some (Int (Targetint. of_int32_exn i))
90- | `Wasm -> Some (Int32 i)
82+ let int32 i = Some (Int32 i)
9183
9284let int32_unop (l : constant list ) (f : int32 -> int32 ) : constant option =
9385 match l with
@@ -362,14 +354,14 @@ let eval_prim x =
362354 | _ -> None )
363355 | _ -> None
364356
365- let the_length_of ~ target info x =
357+ let the_length_of info x =
366358 get_approx
367359 info
368360 (fun x ->
369361 match Flow.Info. def info x with
370362 | Some (Constant (String s )) -> Some (Targetint. of_int_exn (String. length s))
371363 | Some (Prim (Extern " caml_create_string" , [ arg ]))
372- | Some (Prim (Extern "caml_create_bytes" , [ arg ])) -> the_int ~target info arg
364+ | Some (Prim (Extern "caml_create_bytes" , [ arg ])) -> the_int info arg
373365 | None | Some _ -> None )
374366 None
375367 (fun u v ->
@@ -391,9 +383,6 @@ let is_int info x =
391383 (fun x ->
392384 match Flow.Info. def info x with
393385 | Some (Constant (Int _ )) -> Y
394- | Some (Constant (NativeInt _ | Int32 _ )) ->
395- (* These Wasm-specific constants are boxed *)
396- N
397386 | Some (Block (_ , _ , _ , _ ) | Constant _ ) -> N
398387 | None | Some _ -> Unknown )
399388 Unknown
@@ -404,9 +393,6 @@ let is_int info x =
404393 | _ -> Unknown )
405394 x
406395 | Pc (Int _ ) -> Y
407- | Pc (NativeInt _ | Int32 _ ) ->
408- (* These Wasm-specific constants are boxed *)
409- N
410396 | Pc _ -> N
411397
412398let the_tag_of info x get =
@@ -509,7 +495,7 @@ let eval_instr ~target info i =
509495 let c =
510496 match s with
511497 | Pc (String s ) -> Some (Targetint. of_int_exn (String. length s))
512- | Pv v -> the_length_of ~target info v
498+ | Pv v -> the_length_of info v
513499 | _ -> None
514500 in
515501 match c with
@@ -591,7 +577,7 @@ let eval_instr ~target info i =
591577 (* Avoid duplicating the constant here as it would cause an
592578 allocation *)
593579 arg
594- | Some (Int32 _ | NativeInt _ ), `JavaScript -> assert false
580+ | Some (( Int32 _ | NativeInt _ ) as c ) , `JavaScript -> Pc c
595581 | Some ((Float _ | NativeString _ ) as c ), `JavaScript -> Pc c
596582 | Some (String _ as c), `JavaScript
597583 when Config.Flag. use_js_string () -> Pc c
0 commit comments