What the compiler suite is, how it is designed, how it got there, what is good and what is
not, and what could be done about the latter. Read in full: the seven Compiler-* packages
and Kernel-Dag, lang/base/parser.pegjs, the kernel's method model
(kernel-fundamentals.js, kernel-runtime.js), the Importer/Exporter path in
Platform-ImportExport.st, sdk/lib/amberc.js, Helios' use of the debugger, and the 615
commits that touched the compiler sources since 2011. Every number below was measured on
this machine (Node 24.18.0) with throwaway scripts; the appendix says how.
The text describes the tree of 21 October 2026, at 9ef24753. Its file and line
references point into that tree. A note that names 0.31.5 or 0.32.0 tells what that
release changed afterwards.
The earlier documents are not repeated: ANALYSIS-2026-08.md §6–7 for the sail interpreter
and the debugger's future substrate, ANALYSIS-2026-10-archaisms.md §2.2 and §4.2 for the
emitter's syntax level and pegjs → peggy. Where this document reaches the same conclusion it
says so and moves on.
.js is byte-identical
to what the compiler emits today, over all 22 packages.ASTDebugger >> stepInto has been shouldBeImplemented since 2013-02-16), needing
method source, re-parsing per method, 128× slower than compiled code on a loop.Cannot add self to a string instead of a ParseError; an interpreted block answers a
MessageNotUnderstood to numArgs; a non-local return from a block whose method already
returned passes every on:do: as a raw JS array and becomes an error only at the
top-level handler (§6.3). And one divergence that is a choice, not a defect: the
interpreter answers MessageNotUnderstood where inlined code answers
NonBooleanReceiver, because it sends ifTrue: as the plain code generator's code does
instead of inlining it (§3.2).
0.31.5 fixed the three defects.lang
image. amberc over the same image takes 10 s because the import path compiles every
method twice: re-defining an existing class recompiles all its methods (ClassBuilder >>
addSubclassOf:named:slots:package: ends in recompile, since 2017-02-19), and the
method chunks that follow compile them again (§5.2).
Since 0.31.5, a file-in compiles each method once.whileTrue: runs in 313 ms with debug contexts, 234 ms without, 126 ms with the loop
hand-inlined and the sends kept, 0.5 ms as a JS loop (§5.3). Conditionals are inlined;
loops are not.f8d3f39c); the grammar's, 2020-03-03.
The silence ended in October 2026, with 0.31.5 and 0.32.0. The grammar has not changed.grunt amberc); make external variables declared
rather than probed; inline the loop selectors; drop the faked parent pointers and let
their few readers ask the visitor; then the debugger, along the August plan or by
stepping into interpreted callees within the current design.
0.31.5 fixed the defects and the double compilation.
0.32.0 dropped the parent pointers.| package | .st lines |
compiled .js |
holds |
|---|---|---|---|
Kernel-Dag |
227 | 25 KB | DagNode, AbstractDagVisitor, PathDagVisitor; shared by AST and IR; loads with the deploy image |
Compiler-Core |
425 | 63 KB | Compiler (the façade), AbstractCodeGenerator → AstGenerator → CodeGenerator, Evaluator, DoIt, ParseError, TPragmator, Package >> eval: |
Compiler-AST |
786 | 91 KB | the node classes, NodeVisitor, AstPragmator (inlineJS:), CompilerError, CompiledMethod >> ast |
Compiler-Semantic |
792 | 100 KB | SemanticAnalyzer, LexicalScope / MethodLexicalScope, the ScopeVar kinds, the semantic errors, jsOverride: marking |
Compiler-IR |
1,459 | 213 KB | IRASTTranslator (AST → IR, aliasing), the IR node classes, IRVisitor, IRJSTranslator + JSStream (the emitter), IRLatePragmator |
Compiler-Inlining |
771 | 115 KB | ASTPreInliner, IRInliner + the four send inliners, the IRInlined* nodes, IRInliningJSTranslator, InliningCodeGenerator (the default) |
Compiler-Interpreter |
1,133 | 146 KB | ASTInterpreter, AIContext, AIBlockClosure, ASTDebugger, ASTPCNodeVisitor, AISemanticAnalyzer |
Compiler-Tests |
1,344 | 205 KB | 104 test methods, run in up to four execution contexts (§3.3) |
lang/base/parser.pegjs |
265 | 104 KB generated | the grammar; parser.js is generated by pegjs 0.10. Since 0.32.0, peggy 5.1 generates it, 84 KB. |
5,593 lines of Smalltalk without the tests, 6,937 with, plus the grammar; 1.06 MB of
generated JavaScript including the tests. The deploy image (deploy.js) carries only Kernel-Dag; lang.js adds the parser
and the six compiler packages, which is what Helios, amberc and the test runner load.
Loading them costs 70 ms of boot on this machine (deploy 214–238 ms, lang 283–301 ms,
three runs each): 115 more classes, 424 more selectors.
AbstractCodeGenerator >> compileNode: folds the AST through transformers: the values of
a dictionary sorted by key, each a value:-able object (Compiler-Core.st:41-57). The keys
are strings chosen to sort, BASIC-style:
source ─parse─▶ MethodNode
2000-semantic SemanticAnalyzer scopes, bindings, class references, send indexes
2500-semanticPragmas AstSemanticPragmator <inlineJS:> → JSStatementNode; <jsOverride:> → super-send rewiring
3000-inlinerTagging ASTPreInliner marks sends that will be inlined (shouldBeAliased) [InliningCodeGenerator only]
5000-astToIr IRASTTranslator IRMethod tree; aliasing for evaluation order
6000-inliner IRInliner ifTrue:/ifNil:/and:… sends and their blocks → IRInlined* nodes [InliningCodeGenerator only]
7000-irLatePragmas IRLatePragmator <jsOverride:> → method attachments
8000-irToJs IRInliningJSTranslator JS source via JSStream
─▶ IRMethod (compiledSource, attachments, messageSends, classReferences, pragmas)
Compiler >> compile:forClass:protocol: wraps as (function ($methodClass){ return <fn>; }),
evals it in the package's context, and builds the CompiledMethod with that factory as instantiateFn
AstGenerator stops after 2500 and is what CompiledMethod >> ast and Helios' navigation
use; CodeGenerator emits without inlining and exists for the tests; InliningCodeGenerator
is the default (Compiler >> codeGeneratorClass). Compiler >> transformerAt:put: lets a
stage be added or replaced; nothing outside Compiler-Tests uses it, nor
codeGeneratorClass: (checked across Helios and the contrib siblings).
Compiler >> compile:forClass:protocol: / install:forClass:protocol: — Helios saving a
method (through Environment >> compileMethod:for:protocol:), the Importer's
ClassProtocolReader >> compileMethod:, TBehaviorProvider >> recompile.Compiler >> evaluateExpression: / evaluateExpression:on: — every top-level chunk of a
file-in (Importer >> import:, Platform-ImportExport.st:722), workspace DoIts, class
definitions. The expression is wrapped as a method xxxDoIt ^ [ … ] value, installed on
the receiver's class, run, and removed.Smalltalk parse: / Compiler >> ast:forClass:protocol: — Helios' workspace navigation
(navigationNodeAt:ifAbsent:), the PC recovery of the debugger.AIContext class >> fromMethodContext: + ASTDebugger — Helios' debugger
(Helios-Debugger.st:321,380), which calls stepOver, proceed, restart and evaluates
expressions in a context through Evaluator >> evaluate:context:. Nothing else uses the
interpreter.sdk/lib/amberc.js — loads amber/lang plus the libraries, then for each .st runs
Importer new import: and AmdExporter new exportPackage:on:. grunt amberc:lang,
amberc:tests and the sibling projects' builds are this.A 265-line PEG grammar; the generated parser is 104 KB of ES5. The grammar is unusually
readable for a PEG: whitespace is consumed only by rules whose name starts with ws
(wsKeywordMessage, wsBinaryTail, wsStatements), a discipline introduced by the 2015
review that fixed issues #1207–#1210 (83daedf0), so that where a space is legal can be
read off the rule name. Sends are built as a receiver plus a tail of partial SendNodes
folded by ExpressionNode >> withTail: (Compiler-AST.st:110), and cascades as a
CascadeNode whose receiver the semantic analyser fills in later.
Since 0.32.0, peggy 5.1 generates the parser from the same grammar. Its output is 84 KB of
ES2015.
The parser builds the tree by calling into the image: newNode is
nodeClass._new()._location_(location())._source_(text()) (parser.pegjs:4-10), so a
parse needs Compiler-AST loaded and there is no standalone parser. Two consequences:
ASTNode >> location: receives a plain JS object and reads it through JSObjectProxy
message-not-understood dispatch, 1.5 % of compile time for nothing; and pegjs'
SyntaxError reaches Smalltalk as a foreign exception that Compiler >> parse: recognises
by (err basicAt: 'location') notNil and rewrites (Compiler-Core.st:289), dropping the
expected list. Where the error is at end of input pegjs sets found to null, and
'…Unexpected character ', nil raises Cannot add self to a string: five of seven
malformed probes (foo ^ (, foo ^ 1 +, foo ^ 'abc, …) never produce a ParseError
(§6.3).
Since 0.31.5, the message names "end of input" in that case.
Compiler >> parseError:parsing: still drops expected.
What the grammar accepts is Amber's dialect: 16r is the only radix, 1e3 and -2.5e4
exponents, no scaled decimals, no #[…] byte arrays, $a is the one-character string
'a' (since 2014-04-18, 7215b8ef), #(…) may nest with bare parentheses and bare
symbols (#(on:do: Object), 2013-03), {…} and #{… -> …} with leading dots allowed,
pragmas only at method level (a pragma inside a block is a parse error since 2019-02),
thisContext an ordinary identifier bound later by ThisContextVar. Comments are
discarded in the tree.
SemanticAnalyzer pushes a MethodLexicalScope and a LexicalScope per block, declares
slots, arguments and temps, and binds every VariableNode to a ScopeVar, which carries
the variable's JavaScript spelling as alias:
| kind | where declared | alias |
assignable | idempotent |
|---|---|---|---|---|
TempVar |
method / block temps | the name, _-suffixed if a JS reserved word |
yes | no |
ArgVar |
method / block arguments | the name | no | yes |
SlotVar |
the class's slots, all the way up | $self.name |
yes | no |
PseudoVar |
self true false nil |
the name; $self / $nil as receiver |
no | yes |
SuperVar / JavaScriptSuperVar |
super |
$self; lookup through $methodClass |
no | yes |
ThisContextVar |
thisContext |
$core.getThisContext() |
no | yes |
ClassRefVar |
any capitalised unknown | $globals.Name |
no | no |
ExternallyKnownVar |
lower-case unknowns the host knows | the name | no | no |
AliasVar |
compiler-made $1 … $n |
the name | error | yes |
The rules it enforces: assignment only to temps and slots (InvalidAssignmentError), no
shadowing of any visible name including slots (ShadowingVariableError, stricter than
Pharo's warning), and the unknown-variable rule that is the oddest decision in the suite:
a lower-case name bound nowhere is accepted if it is one of
Smalltalk globalJsVariables (window document process global), is among the package's
imports:, or exists in the JavaScript environment the compiler happens to be running
in — isVariableKnown:inPackage: evals typeof(name) !== "undefined" || …
(Compiler-Semantic.st:607). The comment in bindUnscopedVariable: (:559) says it
plainly: the whitelist exists so that code compiles both in a browser and under Node, and
"the ideal solution would be to use a pragma instead". The consequence shows in amberc,
whose jsGlobals option (Gruntfile.js:53, ['navigator']) pre-declares names so that
browser packages compile under Node. The analyser also collects classReferences and the
per-selector send indexes the debugger needs (§2.6).
<inlineJS: '…'> is a pragma since 2016-10 (4cf9cff2; the old <…> verbatim syntax was
removed 2018-04). AstSemanticPragmator turns it into a lone JSStatementNode in the
method's sequence (Compiler-AST.st:670), refusing any other statement, and
IRASTTranslator emits it verbatim. The body is pasted as-is; the compiler imposes no
syntax level on it (archaisms §2.2). TPragmator dispatches a pragma to a method of the
same selector on the pragmator, so a new pragma is one method on the right pragmator;
unknown pragmas are kept on the method and otherwise ignored (test testUnknownPragma).
<jsOverride: #name> / <jsOverride: #name args: #(…)> (2019-09 to 2020-04) is the
JavaScript gateway: the method is also installed under a JS property name so that a JS
superclass's call reaches the Smalltalk override, and super sends inside it go to the JS
prototype under that name, with an argument-order switcher function when the Smalltalk
and JS parameter orders differ (JSSuperSendVisitor, Compiler-Semantic.st:40-69;
attachments at Compiler-IR.st:883-906; installed by installMethodOfJsObjectEx,
kernel-runtime.js:24). It has no user outside its tests: no <jsOverride: and no
beJavaScriptSubclassOf: occurs in production code of lang or of any sibling.
The IR is fourteen classes and mirrors the JavaScript to come:
| IR node | emitted as |
|---|---|
IRMethod |
function (args){ var self=this,$self=this; var temps; [context] [aliases] [try] … } |
IRClosure |
(function(args){ var temps; [block context] … }) |
IRSequence / IRBlockSequence |
statements, ;-terminated unless an if was just closed |
IRReturn / IRBlockReturn / IRNonLocalReturn |
return … / return … / throw $early=[…]; since 0.31.5, throw $nlr=$core.nonLocalReturn($nlr,…) |
IRSend |
$recv(r)._sel_(args), or r._sel_(…) when asReceiver vouches for r |
IRAssignment, IRValue, IRVariable, IRVerbatim |
l=r, a literal via asJavaScriptSource, the alias, the inlineJS: text |
IRDynamicArray / IRDynamicDictionary |
[…] / $globals.HashedCollection._newFromPairs_([…]) |
IRTempDeclaration |
nothing by itself; collected into one var per function |
The one genuinely hard problem a Smalltalk-to-JS compiler has at this level is evaluation
order: JavaScript evaluates a call's receiver and arguments left to right, but an argument
that becomes an inlined if or an assignment turns into statements that must run before
the call, and everything to its left must then be hoisted into temporaries too.
IRASTTranslator >> aliasTemporally: (Compiler-IR.st:71) does exactly that: it walks a
send's children from the right, finds the last one that needs hoisting (shouldBeAliased,
hasOpeningStatements, or a subtree that does), and aliases it and everything before it
into $1 … $n (IRMethod >> newAliasingOf:). Issues #296, #297, #326, #1214 and the
tests testSendReceiverAndArgumentsOrdered, testInnerTemporalDependentElementsOrdered,
testCascadesInSend and friends are the record of getting this right; a block boundary
stops the hoisting (2013-02, 1dbac0d8). 282 of the 2,217 methods end up with aliases.
Cascades get their receiver aliased unless it is idempotent (visitCascadeNode:, :135), a
method without an explicit ^ gets ^ self appended at IR level (:197, 2020-03), and
an IRReturn inside a block becomes IRNonLocalReturn on the strength of
ReturnNode >> nonLocalReturn (scope is not the method's).
IRSendInliner class >> inlinedSelectors (Compiler-Inlining.st:532) is the whole list:
ifTrue: ifFalse: ifTrue:ifFalse: ifFalse:ifTrue: ifNil: ifNotNil: ifNil:ifNotNil:
ifNotNil:ifNil: and: or:. A send is inlined when every argument is a literal block of the
right arity and the receiver is not super (shouldInline:, :546; super sends stopped
being inlined 2019-10-09). Blocks are flattened into IRInlinedClosures whose temps join
the enclosing function and whose last statement becomes the value (inlineClosure:,
:419); and:/or: are rewritten as ifTrue:ifFalse: with a synthesised false/true
branch. The three wrapping inliners (IRAssignmentInliner, IRReturnInliner,
IRNonLocalReturnInliner) push an assignment or a return into each branch, which is what
lets a := x ifTrue: [1] and ^ x ifNil: [0] compile to a plain if with no temporary
and no closure. Booleans are checked at runtime by $core.assert, which signals
NonBooleanReceiver for anything but true/false; ifNil: tests
x == null || x.a$nil, hence the receiver must be idempotent and is aliased first
(inlinedSelectorsNeedingIdempotentReceiver).
Two refinements worth knowing. A non-local return inside an inlined block at method level
is flattened to a local return (IRInliner >> visitIRNonLocalReturn:, :225;
LexicalScope >> canFlattenNonLocalReturns), so x ifTrue: [ ^ 1 ] costs no try:
only 20 of 2,217 methods carry $early handling. And an inlined empty block answers
nil (#1242) — the kind of edge the four-context test matrix (§3.3) catches.
Measured on the lang image, inlining makes the emitted code 10 % smaller (1.20 MB plain,
1.09 MB inlined) and costs 15 % of pipeline time (§5.1). Its runtime value is larger than
the size suggests: every inlined conditional is a closure not allocated and two sends not
made.
IRJSTranslator writes to a JSStream whose methods are the emitter's vocabulary
(nextPutClosureWith:arguments:, nextPutIf:then:else:,
nextPutNonLocalReturnHandlingWith:, …; Compiler-IR.st:1172-1383). The shape of a method,
annotated:
function (aStream){ // nextPutFunctionWith:arguments:
var self=this,$self=this; // both spellings, since 2017-04
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
return $core.withContext(function($ctx1) { // the context, only if a send or inlineJS: is inside
//>>excludeEnd("ctx");
var $1; // aliases, one var statement
if($core.assert($recv($recv([$recv([$self._class() // inlined ifTrue:ifFalse:, $core.assert guards the boolean
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
,$ctx1.sendIdx["class"]=1 // "which `class` send was that": recorded for all but the last occurrence
//>>excludeEnd("ctx");
][0])._name() … ]._isVowel())){ $1="an "; } else { $1="a "; }
$recv(aStream)._nextPutAll_($1);
return self;
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
}, function($ctx1) {$ctx1.fill(self,"printOn:",{aStream:aStream})}); // the context is filled lazily, by this closure, only when something asks
//>>excludeEnd("ctx");
}
The decisions encoded here, each with its date:
7b9e4485): withContext creates a
SmalltalkMethodContext holding only the fill closure; receiver, selector and locals
are materialised when thisContext, an error or the debugger asks (hydrated,
Kernel-Methods.st:655). Methods without sends get no context at all (2014-01-03,
c5348e70): 504 of 2,217. Blocks the same (fillBlock, with the outer context and the
block's index).bd03978d): the //>>excludeStart("ctx") markers let r.js
drop all of it for deploy; 9,255 marker lines in lang/src, the "36 % context
scaffolding" of the August analysis.dc2ff669): the debugger recovers where a context is by
the selector being evaluated (fill writes evaluatedSelector into the caller) plus
how many sends of that selector have completed ($ctx1.sendIdx[sel]=n, emitted as
[expr, …=n][0] so that the expression's value is kept). The last occurrence needs no
record (2013-11, ab78f6e3): 304 methods carry any.5edf7448): throw $early=[value] caught by
catch(e){if(e===$early)return e[0]; throw e} in the home method. Identity on the array
makes it safe against nesting. A block that ^-returns after its home method has
returned throws the bare array too: on:do: lets it through, as it lets every
non-local return through (tryCatch:, #1158), and only the top-level ErrorHandler
turns it into a NonLifoReturn (asSmalltalkException:, 2020-10, 04c7fa75) (§6.3).
Since 0.31.5, $core.nonLocalReturn builds the box. It is an object, {a$nlr: value}.
The home method keeps a marker in $nlr. When the method exits, a finally sets the
marker to null. A block that returns after its home method has returned finds the null.
It signals BlockCannotReturn at the return, as Pharo does.b0ca4adb, #1241): ($methodClass.superclass||$boot.nilAsClass).fn.prototype._sel_.call($self, …),
with $methodClass supplied by the factory the method is wrapped in (§2.7). A method
therefore does not know its class until installed, which is what lets traits and
recompile move methods between classes. supercall = true/false brackets the call in
the context for the debugger.9de77366): $recv(x) (asReceiver,
kernel-language.js:295) turns null/undefined and foreign JS objects into message
receivers; self, $self, literals and $nil skip it (IRInstruction >> asReceiver,
PseudoVar >> asReceiver). 5,828 $recv( in lang/src.e3bca2e2): $globals.Foo, a property read, no lookup call.Compiler >> compile:forClass:protocol: (Compiler-Core.st:170) sanitises line endings,
runs the pipeline, wraps the emitted function as (function ($methodClass){ return …; })
(wrappedSourceOf:, :304; attachments for jsOverride: ride along as a$atx), evals
it in the package's context (Package >> eval:, so imports: names are in scope), and
builds the CompiledMethod with the factory as instantiateFn. The kernel calls the
factory when the method is installed (installAmberMethodIntoAmberClass,
kernel-runtime.js:222), which is also the shape the exporter writes
(Exporter >> exportMethod:on:, Platform-ImportExport.st:334): fn is no longer
serialised, the factory is. The August analysis counts this indirection as "80 % of the
hook a lazy execution scheme needs".
ASTInterpreter is a tree-walking evaluator with an explicit cursor and an explicit stack,
designed to be stepped: node is the next node to evaluate, enterNode descends to the
leftmost leaf (ASTEnterNode), step evaluates the current node and advances to the next
sibling or up to the parent (next), leaves push values and sends pop them. A BlockNode
is not entered; it becomes an AIBlockClosure (Compiler-Interpreter.st:2-90), polymorphic
with BlockClosure, whose valueWithPossibleArguments: creates an inner AIContext, runs a
nested interpreter over a copy of the block's sequence to completion, and propagates a
non-local return by flag (setNonLocalReturnFromContext:).
Since 0.32.0, the nested interpreter runs over the block's own sequence. It starts with no
ancestors, so it stops at the end of the block.
AIContext is the debugger's own context: created from a real MethodContext by copying
receiver, selector, locals, evaluatedSelector, send indexes and the outer chain
(initializeFromMethodContext:, :249), it re-parses the method's source to get an AST
(initializeAST, :243) and finds the current node with ASTPCNodeVisitor by counting
sends of evaluatedSelector up to the recorded index (setupInterpreter:, :313).
AISemanticAnalyzer binds free variables of a typed-in expression to the context's locals,
which is how the debugger's workspace evaluates x + 1 in the stopped frame.
ASTDebugger >> stepInto, :513, shouldBeImplemented
since the class was begun, 2013-02-16 94b28dd6). The reason is structural, not an
omission: sends are performed for real (message sendTo: receiver, :887), so the callee
runs compiled; and a block's body runs inside a nested interpreter that the outer one
cannot see into (visitBlockSequenceNode: forces atEnd, :841). Stepping into either
would mean interpreting the callee from its own AST in a new AIContext — the pieces
exist (initializeAST, evaluateNode:), the wiring does not.excludeIdeData) has no source:, so nothing
can be debugged there. (August §7.5.)3 ifTrue: [1] ifFalse: [2] answers
MessageNotUnderstood interpreted and NonBooleanReceiver compiled by the inlining
generator, because the interpreter sends the message, as the plain generator's code does,
and NonBooleanReceiver is the inliner's own error for a speculation gone wrong. A
choice, not a defect: inlining is one code generator's, and a program compiled by the
plain one steps exactly as it runs.AIBlockClosure >> numArgs is broken — node temps size sends temps to a
BlockNode, which has parameters (§6.3).
0.31.5 fixed it.Compiler-Tests is well organised. The 52 behavioural tests
of AbstractCompilerTest ('foo ^ true ifTrue: [1]' return: 1, …) are run in four
execution contexts chosen by trait composition — compiled and inlined, compiled plain,
interpreted, debugged (TCTInlined/TCTNonInlined × TCTExecuted/TCTInterpreted/
TCTDebugged, Compiler-Tests.st:1222-1337) — so every behaviour is an equivalence
oracle across the four evaluators. The eight JavaScript-gateway tests run in the same
four; the sixteen install-time error tests (InvalidAssignmentError, ParseError,
jsOverride: arity mismatches) in two. With the scope, semantic, position and PC-visitor
tests: 300 test executions of 104 methods, out of the suite's 763. Not covered: the
parser as such (AST shape, positions beyond one case, the error path — which is how the
end-of-input defect survived), where stepping stops (the debugged context runs through
ASTDebugger >> proceed, which is stepOver until atEnd, and nothing asserts the stops),
numArgs.
0.31.5 added tests for each of these.
615 commits touched the compiler sources and the grammar between 2011-03 and 2021-07:
| year | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| commits | 48 | 82 | 180 | 73 | 43 | 53 | 25 | 19 | 70 | 88 | 3 |
Nicolas Petton 247, Herby Vojčík 380 (under two spellings), eight others 51 between them. The milestones, with the reason where the commit or issue gives one:
| when | commit | what | why |
|---|---|---|---|
| 2011-03 | dc8e0218 |
Compiler.st: one class, parser on PetitParser |
the first implementation |
| 2011-07 | 59f6ab2f |
<js code> verbatim JavaScript syntax |
primitives |
| 2011-08/09 | 6682bfae … 82bad4e8 |
first speculative inlining: conditionals, and Number arithmetic behind a checkClass: guard, under a performOptimizations flag |
speed; three fixes to the inlined = within weeks |
| 2011-09-02 | e3b6dda5 |
PEG.js parser, PetitParser removed the next day | "faaaaast" — 100× per the 0.9 changelog |
| 2012-05-10/12 | 470a01b0, 4a2c9415, 9df7ac86 |
Compiler API split from code generation; Herby's ImpCodeGenerator; the generator made pluggable |
a second generator existed, so the seam was made |
| 2012-05-21 → 09-25 | 85133ae9 … a5d64a48 |
the new architecture: AST, SemanticAnalyzer, IR, inliner; default four months later |
"First try at a new compiler architecture" |
| 2012-09-26 | 09ef3fa2 |
unknown lower-case variables accepted if defined in window |
seamless JS interop; the whitelist (2013-06) and package imports: (2015-02, #1150/#1160) narrow it later |
| 2012-12 → 2013-05 | b362fee8, 0d947e96, 1acbf3bf |
AST interpreter: first shot, continuation-passing, then the stack machine | a stepping debugger for Helios (7915ddab, 2013-05-07) |
| 2013-01/02 | c50319f8, 3f44d46f, 1dbac0d8 |
aliasing of temporally dependent nodes; stops at block boundary | #296, #297, #326: evaluation order |
| 2013-02-12 | 7b9e4485 |
lazy context fill through a worker closure; JS temps for locals | contexts cheap enough to leave on |
| 2013-05/10 | f48b4b37, dc2ff669 |
parent pointers and ASTPCNodeVisitor; sendIndexes replace a pc |
the debugger must find the current node in a re-parsed AST |
| 2014-01 | c5348e70, 8898652a |
no context for methods and closures without sends | #787, size and speed |
| 2014-10 | bd03978d, e5840900 |
//>>excludeStart("ctx") pragma; $recv/$core/$globals |
strippable debug data; namespacing |
| 2015-11/12 | 83daedf0, 76a84f54 |
whitespace discipline in the grammar; super kept as a receiver, not renamed |
#1207–#1210; simpler super sends |
| 2016-01-31 | e3bca2e2 |
$globals.Foo direct |
"shorter and faster code" (0.15.1 changelog) |
| 2016-10 → 11 | 155c1ab8, d54b9068, bf8aa708, 7d0f90b2 |
AST and IR re-based on Kernel-Dag; "Compiler is now series of transformers" |
one visitor machinery for both trees; replaceable stages |
| 2016-10-16 | 4cf9cff2 |
<inlineJS: '…'> as a pragma |
pragmas as the general mechanism; legacy syntax removed 2018-04 |
| 2017-04 | e23f53c0, 092b8f03 |
$self beside self; a$nil |
reserved-word-proof spellings; nil across realms |
| 2018-05 | af7b9bce |
general pragma processing (AstPragmator, IRPragmator, TPragmator) |
a pragma is a method on a pragmator |
| 2019-02/03 | 43a59412, 3b2d1900, 76bf06e0, b0ca4adb |
AIContext split from MethodContext; pragmas in .js; the $methodClass factory; super sends through it |
#1241: a method's class is bound at install, not at compile |
| 2019-09/10 | ca5c674e, 8b3314ae, ef1f6f18, 1693b5d5 |
jsOverride:; tests as trait-composed contexts; NLR inliner (#1244); empty inlined block is nil (#1242) |
subclassing JS classes from Smalltalk |
| 2020-02 → 05 | a3d5721c, 9de77366, 3f59afc3, f6a76689, 96470467, 2e36f552 |
the environment probe made explicit; receiver boxing redesigned; $nil; aliasing split by need; and:/or: inlined; package context for eval |
the last sustained rework |
| 2021-07-18 | f4a253cc, f8d3f39c |
IRWrappingSendInliner (#1260); ifNil: without a value |
the last change until October 2026 |
Three readings of this history:
jsOverride:, traits, the
factory wrapper and three generations of aliasing without a rewrite is the strongest
evidence for it.sendIdx, evaluatedSelector, supercall, lazy fill, the ctx pragma: five
mechanisms exist in the emitter so that a separate evaluator can reconstruct where a
compiled frame is. The August analysis' case for a sail interpreter is, at bottom, that
an evaluator which is the execution engine needs none of them.Remove message never sent, Remove ivar that was never used),
deprecations were introduced for every rename — and then the five from Feb–Mar 2020
outlived the one-year rule that cfac736f (2021-02-23) applied to older ones (§6.4).Whole lang image, 2,217 methods with source in 227 traits and classes, each stage run
over all of them after a warm-up pass; two consistent samples (a third, taken while the
machine was busy, was 3–4× slower across the board and is not used):
| stage (cumulative) | ms | per method |
|---|---|---|
| parse | 239–257 | 0.11 |
+ semantic analysis and pragmas (ast:forClass:protocol:) |
494–507 | 0.23 |
+ AST → IR → JS, no inlining (CodeGenerator) |
1,583–1,745 | 0.75 |
+ AST → IR → JS, inlining (InliningCodeGenerator) |
1,832–2,022 | 0.87 |
+ eval of the factory |
1,873–2,122 | 0.90 |
compile:forClass:protocol: complete |
2,081–2,565 | 0.94–1.16 |
The same work split by transformer — each stage's value: timed on its own, one pass over
the image after a warm-up; parse and the final eval are not transformers but are shown
in their place:
| stage | ms | share | per method |
|---|---|---|---|
| parse | 479 | 20 % | 0.22 |
2000 SemanticAnalyzer |
390 | 16 % | 0.18 |
2500 AstSemanticPragmator |
12 | 1 % | 0.01 |
3000 ASTPreInliner |
128 | 5 % | 0.06 |
5000 IRASTTranslator |
306 | 13 % | 0.14 |
6000 IRInliner |
209 | 9 % | 0.09 |
7000 IRLatePragmator |
6 | 0 % | 0.00 |
8000 IRInliningJSTranslator |
616 | 26 % | 0.28 |
eval of the factory |
229 | 10 % | 0.10 |
No stage dominates; the largest, emission, is a quarter.
Where the pipeline's time goes (CPU profile of parse-to-JS over three passes, self time by file and by method):
| share | |
|---|---|
Kernel-Collections (the collection protocol under the visitors) |
20 % |
parser.js |
11 % |
Compiler-IR |
11 % |
| garbage collector | 7 % |
Kernel-Dag |
7 % |
Compiler-AST, kernel-runtime, kernel-language, Kernel-Methods |
6 % each |
Compiler-Semantic |
5 % |
| hottest methods | share |
|---|---|
asReceiver ($recv) |
5.5 % |
PathDagVisitor >> visit: + ParentFakingPathDagVisitor >> visit: — path := path, {aNode} per node, and parent: re-set on every visit |
6.2 % |
$core.withContext — the compiler's own debug contexts |
3.0 % |
StringStream >> nextPutAll: |
2.7 % |
BlockClosure >> value / value: |
4.4 % |
peg$parseseparator |
2.2 % |
Behavior >> new |
1.7 % |
ASTNode >> location: + JSObjectProxy >> doesNotUnderstand: |
1.5 % |
No algorithmic hot spot: the cost is Amber's own per-send overhead applied to idiomatic Smalltalk. For an IDE save (one method) it is invisible; for a whole image it is 2–3 s.
amberc takes 10 s| ms | |
|---|---|
amberc over the 22 packages of the lang set, two runs; output byte-identical to the committed .js |
10,025–10,399 |
| in process: compile all 2,217 methods | 2,341 |
in process: addCompiledMethod: all of them |
164 |
in process: AmdExporter for all 19 packages (2.24 MB) |
366 |
in process: Importer >> import: of the same 22 .st files |
9,665 |
of which ChunkParser alone (374 KB, 5,452 chunks) |
763 |
of which 738 methodsFor: headers as DoIts, 1.0 ms each |
~770 |
of which an unchanged class re-definition as a DoIt (Point, 2 slots, 27 methods) |
27 each |
The last line is the finding. ClassBuilder >> addSubclassOf:named:slots:package:
(Kernel-Classes.st:348-367) ends with recompile on every path that does not migrate
(since 2017-02-19, 91f8a664, "Recompile class moved to package", #1170), so a file-in
recompiles every method of every class from the image's current sources before the
chunks that follow compile them again from the file. A protocol header, a comment stamp
and a trait composition cost a millisecond each; a class definition costs a recompile of
the class. grunt amberc:lang compiles the image roughly twice over; the compiler itself
accounts for a quarter of the wall time.
Since 0.31.5, an unchanged class definition answers the class and recompiles nothing.
Measured in CPU time, the import of the lang set lost a third.
A million iterations, best of five, compiled through the normal pipeline and installed
on DoIt:
| ms | |
|---|---|
[ i <= n ] whileTrue: [ s := s + i. i := i + 1 ] |
313 |
the same, the method's and its blocks' ctx sections stripped (the kernel's whileTrue:, <=, + keep theirs) |
234 |
the same loop hand-inlined as a JS while, the sends kept ($core.assert($recv(i).__lt_eq(n)), $recv(s).__plus(i)) |
126 |
1 to: n do: [ :i \| s := s + i ] (to:do: is a whileTrue: in Number, Kernel-Objects.st:1111) |
426 |
1 to: n do: [ :i \| i odd ifTrue: [ s := s + i ] ] |
900 |
1 to: n do: [ :i \| i = n ifTrue: [ ^ i ] ] ($early) |
485 |
<inlineJS: 'for (…) s = s + i'> |
0.5 |
Reading: a loop iteration costs ~300 ns, of which a quarter is the debug context, a third
is the block-as-send machinery (_value(), closure, $core.assert on the condition
block's result), and the rest is the arithmetic sends with their own contexts. Inlining
the loop selectors would roughly double loop speed in a devel image and more in a deploy
one; the floor, 250×, is the price of sends, which only the sail-style baseline compiler
of August §7.4 or a very different runtime model would move.
Over the 2,217 methods: 239 KB of source become 1.09 MB of JavaScript (4.6×; 1.20 MB
without inlining). 1,713 methods carry a context, 504 do not; 282 have $n aliases; 304
record send indexes; 20 handle a non-local return. In the full lang/src (with tests):
3.31 MB of .js for 512 KB of .st, 4,222 closures, 5,828 $recv(, 9,255 ctx
marker lines, 3,109 ide marker lines.
The transformer list was conceived with a further idea in mind: that the stages could one day be streamed in parallel. Two shapes of that are possible, and only one survives contact with Amber's objects.
A stage per worker — method n being emitted while method n+1 is in the inliner —
needs each intermediate to cross a worker boundary. Workers share no heap; what crosses is
a structured clone, which keeps neither prototypes nor functions. Amber's intermediates are
image-bound object graphs: a VariableNode holds a ScopeVar that holds a LexicalScope
that holds the node and the IR instruction, IRMethod holds a class, a SendNode may hold
an argumentSwitcher function, and parents point up. Since 0.32.0, no parent points up.
The other links remain. Every boundary would be a
serialisation to data and a rebuild into Amber objects, work of the same order as a stage
(0.1–0.3 ms per method, §5.1); and with the largest stage at 26 % of the pipeline, the
best case before that cost is under 4× and realistically about 2×. Not worth building.
A method per worker needs nothing to cross but text: source, class name, side and
protocol in; the emitted JavaScript and the method's data (selector, arguments,
messageSends, referencedClasses) out. Only the eval of the factory and the method
object must happen in the image that installs the method, since a function cannot cross.
Each worker boots its own image and must hold the same class model as the main one — the
same slot names per class, package imports and global whitelist, which is all the semantic
analyser reads. Measured with Node worker_threads, each worker loading amber/lang from
the files, batches of 40 methods, the main image comparing every result with its own:
| workers | boot (wall) | parse-to-text, cold | parse-to-text, warm | warm speed-up | output |
|---|---|---|---|---|---|
| main thread alone | — | 2,460–3,178 ms | 2,255–2,995 ms | 1× | — |
| 1 | 395 ms | 2,983 ms | 2,732 ms | 0.83× | identical, 2,217 of 2,217 |
| 2 | 595 ms | 2,499 ms | 2,021 ms | 1.37× | identical |
| 4 | 735–1,066 ms | 1,742–2,521 ms | 1,568–1,966 ms | 1.5–1.7× | identical |
| 8 | 1,820 ms | 2,936 ms | 2,321 ms | 1.11× | identical |
eval plus method objects for all 2,217 results in the main image afterwards: 41–117 ms.
The shape works — byte-identical output from independent images, a serial remainder under 0.1 s — and on this machine it buys at most 1.7× of the compile phase, with eight workers worse than four. The machine is the reason, and the reason is instructive. It is an i7-1255U, two performance and eight efficiency cores at 15 W. Eight pure-arithmetic workers each run at 68 % of a lone worker's speed, 5.4× in aggregate; eight allocation-heavy workers — objects, arrays, short strings, the compiler's diet, 7 % of its time in the collector — each run at 17 %, 1.4× in aggregate. Compiling Amber is allocation-bound, and allocation does not parallelise on this class of hardware. A desktop with more memory bandwidth would do better; it would not approach its core count.
For amberc: after the double compilation is gone (§5.2), compilation is ~2.3 s of ~6 s;
four workers would make that ~1.6 s plus 0.7–1.1 s of boot — nothing gained here, perhaps
a second elsewhere. Three serial changes each buy as much or more for less: not
recompiling on an unchanged class definition (~2.5 s), reading methodsFor: headers
without compiling a DoIt for each (~0.8 s), a chunk parser in JavaScript (~0.7 s).
0.31.5 made the first of these changes.
Where workers would still earn their place is responsiveness, not throughput: checking a
method as it is typed, or a recompileAll, off the UI thread. Both are
ast:forClass:protocol: or parse-to-text jobs with data results, exactly the shape above.
The prerequisites are the same: declared externals (§7, item 3), because typeof in a
worker's global answers differently from the page's; and a way to give the worker the
class model — a booted image kept in step with definitions, or a small data manifest
(class → slot names, package → imports) answered to the analyser by a stand-in class.
transformersDictionary is the architecture in seven
lines; a reader can list the stages and where to plug one in. Both trees share
Kernel-Dag, so there is one visitor idiom to learn.IRInlinedIfTrueIfFalse, IRInlinedClosure), testable in isolation.ScopeVar >> alias puts the $self., $globals.,
$ctx, reserved-word-suffix rules in nine small classes; asReceiver puts the boxing
rule next to them. The emitter has no case analysis on variable kind.$early only with
non-local return from a real block, send indexes only where ambiguous, $recv only for
unknown receivers, aliases only where order demands. The emitted printOn: above is as
small as this design can make it.recompile and the
exporter all rely on, and leaves a hook for lazy instantiation.navigator exists in the compiling process; the symptoms are the
globalJsVariables whitelist, amberc's jsGlobals, and Gruntfile.js:53. The code
names the cure itself.addDagChild: and add: rightly set no parent. But five readers
walk up to a parent: IRInstruction >> method, scope and replaceWith:,
ASTNode >> position, and the interpreter's next. ParentFakingPathDagVisitor serves
them. It writes the top of its path into every node that it visits. The readers work
only because every pass is such a visitor. The visitors spend 6 % of compile time on
writing the parent and copying the path (§5.1). Since 0.32.0, nodes carry no parent
(§7, item 5).whileTrue:, to:do:, timesRepeat: allocate a closure and go
through _value() per iteration (§5.3), with $core.assert on every condition. No
Amber compiler has inlined a loop: the 2011 one inlined conditionals and Number
arithmetic, the 2012 one conditionals only.expected is dropped, and at
end of input the message itself crashes.
0.31.5 fixed the crash. expected is still dropped.Evaluator >> evaluate:receiver: and
evaluate:context: catch Error and call Terminal alert:; Compiler >> recompile:
reports progress. A library compiler should signal and let the IDE decide.
Since 0.31.5, Evaluator lets the error go to its caller. Since 0.32.0, only
recompileAll reports progress.Compiler is a one-shot pretending to be a façade: compileNode: resets
codeGenerator, ast:forClass:protocol: mutates codeGeneratorClass as a side effect.
Harmless today because every caller does Compiler new ….| where | reproduction | observed | expected | fix |
|---|---|---|---|---|
Compiler >> parseError:parsing:, Compiler-Core.st:289 |
Compiler new parse: 'foo ^ (' (also 'foo ^ 1 +', 'foo ^ ''abc', 'foo ^ 3 foo: ', 'foo ^ #(1 2') |
Error: Cannot add self to a string. from String >> , with nil |
a ParseError naming line, column and "end of input" |
guard found being nil; include pegjs' expected; a test in AbstractCodeGeneratorInstallTest |
AIBlockClosure >> numArgs, Compiler-Interpreter.st:20 |
evaluate [ :a :b \| a + b ] interpreted, send numArgs |
MessageNotUnderstood: a BlockNode does not understand #temps |
2 | node parameters size; a test in ASTInterpreterTest |
JSStream >> nextPutNonLocalReturnWith:, Compiler-IR.st:1357 |
blk ^ [ ^ 42 ] installed; DoIt new blk value |
the bare [42] is thrown; every on:do: lets it through, as it must let live non-local returns through (tryCatch:, #1158); only the top-level ErrorHandler turns it into a NonLifoReturn; a JavaScript caller receives the array |
Pharo signals BlockCannotReturn at the return, catchable by on: Error do: |
the home marks its $early dead on exit (finally), and the return site signals the error when it finds it dead, through a kernel helper beside assert; the August sail design uses the same $early strategy, so decide once for both |
0.31.5 fixed all three. A test pins each fix. The parse error now names "end of input".
It still drops expected.
IRInstruction class >> on: (Compiler-IR.st:369) sends builder:, which nothing in
the image implements; no senders.
0.31.5 removed it.IRInstruction >> remove: (:301): no senders (the unary remove was removed in 2016,
1c73e5ff).
0.32.0 removed it.IRJSTranslator >> visitIRTempDeclaration: (:1103): a body that is a commented-out
statement.
0.31.5 removed it.ParentFakingPathDagVisitor's slot setParentSelector (Compiler-AST.st:686): declared,
never read, left over from 7eed45c3 (2016-10-10).
0.31.5 removed the slot. 0.32.0 removed the class.AbstractCodeGenerator >> pseudoVariables (Compiler-Core.st:27): no senders.
0.32.0 removed it.InliningCodeGenerator >> transformersDictionary (Compiler-Inlining.st:733) re-puts
'8000-irToJs' with the value the superclass already computed through the polymorphic
irTranslatorClass.
Since 0.31.5, the stage is put once.isImmutable on ExpressionNode,
VariableNode and ScopeVar, VariableNode >> value/value:,
IRInstruction >> needsBoxingAsReceiver — past the one-year rule since 2021-03.
0.32.0 removed them.AstPragmator's class comment refers readers
to EarlyPragmator (renamed 2020-03-14, 38acbc50); UnknownVariableError's says "the
default behavior is to allow it"; BlockNode >> nextSiblingNode: carries "this should
not have been called, ever. IMO. -- herby".
0.31.5 corrected all three.Not on the list, though no visitor uses it:
AbstractDagVisitor >> visitDagNodeVariantRedux: (Kernel-Dag.st), the immutable rewriting
variant, which answers a copy of a node whose children changed. It is offered beside
visitDagNodeVariantSimple: on purpose, as the other way a visitor may work, and which way
the compiler's visitors go is a question kept open, not code to remove.
Ordered by what they buy against what they cost; each names the files it would touch.
The three defects, with their tests (§6.3). Hours. Compiler-Core.st,
Compiler-Interpreter.st, Compiler-Tests.st; the escaped-return one also
Kernel-Exceptions.st, kernel-runtime.js, a Recompile. of the image behind it, and
a decision shared with the sail design. Each a complete concern, each its own commit.
0.31.5 fixed all three. A test pins each fix.
Stop the double compilation in the import path (§5.2). ClassBuilder >>
addSubclassOf:named:slots:package: should recompile only when the definition changed —
slots differ or the package differs (what #1170 was about); an unchanged re-definition
should cost what a methodsFor: header costs. Expected: grunt amberc:lang from 10 s
towards 6 s, the release ritual's Recompile steps and every sibling build with it.
One method in Kernel-Classes.st, a test on ClassBuilderTest. The one caution: a
class whose superclass's slots changed still needs its recompile, which today comes
free with the blanket rule; the condition must cover it, or the superclass's
slotsChanged must propagate.
0.31.5 did this. Measured in CPU time, the import of the lang set lost a third. The
new condition looks only at the class's own definition. So the caution is still open.
A probe on 2026-11-02 filed in a package in which a superclass's slots had changed. The
file-in compiled every method in the file again, with the new slots. A subclass's other
methods kept their old binding: extensions from other packages, and methods dropped
from the source. An extension that reads process still answered the global after the
superclass gained a slot process. An extension that reads foo answered undefined
after the superclass lost foo. 0.31.4 recompiled both. But for the lost slot, 0.31.4
stopped the file-in half-way. A class browser re-defines the superclass alone. That
never recompiled a subclass, before 0.31.5 or after. Recompiling the subclasses
whenever a class's slots change would break a legitimate file-in. That file-in moves a
slot down to a subclass. The subclass would recompile before its new definition brings
the slot. The probe reproduced that failure. A fix would recompile the affected
subclasses once the whole import has finished.
Declared externals instead of a probed host (§2.2). A package declares the globals
its code may name — imports: already exists for this and is honoured first — and
isVariableKnown:inPackage: stops evaluating typeof. globalJsVariables and
amberc's jsGlobals go. Breaking for any project that leans on an implicit
document or require: a Working on X change, preceded by a release that warns
(compile succeeds, UnknownVariableError logged) so projects can add the declarations.
Compiler-Semantic.st, Kernel-Infrastructure.st, sdk/lib/amberc.js,
Gruntfile.js.
Inline the loop selectors (§5.3): whileTrue:/whileFalse: (block receiver,
block argument), timesRepeat:, to:do:/to:by:do: with a literal step. Four
IRInlined* nodes, their inliner methods and emitter cases, the ASTPreInliner
marking so that the bounds are aliased, and the non-local-return flattening that already
exists. Measured gain: ~2× on loop-bound code in a devel image, more in deploy. The
sail interpreter will want the same forms as facade escapes (August §6.1), so the
selector list should be decided once. Compiler-Inlining.st, Compiler-IR.st for
JSStream, tests in all four contexts.
No parents; a cheaper path (§6.2). Each reader of a parent finds what it needs
elsewhere. The IR visitors answer the method and the current scope from the path that
they hold. The inliner replaces an instruction through the visitor. The interpreter's
cursor keeps its own ancestors. A node gets its position where it is made. A return
instruction gets its scope there too. Then the parent slots and
ParentFakingPathDagVisitor go. Parents set at construction would be wrong. They would
tie each node to one parent and one tree. The DAG is built to avoid that. Eight commits
did this on 2026-10-23. The first is A node's position is its own. The last is
Nodes have no parent; the faking visitor goes. 0.32.0 released them.
What is left is speed. PathDagVisitor would keep a push/pop stack instead of copying
the path with path , {aNode}. The grammar would pass location().start.line/column
as two integers. Then ASTNode >> location: would not go through a proxy.
Kernel-Dag.st, Compiler-AST.st, parser.pegjs.
The profile of §5.1 was run again on 2026-11-02, three times on each version. On
0.31.5, the two visit: methods take 4.1–5.0 %. §5.1 has 6.2 % for them. On 0.32.0,
PathDagVisitor >> visit: takes 1.8–2.3 %. It still copies the path for every node.
IRVisitor >> currentScope takes 0.1–0.2 %. It reverses a copy of the path for each
send that records its index or goes to super. ASTNode >> location: with the proxy's
doesNotUnderstand: takes 1.0–1.2 %.
The debugger. Two roads, not exclusive:
stepInto for a send whose receiver's method
has source — a new AIContext on the callee's AST, run by the same interpreter —
and for value sends to AIBlockClosures by entering the block's sequence instead
of nesting; give visitSendNode: the $core.assert behaviour for the inlined
selectors. Weeks; stays slow and source-bound.IRJSTranslator (the transformer list is
the seam), the baseline compiler, then a debugger on the sail interpreter, retiring
Compiler-Interpreter and, with it, sendIdx, evaluatedSelector, supercall and
the re-parse. The 48-line sketch of ANALYSIS-2026-08.md §6 is not in the tree
today; it survives in a stash on the maintainer's checkout.
Both start from an oracle for stepping. The test matrix's TCTDebugged context does
step, since ASTDebugger >> proceed is stepOver until atEnd; what it lacked was an
assertion on where the steps stop, which ASTDebuggerTest now has: at each send, in
order.Hygiene, as its own commits: the dead code and the unused slot (§6.4), the Redux
variant excepted; the five deprecations, by the project's own rule; the stale comments;
the duplicate '8000-irToJs' put; Terminal alert: out of Evaluator (signal, and let
Helios catch) — the last one changes behaviour for the workspace and is a small concern
of its own.
0.31.5 did most of this. 0.32.0 removed what was API: IRInstruction >> remove:,
pseudoVariables and the five deprecations.
Tests the suite is missing (§3.3): parser tests on AST shape and positions, the
error path (ParseError at end of input, the message's contents), numArgs and the rest of AIBlockClosure's
BlockClosure protocol, a stepping test.
0.31.5 added all of these.
Already decided elsewhere, not repeated: pegjs → peggy (archaisms §4.2, verified,
waits only on the minifier swap for the CLI bundle); the emitter's syntax level
(archaisms §2.2, "when IRJSTranslator is next touched" — item 4 or 5 above would be
that touch).
Since 0.32.0, peggy builds the parser. Item 5 touched IRJSTranslator in 0.32.0. The
emitter's syntax stayed as it was.
Parallel compilation in workers (§5.5): workable as a method per worker, with byte-identical output demonstrated; not as a stage per worker. It wants item 3 first (the environment probe answers differently in a worker) and item 2 before it can matter, and on allocation-bound hardware it buys little. Take it for responsiveness in the IDE, not for build time.
What to leave alone: the staged pipeline and its unused seams, the IR's shape, the aliasing machinery, the test matrix. They are the parts that have absorbed nine years of change without needing to be rewritten, and the parts the next backend would build on.
Throwaway Node scripts in the session scratchpad, not committed; each loads the image
with RequireJS at the repository root (amber → lang/base, amber/core → lang/src),
requires amber/lang and amber/core/Platform-Node, and waits for initialize().
localMethods entry with a source over
api.traitsOrClasses (both sides of each class), runs each stage over all of them
(parse:, ast:forClass:protocol:, start:forClass:protocol: + compileNode: with
CodeGenerator and with the default, eval:forPackage: of wrappedSourceOf:,
compile:forClass:protocol:) after one warm-up pass; censuses the emitted source; runs
a 200-iteration to:do: method 200 times compiled and 200 times through an AIContext
ASTInterpreter prepared as TCTInterpreted >> prepareContextFor:… does. Three
samples; the first, 3–4× slower in every stage, coincided with other load and was
discarded.node --cpu-prof; the summary attributes self time to Amber methods by mapping each
frame's lang/src/*.js line back to the nearest preceding selector: and the
$globals.<Class>); that closes its addMethod.
Both scripts were rewritten from this description on 2026-11-02, for §7 item 5. On
0.31.5, three runs give the shares by file of §5.1 within two points.jsOverride: checks, printing the class of whatever is raised (a thrown JS array
included).new (require('sdk/lib/amberc.js').Compiler)('lang').main(…) over
the Gruntfile's lang list into a scratch directory with jsGlobals: ['navigator'],
wall-clocked, each output compared byte for byte with lang/src. Profiled once the same
way; after the import re-compiles the compiler, its methods run from eval'd code and
show in the profile without a file, which is why that profile is not tabulated.compile:forClass:protocol: over all methods, then
addCompiledMethod: of the results, then AmdExporter over all packages; Importer new
import: per .st file of the lang set in Gruntfile order; ChunkParser alone over
the same files, classifying chunks as empty, methodsFor: header, method, or other;
Compiler new evaluateExpression: of one chunk of each kind, 50–300 times. (The chunk
loop first ran forever because a Smalltalk nil reaches JavaScript as an object, not
null; the test is chunk == null || chunk.a$nil.)DoIt
through the normal pipeline, n = 1,000,000, best of five after three warm-ups; the
stripped variant removes the method's own //>>excludeStart("ctx")…excludeEnd("ctx")
sections from compiledSource before eval; the hand-inlined variant is a JS while
with the sends written as the emitter would write them.require of amber/deploy or amber/lang and initialize() in a
fresh process, three runs each.InliningCodeGenerator per
method, its transformersDictionary iterated in key order, each value: timed; parse:
before, eval:forPackage: of wrappedSourceOf: after.worker_threads, each loading amber/lang and
Platform-Node through RequireJS and answering batches of {source, className, meta,
protocol} with {wrapped, selector, args, messageSends, referencedClasses}; the main
image times its own cold and warm pass first, then a cold and a warm parallel run, and
compares every wrapped string; run with K = 1, 2, 4, 8, and 4 again with
--v8-pool-size=10 and --max-semi-space-size=64 (the best 4-worker figures).