Skip to content

Commit eb055c2

Browse files
committed
sync up with the compiler and apply single non-constor optimizations (rescript-lang#259)
1 parent cd51c95 commit eb055c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2584
-3977
lines changed

jscomp/js_dump.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,8 @@ and
881881
begin match tag.expression_desc, tag_info with
882882

883883
| Number (Int { i = 0l ; _}) ,
884-
(Tuple | Array | Variant _ | Record _ | NA | Module _
885-
| Constructor ("Some" | "::"))
884+
(Blk_tuple | Blk_array | Blk_variant _ | Blk_record _ | Blk_na | Blk_module _
885+
| Blk_constructor (_, 1))
886886
(* Hack to optimize option which is really pervasive in ocaml,
887887
we need concrete benchmark to support this
888888
*)

jscomp/js_long.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let int64_call (fn : string) args =
2626

2727

2828
(* TODO: make layout easier to change later *)
29-
let record_info = Lambda.Record [| "hi"; "lo"|]
29+
let record_info = Lambda.Blk_record [| "hi"; "lo"|]
3030
let make_const ~lo ~hi =
3131
E.make_block
3232
~comment:"int64" (E.zero_int_literal)

jscomp/js_of_lam_block.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module E = Js_exp_make
2828
let make_block mutable_flag (tag_info : Lambda.tag_info) tag args =
2929

3030
match mutable_flag, tag_info with
31-
| _, Array -> Js_of_lam_array.make_array mutable_flag Pgenarray args
31+
| _, Blk_array -> Js_of_lam_array.make_array mutable_flag Pgenarray args
3232
| _ , _ -> E.make_block tag tag_info args mutable_flag
3333
(* | _, ( Tuple | Variant _ ) -> (\** TODO: check with inline record *\) *)
3434
(* E.arr Immutable *)

jscomp/js_of_lam_exception.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let make_exception exception_str mutable_flag : J.expression =
4949
mutable_flag,
5050
(* TODO: combined with `_001` optimization *)
5151
E.obj_int_tag_literal (* (Obj.object_tag) *),
52-
NA
52+
Blk_na
5353
);
5454
comment = None
5555
}

jscomp/js_of_lam_module.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module E = Js_exp_make
2323
let make ?comment (args : J.expression list) =
2424
E.make_block
2525
?comment E.zero_int_literal
26-
NA (* TODO: it should be Module*) args Immutable
26+
Blk_na (* TODO: it should be Module*) args Immutable
2727

2828
let is_empty_shape (shape : J.expression) =
2929
match shape with

jscomp/js_of_lam_option.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let none : J.expression =
2727
{expression_desc = Number (Int {i = 0l; c = None}); comment = Some "None" }
2828

2929
let some x : J.expression =
30-
{expression_desc = Caml_block ( [x], Immutable, E.zero_int_literal , Constructor "Some" );
30+
{expression_desc = Caml_block ( [x], Immutable, E.zero_int_literal , Blk_constructor ("Some",1) );
3131
comment = None}
3232

3333

jscomp/js_of_lam_record.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
module E = Js_exp_make
2424

25-
let empty_record_info = Lambda.Record [||] (* careful to share*)
25+
let empty_record_info = Lambda.Blk_record [||] (* careful to share*)
2626
(* TODO: add label to the comment *)
2727
let make mutable_flag (args : (string * J.expression) list) =
2828
E.make_block ~comment:"record"

jscomp/js_of_lam_tuple.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
module E = Js_exp_make
2424

2525
let make (args : J.expression list) =
26-
E.make_block ~comment:"tuple" E.zero_int_literal Tuple args Immutable
26+
E.make_block ~comment:"tuple" E.zero_int_literal Blk_tuple args Immutable
2727

jscomp/js_op.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ type required_modules = (Ident.t * string) list
220220

221221

222222
type tag_info = Lambda.tag_info =
223-
| Constructor of string
224-
| Tuple
225-
| Array
226-
| Variant of string
227-
| Record of string array
228-
| Module of string list option
229-
| NA
223+
| Blk_constructor of string * int
224+
| Blk_tuple
225+
| Blk_array
226+
| Blk_variant of string
227+
| Blk_record of string array
228+
| Blk_module of string list option
229+
| Blk_na
230230

231231
type length_object =
232232
| Array

jscomp/lam_compile_global.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let query_lambda id env =
3737
(* TODO: add module into taginfo*)
3838
(* let len = List.length sigs in *)
3939
(* TODO: could be optimized *)
40-
Lambda.Lprim (Pmakeblock(0,NA, Immutable) ,
40+
Lambda.Lprim (Pmakeblock(0, Blk_na, Immutable) ,
4141
(List.mapi (fun i _ ->
4242
Lambda.Lprim(Pfield (i, Lambda.Fld_na), [Lprim(Pgetglobal id,[])])))
4343
sigs))

jscomp/lam_compile_util.ml

+11-10
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ let jsop_of_comp (cmp : Lambda.comparison) : Js_op.binop =
3333

3434
let comment_of_tag_info (x : Lambda.tag_info) =
3535
match x with
36-
| Constructor n -> Some n
37-
| Tuple -> Some "tuple"
38-
| Variant x -> Some ("`" ^ x)
39-
| Record _ -> Some "record"
36+
| Blk_constructor (n, _) -> Some n
37+
| Blk_tuple -> Some "tuple"
38+
| Blk_variant x -> Some ("`" ^ x)
39+
| Blk_record _ -> Some "record"
4040

41-
| Array -> Some "array"
42-
| Module _ ->
41+
| Blk_array -> Some "array"
42+
| Blk_module _ ->
4343
(* Turn it on next time to save some noise diff*)
4444
Some "module"
45-
| NA -> None
45+
| Blk_na -> None
4646
let comment_of_pointer_info (x : Lambda.pointer_info)=
4747
match x with
48-
| NullConstructor x -> Some x
49-
| NullVariant x -> Some x
50-
| NAPointer -> None
48+
| Pt_constructor x -> Some x
49+
| Pt_variant x -> Some x
50+
| Lambda.Pt_module_alias -> None (* FIXME *)
51+
| Pt_na -> None

jscomp/lam_dispatch_primitive.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ let query (prim : Lam_compile_env.primitive_description)
541541
begin match args with
542542
| [ tag;
543543
{expression_desc = Number (Int { i ;_}); _} ] ->
544-
E.make_block tag NA
544+
E.make_block tag Blk_na
545545
(Ext_list.init (Int32.to_int i)
546546
(fun _ -> E.zero_int_literal)) NA
547547

jscomp/lam_util.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ let mk_apply_info ?(loc = Location.none) apply_status : Lambda.apply_info =
313313
{ apply_loc = loc; apply_status }
314314

315315

316-
let lam_true : Lambda.lambda = Lconst (Const_pointer ( 1, NullConstructor "true"))
316+
let lam_true : Lambda.lambda = Lconst (Const_pointer ( 1, Pt_constructor "true"))
317317

318-
let lam_false : Lambda.lambda = Lconst (Const_pointer( 0, NullConstructor "false"))
318+
let lam_false : Lambda.lambda = Lconst (Const_pointer( 0, Pt_constructor "false"))
319319

320320
let is_function (lam : Lambda.lambda) =
321321
match lam with

0 commit comments

Comments
 (0)