@@ -360,53 +360,25 @@ let the_def_of info x =
360
360
x
361
361
| Pc c -> Some (Constant c)
362
362
363
- (* If [constant_identical a b = true], then the two values cannot be
364
- distinguished, i.e., they are not different objects (and [caml_js_equals a b
365
- = true]) and if both are floats, they are bitwise equal. *)
366
- let constant_identical ~(target : [ `JavaScript | `Wasm ] ) a b =
367
- match a, b, target with
368
- | Int i , Int j , _ -> Targetint. equal i j
369
- | Float a , Float b , `JavaScript -> Int64. equal a b
370
- | Float _ , Float _ , `Wasm -> false
371
- | NativeString a , NativeString b , `JavaScript -> Native_string. equal a b
372
- | NativeString _ , NativeString _ , `Wasm ->
373
- false
374
- (* Native strings are boxed (JavaScript objects) in Wasm and are
375
- possibly different objects *)
376
- | String a , String b , `JavaScript -> Config.Flag. use_js_string () && String. equal a b
377
- | String _ , String _ , `Wasm ->
378
- false (* Strings are boxed in Wasm and are possibly different objects *)
379
- | Int32 _ , Int32 _ , `Wasm ->
380
- false (* [Int32]s are boxed in Wasm and are possibly different objects *)
381
- | Int32 a , Int32 b , `JavaScript -> Int32. equal a b
382
- | NativeInt _ , NativeInt _ , `Wasm ->
383
- false (* [NativeInt]s are boxed in Wasm and are possibly different objects *)
384
- | NativeInt a , NativeInt b , `JavaScript -> Int32. equal a b
385
- (* All other values may be distinct objects and thus different by [caml_js_equals]. *)
386
- | Int64 _ , Int64 _ , _ -> false
387
- | Tuple _ , Tuple _ , _ -> false
388
- | Float_array _ , Float_array _ , _ -> false
389
- | (Int _ | Float _ | Int64 _ | Int32 _ | NativeInt _ ), _ , _ -> false
390
- | (String _ | NativeString _ ), _ , _ -> false
391
- | (Float_array _ | Tuple _ ), _ , _ -> false
392
-
393
- let the_const_of ~target info x =
363
+ let the_const_of ~eq info x =
394
364
match x with
395
365
| Pv x ->
396
366
get_approx
397
367
info
398
368
(fun x ->
399
- match info.info_defs.(Var. idx x), target with
400
- | Expr (Constant ((Float _ | Int _ | NativeString _ ) as c )), _ -> Some c
401
- | Expr (Constant ((Int32 _ | NativeInt _ ) as c )), `JavaScript -> Some c
402
- | Expr (Constant (String _ as c )), _ when Config.Flag. safe_string () -> Some c
403
- | Expr (Constant c ), _ ->
404
- if Var.ISet. mem info.info_possibly_mutable x then None else Some c
369
+ match info.info_defs.(Var. idx x) with
370
+ | Expr
371
+ (Constant
372
+ ((Float _ | Int _ | Int32 _ | Int64 _ | NativeInt _ | NativeString _) as
373
+ c)) -> Some c
374
+ | Expr (Constant c)
375
+ when Config.Flag. safe_string ()
376
+ || not (Var.ISet. mem info.info_possibly_mutable x) -> Some c
405
377
| _ -> None )
406
378
None
407
379
(fun u v ->
408
380
match u, v with
409
- | Some i , Some j when constant_identical ~target i j -> u
381
+ | Some i , Some j when eq i j -> u
410
382
| _ -> None )
411
383
x
412
384
| Pc c -> Some c
@@ -429,13 +401,13 @@ let the_int info x =
429
401
| Pc (Int c ) -> Some c
430
402
| Pc _ -> None
431
403
432
- let the_string_of ~ target info x =
433
- match the_const_of info ~target x with
404
+ let the_string_of info x =
405
+ match the_const_of ~eq: ( fun _ _ -> false ) info x with
434
406
| Some (String i ) -> Some i
435
407
| _ -> None
436
408
437
- let the_native_string_of ~ target info x =
438
- match the_const_of ~target info x with
409
+ let the_native_string_of info x =
410
+ match the_const_of ~eq: ( fun _ _ -> false ) info x with
439
411
| Some (NativeString i ) -> Some i
440
412
| Some (String i ) ->
441
413
(* This function is used to optimize the primitives that access
0 commit comments