Skip to content

Commit b62b39e

Browse files
committed
Update tests
1 parent 7e181e4 commit b62b39e

File tree

9 files changed

+2149
-2260
lines changed

9 files changed

+2149
-2260
lines changed

compiler/tests-compiler/direct_calls.ml

+59-74
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,38 @@ let%expect_test "direct calls without --effects=cps" =
5757
[%expect
5858
{|
5959
function test1(param){
60-
function f(g, x){
61-
try{caml_call1(g, x); return;}
62-
catch(e$0){
63-
var e = caml_wrap_exception(e$0);
64-
throw caml_maybe_attach_backtrace(e, 0);
65-
}
60+
try{}
61+
catch(e$0){
62+
var e = caml_wrap_exception(e$0);
63+
throw caml_maybe_attach_backtrace(e, 0);
64+
}
65+
try{}
66+
catch(e){
67+
var e$0 = caml_wrap_exception(e);
68+
throw caml_maybe_attach_backtrace(e$0, 0);
6669
}
67-
f(function(x){return x + 1 | 0;}, 7);
68-
f(function(x){return x * 2.;}, 4.);
6970
return 0;
7071
}
7172
//end
7273
function test2(param){
73-
function f(g, x){
74-
try{caml_call1(g, x); return;}
75-
catch(e$0){
76-
var e = caml_wrap_exception(e$0);
77-
throw caml_maybe_attach_backtrace(e, 0);
78-
}
74+
try{}
75+
catch(e$0){
76+
var e = caml_wrap_exception(e$0);
77+
throw caml_maybe_attach_backtrace(e, 0);
78+
}
79+
try{caml_call2(Stdlib[28], x, cst_a);}
80+
catch(e){
81+
var e$0 = caml_wrap_exception(e);
82+
throw caml_maybe_attach_backtrace(e$0, 0);
7983
}
80-
f(function(x){return x + 1 | 0;}, 7);
81-
f(function(x){return caml_call2(Stdlib[28], x, cst_a$0);}, cst_a);
8284
return 0;
8385
}
8486
//end
85-
function test3(x){
86-
function F(symbol){function f(x){return x + 1 | 0;} return [0, f];}
87-
var M1 = F([0]), M2 = F([0]), _b_ = M2[1].call(null, 2);
88-
return [0, M1[1].call(null, 1), _b_];
89-
}
87+
function test3(x){return [0, 2, 3];}
9088
//end
9189
function test4(x){
92-
function F(symbol){
93-
function f(x){return caml_call2(Stdlib_Printf[2], _a_, x);}
94-
return [0, f];
95-
}
96-
var M1 = F([0]), M2 = F([0]);
97-
M1[1].call(null, 1);
98-
return M2[1].call(null, 2);
90+
caml_call2(Stdlib_Printf[2], _a_, 1);
91+
return caml_call2(Stdlib_Printf[2], _a_, 2);
9992
}
10093
//end |}]
10194

@@ -139,63 +132,55 @@ let%expect_test "direct calls with --effects=cps" =
139132
[%expect
140133
{|
141134
function test1(param, cont){
142-
function f(g, x){
143-
try{g(); return;}
144-
catch(e$0){
145-
var e = caml_wrap_exception(e$0);
146-
throw caml_maybe_attach_backtrace(e, 0);
147-
}
135+
try{}
136+
catch(e$0){
137+
var
138+
e = caml_wrap_exception(e$0),
139+
raise$0 = caml_pop_trap(),
140+
e$2 = caml_maybe_attach_backtrace(e, 0);
141+
return raise$0(e$2);
142+
}
143+
try{}
144+
catch(e){
145+
var
146+
e$0 = caml_wrap_exception(e),
147+
raise = caml_pop_trap(),
148+
e$1 = caml_maybe_attach_backtrace(e$0, 0);
149+
return raise(e$1);
148150
}
149-
f(function(x){});
150-
f(function(x){});
151151
return cont(0);
152152
}
153153
//end
154154
function test2(param, cont){
155-
function f(g, x, cont){
156-
runtime.caml_push_trap
157-
(function(e){
158-
var raise = caml_pop_trap(), e$0 = caml_maybe_attach_backtrace(e, 0);
159-
return raise(e$0);
160-
});
161-
return caml_exact_trampoline_cps_call
162-
(g, x, function(_t_){caml_pop_trap(); return cont();});
155+
try{}
156+
catch(e$1){
157+
var
158+
e = caml_wrap_exception(e$1),
159+
raise = caml_pop_trap(),
160+
e$0 = caml_maybe_attach_backtrace(e, 0);
161+
return raise(e$0);
163162
}
164-
return caml_exact_trampoline_cps_call$0
165-
(f,
166-
function(x, cont){return cont();},
167-
7,
168-
function(_r_){
169-
return caml_exact_trampoline_cps_call$0
170-
(f,
171-
function(x, cont){
172-
return caml_trampoline_cps_call3
173-
(Stdlib[28], x, cst_a$0, cont);
174-
},
175-
cst_a,
176-
function(_s_){return cont(0);});
177-
});
163+
runtime.caml_push_trap
164+
(function(e){
165+
var raise = caml_pop_trap(), e$0 = caml_maybe_attach_backtrace(e, 0);
166+
return raise(e$0);
167+
});
168+
return caml_trampoline_cps_call3
169+
(Stdlib[28],
170+
x,
171+
cst_a,
172+
function(_g_){caml_pop_trap(); return cont(0);});
178173
}
179174
//end
180-
function test3(x, cont){
181-
function F(symbol){function f(x){return x + 1 | 0;} return [0, f];}
182-
var M1 = F(), M2 = F(), _q_ = M2[1].call(null, 2);
183-
return cont([0, M1[1].call(null, 1), _q_]);
184-
}
175+
function test3(x, cont){return cont([0, 2, 3]);}
185176
//end
186177
function test4(x, cont){
187-
function F(symbol){
188-
function f(x, cont){
189-
return caml_trampoline_cps_call3(Stdlib_Printf[2], _o_, x, cont);
190-
}
191-
return [0, f];
192-
}
193-
var M1 = F(), M2 = F();
194-
return caml_exact_trampoline_cps_call
195-
(M1[1],
178+
return caml_trampoline_cps_call3
179+
(Stdlib_Printf[2],
180+
_e_,
196181
1,
197-
function(_p_){
198-
return caml_exact_trampoline_cps_call(M2[1], 2, cont);
182+
function(_f_){
183+
return caml_trampoline_cps_call3(Stdlib_Printf[2], _e_, 2, cont);
199184
});
200185
}
201186
//end

compiler/tests-compiler/double-translation/direct_calls.ml

+54-85
Original file line numberDiff line numberDiff line change
@@ -121,103 +121,72 @@ let%expect_test "direct calls with --effects=double-translation" =
121121
: runtime.caml_call_gen(f, [a0, a1]))
122122
: runtime.caml_trampoline_return(f, [a0, a1, a2], 0);
123123
}
124-
function caml_exact_trampoline_cps_call$0(f, a0, a1, a2){
125-
return runtime.caml_stack_check_depth()
126-
? f.cps ? f.cps.call(null, a0, a1, a2) : a2(f(a0, a1))
127-
: runtime.caml_trampoline_return(f, [a0, a1, a2], 0);
128-
}
129124
var
130-
dummy = 0,
131125
global_data = runtime.caml_get_global_data(),
132-
_z_ = [0, [4, 0, 0, 0, 0], caml_string_of_jsbytes("%d")],
133-
cst_a$0 = caml_string_of_jsbytes("a"),
126+
_k_ = [0, [4, 0, 0, 0, 0], caml_string_of_jsbytes("%d")],
134127
cst_a = caml_string_of_jsbytes("a"),
128+
x = caml_string_of_jsbytes("a"),
135129
Stdlib = global_data.Stdlib,
136130
Stdlib_Printf = global_data.Stdlib__Printf;
137131
function test1(param){
138-
function f(g, x){
139-
try{caml_call1(g, dummy); return;}
140-
catch(e$0){
141-
var e = caml_wrap_exception(e$0);
142-
throw caml_maybe_attach_backtrace(e, 0);
143-
}
132+
try{}
133+
catch(e$0){
134+
var e = caml_wrap_exception(e$0);
135+
throw caml_maybe_attach_backtrace(e, 0);
136+
}
137+
try{}
138+
catch(e){
139+
var e$0 = caml_wrap_exception(e);
140+
throw caml_maybe_attach_backtrace(e$0, 0);
144141
}
145-
f(function(x){});
146-
f(function(x){});
147142
return 0;
148143
}
149-
function f$0(){
150-
function f$0(g, x){
151-
try{caml_call1(g, x); return;}
152-
catch(e$0){
153-
var e = caml_wrap_exception(e$0);
154-
throw caml_maybe_attach_backtrace(e, 0);
155-
}
144+
function test2$0(param){
145+
try{}
146+
catch(e$0){
147+
var e = caml_wrap_exception(e$0);
148+
throw caml_maybe_attach_backtrace(e, 0);
156149
}
157-
function f$1(g, x, cont){
158-
runtime.caml_push_trap
159-
(function(e$0){
160-
var raise = caml_pop_trap(), e = caml_maybe_attach_backtrace(e$0, 0);
161-
return raise(e);
162-
});
163-
return caml_exact_trampoline_cps_call
164-
(g, x, function(_K_){caml_pop_trap(); return cont();});
150+
try{caml_call2(Stdlib[28], x, cst_a);}
151+
catch(e){
152+
var e$0 = caml_wrap_exception(e);
153+
throw caml_maybe_attach_backtrace(e$0, 0);
165154
}
166-
var f = caml_cps_closure(f$0, f$1);
167-
return f;
168-
}
169-
function _h_(){return function(x){};}
170-
function _j_(){
171-
return caml_cps_closure
172-
(function(x){return caml_call2(Stdlib[28], x, cst_a$0);},
173-
function(x, cont){
174-
return caml_trampoline_cps_call3(Stdlib[28], x, cst_a$0, cont);
175-
});
176-
}
177-
function test2$0(param){
178-
var f = f$0();
179-
f(_h_(), 7);
180-
f(_j_(), cst_a);
181155
return 0;
182156
}
183157
function test2$1(param, cont){
184-
var f = f$0();
185-
return caml_exact_trampoline_cps_call$0
186-
(f,
187-
_h_(),
188-
7,
189-
function(_I_){
190-
return caml_exact_trampoline_cps_call$0
191-
(f, _j_(), cst_a, function(_J_){return cont(0);});
192-
});
193-
}
194-
var test2 = caml_cps_closure(test2$0, test2$1);
195-
function test3(x){
196-
function F(symbol){function f(x){return x + 1 | 0;} return [0, f];}
197-
var M1 = F(), M2 = F(), _H_ = caml_call1(M2[1], 2);
198-
return [0, caml_call1(M1[1], 1), _H_];
199-
}
200-
function f(){
201-
function f$0(x){return caml_call2(Stdlib_Printf[2], _z_, x);}
202-
function f$1(x, cont){
203-
return caml_trampoline_cps_call3(Stdlib_Printf[2], _z_, x, cont);
158+
try{}
159+
catch(e$1){
160+
var
161+
e$0 = caml_wrap_exception(e$1),
162+
raise = caml_pop_trap(),
163+
e = caml_maybe_attach_backtrace(e$0, 0);
164+
return raise(e);
204165
}
205-
var f = caml_cps_closure(f$0, f$1);
206-
return f;
166+
runtime.caml_push_trap
167+
(function(e$0){
168+
var raise = caml_pop_trap(), e = caml_maybe_attach_backtrace(e$0, 0);
169+
return raise(e);
170+
});
171+
return caml_trampoline_cps_call3
172+
(Stdlib[28],
173+
x,
174+
cst_a,
175+
function(_s_){caml_pop_trap(); return cont(0);});
207176
}
208-
function F(){function F(symbol){var f$0 = f(); return [0, f$0];} return F;}
177+
var test2 = caml_cps_closure(test2$0, test2$1);
178+
function test3(x){return [0, 2, 3];}
209179
function test4$0(x){
210-
var F$0 = F(), M1 = F$0(), M2 = F$0();
211-
caml_call1(M1[1], 1);
212-
return caml_call1(M2[1], 2);
180+
caml_call2(Stdlib_Printf[2], _k_, 1);
181+
return caml_call2(Stdlib_Printf[2], _k_, 2);
213182
}
214183
function test4$1(x, cont){
215-
var F$0 = F(), M1 = F$0(), M2 = F$0();
216-
return caml_exact_trampoline_cps_call
217-
(M1[1],
184+
return caml_trampoline_cps_call3
185+
(Stdlib_Printf[2],
186+
_k_,
218187
1,
219-
function(_G_){
220-
return caml_exact_trampoline_cps_call(M2[1], 2, cont);
188+
function(_r_){
189+
return caml_trampoline_cps_call3(Stdlib_Printf[2], _k_, 2, cont);
221190
});
222191
}
223192
var test4 = caml_cps_closure(test4$0, test4$1);
@@ -233,18 +202,18 @@ let%expect_test "direct calls with --effects=double-translation" =
233202
tuple = recfuncs(x),
234203
f = tuple[2],
235204
h = tuple[1],
236-
_E_ = h(100),
237-
_F_ = f(12) + _E_ | 0;
238-
return caml_call1(Stdlib[44], _F_);
205+
_p_ = h(100),
206+
_q_ = f(12) + _p_ | 0;
207+
return caml_call1(Stdlib[44], _q_);
239208
}
240209
function g$1(x, cont){
241210
var
242211
tuple = recfuncs(x),
243212
f = tuple[2],
244213
h = tuple[1],
245-
_C_ = h(100),
246-
_D_ = f(12) + _C_ | 0;
247-
return caml_trampoline_cps_call2(Stdlib[44], _D_, cont);
214+
_n_ = h(100),
215+
_o_ = f(12) + _n_ | 0;
216+
return caml_trampoline_cps_call2(Stdlib[44], _o_, cont);
248217
}
249218
var g = caml_cps_closure(g$0, g$1);
250219
return g;
@@ -255,9 +224,9 @@ let%expect_test "direct calls with --effects=double-translation" =
255224
return caml_exact_trampoline_cps_call
256225
(g$0,
257226
42,
258-
function(_A_){
227+
function(_l_){
259228
return caml_exact_trampoline_cps_call
260-
(g$0, - 5, function(_B_){return cont(0);});
229+
(g$0, - 5, function(_m_){return cont(0);});
261230
});
262231
}
263232
var

0 commit comments

Comments
 (0)