Instrumentation into Block IR#355
Conversation
link to functions in Shape.mls
Co-authored-by: Lionel Parreaux <lionel.parreaux@gmail.com>
Co-authored-by: Lionel Parreaux <lionel.parreaux@gmail.com>
|
Somehow there is a compilation error... |
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala
Outdated
Show resolved
Hide resolved
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala
Outdated
Show resolved
Hide resolved
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala
Outdated
Show resolved
Hide resolved
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala
Outdated
Show resolved
Hide resolved
| x = 1 | ||
| x | ||
| fun g(x)(y, z)() = z | ||
| //│ ╔══[WARNING] Multiple parameter lists are not supported in shape propagation yet. |
There was a problem hiding this comment.
Functions with multiple parameter lists can be desugared by the first-class function transformer (Enabled by :ftc. Probably after #404 is merged).
| sym match | ||
| case clsSym: ClassSymbol => | ||
| val name = scope.allocateOrGetName(sym) | ||
| transformParamsOpt(clsSym.defn.get.paramsOpt): paramsOpt => |
There was a problem hiding this comment.
Some class symbols (e.g., generated by another pass) may have no defn, which will lead to a crash.
There was a problem hiding this comment.
Since the parameters are necessary to reconstruct the class instance during specialization, this case throws a compiler error for now.
There was a problem hiding this comment.
I see. Then it is enough to raise a compilation error here. I will set a dummy definition with parameters in #404 so that our code can cooperate.
Is there any other information that you need to retrieve from the defn field?
There was a problem hiding this comment.
From our discussions last time, we need paramsOpt and auxParams.
There was a problem hiding this comment.
OK. It seems that dummy definitions do not help either. I think a proper way is to have another pass before starting instrumentation to collect these locally generated classes (represented in block IR). If there is no definition for the class symbol, you try to retrieve it from the collected data. These generated classes are not visible outside the module, so when we access a class via the path, it should always be possible to find the defined defn field.
There was a problem hiding this comment.
@ChingLongTin are you going to follow @NeilKleistGao's suggestion in this PR? Or in a follow-up one?
There was a problem hiding this comment.
I will do it in a follow-up one.
Co-authored-by: Fa1sePRoMiSe <neilkleist@gmail.com>
…into instrument
|
There's a diff test change on |
|
@ChingLongTin, indeed, there was some flakiness that should be fixed now. |
LPTK
left a comment
There was a problem hiding this comment.
Ok, LGTM, but please remember to address the two remaining comments in follow-up PRs.
Call implementation will be after the algorithms for instrumenting functions are completed.
allocating
optionNmeThis changed some diff tests (
OpenWildcard.mls,Imports.mls,ImportMLs.mls) that imported Option themselves.If I allocate
optionNmeafter checking ifstageCodeis enabled, it fails to link to the file.Is there some way to avoid changing the diff tests, or is this fine?
implementing I-Inst
The current shape for Class
C(n:s)includes the field names (n), but the field names are not available inInstantiation.The field names are used in
sel. If the class is staged using I-Cls, then we can use the stagedClsLikeDefnto retrieve the symbol names, but when do we do when it isn't staged?