Repository navigation
ir: give core-qualified heads the builtin ops - #1060
Conversation
bdd6bb1 to
3209553
Compare
8c039c2 to
7104cc9
Compare
nooga
left a comment
There was a problem hiding this comment.
Reviewed 3209553 against #1058. Qualified builtin detection retains the core Var identity check while accepting explicit core names and aliases, so syntax-quoted macro heads receive the same IR builtin operations as unqualified heads. A qualified non-core Var, including an alias named core, remains a call.
Local verification at this exact head: the complete VM, compiler, bytecode and IR package suites pass, including the qualified/aliased gate and dotimes lowering tests. make check-generated passes through full regeneration, committed-artifact comparison, and Go-lowered compilation/native dispatch. The array recur generated-Go probe also matches bytecode. No actionable finding; approving the delta. GitHub currently shows only skipped performance workflows on this head, so normal correctness CI should run before merging the stack.
7104cc9 to
0e1901f
Compare
3209553 to
f816b64
Compare
nnunley
left a comment
There was a problem hiding this comment.
Approving. intrinsic-builtin-op now resolves a qualified head and compares it to the clojure.core var, so core/< from syntax-quote gets the builtin op and other/inc does not. I checked the alias-to-user-ns case (core aliased to a user ns stays a call) and the unqualified path is unchanged. Merge after #1058, which this stacks on.
0e1901f to
5cb373a
Compare
f816b64 to
9290428
Compare
5cb373a to
d467e98
Compare
intrinsic-builtin-op refused every namespaced head, so clojure.core/< and clojure.core/inc from syntax-quote built as var calls. Under lg compile that left dotimes counters and any macro-emitted arithmetic as vm.Value with a cached-var trampoline per op (#1045). The bytecode side of the gate was fixed in the parent commit; this is the IR side. A qualified head cannot be shadowed by a local, so it skips the shadowing check and keeps the identity check: it must resolve to the clojure.core var of that name. Aliases pass, and a qualified head naming another namespace's var of the same name stays a call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Syntax-quote emits core/< (clojure.core is an alias of the core ns), so the tests now cover that spelling as well as clojure.core/<, an alias named core that points at a user ns, and a dotimes counter that must actually lower to an int64 rather than merely avoid the var trampoline. A core/ head that does not resolve now falls back to the core var, as fastOpcodeCoreName does, so the two engines agree when the current ns has an alias named core. Unqualified heads skip building a new symbol. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9290428 to
ddfb342
Compare
|
@nooga Thanks for the review! Merging. |
Fixes the lowered-Go half of #1045. Stacked on #1058 (base
wt/aget-opcode), which fixed the bytecode half. It does not depend on #1058's code; it is stacked so the two halves of the issue review together.intrinsic-builtin-opinbuild.lgrequired(nil? (namespace head)), so thecore/<andcore/incthat syntax-quote emits built as ordinary var calls, as did any explicitclojure.core/<. Underlg compilethat turned the issue'squalloop and everydotimescounter intovm.Valuelocals with a cached-var trampoline per op.The gate now accepts a qualified head on the same terms #1058 gave the bytecode gate. A qualified symbol cannot be shadowed by a local, so it skips that check and keeps the identity check:
resolveof the head must be theclojure.corevar of that name. That admits aliases and refuses a qualified head that names another namespace'sinc, including through an alias namedcore. Acore/head that does not resolve falls back to the core var, the same fallbackfastOpcodeCoreNamehas, so the two engines agree. The unqualified path is unchanged; it already did the identity check.*ir-compile*builds bytecode from the same IR, so on that path qualified heads now getOP_ADDand the other fast opcodes too, as the plain compiler does after #1058.Verified
qualnow lowers likeplain:j int64,acc int64,j < arg0, noCachedVarFn. New tests inlisp_lower_go_qualified_gate_test.gocover the repro spelledcore/andclojure.core/, an aliased head, adotimescounter lowering toint64throughlower-ns-to-go(which macroexpands, aslg compiledoes), and a qualified non-coreincstaying a call, directly and through an alias namedcore. The four positive tests fail with the old gate restored.pkg/vm,pkg/ir,pkg/compiler,pkg/genmanifestandpkg/rt/...pass;make generateandcheck-generatedare clean; linux, js/wasm, plan9 and wasip1 build.Not timed: the lowered loop has the same native locals and operators as
plain, so the issue'splainnumbers are the expectation.🤖 Generated with Claude Code