diff options
| author | Luuk de Gram <luuk@degram.dev> | 2022-01-19 19:17:34 +0100 |
|---|---|---|
| committer | Luuk de Gram <luuk@degram.dev> | 2022-01-19 22:29:36 +0100 |
| commit | b9fe6a93ff51ecb5ce770c78f463c38a0620de49 (patch) | |
| tree | a155cb583568eb2136dfb8fd42ff40b9c41245f1 /src/link | |
| parent | 1fe1e4d29207de8c972fcc1b61266fbaddb07d63 (diff) | |
| download | zig-b9fe6a93ff51ecb5ce770c78f463c38a0620de49.tar.gz zig-b9fe6a93ff51ecb5ce770c78f463c38a0620de49.zip | |
wasm: Re-use genTypedValue for constants
When a constant will be passed by reference, such as a struct, we will call into genTypedValue
to lower the constant to bytes and store them into the `rodata` section. We will then return the address
of this constant as a `WValue`.
This change means we will have all constants lowered during compilation time, and no longer have
to sacrifice runtime to lower them onto the stack.
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Wasm.zig | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 6e9e7bcbd2..82c1f1f630 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -323,6 +323,7 @@ pub fn createLocalSymbol(self: *Wasm, decl: *Module.Decl, ty: Type) !u32 { var atom = Atom.empty; atom.alignment = ty.abiAlignment(self.base.options.target); + try self.symbols.ensureUnusedCapacity(self.base.allocator, 1); if (self.symbols_free_list.popOrNull()) |index| { atom.sym_index = index; |
