Skip to content

Commit 84d5d60

Browse files
committed
remove caml_obj_block
1 parent 922e69c commit 84d5d60

File tree

13 files changed

+55
-188
lines changed

13 files changed

+55
-188
lines changed

jscomp/core/js_dump.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ and expression_desc cxt ~(level:int) f x : cxt =
847847
else []
848848
) in
849849
if p.num_nonconst = 1 then tails
850-
else ("tag",
850+
else (L.tag,
851851
if !Js_config.debug then tag else {tag with comment = Some p.name}) :: tails in
852852
if p.num_nonconst = 1 && not !Js_config.debug then
853853
pp_comment_option f (Some p.name);
@@ -862,7 +862,7 @@ and expression_desc cxt ~(level:int) f x : cxt =
862862
if p.num_nonconst = 1 then
863863
tails
864864
else
865-
("tag",
865+
(L.tag,
866866
if !Js_config.debug then tag else {tag with comment = Some p.name}) :: tails
867867
in
868868
if p.num_nonconst = 1 && not !Js_config.debug then

jscomp/core/lam_analysis.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
6161
| "caml_make_vect"
6262
| "caml_create_bytes"
6363
| "caml_obj_dup"
64-
| "caml_array_dup"
65-
| "caml_obj_block"
66-
64+
| "caml_array_dup"
6765
), _ -> true
6866
| "caml_ml_open_descriptor_in", [Lconst ( (Const_int {value = 0}))] -> true
6967
| "caml_ml_open_descriptor_out",

jscomp/core/lam_dispatch_primitive.ml

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -647,27 +647,7 @@ let translate loc (prim_name : string)
647647
end
648648
| _ -> assert false
649649
end
650-
| "caml_obj_block" ->
651-
(** TODO: Optimize for [CamlinternalOO] input
652-
external new_block : tag:int -> size:int -> t = "caml_obj_block"
653-
Note that we don't need initialize its content anyway
654-
TODO: more optimizations later
655-
ATTENTION: This optmization is coupled with memory layout
656-
*)
657-
begin match args with
658-
| [ tag;
659-
{expression_desc = Number (Int { i ;_}); _} ] ->
660-
E.make_block tag (Blk_na "obj_block")
661-
(Ext_list.init (Int32.to_int i)
662-
(fun _ -> E.zero_int_literal)) NA
663-
664-
| [ _; _] ->
665-
call Js_runtime_modules.obj_runtime
666-
(* E.uninitialized_object tag size *)
667-
| _ -> assert false
668650

669-
670-
end
671651
| "caml_format_float"
672652
| "caml_hexstring_of_float"
673653
| "caml_nativeint_format"
@@ -735,17 +715,7 @@ let translate loc (prim_name : string)
735715
*)
736716
begin match args with
737717
| [e] -> E.tag e
738-
| _ -> assert false end
739-
740-
(* End of Unix support *)
741-
(* bigarrary support *)
742-
743-
(* call Js_config.bigarray *)
744-
(* End of bigarray support *)
745-
| "caml_bswap16"
746-
| "caml_int32_bswap"
747-
| "caml_nativeint_bswap"
748-
-> call Js_runtime_modules.int32
718+
| _ -> assert false end
749719
| "caml_get_public_method"
750720
->
751721
call Js_runtime_modules.oo

