mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
fix(vm): fix saving ret
on deep jump
This commit is contained in:
parent
e0605156de
commit
103f33f809
2 changed files with 16 additions and 2 deletions
|
@ -257,6 +257,11 @@ int VmState::jump(Ref<Continuation> cont) {
|
|||
|
||||
// general jump to continuation cont
|
||||
int VmState::jump(Ref<Continuation> cont, int pass_args) {
|
||||
cont = adjust_jump_cont(std::move(cont), pass_args);
|
||||
return jump_to(std::move(cont));
|
||||
}
|
||||
|
||||
Ref<Continuation> VmState::adjust_jump_cont(Ref<Continuation> cont, int pass_args) {
|
||||
const ControlData* cont_data = cont->get_cdata();
|
||||
if (cont_data) {
|
||||
// first do the checks
|
||||
|
@ -297,7 +302,7 @@ int VmState::jump(Ref<Continuation> cont, int pass_args) {
|
|||
consume_stack_gas(copy);
|
||||
}
|
||||
}
|
||||
return jump_to(std::move(cont));
|
||||
return cont;
|
||||
} else {
|
||||
// have no continuation data, situation is somewhat simpler
|
||||
if (pass_args >= 0) {
|
||||
|
@ -309,7 +314,7 @@ int VmState::jump(Ref<Continuation> cont, int pass_args) {
|
|||
consume_stack_gas(pass_args);
|
||||
}
|
||||
}
|
||||
return jump_to(std::move(cont));
|
||||
return cont;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -352,6 +352,7 @@ class VmState final : public VmStateInterface {
|
|||
int call(Ref<Continuation> cont, int pass_args, int ret_args = -1);
|
||||
int jump(Ref<Continuation> cont);
|
||||
int jump(Ref<Continuation> cont, int pass_args);
|
||||
Ref<Continuation> adjust_jump_cont(Ref<Continuation> cont, int pass_args);
|
||||
int ret();
|
||||
int ret(int ret_args);
|
||||
int ret_alt();
|
||||
|
@ -379,6 +380,14 @@ class VmState final : public VmStateInterface {
|
|||
if (cnt > free_nested_cont_jump && global_version >= 9) {
|
||||
consume_gas(1);
|
||||
}
|
||||
|
||||
if (cont.not_null()) {
|
||||
const ControlData* cont_data = cont->get_cdata();
|
||||
if (cont_data && (cont_data->stack.not_null() || cont_data->nargs >= 0)) {
|
||||
// if cont has non-empty stack or expects fixed number of arguments, jump is not simple
|
||||
cont = adjust_jump_cont(std::move(cont), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue