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

Detect the overflow of relocation counter #4

Open
francis0407 opened this issue Sep 29, 2020 · 0 comments
Open

Detect the overflow of relocation counter #4

francis0407 opened this issue Sep 29, 2020 · 0 comments

Comments

@francis0407
Copy link
Member

Currently, we detect the overflow by checking if the latest counter is less than before:

        let (c00, c01, c10, c11) = (
            c00_u8.cast::<u16>(),
            c01_u8.cast::<u16>(),
            c10_u8.cast::<u16>(),
            c11_u8.cast::<u16>(),
        );
        (c10 < c00)
            || (c11 < c01)
            || (c10 >= c00.overflow_add(2)
                && c11 >= c01.overflow_add(2)
                && c11 >= c00.overflow_add(3))

But if the relocation happens more than once, this method does not work.

One solution is to leverage the highest bit of the counter as a overflow flag. We can check and reset the flag in this method.

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

No branches or pull requests

1 participant