|
408 | 408 | module Constants : sig
|
409 | 409 | val parse : Obj.t -> Code.constant
|
410 | 410 |
|
411 |
| - val inlined : Code.constant -> bool |
| 411 | + val inlined : target:[ `JavaScript | `Wasm ] -> Code.constant -> bool |
412 | 412 | end = struct
|
413 | 413 | (* In order to check that two custom objects share the same kind, we
|
414 | 414 | compare their identifier. The identifier is currently extracted
|
@@ -474,14 +474,18 @@ end = struct
|
474 | 474 | let i : int = Obj.magic x in
|
475 | 475 | Int (Targetint.of_int_warning_on_overflow i)
|
476 | 476 |
|
477 |
| - let inlined = function |
| 477 | + let inlined ~target c = |
| 478 | + match c with |
478 | 479 | | String _ | NativeString _ -> false
|
479 | 480 | | Float _ -> true
|
480 | 481 | | Float_array _ -> false
|
481 | 482 | | Int64 _ -> false
|
482 | 483 | | Tuple _ -> false
|
483 | 484 | | Int _ -> true
|
484 |
| - | Int32 _ | NativeInt _ -> false |
| 485 | + | Int32 _ | NativeInt _ -> ( |
| 486 | + match target with |
| 487 | + | `JavaScript -> true |
| 488 | + | `Wasm -> false) |
485 | 489 | end
|
486 | 490 |
|
487 | 491 | let const32 i = Constant (Int (Targetint.of_int32_exn i))
|
@@ -744,14 +748,15 @@ let get_global state instrs i =
|
744 | 748 | if debug_parser () then Format.printf "(global access %a)@." Var.print x;
|
745 | 749 | x, State.set_accu state x, instrs
|
746 | 750 | | None -> (
|
747 |
| - if i < Array.length g.constants && Constants.inlined g.constants.(i) |
| 751 | + let target = Config.target () in |
| 752 | + if i < Array.length g.constants && Constants.inlined ~target g.constants.(i) |
748 | 753 | then
|
749 | 754 | (* Inlined constant *)
|
750 | 755 | let x, state = State.fresh_var state in
|
751 | 756 | let cst = g.constants.(i) in
|
752 | 757 | x, state, Let (x, Constant cst) :: instrs
|
753 | 758 | else
|
754 |
| - match i < Array.length g.constants, Config.target () with |
| 759 | + match i < Array.length g.constants, target with |
755 | 760 | | true, _ | false, `JavaScript ->
|
756 | 761 | (* Non-inlined constant, and reference to another compilation
|
757 | 762 | units in case of separate compilation (JavaScript).
|
|
0 commit comments