Skip to content

Commit 39dbf43

Browse files
committed
OxCaml runtime: stubs in Obj, Gc, and Runtime_events
1 parent db2f58f commit 39dbf43

File tree

5 files changed

+77
-3
lines changed

5 files changed

+77
-3
lines changed

runtime/js/gc.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,23 @@ function caml_memprof_discard(_t) {
8686
return 0;
8787
}
8888

89+
//Provides: caml_memprof_participate
90+
//Version: >= 5.2, < 5.3
91+
//OxCaml
92+
function caml_memprof_participate(_config) {
93+
return 0;
94+
}
95+
8996
//Provides: caml_eventlog_resume
90-
//Version: < 5.0
97+
//Version: <= 5.2
98+
//(actually < 5.0, but OxCaml still references it)
9199
function caml_eventlog_resume(_unit) {
92100
return 0;
93101
}
94102

95103
//Provides: caml_eventlog_pause
96-
//Version: < 5.0
104+
//Version: <= 5.2
105+
//(actually < 5.0, but OxCaml still references it)
97106
function caml_eventlog_pause(_unit) {
98107
return 0;
99108
}
@@ -130,3 +139,26 @@ function caml_get_major_bucket(_n) {
130139
function caml_get_major_credit(_n) {
131140
return 0;
132141
}
142+
143+
//Provides: caml_gc_tweak_get
144+
//Requires: caml_invalid_argument
145+
//Version: >= 5.2, < 5.3
146+
//OxCaml
147+
function caml_gc_tweak_get(_name) {
148+
caml_invalid_argument("Gc.Tweak: parameter not found");
149+
}
150+
151+
//Provides: caml_gc_tweak_set
152+
//Requires: caml_invalid_argument
153+
//Version: >= 5.2, < 5.3
154+
//OxCaml
155+
function caml_gc_tweak_set(_name, _value) {
156+
caml_invalid_argument("Gc.Tweak: parameter not found");
157+
}
158+
159+
//Provides: caml_gc_tweak_list_active
160+
//Version: >= 5.2, < 5.3
161+
//OxCaml
162+
function caml_gc_tweak_list_active(_unit) {
163+
return 0;
164+
}

runtime/js/obj.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ function caml_update_dummy_lazy(dummy, newval) {
6464
return 0;
6565
}
6666

67+
//Provides: caml_obj_is_stack
68+
//Version: >= 5.2, < 5.3
69+
//OxCaml
70+
function caml_obj_is_stack(_x) {
71+
return 0;
72+
}
73+
74+
//Provides: caml_succ_scannable_prefix_len
75+
//Version: >= 5.2, < 5.3
76+
//OxCaml
77+
function caml_succ_scannable_prefix_len(_x) {
78+
return 0;
79+
}
80+
81+
//Provides: caml_obj_uniquely_reachable_words
82+
//Requires: caml_failwith
83+
//Version: >= 5.2, < 5.3
84+
//OxCaml
85+
function caml_obj_uniquely_reachable_words(_x) {
86+
caml_failwith("Obj.uniquely_reachable_words is not available in javascript.");
87+
}
88+
6789
//Provides: caml_obj_tag
6890
//Requires: caml_is_ml_bytes, caml_is_ml_string
6991
function caml_obj_tag(x) {

runtime/js/runtime_events.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ function caml_runtime_events_read_poll(_cursor, _callbacks, _num) {
8383
}
8484

8585
//Provides: caml_ml_runtime_events_path const
86-
//Version: >= 5.3
86+
//Version: >= 5.2
87+
//Since 5.3 in OCaml mainstream, but also available in OxCaml
8788
function caml_ml_runtime_events_path(_unit) {
8889
return 0;
8990
}

runtime/wasm/gc.wat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
(func (export "caml_memprof_discard") (param (ref eq)) (result (ref eq))
118118
(ref.i31 (i32.const 0)))
119119

120+
(func (export "caml_memprof_participate") (param (ref eq)) (result (ref eq))
121+
(ref.i31 (i32.const 0)))
122+
120123
(func (export "caml_eventlog_pause") (param (ref eq)) (result (ref eq))
121124
(ref.i31 (i32.const 0)))
122125

runtime/wasm/obj.wat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@
9999
(global $double_array_tag (export "double_array_tag") i32 (i32.const 254))
100100
(global $custom_tag i32 (i32.const 255))
101101

102+
(func (export "caml_obj_is_stack")
103+
(param (ref eq)) (result (ref eq))
104+
(ref.i31 (i32.const 0)))
105+
106+
(func (export "caml_succ_scannable_prefix_len")
107+
(param (ref eq)) (result (ref eq))
108+
(ref.i31 (i32.const 0)))
109+
110+
(@string $unique_words_unsupported
111+
"Obj.uniquely_reachable_words is not available in wasm.")
112+
113+
(func (export "caml_obj_uniquely_reachable_words")
114+
(param (ref eq)) (result (ref eq))
115+
(call $caml_failwith (global.get $unique_words_unsupported))
116+
(ref.i31 (i32.const 0)))
117+
102118
(func $caml_is_closure (export "caml_is_closure")
103119
(param $v (ref eq)) (result i32)
104120
(i32.or (ref.test (ref $closure) (local.get $v))

0 commit comments

Comments
 (0)