Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(aot): a system can declare a resource writable, and the write lands

esenginef3c49e0ca420
diff --git a/compiler/src/abi.ts b/compiler/src/abi.ts
index 8c51651d6..572f2d61e 100644
--- a/compiler/src/abi.ts
+++ b/compiler/src/abi.ts
@@ -193,12 +193,19 @@ function store(mem: AbiMemory, at: number, enc: LeafEnc, v: number | boolean): v
* time — so this function, not a convention, is what both the host and the code
* generator ask. Two readers of one answer; not two answers.
*/
+/** A resource a system declared, and whether it declared it writable. */
+export interface ResourceArg {
+ readonly name: string;
+ readonly mut: boolean;
+}
+
export interface SysPlan {
readonly system: string;
/** One entry per declared `Query`, in declaration order. */
readonly queries: readonly (readonly QueryArg[])[];
- /** One entry per declared `Res`, in declaration order. */
- readonly resources: readonly string[];
+ /** One entry per declared `Res`/`ResMut`, in declaration order. `mut` is
+ * what tells a mirroring host to write the block back after the call. */
+ readonly resources: readonly ResourceArg[];
/** One entry per declared channel (`Commands`, later an event reader). */
readonly channels: readonly string[];
/** A parameter's local id -> which of the three tables, and which slot. */
@@ -207,7 +214,7 @@ export interface SysPlan {
export function planFor(sys: EirSystem): SysPlan {
const queries: (readonly QueryArg[])[] = [];
- const resources: string[] = [];
+ const resources: ResourceArg[] = [];
const channels: string[] = [];
const slots = new Map<number, { table: 'query' | 'res' | 'channel'; slot: number }>();
for (const p of sys.params) {
@@ -218,7 +225,7 @@ export function planFor(sys: EirSystem): SysPlan {
break;
case 'res':
slots.set(p.id, { table: 'res', slot: resources.length });
- resources.push(p.type.name);
+ resources.push({ name: p.type.name, mut: p.type.mut });
break;
case 'channel':
slots.set(p.id, { table: 'channel', slot: channels.length });
@@ -261,7 +268,7 @@ export function materialize(mem: AbiMemory, plan: SysPlan): AbiCall {
});
const resTable = mem.scratch(Math.max(4, plan.resources.length * 4));
- plan.resources.forEach((name, k) => { mem.u32[(resTable >> 2) + k] = mem.resourceBase(name); });
+ plan.resources.forEach((r, k) => { mem.u32[(resTable >> 2) + k] = mem.resourceBase(r.name); });
const cmdCount = mem.scratch(4);
mem.u32[cmdCount >> 2] = 0;
@@ -316,7 +323,7 @@ export function abiHost(mem: AbiMemory, layout: AbiLayout, plan: SysPlan, call:
store(mem, (base as number) + leaf.byteOffset, leaf.enc, v);
},
resource(name) {
- const k = plan.resources.indexOf(name);
+ const k = plan.resources.findIndex((r) => r.name === name);
if (k < 0) throw new Error(`ABI: '${plan.system}' reads a resource it did not declare`);
return mem.u32[(resTable >> 2) + k]!;
},
diff --git a/compiler/src/codegen.ts b/compiler/src/codegen.ts
index 87a078dcf..291c7430b 100644
--- a/compiler/src/codegen.ts
+++ b/compiler/src/codegen.ts
@@ -179,6 +179,9 @@ typedef struct EsSystemDecl {
void (*fn)(es_addr_t);
const EsQueryDecl *queries;
const char *const *resources;
+ /* 1 where the system declared ResMut: a host that MIRRORS a resource into
+ the block has to write that block back, or the write is dropped. */
+ const unsigned char *resourcesMut;
uint32_t queryCount;
uint32_t resourceCount;
} EsSystemDecl;
@@ -780,13 +783,16 @@ function emitManifest(systems: readonly EirSystem[], plans: readonly SysPlan[]):
}
if (plan.resources.length > 0) {
out.push(`static const char *const ${tag}_resources[] = { `
- + `${plan.resources.map((r) => JSON.stringify(r)).join(', ')} };`);
+ + `${plan.resources.map((r) => JSON.stringify(r.name)).join(', ')} };`);
+ out.push(`static const unsigned char ${tag}_resources_mut[] = { `
+ + `${plan.resources.map((r) => (r.mut ? '1u' : '0u')).join(', ')} };`);
}
// C has no zero-length array, so an empty table is a null pointer and a
// count of zero — which is also what a host would check anyway.
rows.push(` { ${JSON.stringify(sys.name)}, ${tag}, `
+ `${plan.queries.length > 0 ? `${tag}_queries` : 'NULL'}, `
+ `${plan.resources.length > 0 ? `${tag}_resources` : 'NULL'}, `
+ + `${plan.resources.length > 0 ? `${tag}_resources_mut` : 'NULL'}, `
+ `${plan.queries.length}u, ${plan.resources.length}u },`);
});
out.push('');
diff --git a/compiler/src/eir.ts b/compiler/src/eir.ts
index 3bf41a83f..08c1626e3 100644
--- a/compiler/src/eir.ts
+++ b/compiler/src/eir.ts
@@ -27,7 +27,8 @@ export type EirType =
/** A component row — its fields come from the component's declared shape. */
| { readonly k: 'comp'; readonly name: string }
/** A resource, addressed by field like a component. */
- | { readonly k: 'res'; readonly name: string }
+ /** `mut` is `ResMut`: the host has to write the block back after the call. */
+ | { readonly k: 'res'; readonly name: string; readonly mut: boolean }
| { readonly k: 'query'; readonly args: readonly QueryArg[] }
/** A deferred-mutation channel: Commands, and later an EventWriter. */
| { readonly k: 'channel'; readonly name: string };
diff --git a/compiler/src/frontend.ts b/compiler/src/frontend.ts
index 62707fc89..0595e0b4c 100644
--- a/compiler/src/frontend.ts
+++ b/compiler/src/frontend.ts
@@ -303,10 +303,10 @@ class SystemLowerer {
throw new NotInSubset(el, 'each parameter must be Query(...) or Res(...)');
}
const kind = el.expression.text;
- if (kind === 'Res') {
+ if (kind === 'Res' || kind === 'ResMut') {
const arg = el.arguments[0];
- if (!arg || !ts.isIdentifier(arg)) throw new NotInSubset(el, 'Res(...) needs a named resource');
- return { k: 'res', name: this.compName(arg.text) } as EirType;
+ if (!arg || !ts.isIdentifier(arg)) throw new NotInSubset(el, `${kind}(...) needs a named resource`);
+ return { k: 'res', name: this.compName(arg.text), mut: kind === 'ResMut' } as EirType;
}
if (kind === 'Commands') {
if (el.arguments.length !== 0) throw new NotInSubset(el, 'Commands() takes no arguments');
diff --git a/compiler/src/verify.ts b/compiler/src/verify.ts
index 98a82d584..ad6701028 100644
--- a/compiler/src/verify.ts
+++ b/compiler/src/verify.ts
@@ -49,6 +49,11 @@ class Verifier {
return l;
}
+ /** What a place is rooted in, which is what says whether writing is allowed. */
+ private rootType(p: Place): EirType | null {
+ return p.p === 'local' ? this.local(p.id)?.type ?? null : this.rootType(p.base);
+ }
+
/** The type a place reads as, or null when it does not resolve. */
placeType(p: Place): EirType | null {
if (p.p === 'local') return this.local(p.id)?.type ?? null;
@@ -156,6 +161,13 @@ class Verifier {
if (target && value && target.k !== value.k) {
this.fail(`assigning ${typeName(value)} into a ${typeName(target)}`);
}
+ // The read-only half of ResMut, proved on the IR: a host writes
+ // a resource block back only when the declaration asked for it,
+ // so a write through `Res` would be dropped rather than refused.
+ const root = this.rootType(s.target);
+ if (root && root.k === 'res' && !root.mut) {
+ this.fail(`'${root.name}' is written but the system declared Res, not ResMut`);
+ }
break;
}
case 'emit': {
diff --git a/compiler/tests/coverage.test.ts b/compiler/tests/coverage.test.ts
index 62e375e7d..27d9b36c2 100644
--- a/compiler/tests/coverage.test.ts
+++ b/compiler/tests/coverage.test.ts
@@ -18,6 +18,12 @@
* different components both named 'Health' and silently gave one
* project the other's shape.
*
+ * The breakdown counts ONE refusal per system: lowering stops at the
+ * first thing it cannot take, so the list says what systems hit FIRST,
+ * not everything that would have to be built to compile them. Clearing
+ * the top line usually reveals the next one rather than raising the
+ * number.
+ *
* It also reports the CEILING: how much of the corpus the contract could
* ever take, counting a system as reachable when every refusal against
* it is `pending` rather than `permanent`. That number is what says the
diff --git a/pipeline/src/bundle/buildCompiledSystems.ts b/pipeline/src/bundle/buildCompiledSystems.ts
index d0d1865c5..8c7962fe4 100644
--- a/pipeline/src/bundle/buildCompiledSystems.ts
+++ b/pipeline/src/bundle/buildCompiledSystems.ts
@@ -44,8 +44,9 @@ export interface CompiledSystemInfo {
symbol: string;
/** One entry per declared Query: its components, in the order it names them. */
queries: { comp: string; mut: boolean }[][];
- /** One entry per declared Res, in declaration order. */
- resources: string[];
+ /** One per declared Res/ResMut, in declaration order. `mut` is what makes the
+ * runtime write a mirrored resource back after the call. */
+ resources: { name: string; mut: boolean }[];
}
export interface CompiledSystemsManifest {
@@ -225,7 +226,7 @@ export async function buildCompiledSystems(
name: sys.name,
symbol: cSymbol(sys.name),
queries: plan.queries.map((q) => q.map((a) => ({ comp: a.comp, mut: a.mut }))),
- resources: [...plan.resources],
+ resources: plan.resources.map((r) => ({ name: r.name, mut: r.mut })),
};
}),
};
diff --git a/pipeline/tests/build-compiled-systems.test.ts b/pipeline/tests/build-compiled-systems.test.ts
index f6078bbb7..c26a55726 100644
--- a/pipeline/tests/build-compiled-systems.test.ts
+++ b/pipeline/tests/build-compiled-systems.test.ts
@@ -218,7 +218,7 @@ describe('the AOT build step', () => {
name: 'MoveSystem',
symbol: 'es_sys_MoveSystem',
queries: [[{ comp: 'Transform', mut: true }, { comp: 'Mover', mut: false }]],
- resources: ['Time'],
+ resources: [{ name: 'Time', mut: false }],
}]);
expect(out.manifest!.engineAbi).toMatch(/^[0-9a-f]{16}$/);
expect(out.manifest!.projectShapes).toMatch(/^[0-9a-f]{16}$/);
diff --git a/pipeline/tests/export-aot.test.ts b/pipeline/tests/export-aot.test.ts
index 649e7a85b..defb2d0ac 100644
--- a/pipeline/tests/export-aot.test.ts
+++ b/pipeline/tests/export-aot.test.ts
@@ -98,13 +98,13 @@ describe('the promised systems in a web package', () => {
const manifest = JSON.parse(readFileSync(path.join(f.out, AOT_MANIFEST), 'utf8')) as {
engineAbi: string; projectShapes: string;
- systems: { name: string; symbol: string; queries: { comp: string; mut: boolean }[][]; resources: string[] }[];
+ systems: { name: string; symbol: string; queries: { comp: string; mut: boolean }[][]; resources: { name: string; mut: boolean }[] }[];
};
expect(manifest.systems).toEqual([{
name: 'MoveSystem',
symbol: 'es_sys_MoveSystem',
queries: [[{ comp: 'Transform', mut: true }, { comp: 'Mover', mut: false }]],
- resources: ['Time'],
+ resources: [{ name: 'Time', mut: false }],
}]);
expect(manifest.engineAbi).toMatch(/^[0-9a-f]{16}$/);
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index b098eb3d7..d41ec17f9 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -521,7 +521,7 @@ systems: readonly AotSystemDecl[]
```
name: string
queries: readonly (readonly { comp: string; mut: boolean; }[])[]
-resources: readonly string[]
+resources: readonly { name: string; mut: boolean; }[]
symbol: string
```
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 768b5bbf5..b676c5b56 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -521,7 +521,7 @@ systems: readonly AotSystemDecl[]
```
name: string
queries: readonly (readonly { comp: string; mut: boolean; }[])[]
-resources: readonly string[]
+resources: readonly { name: string; mut: boolean; }[]
symbol: string
```
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 161a2bb07..61088dbcb 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -516,7 +516,7 @@ systems: readonly AotSystemDecl[]
```
name: string
queries: readonly (readonly { comp: string; mut: boolean; }[])[]
-resources: readonly string[]
+resources: readonly { name: string; mut: boolean; }[]
symbol: string
```
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 1ab62ed45..005de4315 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -516,7 +516,7 @@ systems: readonly AotSystemDecl[]
```
name: string
queries: readonly (readonly { comp: string; mut: boolean; }[])[]
-resources: readonly string[]
+resources: readonly { name: string; mut: boolean; }[]
symbol: string
```
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index e28602be8..e659edac0 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -516,7 +516,7 @@ systems: readonly AotSystemDecl[]
```
name: string
queries: readonly (readonly { comp: string; mut: boolean; }[])[]
-resources: readonly string[]
+resources: readonly { name: string; mut: boolean; }[]
symbol: string
```
diff --git a/sdk/src/ecs/aot/AotDispatch.ts b/sdk/src/ecs/aot/AotDispatch.ts
index 5339d735b..3bf05cfd3 100644
--- a/sdk/src/ecs/aot/AotDispatch.ts
+++ b/sdk/src/ecs/aot/AotDispatch.ts
@@ -69,7 +69,7 @@ interface QueryPlan {
interface Plan {
readonly queries: QueryPlan[];
- readonly resources: readonly string[];
+ readonly resources: readonly { name: string; mut: boolean }[];
/** Rows for every query, back to back, in query order. */
scratch: Uint32Array;
/** Rows written per query this call. */
@@ -101,11 +101,18 @@ export class AotDispatch {
const plan = this.planFor_(twin);
this.packRows_(plan, this.world.layoutEpoch());
- const resources = plan.resources.map((name) => this.runtime.addresses.resourceAt(name) ?? 0);
+ const resources = plan.resources.map((r) => this.runtime.addresses.resourceAt(r.name) ?? 0);
this.runtime.ctx.build(plan.scratch, plan.rowWords, plan.offsets, plan.counts, resources);
twin.call(this.runtime.ctx.address);
this.runtime.systems.noteCall();
+ // A resource is a MIRROR: a `ResMut` write lands in the block and nowhere
+ // else. Only the declared ones — copying a read-only mirror back would
+ // overwrite what the engine wrote this frame with a pre-call snapshot.
+ for (const r of plan.resources) {
+ if (r.mut) this.runtime.addresses.resourceWriteBack(r.name);
+ }
+
for (const cmd of this.runtime.ctx.commands()) {
// Only despawn is in the v1 record set.
if (cmd.kind === CMD_DESPAWN) this.world.despawn(cmd.a as unknown as Entity);
diff --git a/sdk/src/ecs/aot/AotResources.ts b/sdk/src/ecs/aot/AotResources.ts
index 6df22123d..9ca544c87 100644
--- a/sdk/src/ecs/aot/AotResources.ts
+++ b/sdk/src/ecs/aot/AotResources.ts
@@ -66,6 +66,24 @@ export class AotResources {
return block.byteOffset;
}
+ /**
+ * Copy `name`'s block back onto the live resource, for a system that
+ * declared `ResMut`: a mirror nobody reads back is a write that did not
+ * happen. A field the resource does not hold as a number or a boolean is
+ * skipped, because the block never carried it.
+ */
+ writeBack(name: string): void {
+ const fields = resourceFields(name);
+ const view = this.views.get(name);
+ const value = this.read(name) as Record<string, unknown> | undefined;
+ if (!fields || !view || !value) return;
+ fields.forEach((field, i) => {
+ const was = value[field];
+ if (typeof was === 'boolean') value[field] = view[i] !== 0;
+ else if (typeof was === 'number') value[field] = view[i]!;
+ });
+ }
+
dispose(): void {
for (const block of this.blocks.values()) this.memory.release(block);
this.blocks.clear();
diff --git a/sdk/src/ecs/aot/AotRuntime.ts b/sdk/src/ecs/aot/AotRuntime.ts
index 78272e994..bd0b52529 100644
--- a/sdk/src/ecs/aot/AotRuntime.ts
+++ b/sdk/src/ecs/aot/AotRuntime.ts
@@ -26,6 +26,8 @@ export interface AotAddresses {
* doing that per call rather than per row is why it is one call.
*/
resourceAt(name: string): number | undefined;
+ /** Copy the mirror back, for a resource the system declared `ResMut`. */
+ resourceWriteBack(name: string): void;
/** The definition a manifest's component NAME refers to in this world. */
componentNamed(name: string): AnyComponentDef | undefined;
}
diff --git a/sdk/src/ecs/aot/AotSystems.ts b/sdk/src/ecs/aot/AotSystems.ts
index 1ac63532d..337e02040 100644
--- a/sdk/src/ecs/aot/AotSystems.ts
+++ b/sdk/src/ecs/aot/AotSystems.ts
@@ -24,7 +24,9 @@ export interface AotSystemDecl {
readonly symbol: string;
/** One entry per declared Query, in the order the system names them. */
readonly queries: readonly (readonly { comp: string; mut: boolean }[])[];
- readonly resources: readonly string[];
+ /** One per declared Res/ResMut. `mut` is what makes a host write the mirror
+ * back after the call — without it the write is silently dropped. */
+ readonly resources: readonly { name: string; mut: boolean }[];
}
export interface AotManifest {
diff --git a/sdk/src/ecs/aot/installAot.ts b/sdk/src/ecs/aot/installAot.ts
index b59423db3..4a285b4ce 100644
--- a/sdk/src/ecs/aot/installAot.ts
+++ b/sdk/src/ecs/aot/installAot.ts
@@ -116,5 +116,6 @@ export function worldAddresses(resources: AotResources): AotAddresses {
return {
componentNamed,
resourceAt: (name: string) => resources.addressOf(name),
+ resourceWriteBack: (name: string) => resources.writeBack(name),
};
}
diff --git a/sdk/tests/aot-app.test.ts b/sdk/tests/aot-app.test.ts
index a41d5054f..faeaee984 100644
--- a/sdk/tests/aot-app.test.ts
+++ b/sdk/tests/aot-app.test.ts
@@ -11,10 +11,14 @@
*/
import { describe, it, expect } from 'vitest';
import { bootMockApp } from './helpers/mockApp';
-import { buildFadeModule, fadeManifest, FADE_PROBE_ALPHA, FADE_PROBE_C } from './helpers/aotFade';
+import {
+ buildAotModule, buildFadeModule, fadeManifest, timeScaleManifest,
+ FADE_PROBE_ALPHA, FADE_PROBE_C, TIME_SCALE_C,
+} from './helpers/aotFade';
import { FakeEngine } from './fakeEngine';
import { emccPath } from '../../build-tools/utils/emscripten.js';
import { defineComponent } from '../src/ecs/component';
+import { Time } from '../src/ecs/resource';
import { defineSystem, Schedule } from '../src/ecs/system';
import { Query, Mut } from '../src/ecs/query';
import type { AnyComponentDef } from '../src/ecs/component';
@@ -117,6 +121,22 @@ describe('an App told to run its compiled twins', () => {
expect(app.compiledSystems).toEqual({ installed: ['Fade'], calls: 3 });
});
+ it.skipIf(!EMCC)('writes a ResMut resource back, and leaves a Res one alone', async () => {
+ const wasm = buildAotModule(EMCC!, TIME_SCALE_C, 'es_sys_Speed');
+ const scaleAfter = async (mut: boolean): Promise<number> => {
+ const { app } = bootMockApp();
+ app.addSystemToSchedule(Schedule.Update, defineSystem([], () => { /* the twin is the point */ },
+ { name: 'Speed' }));
+ await app.useCompiledSystems({ host: new FakeEngine(), manifest: timeScaleManifest(mut), wasm });
+ await app.tick(1 / 60);
+ return app.getResource(Time).scale;
+ };
+ // A resource is mirrored into the block, so the twin's write reaches the
+ // world only if the host copies it back — and only when ResMut asked.
+ expect(await scaleAfter(true)).toBe(2);
+ expect(await scaleAfter(false)).toBe(1);
+ });
+
it.skipIf(!EMCC)('refuses a module built for other shapes, and the App keeps interpreting', async () => {
const { app, Fade } = fadeApp();
await expect(app.useCompiledSystems({
diff --git a/sdk/tests/helpers/aotFade.ts b/sdk/tests/helpers/aotFade.ts
index d4f0dc45f..b74a622ac 100644
--- a/sdk/tests/helpers/aotFade.ts
+++ b/sdk/tests/helpers/aotFade.ts
@@ -53,20 +53,52 @@ export const FADE_PROBE_ALPHA = -1;
export const FADE_FIELDS = ['alpha', 'step'];
-export function buildFadeModule(emcc: string, source: string = FADE_C): Uint8Array {
- const dir = mkdtempSync(path.join(tmpdir(), 'estella-fade-'));
+export function buildAotModule(emcc: string, source: string, symbol: string): Uint8Array {
+ const dir = mkdtempSync(path.join(tmpdir(), 'estella-aot-'));
mkdirSync(dir, { recursive: true });
writeFileSync(path.join(dir, 'sys.c'), source);
const out = path.join(dir, 'sys.wasm');
const built = spawnSync(emcc, [
'-std=c11', '-O2', '-ffp-contract=off', '-Wall', '-Wextra',
- ...WASM_LINK_FLAGS, '-sEXPORTED_FUNCTIONS=_es_sys_Fade',
+ ...WASM_LINK_FLAGS, `-sEXPORTED_FUNCTIONS=_${symbol}`,
'-o', out, path.join(dir, 'sys.c'),
], { encoding: 'utf8', cwd: dir, shell: process.platform === 'win32' });
if (built.status !== 0) throw new Error(`emcc failed:\n${built.stderr}`);
return readFileSync(out);
}
+export function buildFadeModule(emcc: string, source: string = FADE_C): Uint8Array {
+ return buildAotModule(emcc, source, 'es_sys_Fade');
+}
+
+/**
+ * A system that writes a RESOURCE: `Time.scale = 2`. Time is the resource with
+ * a layout, and `scale` is slot 6 of it — the order in `resourceShapes.ts` IS
+ * the layout, which is why both sides read that one file.
+ */
+export const TIME_SCALE_C = `#include <stdint.h>
+#include <string.h>
+typedef uint32_t es_addr_t;
+#define ES_PTR(a) ((unsigned char *)(a))
+typedef struct { es_addr_t queries, resources, cmdBuf, cmdCap, cmdCount, events; } EsSysCtx;
+static void st(unsigned char *p, double v) { memcpy(p, &v, 8); }
+
+void es_sys_Speed(es_addr_t ctx) {
+ const EsSysCtx *c = (const EsSysCtx *)ES_PTR(ctx);
+ const es_addr_t *res = (const es_addr_t *)ES_PTR(c->resources);
+ st(ES_PTR(res[0]) + 6u * 8u, 2.0); /* Time.scale = 2 */
+}
+`;
+
+/** What a build writes for that one, with Time declared writable or not. */
+export function timeScaleManifest(mut: boolean): AotManifest {
+ return {
+ engineAbi: engineAbiDigest(4),
+ projectShapes: projectShapeDigest([]),
+ systems: [{ name: 'Speed', symbol: 'es_sys_Speed', queries: [], resources: [{ name: 'Time', mut }] }],
+ };
+}
+
/** What a build would have written beside that module, for THIS engine. */
export function fadeManifest(
shapes = projectShapeDigest([{ name: 'Fade', fields: FADE_FIELDS }]),
diff --git a/src/esengine/aot/estella_abi.h b/src/esengine/aot/estella_abi.h
index 04d6a0aa0..81277bbd2 100644
--- a/src/esengine/aot/estella_abi.h
+++ b/src/esengine/aot/estella_abi.h
@@ -74,6 +74,9 @@ typedef struct EsSystemDecl {
void (*fn)(es_addr_t);
const EsQueryDecl *queries;
const char *const *resources;
+ /* 1 where the system declared ResMut: a host that MIRRORS a resource into
+ the block has to write that block back, or the write is dropped. */
+ const unsigned char *resourcesMut;
uint32_t queryCount;
uint32_t resourceCount;
} EsSystemDecl;
diff --git a/tests/aot/generated/move_system_decl.c b/tests/aot/generated/move_system_decl.c
index 484cb69dd..27442f09c 100644
--- a/tests/aot/generated/move_system_decl.c
+++ b/tests/aot/generated/move_system_decl.c
@@ -21,8 +21,9 @@ static const char *const es_sys_MoveSystem_q0_comps[] = { "Transform", "Mover" }
static const unsigned char es_sys_MoveSystem_q0_mut[] = { 1u, 0u };
static const EsQueryDecl es_sys_MoveSystem_queries[] = { { es_sys_MoveSystem_q0_comps, es_sys_MoveSystem_q0_mut, 2u } };
static const char *const es_sys_MoveSystem_resources[] = { "Time" };
+static const unsigned char es_sys_MoveSystem_resources_mut[] = { 0u };
const EsSystemDecl es_systems[] = {
- { "MoveSystem", es_sys_MoveSystem, es_sys_MoveSystem_queries, es_sys_MoveSystem_resources, 1u, 1u },
+ { "MoveSystem", es_sys_MoveSystem, es_sys_MoveSystem_queries, es_sys_MoveSystem_resources, es_sys_MoveSystem_resources_mut, 1u, 1u },
};
const uint32_t es_system_count = 1u;