Skip to content

Changes that hopefully fix #1552.#1557

Merged
yav merged 1 commit intomasterfrom
1552
Oct 26, 2023
Merged

Changes that hopefully fix #1552.#1557
yav merged 1 commit intomasterfrom
1552

Conversation

@yav
Copy link
Member

@yav yav commented Jul 26, 2023

  • Make the code more thread safe
  • Do a bounds check in the GC closure

Not sure if the 2nd is needed, or if we have an assumption that lookupSeqMap will only be called with in bounds values---this is something we should investigate and document.

* Make the code more thread safe
* Do a bounds check in the GC closure

Not sure if the 2nd is needed, or if we have an assumption that `lookupSeqMap`
will only be called with in bounds values---this is something we should
investigate and document.
@yav yav temporarily deployed to github-pages July 26, 2023 00:23 — with GitHub Actions Inactive
-- this code should never run (unless we messed up something).
evalPanic i = case sz of
Nat sz' | i < 0 || i >= sz' -> invalidIndex sym i
_ -> panic "lookupSeqMap"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit pick: this function is no longer located in lookupSeqMap, so it would be worth changing the string used in the call to panic here.

Comment on lines +76 to +77
!(Integer -> SEval sym a)
-- Use this to overwrite the evaluation function when the cache is full
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure why we need to add this as an additional field to MemoSeqMap. Unless I'm missing something, the only place where we ever construct MemoSeqMap values is in the memoMap function, and memoMap only ever instantiates this field to evalPanic. Perhaps we should just turn evalPanic into a top-level function and refer to that instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to add it there, because evalPanic (which perhaps should be renamed) throws an exception if the index is out of bounds, and that needs access to the backend sym. Unfortunately, sym is not passed to lookupSeqMap, so instead of changing the API I just added the function to use when the cache is complete.

I imagine passing in the sym would not be a huge change though, so perhaps we should do that instead.

One other thing I am not sure, and we really should document, is what are the invariants on lookupSeqMap. In particular, I am not sure if it might be assuming that someone has already checked that the index is in bounds, so maybe we don't even need that exception... I added it because in the original ticket it looked like that map size is 2, and the index is 2, so that would make it out of bounds, which would suggest that we don't have such an invariant.

@yav yav merged commit 9934ba9 into master Oct 26, 2023
@yav yav deleted the 1552 branch October 26, 2023 23:32
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.

3 participants