Re:The Bytecode Alliance: Building a secure, composable futu...
by AnIdiotOnTheNet on Tuesday November 12, 2019 @01:16PM
(#21516505)
Last I checked WebAssembly still didn't have a way of actually freeing memory it has allocated either.
[ Parent
| on HN ]
Re:The Bytecode Alliance: Building a secure, composable futu...
by thrax on Tuesday November 12, 2019 @01:38PM
(#21516729)
You give it a heap. It doesn't allocate memory. It may allocate within its own heap, using whatever allocator/gc strategy it inherits from it's host language.
Re:The Bytecode Alliance: Building a secure, composable futu...
by kllrnohj on Tuesday November 12, 2019 @02:29PM
(#21517247)
Which means it can't free. But that's also not accurate, anyway, there's a brk() method to grow the heap. Which is such a bad starting point for a new runtime.
Re:The Bytecode Alliance: Building a secure, composable futu...
by saagarjha on Tuesday November 12, 2019 @06:27PM
(#21519394)
Would it be impossible to implement mmap and sbrk in the runtime?
Re:The Bytecode Alliance: Building a secure, composable futu...
by kllrnohj on Tuesday November 12, 2019 @06:48PM
(#21519525)
mmap is arguably the only thing it should have had in the first place. brk/sbrk is fairly dead.
Re:The Bytecode Alliance: Building a secure, composable futu...
by saagarjha on Wednesday November 13, 2019 @04:47AM
(#21522471)
$ strace /bin/ls 2>&1 | grep brk
brk(NULL) = 0x55fb032b3000
brk(NULL) = 0x55fb032b3000
brk(0x55fb032d4000) = 0x55fb032d4000
Re:The Bytecode Alliance: Building a secure, composable futu...
by wahern on Wednesday November 13, 2019 @11:50PM
(#21532881)
$ ktrace /bin/ls >/dev/null
$ kdump | grep brk | wc -l
0
$ kdump | grep mmap | wc -l
130
glibc, musl, and jemalloc got the memo, they just couldn't be bothered to stop using brk by default. They're all capable of using mmap exclusively, however, because whether or not brk is actually dead, there's long been consensus that mmap is the better abstraction on balance, particularly given the benefit of ASLR. So there's little reason to support brk instead of mmap for compatibility. Presumably it was chosen for the convenience of WebAssembly implementations--contiguous, flat memory is a great simplifier of VM, JIT, and even traditional AoT architectures.
Re:The Bytecode Alliance: Building a secure, composable futu...
by AnIdiotOnTheNet on Tuesday November 12, 2019 @04:21PM
(#21518303)
Right, and while you can grow the heap you can't give any of it back, so you can't really dynamically contract your memory without restarting the process.
Re:The Bytecode Alliance: Building a secure, composable futu...
by TomMarius on Tuesday November 12, 2019 @01:38PM
(#21516732)
I thought that was the host's work. You import a function that does it. If we're talking about shared objects. Your own module's memory is managed by you (or your language's runtime)