feat(compiler, wasm): do not hard code memory addresses to uninitialized sections

Rather, allocate unitialized segments as needed.
This commit is contained in:
vsariola
2021-04-15 23:24:58 +03:00
parent f330ccebf7
commit f3cf4a52ce
6 changed files with 116 additions and 38 deletions

View File

@ -1,5 +1,5 @@
{{- if not .Output16Bit }}
(i64.store (global.get $outputBufPtr) (i64.load (i32.const 4128))) ;; load the sample from left & right channels as one 64bit int and store it in the address pointed by outputBufPtr
(i64.store (global.get $outputBufPtr) (i64.load (i32.const {{index .Labels "su_globalports"}}))) ;; load the sample from left & right channels as one 64bit int and store it in the address pointed by outputBufPtr
(global.set $outputBufPtr (i32.add (global.get $outputBufPtr) (i32.const 8))) ;; advance outputbufptr
{{- else }}
(local.set $channel (i32.const 0))
@ -7,7 +7,7 @@
(i32.store16 (global.get $outputBufPtr) (i32.trunc_f32_s
(f32.mul
(call $clip
(f32.load offset=4128 (i32.mul (local.get $channel) (i32.const 4)))
(f32.load offset={{index .Labels "su_globalports"}} (i32.mul (local.get $channel) (i32.const 4)))
)
(f32.const 32767)
)
@ -16,4 +16,4 @@
(br_if $channelLoop (local.tee $channel (i32.eqz (local.get $channel))))
end
{{- end }}
(i64.store (i32.const 4128) (i64.const 0)) ;; clear the left and right ports
(i64.store (i32.const {{index .Labels "su_globalports"}}) (i64.const 0)) ;; clear the left and right ports