Skip to content

Instrumentation into Block IR#355

Open
ChingLongTin wants to merge 266 commits intohkust-taco:hkmc2from
ChingLongTin:instrument
Open

Instrumentation into Block IR#355
ChingLongTin wants to merge 266 commits intohkust-taco:hkmc2from
ChingLongTin:instrument

Conversation

@ChingLongTin
Copy link

Call implementation will be after the algorithms for instrumenting functions are completed.

  1. allocating optionNme
    This changed some diff tests (OpenWildcard.mls, Imports.mls, ImportMLs.mls) that imported Option themselves.
    If I allocate optionNme after checking if stageCode is enabled, it fails to link to the file.
    Is there some way to avoid changing the diff tests, or is this fine?

  2. implementing I-Inst
    The current shape for Class C(n:s) includes the field names (n), but the field names are not available in Instantiation.
    The field names are used in sel. If the class is staged using I-Cls, then we can use the staged ClsLikeDefn to retrieve the symbol names, but when do we do when it isn't staged?

class A(a)
staged module B
  class C(a)
  fun f() = 
    new C(1) // ok, C is staged
    new A(1) // not ok, we don't know field names of A after instrumentation

@ChingLongTin ChingLongTin marked this pull request as ready for review December 23, 2025 06:36
@ChingLongTin ChingLongTin changed the title Instrumentation (without Call) Instrumentation into Block IR Dec 23, 2025
ChingLongTin and others added 5 commits December 23, 2025 20:40
@ChingLongTin ChingLongTin requested a review from LPTK January 23, 2026 17:06
ChingLongTin and others added 4 commits January 28, 2026 00:11
we check if a function is staged through defCtx, so we can substitute the symbol there
_instr function only returns the block IR, whereas _gen functions will include the shape propagation
val debugBlock = debugPrintCode.foldRight(Return(unit, true))(concat)
def debugCont(rest: Block) =
Begin(debugBlock, rest)
val newCtor = impl.transformBlock(companion.ctor)(using new HashMap())(_ => debugCont(End()))
Copy link
Member

Choose a reason for hiding this comment

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

So far, if we introduce things from #387, it will fail, since we do not consider the mutable features that #387 is using. We probably need to only handle classes inside modules and leave other things untouched.

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.

4 participants