Skip to content

Commit 6037c66

Browse files
committedMay 20, 2020
move caml_obj_extern primitives into Obj module
The reason is that it is easier for us to grep primitive usage Obj.field etc
1 parent eff41b4 commit 6037c66

14 files changed

+64
-91
lines changed
 

Diff for: ‎jscomp/runtime/block.ml

+1-1
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

Diff for: ‎jscomp/runtime/bs_stdlib_mini.mli

+8-1
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

Diff for: ‎jscomp/runtime/caml_chrome_debugger.ml

+1-1
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 =

Diff for: ‎jscomp/runtime/caml_hash.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ let caml_hash (count : int) _limit (seed : nativeint)
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;

Diff for: ‎jscomp/runtime/caml_js_exceptions.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exception Error of t
1010
{[
1111
exception A of int;;
1212
let v = A 3 ;;
13-
Caml_obj_extern.tag (Caml_obj_extern.field (Caml_obj_extern.repr v) 0);;
13+
Obj.tag (Obj.field (Obj.repr v) 0);;
1414
- : int = 248
1515
]}
1616
This function has to be in this module Since

Diff for: ‎jscomp/runtime/caml_module.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let init_mod (loc : string * int * int) (shape : shape) =
6565
)
6666
| Module comps
6767
->
68-
let v = Caml_obj_extern.repr (module struct end : Empty) in
68+
let v = Obj.repr (module struct end : Empty) in
6969
set_field struct_ idx v ;
7070
let len = Array.length comps in
7171
for i = 0 to len - 1 do
@@ -74,7 +74,7 @@ let init_mod (loc : string * int * int) (shape : shape) =
7474
done
7575
| Value v ->
7676
set_field struct_ idx v in
77-
let res = Caml_obj_extern.repr (module struct end : Empty) in
77+
let res = Obj.repr (module struct end : Empty) in
7878
let dummy_name = "dummy" in
7979
loop shape res dummy_name;
8080
get_field res dummy_name

Diff for: ‎jscomp/runtime/caml_obj.ml

+25-25
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ end
5959
block creation
6060
*)
6161
let caml_obj_block tag size =
62-
let v = Caml_obj_extern.repr (Caml_array_extern.new_uninitialized size) in
63-
Caml_obj_extern.set_tag v tag ;
62+
let v = Obj.repr (Caml_array_extern.new_uninitialized size) in
63+
Obj.set_tag v tag ;
6464
v
6565

