Skip to content

Commit 5ee1b72

Browse files
committed
Runtime: adjust obj prims
1 parent 1bbb485 commit 5ee1b72

File tree

7 files changed

+11
-48
lines changed

7 files changed

+11
-48
lines changed

compiler/tests-check-prim/main.output

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,6 @@ caml_to_js_string
144144
From +nat.js:
145145
compare_nat_real
146146

147-
From +obj.js:
148-
caml_lazy_read_result
149-
caml_lazy_reset_to_lazy
150-
caml_lazy_update_to_forcing
151-
caml_lazy_update_to_forward
152-
caml_obj_compare_and_swap
153-
caml_obj_is_block
154-
caml_obj_is_shared
155-
caml_obj_update_tag
156-
157147
From +stdlib.js:
158148
caml_build_symbols
159149
caml_is_printable

compiler/tests-check-prim/main.output5

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ caml_to_js_string
127127
From +nat.js:
128128
compare_nat_real
129129

130-
From +obj.js:
131-
caml_obj_is_block
132-
caml_obj_make_forward
133-
caml_obj_set_tag
134-
caml_obj_truncate
135-
136130
From +runtime_events.js:
137131
caml_runtime_events_create_cursor
138132
caml_runtime_events_free_cursor

compiler/tests-check-prim/unix-unix.output

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,6 @@ caml_to_js_string
253253
From +nat.js:
254254
compare_nat_real
255255

256-
From +obj.js:
257-
caml_lazy_read_result
258-
caml_lazy_reset_to_lazy
259-
caml_lazy_update_to_forcing
260-
caml_lazy_update_to_forward
261-
caml_obj_compare_and_swap
262-
caml_obj_is_block
263-
caml_obj_is_shared
264-
caml_obj_update_tag
265-
266256
From +stdlib.js:
267257
caml_build_symbols
268258
caml_is_printable

compiler/tests-check-prim/unix-unix.output5

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,6 @@ caml_to_js_string
238238
From +nat.js:
239239
compare_nat_real
240240

241-
From +obj.js:
242-
caml_obj_is_block
243-
caml_obj_make_forward
244-
caml_obj_set_tag
245-
caml_obj_truncate
246-
247241
From +runtime_events.js:
248242
caml_runtime_events_create_cursor
249243
caml_runtime_events_free_cursor

compiler/tests-check-prim/unix-win32.output

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,6 @@ caml_to_js_string
218218
From +nat.js:
219219
compare_nat_real
220220

221-
From +obj.js:
222-
caml_lazy_read_result
223-
caml_lazy_reset_to_lazy
224-
caml_lazy_update_to_forcing
225-
caml_lazy_update_to_forward
226-
caml_obj_compare_and_swap
227-
caml_obj_is_block
228-
caml_obj_is_shared
229-
caml_obj_update_tag
230-
231221
From +stdlib.js:
232222
caml_build_symbols
233223
caml_is_printable

compiler/tests-check-prim/unix-win32.output5

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ caml_to_js_string
204204
From +nat.js:
205205
compare_nat_real
206206

207-
From +obj.js:
208-
caml_obj_is_block
209-
caml_obj_make_forward
210-
caml_obj_set_tag
211-
caml_obj_truncate
212-
213207
From +runtime_events.js:
214208
caml_runtime_events_create_cursor
215209
caml_runtime_events_free_cursor

runtime/js/obj.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function caml_alloc_dummy_infix() {
3939
}
4040

4141
//Provides: caml_obj_is_block const (const)
42+
//Version: < 4.12
4243
function caml_obj_is_block(x) {
4344
return +Array.isArray(x);
4445
}
@@ -55,6 +56,7 @@ function caml_obj_tag(x) {
5556
}
5657

5758
//Provides: caml_obj_set_tag (mutable, const)
59+
//Version: < 5.0
5860
function caml_obj_set_tag(x, tag) {
5961
x[0] = tag;
6062
return 0;
@@ -86,20 +88,23 @@ function caml_obj_dup(x) {
8688

8789
//Provides: caml_obj_truncate (mutable, const)
8890
//Requires: caml_invalid_argument
91+
//Version: < 5.0
8992
function caml_obj_truncate(x, s) {
9093
if (s <= 0 || s + 1 > x.length) caml_invalid_argument("Obj.truncate");
9194
if (x.length !== s + 1) x.length = s + 1;
9295
return 0;
9396
}
9497

9598
//Provides: caml_obj_make_forward
99+
//Version: < 5.0
96100
function caml_obj_make_forward(b, v) {
97101
b[0] = 250;
98102
b[1] = v;
99103
return 0;
100104
}
101105

102106
//Provides: caml_obj_compare_and_swap
107+
//Version: >= 5.0
103108
function caml_obj_compare_and_swap(x, i, old, n) {
104109
if (x[i + 1] === old) {
105110
x[i + 1] = n;
@@ -109,6 +114,7 @@ function caml_obj_compare_and_swap(x, i, old, n) {
109114
}
110115

111116
//Provides: caml_obj_is_shared
117+
//Version: >= 5.0
112118
function caml_obj_is_shared(x) {
113119
return 1;
114120
}
@@ -182,6 +188,7 @@ function caml_obj_add_offset(v, offset) {
182188
}
183189

184190
//Provides: caml_obj_update_tag
191+
//Version: >= 5.0
185192
function caml_obj_update_tag(b, o, n) {
186193
if (b[0] === o) {
187194
b[0] = n;
@@ -192,6 +199,7 @@ function caml_obj_update_tag(b, o, n) {
192199

193200
//Provides: caml_lazy_update_to_forcing
194201
//Requires: caml_obj_update_tag
202+
//Version: >= 5.0
195203
function caml_lazy_update_to_forcing(o) {
196204
if (
197205
Array.isArray(o) &&
@@ -206,20 +214,23 @@ function caml_lazy_update_to_forcing(o) {
206214

207215
//Provides: caml_lazy_update_to_forward
208216
//Requires: caml_obj_update_tag
217+
//Version: >= 5.0
209218
function caml_lazy_update_to_forward(o) {
210219
caml_obj_update_tag(o, 244, 250);
211220
return 0; // unit
212221
}
213222

214223
//Provides: caml_lazy_reset_to_lazy
215224
//Requires: caml_obj_update_tag
225+
//Version: >= 5.0
216226
function caml_lazy_reset_to_lazy(o) {
217227
caml_obj_update_tag(o, 244, 246);
218228
return 0;
219229
}
220230

221231
//Provides: caml_lazy_read_result
222232
//Requires: caml_obj_tag
233+
//Version: >= 5.0
223234
function caml_lazy_read_result(o) {
224235
return caml_obj_tag(o) === 250 ? o[1] : o;
225236
}

0 commit comments

Comments
 (0)