Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ about: Create a report to help us improve
A clear and concise description of what the bug is and how it happens.

* Include the steps required to reproduce the bug (e.g. a small code example or a link to your project code)
* Publish a [gist](https://gist.github.com/) with the `compiler`, `languageServer`, and VSCode Output for `wurstLanguageServer`, and provide a link. Cut and paste the template below:
* Publish a [gist](https://gist.github.com/) with the `compiler`, `languageServer`, and VSCode Output for `Wurstscript Language Server`, and provide a link. Cut and paste the template below:

<!--
# compiler logs
Expand All @@ -23,9 +23,9 @@ logs from `~/.wurst/logs/compiler.log` (~ refers to your user's home directory)
logs from `~/.wurst/logs/languageServer.log` (~ refers to your user's home directory)
```

# wurstLanguageServer VSCode output
# Wurstscript Language Server VSCode output

```
Copy and paste the VSCode Output (CTRL + SHIFT + U) for `wurstLanguageServer` (drop down menu)
Copy and paste the VSCode Output (CTRL + SHIFT + U) for `Wurstscript Language Server` (drop down menu)
```
-->
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Separate repositories, checked out next to this repository's main checkout (in a
* **WurstSetup** (`grill`): the CLI that installs dependencies and runs `-build` through `CliBuildMap`.
* **wurst4vscode**: the VS Code extension, the LSP client (§5).
* **wurst-project-config**: the shared `wurst.build` model (§6).
* **wc3libs** (pinned in `build.gradle`) and **JMPQ3** (reached through wc3libs): Warcraft file formats and MPQ.
* **wc3libs** and **JMPQ3** (both pinned in `build.gradle`): Warcraft file formats and MPQ.
* **jass-history**: `common.j`, `blizzard.j` and Lua dumps per patch (§6, `luaruntime/README.md`).
* **abstractsyntaxgen**: the `.parseq` generator (above). **casc-ts**: the CASC reader for game data (§12).

Expand Down Expand Up @@ -178,8 +178,8 @@ This repository has multiple entry points that may trigger compilation/build beh
wurst4vscode starts the server with `-XX:+AutoCreateSharedArchive`: the JVM writes an AppCDS archive next to the
compiler jar when the first session ends, and the sessions after it start from it. That archive sits on the
runtime's own base archive, which `deploy.gradle` makes (`jlink --generate-cds-archive`; macOS copies a full JDK, which
usually has one, and `assembleSlimCompilerDist` dumps one with `java -Xshare:dump` when the JDK has none: the Temurin
for macOS x64 on CI does not). `assembleSlimCompilerDist` then starts the runtime with `-Xshare:on`, which fails when
usually has one, and `assembleSlimCompilerDist` dumps one with `java -Xshare:dump` when the JDK has none: a copied JDK
need not ship one). `assembleSlimCompilerDist` then starts the runtime with `-Xshare:on`, which fails when
there is no usable archive. Without one the JVM silently runs without any, which is how the earlier attempt went
unnoticed. Pull-request CI packages nothing; the versioned release workflow packages every supported host, so a change
here is not tested on macOS before it merges. Java 27 enables compact object headers by default. The build clears the JVM option
Expand Down Expand Up @@ -483,7 +483,7 @@ The game is the specification; the IM interpreter, the Lua test runtime and Bliz

* **Wurst has no garbage collector.** An instance is an integer id on both targets, `destroy` is the only release, and `ondestroy` is an observable side effect. Never elide, duplicate, reorder or "tidy" an alloc, dealloc or `ondestroy`, and never rely on Lua to collect a Wurst object. Both targets hand the most recently freed id out first, so a stale reference reads the next object, which may belong to a related class on Jass (one allocator per inheritance group) and to any class on Lua (one id space).
* **The game's Lua is not the test Lua.** Tests run a stock Lua with every library and double reals (5.3 on Windows and the Linux CI, unchecked elsewhere). Emit no `debug`, `collectgarbage`, `io`, `os`, `package` or `require`. Two tests guard it: `emittedLuaUsesOnlyLibrariesTheGameProvides` over one program's output, and `noLuaBackendLiteralNamesALibraryTheGameWithholds`, which scans the string literals under `translation/` because natives and fallback helpers are emitted only on demand and no program reaches them all. Only the test-only `testSuccess` is exempt. Never take a passing Lua test run as evidence about the game.
* **Nothing optimises the emitted script at run time** (the reference Lua 5.3 neither inlines nor caches lookups, and the game is reported to run it). The inliner and the local optimisations are the only optimiser, so a helper call, global read, table index or allocation left in the script is paid on every execution, and `-stacktraces` adds a push and a pop to each instrumented function (`wurst_stack`). Benchmark like a shipping map: `-inline -localOptimizations`, no `-stacktraces` (the `wurst_run.args` default is the opposite).
* **Nothing optimises the emitted script at run time** (the reference Lua 5.3 neither inlines nor caches lookups, and the game is reported to run it). The inliner and the local optimisations are the only optimiser, so a helper call, global read, table index or allocation left in the script is paid on every execution, and `-stacktraces` adds a push and a pop to each instrumented function (`wurst_stack`). Benchmark like a shipping map: `-inline -localOptimizations`, no `-stacktraces` (a generated `wurst_run.args` keeps `-stacktraces` and inlines builds only).
* **Lockstep: never iterate a Lua table whose order is observable** (`pairs`, `next`). The order differs between players and desyncs the game. A table is safe as a membership set; anything iterated needs an insertion-ordered array. Decide this when designing a structure, not afterwards.
* **`I2S(1 div 0)` is the deliberate thread abort** (Jass has no `throw`); Lua lowers that exact shape to `error("__wurst_abort_thread", 0)`. A rewrite of `div` or `I2S` must keep the shape (`LuaBackendAuditTests`, `OptimizerTests` cover it).
* **Death is life <= 0.405, never 0**, and reals are not doubles: see "Interpreter native mocks" and "Reference semantics for arithmetic" in §7.
Expand Down
35 changes: 9 additions & 26 deletions BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Notes; finished-work narrative does not.
sends `wurst.buildmap` and `wurst.startmap` without saving the open files first. Whether a build should
save first, or refuse unsaved files, is open.

- **Reuse translation work on unchanged map runs.** After checked-model reuse, Survival Chaos Reborn
- **Reuse translation work on unchanged map runs.** After checked-model reuse, a large Jass map
takes 4.5 to 5.2 s for an unoptimised warm RunMap: AST→IM 1.3 to 1.4 s, required Jass lowering 1.3 to 1.7 s,
compile-time work 0.9 to 1.0 s, map injection 0.4 to 0.6 s. Whole-project typechecking is now skipped.
Investigate retaining a pristine IM snapshot keyed by model/config/target state, then copying it
Expand Down Expand Up @@ -76,9 +76,10 @@ Notes; finished-work narrative does not.
class (a generic parent which nothing allocates directly keeps a specialised class table with the method).

- **Build the local-player analysis fewer times, or incrementally.** An optimised Lua build of castle fight
constructs `LocalPlayerContextAnalyzer` five times: for the compile-time state function the splitter optimises
(`FunctionSplitter`, once per split target), for `ImInliner.doInlining`, once per `ImOptimizer.runLocalOptimizationSweep`
(two sweeps) and for `LuaOldGenericsCasts`, about 4 s of the compiler thread (7% of its samples). Each one is the
constructs `LocalPlayerContextAnalyzer` four times: for the compile-time state function the splitter optimises
(`FunctionSplitter`, once per split target with locals), for `ImInliner.doInlining` and once per
`ImOptimizer.runLocalOptimizationSweep` (two sweeps). With a fifth (`LuaOldGenericsCasts`, since removed) they
took about 4 s of the compiler thread (7% of its samples). Each one is the
whole program, because the fact about a variable or a function depends on every caller and every writer.
Keeping the analysis of the first sweep for the second is not output-neutral: it changed about 40,000 lines of the
castle fight script (different local merges), so a construction per sweep stays until the analysis can retract a
Expand Down Expand Up @@ -126,11 +127,6 @@ Notes; finished-work narrative does not.
waits for the parse threads, so the scan is not on the critical path while parsing is parallel.
- **What a large map's build still spends, by step (`-measure`), and why.** Measured on a Jass map of 1,625 files
with thousands of compile-time functions:
- *MPQ, on every run and build:* `Applying Map Config` (1.2 s) and `Injecting map data` (1.8 s) are mostly two
lookups in JMPQ3 which are linear per call and called once per file: `MpqArchive.localesOf` scans every hash
table mapping (from `MpqArchiveWriter.from`) and `MpqArchiveWriter.contains` streams over every pending key
(from `Jmpq3BasedEditor.hasFile` per imported file). `Finalize map` (7.8 s, release builds only) recompresses every
file on one thread. Fix in JMPQ3 and bump the pin.
- *Type check (12 s):* Guava collections are about 11% of its samples (name tables about 5%, the dataflow states
about 4%). The dataflow anomaly analysis (`VarStates`, `VState`) copies its immutable maps and multimaps on every
read and write, about 7% with its merges; persistent or mutable states would remove most of that. The rest is
Expand All @@ -155,19 +151,6 @@ Notes; finished-work narrative does not.
way. Find the decisions of the Wurst and Jass grammars which need the context of the calling rule (the syntax
error the SLL pass reports on such a file, with the full-prediction pass switched off, names the place) and
left-factor them. That removes the second parse for valid files, which would then only be paid by broken ones.
- **Preserve effects of every virtual implementation.** A reproduced Lua miscompile drops an unread
`Base.value()` call when only `Child.value()` increments a global; all Jass harness modes pass.
It fails even without optional Lua optimization flags. `SideEffectAnalyzer.directlyCalledFunctions`
follows only the root implementation. Fix the owning effect/call analysis to include all possible
overrides transitively, including generic/module paths, destruction and native effects. This is a
correctness prerequisite for more dispatch caching. Repro and controls:
[docs/LUA_RUNTIME_OPPORTUNITIES.md](docs/LUA_RUNTIME_OPPORTUNITIES.md).
- **Preserve unused allocations on optimized Lua.** `new Empty(); new Empty(); new Empty()` with only
the first/last IDs retained must advance by two. Jass and unoptimized Lua pass; Lua with
`-inline -localOptimizations` drops the middle allocation. Investigate allocation effects in
`SideEffectAnalyzer` and statement conversion in `Flatten.exprToStatements`; preserve the original
allocation through every pass, including unread assignments. Add ID-reuse and allocator-limit
regressions. The opt-in failing repro is in the same investigation note.
- **Devirtualize proven exact receivers before inlining.** Optimized Lua still dispatches an interface
local initialized with `new A()` virtually when the method has sibling implementations.
`LuaMethodCallLowering` currently considers only methods with no submethods. Start with bounded
Expand Down Expand Up @@ -272,13 +255,13 @@ Notes; finished-work narrative does not.
reach is bounded by how much of the roughly one thousand natives the shim models, so those tests
stay small and targeted. There is no Wurst-level end-to-end feature; correctness in a real map on
the Lua target is asserted in the agent workflow.
- `wurst_run.args` in a generated project defaults to `-stacktraces` and no `-inline`, so every
emitted function pays `wurst_stack` bookkeeping and no leaf is inlined. Benchmarks that inform
- `wurst_run.args` in a generated project turns on `-stacktraces` for runs and builds and `-inline` only
for builds, so every emitted function pays `wurst_stack` bookkeeping and a run inlines no leaf. Benchmarks that inform
stdlib design must use `-inline -localOptimizations` without `-stacktraces`, or they measure the
debug configuration.
- Test forks: eight forks won on eight cores (7m03s wall against 13m11s serial) even though each
test runs 2.6 times slower there. Wall time cannot go below the slowest class, `ExportToWurstTest`
at 108s, until it is split.
test runs 2.6 times slower there. Wall time cannot go below the slowest class (`BugTests`, 73 s in
`test-class-weights.txt`) until it is split.
- The stdlib copy under `de.peeeq.wurstscript/temp/WurstStdlib2` is a fetched artefact for tests.
Real stdlib changes belong in the WurstStdlib2 repo.
- `WURST_LANGUAGE.md` ships as a compiler resource at
Expand Down
14 changes: 7 additions & 7 deletions HelperScripts/generate-obj-mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function parseObjEditingFile(content: string): ClassDef[] {
continue;
}

// Pattern 2: def.set[Type]("fieldId", value) — no level at all (units, items, buffs)
// Pattern 2: def.set[Type]("fieldId", value): no level at all (units, items, buffs)
const noLvlMatch = line.match(
/^\t\tdef\.(set(?!Lvl|Levels)(?:String|Int|Unreal|Real|Boolean))\("([^"]{4})",/
);
Expand Down Expand Up @@ -424,7 +424,7 @@ function generateJson(

// ===========================================================================
// KNOWLEDGE BASE GENERATION
// Reads all gamedata SLK/txt files and produces wc3-knowledge-base.json —
// Reads all gamedata SLK/txt files and produces wc3-knowledge-base.json,
// a self-contained description of all WC3 object types, their field schemas
// (display names, types, categories) and all base-game object records.
// ===========================================================================
Expand Down Expand Up @@ -590,7 +590,7 @@ function mergeFuncMaps(
}

// ---------------------------------------------------------------------------
// Field schema — derived from *metadata.slk files
// Field schema, derived from *metadata.slk files
// ---------------------------------------------------------------------------

interface KBFieldSchema {
Expand Down Expand Up @@ -695,7 +695,7 @@ function buildSchemas(
}

// ---------------------------------------------------------------------------
// Object records — merge SLK maps + func/skin map for each object type
// Object records: merge SLK maps + func/skin map for each object type
// ---------------------------------------------------------------------------

type ObjRecord = Record<string, string | number>;
Expand Down Expand Up @@ -775,7 +775,7 @@ function generateKnowledgeBase(

// --- Object data: merge SLK + func/skin sources per object type ---

// Units — five SLK files, all keyed by the same 4-char unit ID
// Units: five SLK files, all keyed by the same 4-char unit ID
const unitFunc = loadFunc(
"humanunitfunc.txt", "orcunitfunc.txt", "nightelfunitfunc.txt",
"undeadunitfunc.txt", "neutralunitfunc.txt", "campaignunitfunc.txt",
Expand All @@ -801,7 +801,7 @@ function generateKnowledgeBase(
);
const abilityObjects = buildObjectMap([loadSLK("abilitydata.slk")], abilityFunc);

// Buffs/effects — abilitybuffdata.slk; buff IDs may also appear in ability func files
// Buffs/effects: abilitybuffdata.slk; buff IDs may also appear in ability func files
const buffObjects = buildObjectMap([loadSLK("abilitybuffdata.slk")], abilityFunc);

// Items
Expand Down Expand Up @@ -943,7 +943,7 @@ console.log(`Total classes with own fields: ${totalClasses}`);

const westringsContent = tryRead(gdPath("WorldEditStrings.txt"));
if (!westringsContent) {
console.log("\nHelperScripts/gamedata/ not found — skipping knowledge base generation.");
console.log("\nHelperScripts/gamedata/ not found; skipping knowledge base generation.");
console.log("Place WC3 game data files in HelperScripts/gamedata/ to enable this output.");
} else {
console.log("\n--- Generating wc3-knowledge-base.json ---");
Expand Down
5 changes: 2 additions & 3 deletions HelperScripts/src/objEditing/abilities/GenAbilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.google.common.collect.Sets;
import com.google.common.io.Files;
import net.moonlightflower.wc3libs.misc.FieldId;
import net.moonlightflower.wc3libs.misc.ObjId;
import net.moonlightflower.wc3libs.slk.MetaSLK;
import net.moonlightflower.wc3libs.slk.app.meta.AbilityMetaSLK;
import net.moonlightflower.wc3libs.slk.app.objs.AbilSLK;
Expand Down Expand Up @@ -155,7 +154,7 @@ private String typePost() {
}
}

/** Null-safe field getter for SLK objects — returns null instead of throwing when the field is absent. */
/** Null-safe field getter for SLK objects: returns null instead of throwing when the field is absent. */
private static String safeGet(net.moonlightflower.wc3libs.slk.SLK.Obj<?> obj, String field) {
net.moonlightflower.wc3libs.dataTypes.DataType val = obj.get(FieldId.valueOf(field));
return val == null ? null : val.toString();
Expand Down Expand Up @@ -295,7 +294,7 @@ public static void main(String[] args) throws IOException {
}
}

// Abilities with specific fields (including inherited ones) — output to main wurst file
// Abilities with specific fields (including inherited ones): output to main wurst file
// and to the additions file (for stdlib integration), both using AbilityIds.xxx
StringBuilder idsBlock = new StringBuilder();
StringBuilder completeIds = new StringBuilder("package AbilityIds\nimport NoWurst\n\npublic class AbilityIds\n");
Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ Releases are published via GitHub workflows and GitHub Releases:
- Workflow: https://github.com/wurstscript/WurstScript/actions/workflows/release.yml
- Releases: https://github.com/wurstscript/WurstScript/releases

The version string can be updated in [build.gradle](https://github.com/wurstscript/WurstScript/blob/master/de.peeeq.wurstscript/build.gradle#L28).
The version string is in [version.txt](de.peeeq.wurstscript/version.txt); see [docs/RELEASING.md](docs/RELEASING.md).
19 changes: 0 additions & 19 deletions de.peeeq.wurstscript/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
buildscript {
repositories { mavenCentral() }
dependencies {
// used at configuration-time for version info
classpath 'org.eclipse.jgit:org.eclipse.jgit:5.7.+'
classpath "javax.inject:javax.inject:1"
}
}
Expand All @@ -16,12 +14,9 @@ plugins {
id 'net.ltgt.errorprone' version '5.1.1'
id 'maven-publish'
id 'com.gradleup.shadow' version '9.2.2'
id 'de.undercouch.download' version '5.6.0'
}


import de.undercouch.gradle.tasks.download.Download

import java.util.regex.Pattern
import java.time.Duration

Expand Down Expand Up @@ -152,7 +147,6 @@ dependencies {
implementation 'com.google.guava:guava:32.1.3-jre'
implementation 'io.vavr:vavr:0.10.7'
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.24.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.2'
implementation 'org.eclipse.jdt:org.eclipse.jdt.annotation:2.1.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'commons-lang:commons-lang:2.6'
Expand Down Expand Up @@ -435,19 +429,6 @@ tasks.named('clean') {
doFirst { delete genDir }
}

/** -------- Download helpers -------- */

tasks.register('downloadZipFile', Download) {
src 'https://github.com/wurstscript/wurstStdlib2/archive/master.zip'
dest new File(buildDir, 'stdlib2.zip')
}

tasks.register('downloadAndUnzipFile', Copy) {
dependsOn 'downloadZipFile'
from zipTree(tasks.named('downloadZipFile').get().dest)
into new File(buildDir, '/deps/')
}

/** -------- Shadow / packaging -------- */

shadowJar {
Expand Down
Loading
Loading