File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,11 @@ int VmState::jump(Ref<Continuation> cont) {
247
247
248
248
// general jump to continuation cont
249
249
int VmState::jump (Ref<Continuation> cont, int pass_args) {
250
+ cont = adjust_jump_cont (std::move (cont), pass_args);
251
+ return jump_to (std::move (cont));
252
+ }
253
+
254
+ Ref<Continuation> VmState::adjust_jump_cont (Ref<Continuation> cont, int pass_args) {
250
255
const ControlData* cont_data = cont->get_cdata ();
251
256
if (cont_data) {
252
257
// first do the checks
@@ -287,7 +292,7 @@ int VmState::jump(Ref<Continuation> cont, int pass_args) {
287
292
consume_stack_gas (copy);
288
293
}
289
294
}
290
- return jump_to ( std::move ( cont)) ;
295
+ return cont;
291
296
} else {
292
297
// have no continuation data, situation is somewhat simpler
293
298
if (pass_args >= 0 ) {
@@ -299,7 +304,7 @@ int VmState::jump(Ref<Continuation> cont, int pass_args) {
299
304
consume_stack_gas (pass_args);
300
305
}
301
306
}
302
- return jump_to ( std::move ( cont)) ;
307
+ return cont;
303
308
}
304
309
}
305
310
Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ class VmState final : public VmStateInterface {
347
347
int call (Ref<Continuation> cont, int pass_args, int ret_args = -1 );
348
348
int jump (Ref<Continuation> cont);
349
349
int jump (Ref<Continuation> cont, int pass_args);
350
+ Ref<Continuation> adjust_jump_cont (Ref<Continuation> cont, int pass_args);
350
351
int ret ();
351
352
int ret (int ret_args);
352
353
int ret_alt ();
@@ -374,6 +375,14 @@ class VmState final : public VmStateInterface {
374
375
if (cnt > free_nested_cont_jump && global_version >= 9 ) {
375
376
consume_gas (1 );
376
377
}
378
+
379
+ if (cont.not_null ()) {
380
+ const ControlData* cont_data = cont->get_cdata ();
381
+ if (cont_data && (cont_data->stack .not_null () || cont_data->nargs >= 0 )) {
382
+ // if cont has non-empty stack or expects fixed number of arguments, jump is not simple
383
+ cont = adjust_jump_cont (std::move (cont), -1 );
384
+ }
385
+ }
377
386
}
378
387
return res;
379
388
}
You can’t perform that action at this time.
0 commit comments