Avoid CPS effect type instantiation#2814
Conversation
CPS only needs the callee effect when deciding whether a call needs continuation or mutation handling. The previous check used typeOf on the callee, which can instantiate the full function type even though the effect is already present in the schema for the common cases. Read the effect through schemaOf instead. Ordinary variables and attribute selections keep the same effect result without forcing the extra type instantiation, while expressions whose schema must still be derived keep using the existing schema path.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8461bf2f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _ -> genExp env t e | ||
| else genExp env t e | ||
| else if B.isUnboxable t | ||
| then gen env e |
There was a problem hiding this comment.
Preserve argument coercions for unboxed initializers
For unboxable local declarations this now bypasses genExp, but genExp does more than the final result cast: it runs qType, whose Call case applies qMatch to coerce each argument to the callee's parameter types. When an initializer such as x: int = f(v) calls a function whose argument needs one of those non-unboxable casts (for example an optional or superclass parameter), the generated call now uses raw gen env e and omits the required argument coercion, while the old path still avoided any final cast because adjust is a no-op for unboxable result types. This can produce invalid or mis-typed C for typed local initializers even though the target itself is unboxable.
Useful? React with 👍 / 👎.
d8461bf to
09dbe07
Compare
Summary
schemaOfinstead of forcing the full callee type withtypeOf.QuickTypeskip after review. That path can lose argument coercions becausegenExp/qTypealso rewrites call arguments withqMatch.Performance
Measured on the 61 MB
concurrent_typecheck_class_heavyfixture withoutcleared before each run:The earlier combined numbers included the dropped QuickType commit and no longer apply. This is the current one-commit branch result compared with the previous baseline run from the compiler-bench head now merged to
main.This run does not show a wall-time improvement for the remaining CPS-only change. Back allocation is slightly lower, but back wall time is worse in this sample.
Check