Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
dc4957a
Draft dpf
NeilKleistGao Aug 25, 2026
207ab7a
WIP: Build web
NeilKleistGao Aug 27, 2026
fa30dd9
WIP: Fix dup web
NeilKleistGao Aug 28, 2026
cf9f267
WIP: Use pipeline
NeilKleistGao Aug 28, 2026
cb66e8b
Merge branch 'hkmc2' of github.com:hkust-taco/mlscript into web🦚
NeilKleistGao Aug 31, 2026
580483e
WIP: Fix merge errors
NeilKleistGao Aug 31, 2026
6b30c90
WIP: Retrieve shape information from flow analysis
NeilKleistGao Aug 31, 2026
f91c6b1
WIP: Fix web construction
NeilKleistGao Sep 1, 2026
356f9b2
WIP: Insert tags and minor fix
NeilKleistGao Sep 1, 2026
623db84
WIP: Remove union tag insertion
NeilKleistGao Sep 3, 2026
2e64870
WIP: Add annotations for match
NeilKleistGao Sep 3, 2026
5641244
WIP: Minor
NeilKleistGao Sep 4, 2026
2becb73
WIP: Clean
NeilKleistGao Sep 8, 2026
0593648
WIP: Add checks in flow analysis
NeilKleistGao Sep 8, 2026
65cc0dd
WIP: Match branches
NeilKleistGao Sep 11, 2026
9846bef
WIP: Add tests
NeilKleistGao Sep 11, 2026
c44134d
WIP: Fix flow analysis and consumer comp
NeilKleistGao Sep 11, 2026
eaf5508
WIP: Minor fix
NeilKleistGao Sep 14, 2026
52cdd98
WIP: Add tests
NeilKleistGao Sep 14, 2026
2b329ce
WIP: Add join point checks
NeilKleistGao Sep 15, 2026
1595976
WIP: Rename the pass
NeilKleistGao Sep 16, 2026
6d279ae
WIP: Check patterns not matched
NeilKleistGao Sep 16, 2026
b5ca410
WIP: Refactor
NeilKleistGao Sep 16, 2026
973f81f
WIP: Refactor
NeilKleistGao Sep 16, 2026
b9232cc
Misc changes
NeilKleistGao Sep 16, 2026
cf47940
Merge from hkmc2
NeilKleistGao Sep 16, 2026
4f0f237
Clean
NeilKleistGao Sep 16, 2026
80c80fe
Minor
NeilKleistGao Sep 16, 2026
89ffca5
Minor
NeilKleistGao Sep 16, 2026
389d27c
Minor
NeilKleistGao Sep 16, 2026
196b012
Merge branch 'hkmc2' into web🦚
NeilKleistGao Sep 21, 2026
05664b1
Merge from hkmc2
NeilKleistGao Sep 22, 2026
e52b7e7
Add cycle detection
NeilKleistGao Sep 22, 2026
eb94ba8
Add error for missing noFreeze config
NeilKleistGao Sep 22, 2026
ae58e70
Add checks for tuple elements
NeilKleistGao Sep 22, 2026
1f5ff87
Use SymbolRefresher
NeilKleistGao Sep 22, 2026
00b14ba
Add error messages
NeilKleistGao Sep 22, 2026
b63220d
Add warning messages
NeilKleistGao Sep 22, 2026
9d24fdb
Add short-circuit and comments
NeilKleistGao Sep 23, 2026
dce95c4
Merge from hkmc2
NeilKleistGao Sep 25, 2026
ac25c95
test: reproduce class tag optimization review findings
codex Sep 28, 2026
9133c14
WIP: Add errors for mutable features and add todo for tag field
NeilKleistGao Sep 28, 2026
6a79c98
WIP: Add check for tag check
NeilKleistGao Sep 29, 2026
cf21f47
WIP: Fix web computation & test cases
NeilKleistGao Sep 29, 2026
e30be24
WIP: Report for unannotated match
NeilKleistGao Sep 29, 2026
324f553
WIP: Reject named functions as arms
NeilKleistGao Sep 29, 2026
c537eee
WIP: Add a pass to reject unsupported definitions
NeilKleistGao Sep 29, 2026
314c787
WIP: Fix web computation across functions
NeilKleistGao Sep 29, 2026
2a05f35
WIP: Fix poly
NeilKleistGao Sep 30, 2026
6f7b018
Add threshold for flatten
NeilKleistGao Sep 30, 2026
3585f95
Do not insert tags for objects that are not matched by `shape.match`
NeilKleistGao Sep 30, 2026
93246cc
Relax some changes
NeilKleistGao Oct 1, 2026
c748224
Merge from hkmc2
NeilKleistGao Oct 1, 2026
e785fae
Merge branch 'hkmc2' into web🦚
LPTK Oct 4, 2026
2fbdb73
test: record remaining class-tag review issues
codex Oct 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions hkmc2/shared/src/main/scala/hkmc2/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ case class Config(
stageCode: Bool,
target: CompilationTarget,
rewriteWhileLoops: Bool,
classTags: Opt[ClassTags],
qqEnabled: Bool,
funcToCls: Bool,
commentGeneratedCode: Bool,
Expand Down Expand Up @@ -80,6 +81,7 @@ object Config:
target = CompilationTarget.JS,
rewriteWhileLoops = false,
stageCode = false,
classTags = N,
qqEnabled = false,
funcToCls = false,
commentGeneratedCode = false,
Expand Down Expand Up @@ -212,6 +214,13 @@ object Config:
def withDebug(debug: Bool) =
FlowBasedOpt(default.config.copy(debug = debug))

case class ClassTags(debug: Bool, mono: Bool)
object ClassTags:
val default = ClassTags(
debug = false,
mono = false,
)

/** `altSmallThreshold` is the alternative threshold for inlining things into @inline functions.
* Normally, we avoid inlining into @inline functions as that could lead to unexpected code bloat. */
case class Inliner(inlineThreshold: Int, altSmallThreshold: Int = 2)
Expand Down Expand Up @@ -595,6 +604,24 @@ object ConfigParser:
).map:
Config.FlowBasedOpt.apply

private def parseClassTags(tree: Tree, current: Opt[Config.ClassTags])(using Raise): Opt[Config.ClassTags] =
tree match
case Call("ClassTags", args) =>
val base = current.getOrElse(Config.ClassTags.default)
var debug = base.debug
var mono = base.mono
args.foreach:
case NamedArg("debug", value) =>
setFrom(value)(parseBool)(v => debug = v)
case NamedArg("mono", value) =>
setFrom(value)(parseBool)(v => mono = v)
case other =>
unsupported("ClassTags", other)
S(Config.ClassTags(debug, mono))
case _ =>
expect("ClassTags(...)")(tree)
N

/** Parse a single field override like `tailRecOpt: false`. */
private def parseField(name: Str, value: Tree)(using Raise): Config => Config = name match
case "language" => parseLanguageOverride(value)
Expand Down Expand Up @@ -626,6 +653,10 @@ object ConfigParser:
optionalFieldWithCurrent(value)(_.deforest)(
(tree, current) => parseDeforest(tree, current)
)(v => _.mapOptimizer(_.copy(deforest = v)))
case "classTags" =>
optionalFieldWithCurrent(value)(_.classTags)(
(tree, current) => parseClassTags(tree, current)
)(v => _.copy(classTags = v))
case "flowBasedOpt" =>
optionalFieldWithCurrent(value)(_.flowBasedOpt)(
(tree, current) => parseFlowBasedOpt(tree, current)
Expand Down
Loading
Loading