Skip to content

Commit

Permalink
update to latest compiler code, ease monkey patch (#92)
Browse files Browse the repository at this point in the history
* separate local cache restoring logic from monkey patch on `abstract_call_method_with_const_args`

* add developer note
  • Loading branch information
aviatesk committed Jan 25, 2021
1 parent 84d24fd commit ecad7fc
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 454 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ No errors !

### TODOs

- remove `Core.eval(CC, ...)` monkey patches
- documentation, release
- more accurate error reports in general
- performance linting: report performance pitfalls
Expand All @@ -160,6 +161,22 @@ No errors !
* but then it's highly possible that we face performance problem on profiling on code using "big" packages, and so we will need some kind of incremental profiling (for fast watch mode)


### developer note

JET.jl overloads functions from Juila's `Core.Compiler` module, which are intended for its native JIT type inference.

They're overloaded on `JETInterpreter` so that `typeinf(::JETInterpreter, ::InferenceState)` will do abstract interpretation tuned for JET.jl's type error analysis.
Most overloads are done by using `invoke`, which allows us to call down to and reuse the original `NativeInterpreter`'s abstract interpretation methods while passing `JETInterpreter` for subsequent (maybe overloaded) callees (see `@invoke` macro).

But sometimes we can't just use `@invoke` and have to change/discard some logics that are hard-coded within original native function.
In such cases, currently JET.jl copy-and-pasted the original body of the overloaded function and applies monkey patches.
I'm planning to remove those monkey patches by adding some tweaks to Julia's compiler code itself, but for now, in order to keep the least maintainability, we do:
- use syntactic hacks (`#=== ... ===#`) to indicate the locations and purposes of each patch
- each overload is directly evaluated in the `Core.Compiler` module so that we don't need to maintain miscellaneous imports
- as such, the overloads are done within `__init__` hook; there are wrapper functions whose name starts with `overload_` for each overloading and the wrappers are registered to `push_inithook!`
- the docstrings of the wrappers tell the purposes of each overload


### acknowledgement

This project started as my grad thesis project at Kyoto University, supervised by Prof. Takashi Sakuragawa.
Expand Down
15 changes: 0 additions & 15 deletions patches/README.md

This file was deleted.

109 changes: 0 additions & 109 deletions patches/abstract_call_gf_by_type.diff

This file was deleted.

168 changes: 0 additions & 168 deletions patches/abstract_call_gf_by_type.jl

This file was deleted.

48 changes: 0 additions & 48 deletions patches/abstract_call_method_with_const_args.diff

This file was deleted.

Loading

0 comments on commit ecad7fc

Please sign in to comment.