File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 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) {
247247
248248// general jump to continuation cont
249249int 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) {
250255 const ControlData* cont_data = cont->get_cdata ();
251256 if (cont_data) {
252257 // first do the checks
@@ -287,7 +292,7 @@ int VmState::jump(Ref<Continuation> cont, int pass_args) {
287292 consume_stack_gas (copy);
288293 }
289294 }
290- return jump_to ( std::move ( cont)) ;
295+ return cont;
291296 } else {
292297 // have no continuation data, situation is somewhat simpler
293298 if (pass_args >= 0 ) {
@@ -299,7 +304,7 @@ int VmState::jump(Ref<Continuation> cont, int pass_args) {
299304 consume_stack_gas (pass_args);
300305 }
301306 }
302- return jump_to ( std::move ( cont)) ;
307+ return cont;
303308 }
304309}
305310
Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ class VmState final : public VmStateInterface {
347347 int call (Ref<Continuation> cont, int pass_args, int ret_args = -1 );
348348 int jump (Ref<Continuation> cont);
349349 int jump (Ref<Continuation> cont, int pass_args);
350+ Ref<Continuation> adjust_jump_cont (Ref<Continuation> cont, int pass_args);
350351 int ret ();
351352 int ret (int ret_args);
352353 int ret_alt ();
@@ -374,6 +375,14 @@ class VmState final : public VmStateInterface {
374375 if (cnt > free_nested_cont_jump && global_version >= 9 ) {
375376 consume_gas (1 );
376377 }
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+ }
377386 }
378387 return res;
379388 }
You can’t perform that action at this time.
0 commit comments