6666
(**
@@ -116,7 +116,7 @@ let caml_obj_truncate (x : Caml_obj_extern.t) (new_size : int) =
116116
if len <> new_size then
117117
begin
118118
for i = new_size to len - 1 do
119-
Caml_obj_extern.set_field x i (Obj.magic 0)
119+
Obj.set_field x i (Obj.magic 0)
120120
done;
121121
Caml_obj_extern.set_length x new_size
122122
end
@@ -203,33 +203,33 @@ let rec caml_compare (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : int =
203203
| "number", "number" ->
204204
Pervasives.compare (Obj.magic a : int) (Obj.magic b : int)
205205
| "number", _ ->
206-
if b == Caml_obj_extern.repr Js.null || Caml_obj_extern.tag b = 256 then 1 (* Some (Some ..) < x *)
206+
if b == Obj.repr Js.null || Obj.tag b = 256 then 1 (* Some (Some ..) < x *)
207207
else
208208
-1 (* Integer < Block in OCaml runtime GPR #1195, except Some.. *)
209209
| _, "number" ->
210-
if a == Caml_obj_extern.repr Js.null || Caml_obj_extern.tag a = 256 then -1
210+
if a == Obj.repr Js.null || Obj.tag a = 256 then -1
211211
else 1
212212
| _ ->
213-
if a == Caml_obj_extern.repr Js.null then
213+
if a == Obj.repr Js.null then
214214
(* [b] could not be null otherwise would equal *)
215-
if Caml_obj_extern.tag b = 256 then 1 else -1
216-
else if b == Caml_obj_extern.repr Js.null then
217-
if Caml_obj_extern.tag a = 256 then -1 else 1
215+
if Obj.tag b = 256 then 1 else -1
216+
else if b == Obj.repr Js.null then
217+
if Obj.tag a = 256 then -1 else 1
218218
else
219-
let tag_a = Caml_obj_extern.tag a in
220-
let tag_b = Caml_obj_extern.tag b in
219+
let tag_a = Obj.tag a in
220+
let tag_b = Obj.tag b in
221221
(* double_array_tag: 254
222222
*)
223223
if tag_a = 256 then
224224
if tag_b = 256 then
225-
Pervasives.compare (Obj.magic (Caml_obj_extern.field a 1) : int)
226-
(Obj.magic (Caml_obj_extern.field b 1) : int)
225+
Pervasives.compare (Obj.magic (Obj.field a 1) : int)
226+
(Obj.magic (Obj.field b 1) : int)
227227
(* Some None < Some (Some None)) *)
228228
else (* b could not be undefined/None *)
229229
(* Some None < Some ..*)
230230
-1
231231
else if tag_a = 248 (* object/exception *) then
232-
Pervasives.compare (Obj.magic (Caml_obj_extern.field a 1) : int) (Obj.magic (Caml_obj_extern.field b 1 ))
232+
Pervasives.compare (Obj.magic (Obj.field a 1) : int) (Obj.magic (Obj.field b 1 ))
233233
else if tag_a = 251 (* abstract_tag *) then
234234
raise (Invalid_argument "equal: abstract value")
235235
else if tag_a <> tag_b then
@@ -251,19 +251,19 @@ and aux_same_length (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i same_leng
251251
if i = same_length then
252252
0
253253
else
254-
let res = caml_compare (Caml_obj_extern.field a i) (Caml_obj_extern.field b i) in
254+
let res = caml_compare (Obj.field a i) (Obj.field b i) in
255255
if res <> 0 then res
256256
else aux_same_length a b (i + 1) same_length
257257
and aux_length_a_short (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i short_length =
258258
if i = short_length then -1
259259
else
260-
let res = caml_compare (Caml_obj_extern.field a i) (Caml_obj_extern.field b i) in
260+
let res = caml_compare (Obj.field a i) (Obj.field b i) in
261261
if res <> 0 then res
262262
else aux_length_a_short a b (i+1) short_length
263263
and aux_length_b_short (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i short_length =
264264
if i = short_length then 1
265265
else
266-
let res = caml_compare (Caml_obj_extern.field a i) (Caml_obj_extern.field b i) in
266+
let res = caml_compare (Obj.field a i) (Obj.field b i) in
267267
if res <> 0 then res
268268
else aux_length_b_short a b (i+1) short_length
269269
and aux_obj_compare (a: Caml_obj_extern.t) (b: Caml_obj_extern.t) =
@@ -314,23 +314,23 @@ let rec caml_equal (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : bool =
314314
if b_type = "number" || b_type = "undefined" || b == [%raw{|null|}] then false
315315
else
316316
(* [a] [b] could not be null, so it can not raise *)
317-
let tag_a = Caml_obj_extern.tag a in
318-
let tag_b = Caml_obj_extern.tag b in
317+
let tag_a = Obj.tag a in
318+
let tag_b = Obj.tag b in
319319
(* double_array_tag: 254
320320
forward_tag:250
321321
*)
322322
if tag_a = 250 then
323-
caml_equal (Caml_obj_extern.field a 0) b
323+
caml_equal (Obj.field a 0) b
324324
else if tag_b = 250 then
325-
caml_equal a (Caml_obj_extern.field b 0)
325+
caml_equal a (Obj.field b 0)
326326
else if tag_a = 248 (* object/exception *) then
327-
(Obj.magic (Caml_obj_extern.field a 1)) == (Obj.magic (Caml_obj_extern.field b 1 ))
327+
(Obj.magic (Obj.field a 1)) == (Obj.magic (Obj.field b 1 ))
328328
else if tag_a = 251 (* abstract_tag *) then
329329
raise (Invalid_argument "equal: abstract value")
330330
else if tag_a <> tag_b then
331331
false
332332
else if tag_a = 256 then
333-
(Obj.magic (Caml_obj_extern.field a 1) : int) = Obj.magic (Caml_obj_extern.field b 1)
333+
(Obj.magic (Obj.field a 1) : int) = Obj.magic (Obj.field b 1)
334334
else
335335
let len_a = Caml_obj_extern.length a in
336336
let len_b = Caml_obj_extern.length b in
@@ -345,7 +345,7 @@ and aux_equal_length (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i same_len
345345
if i = same_length then
346346
true
347347
else
348-
caml_equal (Caml_obj_extern.field a i) (Caml_obj_extern.field b i)
348+
caml_equal (Obj.field a i) (Obj.field b i)
349349
&& aux_equal_length a b (i + 1) same_length
350350
and aux_obj_equal (a: Caml_obj_extern.t) (b: Caml_obj_extern.t) =
351351
let result = ref true in
@@ -391,5 +391,5 @@ let caml_min (x : Caml_obj_extern.t) y =
391391
let caml_max (x : Caml_obj_extern.t) y =
392392
if caml_compare x y >= 0 then x else y
393393

394-
let caml_obj_set_tag = Caml_obj_extern.set_tag
394+
let caml_obj_set_tag = Obj.set_tag
395395

Diff for: ‎jscomp/runtime/caml_obj_extern.ml

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,17 @@
2424

2525
(** *)
2626

27-
type t
28-
external tag : t -> int = "caml_obj_tag"
29-
external repr : 'a -> t = "%identity"
30-
external field : t -> int -> t = "%obj_field"
31-
external set_field : t -> int -> t -> unit = "%obj_set_field"
27+
type t = Bs_stdlib_mini.Obj.t
28+
29+
30+
3231

3332
external set_length : t -> int -> unit = "length" [@@bs.set]
3433
external length : t -> int = "#obj_length"
3534

36-
(** The same as {!Obj.set_tag} *)
37-
external set_tag : t -> int -> unit = "tag" [@@bs.set]
3835

3936
external size_of_t : t -> 'a Js.undefined =
4037
"length" [@@bs.get]
4138

4239

43-
external magic : 'a -> 'b = "%identity"
40+

Diff for: ‎jscomp/runtime/caml_oo.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ external get_methods : obj -> closure array =
5959
6060
]}*)
6161
let caml_set_oo_id (b : obj) : obj =
62-
Caml_obj_extern.set_field
63-
(Caml_obj_extern.repr b) 1
64-
(Caml_obj_extern.repr Caml_exceptions.id.contents);
62+
Obj.set_field
63+
(Obj.repr b) 1
64+
(Obj.repr Caml_exceptions.id.contents);
6565
Caml_exceptions.id.contents <- Caml_exceptions.id.contents + 1;
6666
b
6767

@@ -73,18 +73,18 @@ let caml_get_public_method
7373
let module Array = Caml_array_extern in
7474
let meths = get_methods obj in (* the first field of object is mehods *)
7575
let offs = caml_methods_cache.(cacheid) in
76-
if (Caml_obj_extern.magic meths.(offs) : int) = tag then meths.(offs - 1)
76+
if (Obj.magic meths.(offs) : int) = tag then meths.(offs - 1)
7777
else
7878
(* TODO: binary search *)
7979
let rec aux (i : int) : int =
8080
if i < 3 then assert false
81-
else if (Caml_obj_extern.magic meths.(i) : int) = tag then
81+
else if (Obj.magic meths.(i) : int) = tag then
8282
begin
8383
caml_methods_cache.(cacheid) <- i;
8484
i
8585
end
8686
else
8787
aux (i - 2)
8888
in
89-
meths.(aux (Caml_obj_extern.magic ((Caml_obj_extern.magic meths.(0) : int) * 2 + 1) : int) - 1)
89+
meths.(aux (Obj.magic ((Obj.magic meths.(0) : int) * 2 + 1) : int) - 1)
9090

Diff for: ‎jscomp/runtime/caml_option.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626

2727
let some ( x : Caml_obj_extern.t) : Caml_obj_extern.t =
2828
if Obj.magic x = None then
29-
(let block = Caml_obj_extern.repr (undefinedHeader, 0) in
30-
Caml_obj_extern.set_tag block 256;
29+
(let block = Obj.repr (undefinedHeader, 0) in
30+
Obj.set_tag block 256;
3131
block)
3232
else
33-
if x != Caml_obj_extern.repr Js.null && fst (Obj.magic x ) == Caml_obj_extern.repr undefinedHeader then
33+
if x != Obj.repr Js.null && fst (Obj.magic x ) == Obj.repr undefinedHeader then
3434
(
3535
let nid = snd (Obj.magic x) + 1 in
36-
let block = Caml_obj_extern.repr (undefinedHeader, nid) in
37-
Caml_obj_extern.set_tag block 256;
36+
let block = Obj.repr (undefinedHeader, nid) in
37+
Obj.set_tag block 256;
3838
block
3939
)
4040
else x
@@ -60,7 +60,7 @@ let null_to_opt (type t ) ( x : t Js.null) : t option =
6060
(** The input is already of [Some] form, [x] is not None,
6161
make sure [x[0]] will not throw *)
6262
let valFromOption (x : Caml_obj_extern.t) : Caml_obj_extern.t =
63-
if x != Caml_obj_extern.repr Js.null && fst (Obj.magic x) == Caml_obj_extern.repr undefinedHeader
63+
if x != Obj.repr Js.null && fst (Obj.magic x) == Obj.repr undefinedHeader
6464
then
6565
let depth : int = snd (Obj.magic x) in
6666
if depth = 0 then Obj.magic None
@@ -70,11 +70,11 @@ let valFromOption (x : Caml_obj_extern.t) : Caml_obj_extern.t =
7070

7171
let option_get (x : 'a option) =
7272
if x = None then Caml_undefined_extern.empty
73-
else Obj.magic (valFromOption (Caml_obj_extern.repr x))
73+
else Obj.magic (valFromOption (Obj.repr x))
7474

7575

7676
(** [input] is optional polymorphic variant *)
7777
let option_get_unwrap (x : 'a option) =
7878
if x = None then Caml_undefined_extern.empty
79-
else Obj.magic (Caml_obj_extern.field (Caml_obj_extern.repr (valFromOption (Caml_obj_extern.repr x))) 1 )
79+
else Obj.magic (Obj.field (Obj.repr (valFromOption (Obj.repr x))) 1 )
8080

Diff for: ‎jscomp/runtime/caml_weak.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let caml_weak_get xs i =
4646
let caml_weak_get_copy xs i =
4747
match Caml_undefined_extern.toOption (Caml_array_extern.unsafe_get xs i) with
4848
| None -> None
49-
| Some x -> Some (Obj.magic (Caml_obj.caml_obj_dup (Caml_obj_extern.repr x) ))
49+
| Some x -> Some (Obj.magic (Caml_obj.caml_obj_dup (Obj.repr x) ))
5050

5151
let caml_weak_check xs i =
5252
Caml_array_extern.unsafe_get xs i <> Caml_undefined_extern.empty

Diff for: ‎jscomp/runtime/release.ninja

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ build runtime/caml_module.cmj : cc_cmi runtime/caml_module.ml | runtime/caml_arr
4545
build runtime/caml_module.cmi : cc runtime/caml_module.mli | runtime/bs_stdlib_mini.cmi runtime/caml_obj_extern.cmj runtime/js.cmi runtime/js.cmj
4646
build runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.ml | runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_obj_extern.cmj runtime/caml_primitive.cmj runtime/js.cmj
4747
build runtime/caml_obj.cmi : cc runtime/caml_obj.mli | runtime/bs_stdlib_mini.cmi runtime/caml_obj_extern.cmj runtime/js.cmi runtime/js.cmj
48-
build runtime/caml_oo.cmj : cc_cmi runtime/caml_oo.ml | runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/caml_obj_extern.cmj runtime/caml_oo.cmi
48+
build runtime/caml_oo.cmj : cc_cmi runtime/caml_oo.ml | runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/caml_exceptions.cmj runtime/caml_oo.cmi
4949
build runtime/caml_oo.cmi : cc runtime/caml_oo.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
5050
build runtime/caml_option.cmj : cc_cmi runtime/caml_option.ml | runtime/caml_obj_extern.cmj runtime/caml_option.cmi runtime/caml_undefined_extern.cmj runtime/js.cmj
5151
build runtime/caml_option.cmi : cc runtime/caml_option.mli | runtime/bs_stdlib_mini.cmi runtime/caml_obj_extern.cmj runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj
@@ -59,12 +59,12 @@ build runtime/caml_string.cmj : cc_cmi runtime/caml_string.ml | runtime/caml_str
5959
build runtime/caml_string.cmi : cc runtime/caml_string.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6060
build runtime/caml_sys.cmj : cc_cmi runtime/caml_sys.ml | runtime/caml_array_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_sys.cmi runtime/caml_undefined_extern.cmj runtime/js.cmj
6161
build runtime/caml_sys.cmi : cc runtime/caml_sys.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
62-
build runtime/caml_weak.cmj : cc_cmi runtime/caml_weak.ml | runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/caml_obj.cmj runtime/caml_obj_extern.cmj runtime/caml_option.cmj runtime/caml_undefined_extern.cmj runtime/caml_weak.cmi
62+
build runtime/caml_weak.cmj : cc_cmi runtime/caml_weak.ml | runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/caml_obj.cmj runtime/caml_option.cmj runtime/caml_undefined_extern.cmj runtime/caml_weak.cmi
6363
build runtime/caml_weak.cmi : cc runtime/caml_weak.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6464
build runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj : cc runtime/caml_array_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6565
build runtime/caml_bytes_extern.cmi runtime/caml_bytes_extern.cmj : cc runtime/caml_bytes_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6666
build runtime/caml_char.cmi runtime/caml_char.cmj : cc runtime/caml_char.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
67-
build runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj : cc runtime/caml_exceptions.ml | runtime/bs_stdlib_mini.cmi runtime/caml_obj_extern.cmj runtime/js.cmi runtime/js.cmj
67+
build runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj : cc runtime/caml_exceptions.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6868
build runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj : cc runtime/caml_external_polyfill.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6969
build runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
7070
build runtime/caml_int32_extern.cmi runtime/caml_int32_extern.cmj : cc runtime/caml_int32_extern.ml | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj

Diff for: ‎jscomp/stdlib-406/release.ninja

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ build stdlib-406/camlinternalFormat.cmj : cc_cmi stdlib-406/camlinternalFormat.m
3939
build stdlib-406/camlinternalFormat.cmi : cc stdlib-406/camlinternalFormat.mli | stdlib-406/buffer.cmi stdlib-406/camlinternalFormatBasics.cmi stdlib-406/pervasives.cmj others
4040
build stdlib-406/camlinternalLazy.cmj : cc_cmi stdlib-406/camlinternalLazy.ml | stdlib-406/camlinternalLazy.cmi others
4141
build stdlib-406/camlinternalLazy.cmi : cc stdlib-406/camlinternalLazy.mli | stdlib-406/pervasives.cmj others
42-
build stdlib-406/camlinternalMod.cmj : cc_cmi stdlib-406/camlinternalMod.ml | stdlib-406/array.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalOO.cmj stdlib-406/obj.cmj others
42+
build stdlib-406/camlinternalMod.cmj : cc_cmi stdlib-406/camlinternalMod.ml | stdlib-406/camlinternalMod.cmi stdlib-406/obj.cmj others
4343
build stdlib-406/camlinternalMod.cmi : cc stdlib-406/camlinternalMod.mli | stdlib-406/obj.cmi stdlib-406/pervasives.cmj others
4444
build stdlib-406/camlinternalOO.cmj : cc_cmi stdlib-406/camlinternalOO.ml | stdlib-406/array.cmj stdlib-406/camlinternalOO.cmi stdlib-406/char.cmj stdlib-406/list.cmj stdlib-406/map.cmj stdlib-406/obj.cmj stdlib-406/string.cmj stdlib-406/sys.cmj others
4545
build stdlib-406/camlinternalOO.cmi : cc stdlib-406/camlinternalOO.mli | stdlib-406/obj.cmi stdlib-406/pervasives.cmj others

Diff for: ‎jscomp/test/test_list.ml

-31
Original file line numberDiff line numberDiff line change
@@ -294,37 +294,6 @@ let stable_sort cmp l =
294294
let sort = stable_sort;;
295295
let fast_sort = stable_sort;;
296296

297-
(* Note: on a list of length between about 100000 (depending on the minor
298-
heap size and the type of the list) and Sys.max_array_size, it is
299-
actually faster to use the following, but it might also use more memory
300-
because the argument list cannot be deallocated incrementally.
301-
302-
Also, there seems to be a bug in this code or in the
303-
implementation of obj_truncate.
304-
305-
external obj_truncate : 'a array -> int -> unit = "caml_obj_truncate"
306-
307-
let array_to_list_in_place a =
308-
let l = Array.length a in
309-
let rec loop accu n p =
310-
if p <= 0 then accu else begin
311-
if p = n then begin
312-
obj_truncate a p;
313-
loop (a.(p-1) :: accu) (n-1000) (p-1)
314-
end else begin
315-
loop (a.(p-1) :: accu) n (p-1)
316-
end
317-
end
318-
in
319-
loop [] (l-1000) l
320-
;;
321-
322-
let stable_sort cmp l =
323-
let a = Array.of_list l in
324-
Array.stable_sort cmp a;
325-
array_to_list_in_place a
326-
;;
327-
*)
328297

329298

330299
(** sorting + removing duplicates *)

0 commit comments

Comments
 (0)