diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-28 16:25:01 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-28 16:25:01 -0700 |
| commit | 41be002e89358649da46c33c8245aa786afdad6a (patch) | |
| tree | fcd5fb874fe4c5596ba8fcaa45b82eede5ac558e /skills/chapter25-codex-notes.md | |
| parent | 75390f477ac7d4568ac02f97358d146ff9879d6e (diff) | |
| download | Simple-41be002e89358649da46c33c8245aa786afdad6a.tar.gz Simple-41be002e89358649da46c33c8245aa786afdad6a.zip | |
Extend smaller-width C results to full width
Diffstat (limited to 'skills/chapter25-codex-notes.md')
| -rw-r--r-- | skills/chapter25-codex-notes.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/skills/chapter25-codex-notes.md b/skills/chapter25-codex-notes.md index 1f75814c..5cb7dc53 100644 --- a/skills/chapter25-codex-notes.md +++ b/skills/chapter25-codex-notes.md @@ -438,9 +438,20 @@ Consequences: selection, which removes the lifetime edge from machine operands before scheduling and cloning. Never substitute relocation-array growth or a linker address scan for correct retention. +- The direct-call exemption requires the pointer to occur only as the call + target: `call.fptr()==ptr && call._inputs.find(ptr)==call.nIns()-1`. A pointer + also passed as an argument still needs unknown callers retained. - Validate returned addresses by calling them. Include anonymous and library functions, plus unused-body removal. Methods gain a receiver argument in 23; native/emulator probes must honor it even when the body does not use self. + A wrong native signature initially passed because a stale argument register + happened to contain the right pointer; a passing call alone cannot prove ABI + correctness. +- Chapter 21's empty-main heuristic can remove main for `return {->42;};`. + Use `if(arg) return {->42;}; return {->43;};` to probe returned addresses, + and invoke main explicitly at its encoding offset. Its CodeGen.driver cannot + resume after an explicit opto() call; use the remaining phases explicitly or + start a fresh driver. - Function-address encoding begins in 21. RISC-V AUIPC/ADDI occupies eight bytes; patch the second instruction at opStart+4 and round the high part for signed low bits. Anonymous bodies need emitted code, but no exported ELF symbol. @@ -467,6 +478,21 @@ Consequences: ## Serialization and code generation +- Narrow direct C integer returns are normalized during instruction selection + in 22-25, using the declaration's width and signedness. An ideal cast would + fold away because the CallEnd already advertises the narrow semantic type. + In 25, identify external functions through their FIDX mapping: ExternNode can + fold into an ordinary ConstantNode. x86 upper return bits can be garbage; + RV64 sign-extends even u32 returns, which Simple must zero-extend again. + Native/emulator regressions start in Chapter22Test; Chapter25Test's errno + check also verifies the negative close result after importing sys.o. +- Machine expansions must use the copying constructor and directly populate + input arrays, leaving reverse edges to CodeGen._instOuts. Using the ordinary + edge-registering constructor duplicates uses; the narrow-return expansion + exposed this during FileIO register splitting. +- Keep Serialize's magic C0DE unchanged for now. Cliff explicitly unwound the + proposed magic bump; a real format version is future work. Rebuild all object + files after incompatible layout changes while there are no external users. - Class storage must be writable during `<clinit>`, even when all final field values are constant. `Encoding.Relo.readOnly()` owns this distinction for pool emission, ELF symbols, in-memory linking, and assembly printing. Ordinary |
