Skip to content

Commit 1f462bd

Browse files
authored
Merge pull request #4402 from BuckleScript/caml_oo
move caml_set_oo_id into caml_oo module
2 parents d8a1145 + 42e5c2a commit 1f462bd

40 files changed

+695
-828
lines changed

jscomp/core/js_of_lam_exception.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,3 @@ let make exception_str : J.expression =
4545

4646

4747

48-
(* TODO: only used in camlinternalOO, split it off as a separate module? *)
49-
let caml_set_oo_id args =
50-
E.runtime_call Js_runtime_modules.exceptions "caml_set_oo_id" args
51-

jscomp/core/js_of_lam_exception.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
val caml_set_oo_id :
27-
J.expression list -> J.expression
2826

2927

3028
val make : J.expression -> J.expression

jscomp/core/lam_dispatch_primitive.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ let translate loc (prim_name : string)
584584
call Js_runtime_modules.caml_js_exceptions
585585
| "caml_set_oo_id" (* needed in {!camlinternalOO.set_id} *)
586586
->
587-
Js_of_lam_exception.caml_set_oo_id args
587+
call Js_runtime_modules.oo
588588

589589
| "caml_sys_get_argv"
590590
(** TODO: refine

jscomp/main/builtin_cmi_datasets.ml

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

jscomp/main/builtin_cmj_datasets.ml

Lines changed: 7 additions & 7 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
@@ -32,7 +32,7 @@ type obj = Caml_obj_extern.t
3232
(* Note that when we introduce it in {!Js_dump}
3333
we need introduce dependency properly *)
3434
let __ tag block =
35-
Caml_obj_extern.set_tag block tag; block
35+
Obj.set_tag block tag; block
3636

3737

3838

jscomp/runtime/bs_stdlib_mini.mli

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ external ( -. ) : float -> float -> float = "%subfloat"
5353
external ( *. ) : float -> float -> float = "%mulfloat"
5454
external ( /. ) : float -> float -> float = "%divfloat"
5555

56-
module Obj : sig
56+
module Obj : sig
57+
type t
58+
external field : t -> int -> t = "%obj_field"
59+
external set_field : t -> int -> t -> unit = "%obj_set_field"
60+
external tag : t -> int = "caml_obj_tag"
61+
(* The compiler ensures (|0) operation *)
62+
external set_tag : t -> int -> unit = "tag" [@@bs.set]
63+
external repr : 'a -> t = "%identity"
5764
external magic : 'a -> 'b = "%identity"
5865
end
5966

jscomp/runtime/caml_chrome_debugger.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ let __ = Block.__
154154

155155
let variant meta tag xs =
156156
setupOnce () [@bs];
157-
xs |. Caml_obj_extern.set_tag tag;
157+
xs |. Obj.set_tag tag;
158158
xs |. addProp (cacheSymbol "BsVariant") {value = meta }
159159

160160
let simpleVariant meta xs =

jscomp/runtime/caml_exceptions.ml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,7 @@ type t = {
3636
{[ a = caml_set_oo_id([248,"tag", caml_oo_last_id++]) ]}
3737
*)
3838

39-
let%private id = ref 0
40-
41-
42-
(* see #251
43-
{[
44-
CAMLprim value caml_set_oo_id (value obj) {
45-
Field(obj, 1) = oo_last_id;
46-
oo_last_id += 2;
47-
return obj;
48-
}
49-
50-
]}*)
51-
let caml_set_oo_id (b : Caml_obj_extern.t) : Caml_obj_extern.t =
52-
Caml_obj_extern.set_field (Caml_obj_extern.repr b) 1 (Caml_obj_extern.repr id.contents);
53-
id .contents <- id.contents + 1;
54-
b
55-
(* FXIME: this is only relevant to OO module now *)
39+
let id = ref 0
5640

5741

5842
let create (str : string) : string =

jscomp/runtime/caml_hash.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ let caml_hash (count : int) _limit (seed : nativeint)
125125
else if Js.typeof obj = "undefined" then
126126
()
127127
else if Js.typeof obj = "symbol" then
128-
assert false (* TODO *)
128+
()
129129
else if Js.typeof obj = "function" then
130130
()
131131
else
132132
let size = Caml_obj_extern.size_of_t obj in
133133
match Js.undefinedToOption size with
134134
| None -> ()
135135
| Some size ->
136-
let obj_tag = Caml_obj_extern.tag obj in
136+
let obj_tag = Obj.tag obj in
137137
let tag = (size lsl 10) lor obj_tag in
138138
if tag = 248 (* Obj.object_tag*) then
139139
hash.contents <- caml_hash_mix_int hash.contents (Caml_nativeint_extern.of_int (oo_id obj))
@@ -143,7 +143,7 @@ let caml_hash (count : int) _limit (seed : nativeint)
143143
let block =
144144
let v = size - 1 in if v < num.contents then v else num.contents in
145145
for i = 0 to block do
146-
push_back queue (Caml_obj_extern.field obj i )
146+
push_back queue (Obj.field obj i )
147147
done
148148
end
149149
done;

0 commit comments

Comments
 (0)