Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete implementation for Verify #744

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

zhouwfang
Copy link
Member

#46

@zhouwfang zhouwfang requested a review from ia0 as a code owner February 16, 2025 07:13
@zhouwfang
Copy link
Member Author

zhouwfang commented Feb 17, 2025

@ia0 Could you also take a look at the follow-up PR in my fork? Thanks.

Copy link
Member

@ia0 ia0 left a comment

Choose a reason for hiding this comment

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

Thanks! I've pushed an unrelated simplification on top that occurred to me while reviewing.

@@ -132,13 +132,18 @@ impl<'m> BranchTableApi<'m> for &mut Vec<BranchTableEntry> {
}
}

struct MetadataView<'m> {
Copy link
Member

Choose a reason for hiding this comment

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

This is good to have side table views specific to verification in valid.rs because exec.rs will need different views (it won't need the mutable index used only for verification).

fn stitch_branch(
&mut self, source: SideTableBranch<'m>, target: SideTableBranch<'m>,
) -> CheckResult {
check(source == target)
}

fn patch_branch(&self, mut source: SideTableBranch<'m>) -> Result<SideTableBranch<'m>, Error> {
let entry = self.branch_table()[source.branch_table].view();
source.branch_table = self.branch_idx;
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit surprised by this. In theory, we should have source.branch_table + 1 == self.branch_idx, so this smells like an off-by-one error. Let's merge like this but keep it in mind. This might be a source of error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you explain why you believe so?

Before this function, next_index() and allocate_branch() are called.

For Prepare, next_index() returns the length of the branch table, and allocate_branch() pushes an invalid entry to the branch table, which patch_branch returns.

For Verify, to be consistent with Prepare, I thought we should also use the next branch in patch_branch().

Copy link
Member

Choose a reason for hiding this comment

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

For Verify, to be consistent with Prepare, I thought we should also use the next branch in patch_branch().

What does this mean?

patch_branch() should only do something in Verify (which is why it's the identity function in Prepare). In Verify it is supposed to convert the source branch to its target branch using the branch table. The branch index is given by the source branch. We shouldn't access branch_idx at all in this function. This field is only meaningful for next_index() and allocated_branch(), because it represents the current length of the branch table. In practice, patch_branch() is called right after the source branch is created, so it's the current last branch (thus its index is one less than the current length), but we shouldn't rely on this, in particular because it doesn't bring anything.

@ia0 ia0 merged commit 888c329 into google:dev/fast-interp Feb 17, 2025
20 checks passed
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