Skip to content

Commit 13344b8

Browse files
authored
Merge pull request #4403 from BuckleScript/caml_oo
clean up, keep runtime exposure minimal to prepare data representation changes
2 parents 1f462bd + 62a6d24 commit 13344b8

Some content is hidden

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

53 files changed

+2106
-4382
lines changed

jscomp/core/lam_dispatch_primitive.ml

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ let translate loc (prim_name : string)
684684
(* "caml_alloc_dummy"; *)
685685
(* TODO: "caml_alloc_dummy_float"; *)
686686
| "caml_obj_dup"
687-
| "caml_obj_truncate"
688687
->
689688
call Js_runtime_modules.obj_runtime
690689

@@ -766,14 +765,6 @@ let translate loc (prim_name : string)
766765
-> call Js_runtime_modules.hash_primitive
767766
| "caml_hash"
768767
-> call Js_runtime_modules.hash
769-
| "caml_weak_set"
770-
| "caml_weak_create"
771-
| "caml_weak_get"
772-
| "caml_weak_check"
773-
| "caml_weak_blit"
774-
| "caml_weak_get_copy"
775-
-> call Js_runtime_modules.weak
776-
777768
| "caml_ml_open_descriptor_in" when
778769
args_const_unbox_approx_int_zero args ->
779770
E.runtime_ref Js_runtime_modules.io "stdin"
@@ -782,60 +773,7 @@ let translate loc (prim_name : string)
782773
E.runtime_ref Js_runtime_modules.io "stdout"
783774
| "caml_ml_open_descriptor_out" when
784775
args_const_unbox_approx_int_two args ->
785-
E.runtime_ref Js_runtime_modules.io "stderr"
786-
787-
| "caml_ba_create"
788-
| "caml_ba_get_generic"
789-
| "caml_ba_set_generic"
790-
| "caml_ba_num_dims"
791-
| "caml_ba_dim"
792-
| "caml_ba_kind"
793-
| "caml_ba_layout"
794-
| "caml_ba_sub"
795-
| "caml_ba_slice"
796-
| "caml_ba_blit"
797-
| "caml_ba_fill"
798-
| "caml_ba_reshape"
799-
| "caml_ba_map_file_bytecode"
800-
801-
(* caml_ba_get_1, (\* %caml_ba_ref_1 *\) *)
802-
(* caml_ba_get_2, *)
803-
(* caml_ba_get_3, *)
804-
805-
(* caml_ba_set_1, // %caml_ba_set_1 *)
806-
(* caml_ba_set_2, *)
807-
(* caml_ba_set_3, *)
808-
809-
(* caml_ba_dim_1, // %caml_ba_dim_1 *)
810-
(* caml_ba_dim_2, *)
811-
(* caml_ba_dim_3, *)
812-
| "caml_output_value_to_buffer"
813-
| "caml_marshal_data_size"
814-
| "caml_input_value_from_string"
815-
| "caml_output_value"
816-
| "caml_input_value"
817-
| "caml_output_value_to_string"
818-
| "caml_md5_chan"
819-
| "caml_hash_univ_param"
820-
| "caml_sys_close"
821-
| "caml_sys_open"
822-
| "caml_ml_input"
823-
| "caml_ml_input_scan_line"
824-
| "caml_ml_input_int"
825-
| "caml_ml_close_channel"
826-
| "caml_ml_output_int"
827-
828-
| "caml_ml_channel_size_64"
829-
| "caml_ml_channel_size"
830-
| "caml_ml_pos_in_64"
831-
| "caml_ml_pos_in"
832-
| "caml_ml_seek_in"
833-
| "caml_ml_seek_in_64"
834-
| "caml_ml_pos_out"
835-
| "caml_ml_pos_out_64"
836-
| "caml_ml_seek_out"
837-
| "caml_ml_seek_out_64"
838-
| "caml_ml_set_binary_mode"
776+
E.runtime_ref Js_runtime_modules.io "stderr"
839777
| _ ->
840778
Bs_warnings.warn_missing_primitive loc prim_name ;
841779
E.resolve_and_apply prim_name args

jscomp/ext/js_runtime_modules.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ let caml_oo_curry = "Caml_oo_curry"
4343
let caml_primitive = "Caml_primitive"
4444
let int64 = "Caml_int64"
4545
let md5 = "Caml_md5"
46-
let weak = "Caml_weak"
47-
4846
let gc = "Caml_gc"
4947
let int32 = "Caml_int32"
5048
let block = "Block"

jscomp/main/builtin_cmi_datasets.ml

Lines changed: 127 additions & 131 deletions
Large diffs are not rendered by default.

jscomp/main/builtin_cmj_datasets.ml

Lines changed: 11 additions & 15 deletions
Large diffs are not rendered by default.

jscomp/runtime/block.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929

30-
type obj = Caml_obj_extern.t
30+
type obj = Obj.t
3131

3232
(* Note that when we introduce it in {!Js_dump}
3333
we need introduce dependency properly *)

jscomp/runtime/block.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
(** *)
30-
type obj = Caml_obj_extern.t
30+
type obj = Obj.t
3131

3232
val __ : int -> obj -> obj
3333

jscomp/runtime/bs_stdlib_mini.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module Obj : sig
6262
external set_tag : t -> int -> unit = "tag" [@@bs.set]
6363
external repr : 'a -> t = "%identity"
6464
external magic : 'a -> 'b = "%identity"
65+
external size : t -> int = "#obj_length"
6566
end
6667

6768

jscomp/runtime/caml_chrome_debugger.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
type obj = Caml_obj_extern.t
26+
type obj = Obj.t
2727

2828
let setupChromeDebugger : unit -> unit [@bs]= [%raw{|
2929
function () {

jscomp/runtime/caml_chrome_debugger.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type obj = Caml_obj_extern.t
25+
type obj = Obj.t
2626

2727
val __ : int -> obj -> obj
2828

jscomp/runtime/caml_hash.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ external ( +~ ) : nativeint -> nativeint -> nativeint =
8080
"caml_int32_add"
8181

8282
(*ATTENTION: refer {!Oo.id} *)
83-
external oo_id : Caml_obj_extern.t -> int = "%field1"
83+
external oo_id : Obj.t -> int = "%field1"
8484

8585
open Caml_hash_primitive
8686

8787
let caml_hash (count : int) _limit (seed : nativeint)
88-
(obj : Caml_obj_extern.t) : nativeint =
88+
(obj : Obj.t) : nativeint =
8989
let hash = ref seed in
9090
if Js.typeof obj = "number" then
9191
begin
@@ -129,10 +129,8 @@ let caml_hash (count : int) _limit (seed : nativeint)
129129
else if Js.typeof obj = "function" then
130130
()
131131
else
132-
let size = Caml_obj_extern.size_of_t obj in
133-
match Js.undefinedToOption size with
134-
| None -> ()
135-
| Some size ->
132+
let size = Obj.size obj in
133+
if size <> 0 then
136134
let obj_tag = Obj.tag obj in
137135
let tag = (size lsl 10) lor obj_tag in
138136
if tag = 248 (* Obj.object_tag*) then
@@ -143,7 +141,7 @@ let caml_hash (count : int) _limit (seed : nativeint)
143141
let block =
144142
let v = size - 1 in if v < num.contents then v else num.contents in
145143
for i = 0 to block do
146-
push_back queue (Obj.field obj i )
144+
push_back queue (Obj.field obj i )
147145
done
148146
end
149147
done;

0 commit comments

Comments
 (0)