# wasm-linker: parse symbols into atoms lazily · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/8856ba75059f74a326d1f8d3af40a30c5a3ac1ed)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 8856ba75059f74a326d1f8d3af40a30c5a3ac1ed

Requested commit: 8856ba75059f74a326d1f8d3af40a30c5a3ac1ed

Commit: 8856ba75059f74a326d1f8d3af40a30c5a3ac1ed

Tree: 35ceb0bd2015c4bf89dda04c8ffc2bc49633c3bf

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm-linker: parse symbols into atoms lazily

Rather than parsing every symbol into an atom, we now only parse them
into an atom when such atom is marked. This means garbage-collected
symbols will also not be parsed into atoms, and neither are discarded
symbols which have been resolved by other symbols. (Such as multiple
weak symbols).

This also introduces a binary search for finding the start index into
the list of relocations. This speeds up finding the corresponding
relocations tremendously as they're ordered ascended by address.

Lastly, we re-use the memory of atom's data as well as relocations
instead of duplicating it. This means we half the memory usage of
atom's data and relocations for linked object files. As we are
aware of decls and synthetic atoms, we free the memory of those
atoms indepedently of the atoms of object files to prevent double-frees.

```

## Parents

- [c986c6c90a5746cb671177e486a77bd78a5946b0](https://git.cafe/gitcafe/zig/commit/c986c6c90a5746cb671177e486a77bd78a5946b0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/8856ba75059f74a326d1f8d3af40a30c5a3ac1ed?format=markdown)
