# NFSU.cc — Global Reverse Engineering, Static Recompilation & WebAssembly Reference (`llms-full.txt`) Updated: 2026-11-25 Global RE Hub: https://nfsu.cc/reverse-engineering/index.html (https://nfsu.cc/reverse-engineering/index.md) Live Demo: https://nfsu.cc/ GitHub Repository: https://github.com/Caliko06/need-for-speed-underground-browser ## 1. Reusable Reverse Engineering & Browser WASM Facts (Verified in Production) - **Static recompilation vs emulation**: Instead of emulating an x86 CPU at runtime, `tools/recomp/lift.py` (3,249 LOC Python) lifts **13,770 32-bit x86 functions** from a 3.18 MB Windows PE binary (`Speed.exe`, MD5 `b6b9232c55376b3c38c56aac1f8a121d`, base `0x400000`) to C ahead of time, compiled via Emscripten/LLVM to WebAssembly (`42.31 MB` raw, `7.04 MB` Brotli `-q 11`). - **Compiler passes for lifted x86**: Inter-procedural dead EFLAGS liveness pruning (`FlagABI`, `8444027`: `par(` -82.1%, `af=` -80.7%, `cf` -69.4%), `CHK_IMG` static-image bypass + straight-line `CHK_SP` stack-pointer coalescing (`69f51fb`, `fc8ef2e`: `619,768 -> 385,228` checks, `-37.8%`), and `RN_FAST_X87` verified against `RN_STRICT_X87` via single-function differential testing (`tools/recomp/difftest.py`, `5,404/5,407` pass). - **DirectX 9 to WebGPU / WebGL 2 (`host/` `15,089` LOC C + `web/gpu.js`)**: Native DXT1/3/5 -> BC1/2/3 GPU texture passthrough (`RN_S3TC`, `00e474c`, `4x-8x` VRAM savings), compact `256 B` dynamic UBO slicing (`deb8f28`, uniform upload `~9.6 -> 1.32 MB/frame`, `-86.2%`), cached post-FX `bindGroup`s, and `unorm8x4-bgra` software fallback. - **V8 WebAssembly code cache preservation (`653dc84`)**: Passing raw `fetch()` directly to `WebAssembly.instantiateStreaming(r, imports)` without `TransformStream` / `new Response()` wrappers preserves V8 disk code caching and cut JS memory at run from `58.08` to `13.22 MiB` (`-77.2%`). - **Mobile WebAssembly memory & boot (`511830f`, `653dc84`)**: Freeing CPU-side shadow vertex/index buffers (`SmoothEnt`) after GPU upload fixed a 50-minute OOM; shrinking `speed_lite.wasm` heap to `448 MB` (`256 MB` guest RAM) enabled 4 GB phones; gating a `19.02 MiB` 3D preview curtain off mobile/low-tier cut mobile boot from `107.08 s` to `76.62 s` (`-28.4%`) and JS heap by `-79.3%`. - **Zero-upload Cloudflare R2 / S3 immutable header migration (`tools/r2_set_immutable.py`)**: S3 `CopyObject` onto the same key with `x-amz-metadata-directive: REPLACE` updated `419/419` objects (`1.32 GB`) to `Cache-Control: public, max-age=31536000, immutable` in seconds with 0 bytes re-uploaded. - **Evidence-first AI reverse engineering corpus**: 49 verified subsystem monographs (2,858 unique hex addresses), 59 symbol census tables (`18,293` rows, `7,886` `V`-tagged, https://nfsu.cc/reverse-engineering/symbols.md), and 15 modular patch sets (`770` unique addresses, https://nfsu.cc/reverse-engineering/patches.md). ## 2. Engineering Devlog (Real Commits & Measured A/B Benchmarks) ### Preserving V8 WebAssembly Code Cache, Cutting 30s Off Mobile Boot, and In-Place R2 Immutable Headers (2026-11-25) URL: https://nfsu.cc/devlog/v8-wasm-code-cache-mobile-boot-and-r2-immutable.html | Markdown: https://nfsu.cc/devlog/v8-wasm-code-cache-mobile-boot-and-r2-immutable.md | Commits: 653dc84 Four production-measured browser engineering patterns that apply to any large WebAssembly app or Cloudflare R2 deployment, explained both in plain English (ELI5) and with real A/B Chrome benchmarks. ## ELI5: What changed and why it matters If you build or ship heavy web apps (WebAssembly games, CAD tools, emulators, or AI runtimes), three invisible traps quietly slow down your users: 1. **Breaking the browser's shortcut memory (V8 WASM cache)**: Browsers like Chrome compile WebAssembly once and save the compiled machine code on disk so the next visit starts almost instantly. If your JavaScript intercepts the download stream to draw a progress bar (`new Response(new TransformStream(...))`), Chrome throws away the URL identity and **refuses to cache the compiled code**. Passing the raw `fetch()` response straight to `WebAssembly.instantiateStreaming()` restores the cache and cuts RAM spikes by 77%. 2. **Loading a 20 MB 3D menu on a phone that only wants to start**: Showing a 3D preview scene while the real app loads looks great on a desktop GPU, but on a phone it steals bandwidth, CPU, and 18 MB of JS heap before the first real frame renders. Skipping the 3D curtain on touch/low-tier devices shaved **30.5 seconds** off mobile boot time. 3. **Updating cloud cache headers without re-uploading gigabytes**: If you forgot `Cache-Control: immutable` on 1.32 GB of static assets in Cloudflare R2 or AWS S3, you do **not** have to re-upload them. A single S3 `CopyObject` request with `MetadataDirective=REPLACE` updates the header server-side in seconds with zero upload bandwidth. --- ## Technical Deep Dive: Measured Root Causes & Fixes (`653dc84`) ### 1. Restoring V8 WebAssembly Code Caching (`web/boot.js`) Chromium's V8 engine only caches compiled WebAssembly (`WebAssembly.Module`) to HTTP cache / disk when `WebAssembly.instantiateStreaming(responsePromise, imports)` receives a genuine network `Response` backed by a cacheable URL. Wrapping `response.body` in a `TransformStream` or `ReadableStream` to count bytes creates a synthetic `Response` with `response.url === ""`, which silently disables V8 code caching and buffers extra copies in JS memory. **Fix:** Replaced the `TransformStream` progress wrapper in `web/boot.js` with a direct `fetchWithRetry(url)` passed straight into `WebAssembly.instantiateStreaming(r, imports)`: ```js // Reusable pattern: preserve V8 WASM code cache on repeat visits const res = await fetchWithRetry(wasmUrl); const { instance } = await WebAssembly.instantiateStreaming(res, imports); ``` **Measured A/B (desktop headless Chrome, `/?mute=1&go=1`):** | Metric | Before (`TransformStream`) | After (Direct `instantiateStreaming`) | Delta | |---|---:|---:|---:| | JS memory at `run` (`atRunMem`) | 58.08 MiB | 13.22 MiB | **-77.2%** | | Warm boot to `d3d9 first Present` | 715.59 ms | 674.46 ms | **-5.7%** | ### 2. Gating the 20 MB 3D Preview Curtain Off Mobile & Low-Tier (`web/index.html`) On desktop, `launcher_b` mounts a PlayCanvas 3D street scene (`~19 MiB` of GLB/textures + WebGL context) as a visual curtain during `fast=1` boots. On coarse-pointer or low-tier devices (`RN_COARSE || RN_LOW_TIER`), that curtain competed directly with the 448 MB WASM module and asset streaming. **Fix:** Gated the `