wasm linker: implement missing logic

fix some compilation errors for reworked Emit now that it's actually
referenced

introduce DataSegment.Id for sorting data both from object files and
from the Zcu.

introduce optimization: data segment sorting includes a descending sort
on reference count so that references to data can be smaller integers
leading to better LEB encodings. this optimization is skipped for object
files.

implement uav address access function which is based on only 1 hash
table lookup to find out the offset after sorting.
This commit is contained in:
Andrew Kelley
2024-12-17 21:12:01 -08:00
parent 761387dc55
commit 458f658b42
8 changed files with 626 additions and 257 deletions

View File

@@ -620,6 +620,13 @@ pub const Nav = struct {
};
}
/// Asserts that `status == .resolved`.
pub fn isThreadLocal(nav: Nav, ip: *const InternPool) bool {
const val = nav.status.resolved.val;
if (!isVariable(ip, val)) return false;
return ip.indexToKey(val).variable.is_threadlocal;
}
/// Get the ZIR instruction corresponding to this `Nav`, used to resolve source locations.
/// This is a `declaration`.
pub fn srcInst(nav: Nav, ip: *const InternPool) TrackedInst.Index {