Skip to content

Commit

Permalink
remove Caml compile time constants
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Aug 27, 2024
1 parent 865de75 commit 6589728
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 185 deletions.
1 change: 0 additions & 1 deletion jscomp/core/lam_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ let rec no_side_effects (lam : Lam.t) : bool =
| Pasrint64 | Pint64comp _
(* Operations on big arrays: (unsafe, #dimensions, kind, layout) *)
(* Compile time constants *)
| Pctconst _ (* Integer to external pointer *)
| Poffsetint _ | Pstringadd | Pjs_function_length | Pcaml_obj_length
| Pwrap_exn
| Praw_js_code
Expand Down
8 changes: 0 additions & 8 deletions jscomp/core/lam_compat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ let cmp_int (cmp : comparison) (a : int) b : bool =
| Clt -> a < b
| Cge -> a >= b

type compile_time_constant =
| Backend_type

(** relies on the fact that [compile_time_constant] is enum type *)
let eq_compile_time_constant (p : compile_time_constant)
(p1 : compile_time_constant) =
p = p1

type let_kind = Lambda.let_kind = Strict | Alias | StrictOpt | Variable

type field_dbg_info = Lambda.field_dbg_info =
Expand Down
6 changes: 0 additions & 6 deletions jscomp/core/lam_compat.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ type boxed_integer = Lambda.boxed_integer = Pbigint | Pint32 | Pint64

type comparison = Lambda.comparison = Ceq | Cneq | Clt | Cgt | Cle | Cge

type compile_time_constant =
| Backend_type

type let_kind = Lambda.let_kind = Strict | Alias | StrictOpt | Variable

type field_dbg_info = Lambda.field_dbg_info =
Expand Down Expand Up @@ -62,6 +59,3 @@ val cmp_int : comparison -> int -> int -> bool
val eq_comparison : comparison -> comparison -> bool

val eq_boxed_integer : boxed_integer -> boxed_integer -> bool

val eq_compile_time_constant :
compile_time_constant -> compile_time_constant -> bool
6 changes: 0 additions & 6 deletions jscomp/core/lam_compile_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,6 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
(* FIXME, this can be removed later *)
| Pisint -> E.is_type_number (Ext_list.singleton_exn args)
| Pis_poly_var_block -> E.is_type_object (Ext_list.singleton_exn args)
| Pctconst ct -> (
match ct with
| Backend_type ->
E.make_block E.zero_int_literal
(Blk_constructor { name = "Other"; num_nonconst = 1; tag = 0; attrs = [] })
[ E.str "BS" ] Immutable)
| Pduprecord -> Lam_dispatch_primitive.translate loc "?obj_dup" args
| Plazyforce
(* FIXME: we don't inline lazy force or at least
Expand Down
7 changes: 0 additions & 7 deletions jscomp/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,6 @@ let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
match x with
| Pbigint | Pint32 -> prim ~primitive:Pasrint ~args loc
| Pint64 -> prim ~primitive:Pasrint64 ~args loc)
| Pctconst x -> (
match x with
| Word_size | Int_size ->
Lam.const (Const_int { i = 32l; comment = None })
| Max_wosize ->
Lam.const (Const_int { i = 2147483647l; comment = Some "Max_wosize" })
| Backend_type -> prim ~primitive:(Pctconst Backend_type) ~args loc)
| Pcvtbint (a, b) -> (
match (a, b) with
| (Pbigint | Pint32), (Pbigint | Pint32) | Pint64, Pint64 ->
Expand Down
8 changes: 0 additions & 8 deletions jscomp/core/lam_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ type t =
| Plslint64
| Plsrint64
| Pasrint64
(* Compile time constants *)
| Pctconst of Lam_compat.compile_time_constant (* Integer to external pointer *)
| Pdebugger
| Pjs_unsafe_downgrade of { name : string; setter : bool }
| Pinit_mod
Expand Down Expand Up @@ -331,12 +329,6 @@ let eq_primitive_approx (lhs : t) (rhs : t) =
| Pint64comp comparison1 ->
Lam_compat.eq_comparison comparison comparison1
| _ -> false)
| Pctconst compile_time_constant -> (
match rhs with
| Pctconst compile_time_constant1 ->
Lam_compat.eq_compile_time_constant compile_time_constant
compile_time_constant1
| _ -> false)
| Pjs_unsafe_downgrade { name; setter } -> (
match rhs with
| Pjs_unsafe_downgrade rhs -> name = rhs.name && setter = rhs.setter
Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/lam_primitive.mli
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ type t =
| Plslint64
| Plsrint64
| Pasrint64
(* Compile time constants *)
| Pctconst of Lam_compat.compile_time_constant
(* Integer to external pointer *)
| Pdebugger
| Pjs_unsafe_downgrade of { name : string; setter : bool }
Expand Down
6 changes: 0 additions & 6 deletions jscomp/core/lam_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ let primitive ppf (prim : Lam_primitive.t) =
| Parraysetu -> fprintf ppf "array.unsafe_set"
| Parrayrefs -> fprintf ppf "array.get"
| Parraysets -> fprintf ppf "array.set"
| Pctconst c ->
let const_name =
match c with
| Backend_type -> "backend_type"
in
fprintf ppf "sys.constant_%s" const_name
| Pisint -> fprintf ppf "isint"
| Pis_poly_var_block -> fprintf ppf "#is_poly_var_block"
| Pisout i -> fprintf ppf "isout %d" i
Expand Down
13 changes: 0 additions & 13 deletions jscomp/ml/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
(* *)
(**************************************************************************)





type compile_time_constant =
| Word_size
| Int_size
| Max_wosize
| Backend_type

type loc_kind =
| Loc_FILE
| Loc_LINE
Expand Down Expand Up @@ -181,8 +171,6 @@ type immediate_or_pointer =
| Immediate
| Pointer



type is_safe =
| Safe
| Unsafe
Expand Down Expand Up @@ -261,7 +249,6 @@ type primitive =
| Plsrbint of boxed_integer
| Pasrbint of boxed_integer
| Pbintcomp of boxed_integer * comparison
| Pctconst of compile_time_constant
| Pcreate_extension of string
and comparison =
Ceq | Cneq | Clt | Cgt | Cle | Cge
Expand Down
7 changes: 0 additions & 7 deletions jscomp/ml/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

open Asttypes

type compile_time_constant =
| Word_size
| Int_size
| Max_wosize
| Backend_type

type loc_kind =
| Loc_FILE
| Loc_LINE
Expand Down Expand Up @@ -228,7 +222,6 @@ type primitive =
| Plsrbint of boxed_integer
| Pasrbint of boxed_integer
| Pbintcomp of boxed_integer * comparison
| Pctconst of compile_time_constant
| Pcreate_extension of string
and comparison =
Ceq | Cneq | Clt | Cgt | Cle | Cge
Expand Down
8 changes: 0 additions & 8 deletions jscomp/ml/printlambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,6 @@ let primitive ppf = function
| Parraysetu -> fprintf ppf "array.unsafe_set"
| Parrayrefs -> fprintf ppf "array.get"
| Parraysets -> fprintf ppf "array.set"
| Pctconst c ->
let const_name = match c with
| Word_size -> "word_size"
| Int_size -> "int_size"
| Max_wosize -> "max_wosize"
| Backend_type -> "backend_type" in
fprintf ppf "sys.constant_%s" const_name
| Pisint -> fprintf ppf "isint"
| Pisout -> fprintf ppf "isout"
| Pbintofint bi -> print_boxed_integer "of_int" ppf bi
Expand Down Expand Up @@ -316,7 +309,6 @@ let name_of_primitive = function
| Parraysetu -> "Parraysetu"
| Parrayrefs -> "Parrayrefs"
| Parraysets -> "Parraysets"
| Pctconst _ -> "Pctconst"
| Pisint -> "Pisint"
| Pisout -> "Pisout"
| Pbintofint _ -> "Pbintofint"
Expand Down
4 changes: 0 additions & 4 deletions jscomp/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ let primitives_table =
("%sequand", Psequand);
("%sequor", Psequor);
("%boolnot", Pnot);
("%backend_type", Pctconst Backend_type);
("%word_size", Pctconst Word_size);
("%int_size", Pctconst Int_size);
("%max_wosize", Pctconst Max_wosize);
("%negint", Pnegint);
("%succint", Poffsetint 1);
("%predint", Poffsetint (-1));
Expand Down
71 changes: 0 additions & 71 deletions jscomp/test/406_primitive_test.js

This file was deleted.

36 changes: 0 additions & 36 deletions jscomp/test/406_primitive_test.res

This file was deleted.

3 changes: 1 addition & 2 deletions jscomp/test/build.ninja

Large diffs are not rendered by default.

0 comments on commit 6589728

Please sign in to comment.