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

return Result<T, E> from IO functions #407

Merged
merged 17 commits into from
Aug 6, 2024
Merged

return Result<T, E> from IO functions #407

merged 17 commits into from
Aug 6, 2024

Conversation

enricozb
Copy link
Contributor

@enricozb enricozb commented Aug 1, 2024

No description provided.

enricozb added 6 commits July 24, 2024 16:41
because of the original form of this if-statement, threads that were in
WORK mode and that had a high-priority redex but no low priority redexes
would not do any work. this led to a bug where `save_redexes` was called
while high-priority redexes were still present.
returns Result<T,E> for appropriate io functions, matches up with C
implementation
@enricozb enricozb requested a review from developedby August 1, 2024 14:09
Copy link
Member

@developedby developedby left a comment

Choose a reason for hiding this comment

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

Remember to also update hvm.h

src/hvm.c Show resolved Hide resolved
src/run.c Show resolved Hide resolved
src/run.c Outdated Show resolved Hide resolved
src/run.c Outdated Show resolved Hide resolved
src/run.c Outdated Show resolved Hide resolved
Since some IO errors are shared across IO functions (invalid argument
type, unexpected IO function name), we add a custom IOError ADT. Now,
every IO function (even those that cannot fail) will return a
Result<T, IOError<E>>. When attempting to invoke an IO function with an
invalid name, an IOError/Name is returned.
Add io programs that test basic functionality, including failures.
This also updates the "smoke test" file, that does a sequence of
open, read, write, close io calls on a file.
basic.bend couldn't be run in CUDA as the main definition was too large
otherwise the rust impl will run on these
they were stale, and didn't represent the shortest bend code that can
invoke io functions
@enricozb enricozb requested a review from developedby August 5, 2024 10:48
Copy link
Member

@developedby developedby left a comment

Choose a reason for hiding this comment

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

Remember to update the lib headers hvm.h and hvm.cuh

examples/demo_io/main.bend Outdated Show resolved Hide resolved
the README is more likely to change and break tests than the LICENSE
file.
the Str struct was stale in the header files
@enricozb enricozb requested a review from developedby August 5, 2024 17:33
@enricozb enricozb marked this pull request as ready for review August 5, 2024 17:34
Copy link
Member

@developedby developedby left a comment

Choose a reason for hiding this comment

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

looks alright

@enricozb
Copy link
Contributor Author

enricozb commented Aug 6, 2024

Going to hold off on merging as there is some issue with the C runtime hanging on this code (on an M1 mac only, not on my intel machine)

def unwrap(res):
  match res:
    case Result/Ok:
      return res.val
    case Result/Err:
      return res.val

(Main) =
  with IO {
    ask res = (call "foo" (1, 2))

    (unwrap res)
  }

amazingly this bug hadn't been caught before. we were not checking the
number of arguments in `ctr` before accessing them, therefore accessing
meaningless memory regions, which could lead to infinite loops as
nothing would be reduced and the same "interaction" would be attempted
endlessly.
@enricozb enricozb merged commit a5e6788 into main Aug 6, 2024
3 of 4 checks passed
@developedby developedby mentioned this pull request Aug 20, 2024
2 tasks
@enricozb enricozb mentioned this pull request Aug 20, 2024
6 tasks
@kings177 kings177 added this to the HVM IO lib v0 milestone Aug 20, 2024
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