[fix] fix func_index_ update in VirtualMachine#7419
[fix] fix func_index_ update in VirtualMachine#7419yhj050806 wants to merge 1 commit intoapache:mainfrom
Conversation
| * This does not begin execution of the VM. | ||
| */ | ||
| void InvokeGlobal(const VMFunction& func, const std::vector<ObjectRef>& args); | ||
| void InvokeGlobal(const VMFunction& func, Index func_index, const std::vector<ObjectRef>& args); |
There was a problem hiding this comment.
Why do we need to pass the function index here?
There was a problem hiding this comment.
I see the code has been refactored, I think we should store the function index in the function itself so we don't have to pass extra state around and the VMFunctions are sufficient to construct local state.
There was a problem hiding this comment.
Because VirtualMachine::func_index_ is not updated in the function VirtualMachine::InvokeGlobal like VirtualMachine::pc_ does。
or VirtualMachine::func_index_ should be deleted, I'm not seeing any place that use VirtualMachine::func_index_ in current code。
If VirtualMachine::func_index_ will be used in future。 then VirtualMachine::func_index_ should be updated in VirtualMachine::InvokeGlobal. otherwise, the logic is not right.
There was a problem hiding this comment.
in VirtualMachine::InvokeGlobal , function PushFrame is pushing a frame which include curernt's code_ ,pc_, func_idx_ into VirtualMachine::frames_. current's code_, pc_ is updated in VirtualMachine::InvokeGlobal. but current func_idx_ isn't updated in the entire code . I think func_idx_ should be updated in VirtualMachine::InvokeGlobal the same way as pc_ and code_. So I pass the func_idx to the function VirtualMachine::InvokeGlobal
I think there's problem dealing with func_index_ in VirtualMachine class.
func_index_ should be updated the same way as pc_ and code_ in the function VirtualMachine::InvokeGlobal.
cc @zhiics @jroesch please help to review the PR, thx