-
Notifications
You must be signed in to change notification settings - Fork 55
Implement proper exception handling #44
Comments
Preliminary progress on 1:
|
As a result of implementing #44, almost all RTS APIs have different type signatures from the original versions:
Before next merge to |
For a more uniform styled RTS API, we should avoid passing
I'll try the last approach first |
…ge & prep for #44 (+8 squashed commit)
Simplified runtime & RTS API is merged to
|
Handling stack overflow requires dealing with chunked stacks and underflow frames, adding extra difficulty for this issue. We'll just allocate a large stack upon |
Finally! We no longer need to allocate a huge heap upon startup; both the nursery and the object pool can grow on demand, and the scheduler gracefully handles |
It's been a long time. We have gc and exceptions now. |
Status quo of exceptions: When a Haskell exception is thrown, the scheduler returns with an error code, which is later checked by
rts_checkSchedStatus
and re-thrown as a JavaScript exception. We don't really know what is thrown; and whenrts_checkSchedStatus
finds out the Haskell thread hasn't exited gracefully, there's no chance to get back to the crime scene and fix stuff. Besides Haskell exceptions, there are also errors signaled in the runtime itself, and the same problems apply as well.We definitely need to improve the exception story. Types of exceptions I can come up at the moment:
throw
/throwIO
calls in Haskellforeign import javascript
code, or rts.js codebarf()
in rts cmm codeAll possible exceptions can be roughly grouped into three kinds:
The key to handle all three kinds of exceptions is improving the current one-shot scheduler. When an
StgRun
loop yields back toscheduleWaitThread
, we need some (potentially async) JavaScript logic to check and fix stuff, then re-enter the loop and get back to Haskell execution.A rough roadmap for this issue:
Improve
scheduleWaitThread
, so Haskell execution may be automatically resumed for simple cases like heap/stack check failures. The storage manager won't need to allocate a large fixed-size nursery/object pool; it can take advantage of the recently implemented fast block allocator and only request as many blocks as needed. Also, thecreateThread
wrapper functions perform extra bookkeeping, so when the thread is created from a static closure and a fatal error is signaled, it's possible to simply re-initiate a new instance and restart execution from there. This one will be delivered this week.Refactor the throw/catch primitives in
PrimOps.cmm
/Exception.cmm
to fit the new scheduler, enabling exceptions to be caught and handled in Haskell.Well, let's first see if 1 & 2 work as expected.
The text was updated successfully, but these errors were encountered: