Skip to content

[fix] fix func_index_ update in VirtualMachine#7419

Closed
yhj050806 wants to merge 1 commit intoapache:mainfrom
yhj050806:fix_func_index_update
Closed

[fix] fix func_index_ update in VirtualMachine#7419
yhj050806 wants to merge 1 commit intoapache:mainfrom
yhj050806:fix_func_index_update

Conversation

@yhj050806
Copy link
Copy Markdown
Contributor

@yhj050806 yhj050806 commented Feb 8, 2021

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

* 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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to pass the function index here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@yhj050806 yhj050806 Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@yhj050806 yhj050806 closed this Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants