Exception and RPC implementation #181

Merged
sb10q merged 7 commits from exception-rpc into master 2022-02-13 10:40:13 +08:00

7 Commits

Author SHA1 Message Date
pca006132 b18626b149 Fix compilation and test failures 2022-02-12 22:50:32 +08:00
pca006132 750d912eb4 nac3core: do list bound check and negative index handling
Raise error when index out of range. Note that we use llvm.expect to
tell the optimizer that we expect not to raise an exception, so the
normal path performance would be better. If this assumption is violated,
the exception overhead might be slightly larger, but the percentage
increase in overhead should not be high since exception unwinding is
already pretty slow.
2022-02-12 22:50:32 +08:00
pca006132 bf52e294ee nac3artiq: RPC support 2022-02-12 22:50:32 +08:00
pca006132 e303248261 nac3core: exception type check and codegen 2022-02-12 22:50:32 +08:00
pca006132 7ea5a5f84d nac3core: codegen refactoring
- No longer check if the statement will return. Instead, we check if
  the current basic block is terminated, which is simpler and handles
  exception/break/continue better.
- Use invoke statement when unwind is needed.
- Moved codegen for a block of statements into a separate function.
2022-02-12 22:13:59 +08:00
pca006132 b267a656a8 nac3core: added exception type and fixed primitive representation
- Added `Exception` primitive type and some builtin exception types.
  Note that all exception types share the same layout, and should
  inherit from the base `Exception` type. There are some hacks in the
  toplevel module for handling exception types, we should revisit and
  fix them later.
- Added new primitive types to concrete type module, otherwise there
  would be some weird type errors.
- Changed the representation of strings to CSlice<u8>, instead of
  CString.
2022-02-12 22:13:59 +08:00
pca006132 050c862c1a nac3core: function codegen callback changes
Added code generator argument to the callback, so it would be easier to
write complicated codegen with that callback. To prepare for RPC
codegen.
2022-02-12 21:24:41 +08:00