jscomp/main/builtin_cmj_datasets.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* a6ef764a95e857fb790f85fcc5f16e08 *)
1+
(* 49b8700d850ed87f5ed554cc526795d4 *)
22
let module_names : string array = Obj.magic (
33
"Gc" (* 220 *),
44
"Js" (* 23 *),
@@ -239,7 +239,7 @@ let module_data : string array = Obj.magic (
239239
(* Belt_MapString *)"\132\149\166\190\000\000\003p\000\000\001\011\000\000\003i\000\000\0031\160\b\000\000\212\000\176\"eq\144\160\160C@@@\176#cmp\144\160\160C@@@\176#eqU\144\160\160C@@@\176#get\144\160\160B@@@\176#has\144\160\160B@@@\176#map\144\160\160B@@@\176#set\144\160\160C@@@\176$cmpU\144\160\160C@@@\176$keep\144\160\160B@@@\176$mapU\144\160\160B@@@\176$size\144\160\160A@@@\176$some\144\160\160B@@@\176%empty\144@\144\146A\176%every\144\160\160B@@@\176%keepU\144\160\160B@@@\176%merge\144\160\160C@@@\176%someU\144\160\160B@@@\176%split\144\160\160B@@@\176&everyU\144\160\160B@@@\176&getExn\144\160\160B@@@\176&maxKey\144\160\160A@@@\176&mergeU\144\160\160C@@@\176&minKey\144\160\160A@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176&toList\144\160\160A@@@\176&update\144\160\160C@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'maximum\144\160\160A@@@\176'minimum\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176'updateU\144\160\160C@@@\176(forEachU\144\160\160B@@@\176)fromArray\144\160\160A@@@\176)mergeMany\144\160\160B@@@\176)partition\144\160\160B@@@\176*mapWithKey\144\160\160B@@@\176*partitionU\144\160\160B@@@\176*removeMany\144\160\160B@@@\176+findFirstBy\144\160\160B@@@\176+keysToArray\144\160\160A@@@\176+mapWithKeyU\144\160\160B@@@\176,findFirstByU\144\160\160B@@@\176,getUndefined\144\160\160B@@@\176,maxUndefined\144\160\160A@@@\176,minUndefined\144\160\160A@@@\176-valuesToArray\144\160\160A@@@\176.getWithDefault\144\160\160C@@@\176/maxKeyUndefined\144\160\160A@@@\176/minKeyUndefined\144\160\160A@@@\1766checkInvariantInternal\144\160\160A@@@A",
240240
(* Belt_SetString *)"\132\149\166\190\000\000\002}\000\000\000\197\000\000\002\130\000\000\002Y\160\b\000\000\156\000\176\"eq\144\160\160B@@@\176#add\144\160\160B@@@\176#cmp\144\160\160B@@@\176#get\144\160\160B@@@\176#has\144\160\160B@@@\176$diff\144\160\160B@@@\176$keep\144\160\160B@@@\176$size\144\160\160A@@@\176$some\144\160\160B@@@\176%empty\144@\144\146A\176%every\144\160\160B@@@\176%keepU\144\160\160B@@@\176%someU\144\160\160B@@@\176%split\144\160\160B@@@\176%union\144\160\160B@@@\176&everyU\144\160\160B@@@\176&getExn\144\160\160B@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176&subset\144\160\160B@@@\176&toList\144\160\160A@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'maximum\144\160\160A@@@\176'minimum\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176)fromArray\144\160\160A@@@\176)intersect\144\160\160B@@@\176)mergeMany\144\160\160B@@@\176)partition\144\160\160B@@@\176*partitionU\144\160\160B@@@\176*removeMany\144\160\160B@@@\176,getUndefined\144\160\160B@@@\176,maxUndefined\144\160\160A@@@\176,minUndefined\144\160\160A@@@\1765fromSortedArrayUnsafe\144\160\160A@@@\1766checkInvariantInternal\144\160\160A@@@A",
241241
(* Belt_SortArray *)"\132\149\166\190\000\000\001U\000\000\000R\000\000\001\031\000\000\001\004\160\b\000\000@\000\176$diff\144\160\160I@@@\176%diffU\144\160\160I@@@\176%union\144\160\160I@@@\176&unionU\144\160\160I@@@\176(isSorted\144\160\160B@@@\176)intersect\144\160\160I@@@\176)isSortedU\144\160\160B@@@\176*intersectU\144\160\160I@@@\176,stableSortBy\144\160\160B@@@\176-stableSortByU\144\160\160B@@@\176.binarySearchBy\144\160\160C@@@\176/binarySearchByU\144\160\160C@@@\1763stableSortInPlaceBy\144\160\160B@@@\1764stableSortInPlaceByU\144\160\160B@@@\1764strictlySortedLength\144\160\160B@@@\1765strictlySortedLengthU\144\160\160B@@@A",
242-
(* CamlinternalOO *)"\132\149\166\190\000\000\003q\000\000\000\198\000\000\002\193\000\000\002\131\160\b\000\000l\000\176$copy\144\160\160A@@\144\180A\160\176\001\003\250!o@@\151\176\148.caml_set_oo_id\160\151\176\148,caml_obj_dup\160\144\004\r@\176\192<stdlib-406/camlinternalOO.ml^\001\005U\001\005h\192\004\002^\001\005U\001\005~@@\176\192\004\004_\001\005\131\001\005\133\192\004\005_\001\005\131\001\005\141@\176%stats\144\160\160A@@@\176%widen\144\160\160A@@@\176&narrow\144\160\160D@@@\176(inherits\144\160\160F@@@\176*get_method\144\160\160B@@@\176*init_class\144\160\160A@@@\176*make_class\144\160\160B@@@\176*new_method\144\160\160A@@@\176*set_method\144\160\160C@@@\176+set_methods\144\160\160B@@@\176,create_table\144\160\160A@@@\176,get_variable\144\160\160B@@\144\180B\160\176\001\006e%table@\160\176\001\006f$name@@\147\192\151\176\161b\146&getExn\160\145\[email protected]_MapStringA@\176\192&_none_A@\000\255\004\002A\160\151\176\161F\161$varsA\160\144\004\027@\176\192\004a\001\001b\001(\164\001(\180\192\004b\001\001b\001(\164\001(\190@\160\144\004\029@\176\192\004f\001\001b\001(\164\001(\168\192\004g\001\001b\001(\164\001(\195@A\176,new_variable\144\160\160B@@@\176-create_object\144\160\160A@@@\176-get_variables\144\160\160B@@@\176-lookup_tables\144\160\160B@@@\176/add_initializer\144\160\160B@@@\1760get_method_label\144\160\160B@@@\1760make_class_store\144\160\160C@@@\1760run_initializers\144\160\160B@@@\1761create_object_opt\144\160\160B@@@\1761get_method_labels\144\160\160B@@@\1763public_method_label\144\160\160A@@@\1764run_initializers_opt\144\160\160C@@@\1765new_methods_variables\144\160\160C@@@\176\t\"create_object_and_run_initializers\144\160\160B@@@A",
242+
(* CamlinternalOO *)"\132\149\166\190\000\000\003q\000\000\000\198\000\000\002\193\000\000\002\131\160\b\000\000l\000\176$copy\144\160\160A@@\144\180A\160\176\001\003\240!o@@\151\176\148.caml_set_oo_id\160\151\176\148,caml_obj_dup\160\144\004\r@\176\192<stdlib-406/camlinternalOO.ml`\001\005G\001\005Z\192\004\002`\001\005G\001\005p@@\176\192\004\004a\001\005u\001\005w\192\004\005a\001\005u\001\005\127@\176%stats\144\160\160A@@@\176%widen\144\160\160A@@@\176&narrow\144\160\160D@@@\176(inherits\144\160\160F@@@\176*get_method\144\160\160B@@@\176*init_class\144\160\160A@@@\176*make_class\144\160\160B@@@\176*new_method\144\160\160A@@@\176*set_method\144\160\160C@@@\176+set_methods\144\160\160B@@@\176,create_table\144\160\160A@@@\176,get_variable\144\160\160B@@\144\180B\160\176\001\006e%table@\160\176\001\006f$name@@\147\192\151\176\161b\146&getExn\160\145\[email protected]_MapStringA@\176\192&_none_A@\000\255\004\002A\160\151\176\161F\161$varsA\160\144\004\027@\176\192\004a\001\001d\001(\150\001(\166\192\004b\001\001d\001(\150\001(\176@\160\144\004\029@\176\192\004f\001\001d\001(\150\001(\154\192\004g\001\001d\001(\150\001(\181@A\176,new_variable\144\160\160B@@@\176-create_object\144\160\160A@@@\176-get_variables\144\160\160B@@@\176-lookup_tables\144\160\160B@@@\176/add_initializer\144\160\160B@@@\1760get_method_label\144\160\160B@@@\1760make_class_store\144\160\160C@@@\1760run_initializers\144\160\160B@@@\1761create_object_opt\144\160\160B@@@\1761get_method_labels\144\160\160B@@@\1763public_method_label\144\160\160A@@@\1764run_initializers_opt\144\160\160C@@@\1765new_methods_variables\144\160\160C@@@\176\t\"create_object_and_run_initializers\144\160\160B@@@A",
243243
(* Js_typed_array *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
244244
(* Belt_HashMapInt *)"\132\149\166\190\000\000\0025\000\000\000\156\000\000\002\007\000\000\001\230\160\b\000\000X\000\176#get\144\160\160B@@@\176#has\144\160\160B@@@\176#set\144\160\160C@@@\176$copy\144\160\160A@@@\176$make\144\160\160A@@\144\180A\160\176\001\004\241(hintSize@@\147\192\151\176\161A\146$make\160\145\176@8Belt_internalBucketsTypeA@\176\192&_none_A@\000\255\004\002A\160\146A\160\146A\160\144\004\022@\176\1926others/hashmap.cppo.ml\001\000\181\001\021;\001\021P\192\004\002\001\000\181\001\021;\001\021p@A\176$size\144\160\160A@@\144\180A\160\176\001\004\244!h@@\151\176\161@\161$sizeA\160\144\004\t@\176\192\004\021\001\000\183\001\021\133\001\021\146\192\004\022\001\000\183\001\021\133\001\021\154@\176%clear\144\160\160A@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176(logStats\144\160\160A@@@\176)fromArray\144\160\160A@@@\176)mergeMany\144\160\160B@@@\176+keysToArray\144\160\160A@@@\176-valuesToArray\144\160\160A@@@\176.keepMapInPlace\144\160\160B@@@\176/keepMapInPlaceU\144\160\160B@@@\1762getBucketHistogram\144\160\160A@@@A",
245245
(* Belt_HashSetInt *)"\132\149\166\190\000\000\001\208\000\000\000\131\000\000\001\177\000\000\001\151\160\b\000\000D\000\176#add\144\160\160B@@@\176#has\144\160\160B@@@\176$copy\144\160\160A@@@\176$make\144\160\160A@@\144\180A\160\176\001\004\227(hintSize@@\147\192\151\176\161A\146$make\160\145\176@8Belt_internalBucketsTypeA@\176\192&_none_A@\000\255\004\002A\160\146A\160\146A\160\144\004\022@\176\1926others/hashset.cppo.ml\001\000\137\001\014=\001\014R\192\004\002\001\000\137\001\014=\001\014r@A\176$size\144\160\160A@@\144\180A\160\176\001\004\230!h@@\151\176\161@\161$sizeA\160\144\004\t@\176\192\004\021\001\000\140\001\014\136\001\014\149\192\004\022\001\000\140\001\014\136\001\014\157@\176%clear\144\160\160A@@@\176&reduce\144\160\160C@@@\176&remove\144\160\160B@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176(logStats\144\160\160A@@@\176)fromArray\144\160\160A@@@\176)mergeMany\144\160\160B@@@\1762getBucketHistogram\144\160\160A@@@A",

jscomp/runtime/caml_exceptions.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type t = {
3333
It's common that we have
3434
{[ a = caml_set_oo_id([248,"string",0]) ]}
3535
This can be inlined as
36-
{[ a = caml_set_oo_id([248,"tag", caml_oo_last_id++]) ]}
36+
{[ a = caml_set_oo_id([248,"string", caml_oo_last_id++]) ]}
3737
*)
3838

3939
let id = ref 0

jscomp/runtime/caml_obj.ml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,7 @@ module O = struct
4444
end
4545

4646

47-
(** Mainly used in camlinternalOO
48-
{[
49-
let dummy_met : item = obj (Obj.new_block 0 0)
50-
let obj = Obj.new_block Obj.object_tag table.size
51-
]}
52-
53-
Here we only need generate expression like this
54-
{[
55-
{ tag : tag ; length : size }
56-
]}
57-
we don't need fill fields, since it is not required by GC
58-
This function should never be used in variant
59-
block creation
60-
*)
61-
let caml_obj_block tag size =
62-
let v = Obj.repr (Caml_array_extern.new_uninitialized size) in
63-
Obj.set_tag v tag ;
64-
v
47+
6548

6649
(**
6750
Since now we change it back to use

jscomp/runtime/caml_obj.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
type t = Obj.t
3030

3131

32-
val caml_obj_block : int -> int -> Obj.t
32+
3333
val caml_obj_dup : Obj.t -> Obj.t
3434

3535

jscomp/stdlib-406/camlinternalOO.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
(* *)
1414
(**************************************************************************)
1515

16-
let object_tag = 248
17-
external new_block : int -> int -> Obj.t = "caml_obj_block"
18-
let new_object_tag_block size =
19-
new_block object_tag size
16+
17+
let new_object_tag_block : int -> Obj.t = [%raw{|function(size){
18+
var v = new Array(size)
19+
v.tag = 248 // tag
20+
return v
21+
}|}]
2022

2123
open Obj
2224

0 commit comments

Comments
 (0)