[PATCH] D59343: [WebAssembly] Use passive segments when memory is shared

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 11:19:08 PDT 2019


tlively planned changes to this revision.
tlively added a comment.

This CL should not be merged until Chrome 75 releases to stable on June 4.



================
Comment at: lld/wasm/MarkLive.cpp:81
     Enqueue(WasmSym::CallCtors);
+  }
+
----------------
sbc100 wrote:
> The coding style for lld is to not include braces for single line blocks.
> 
> We need to think a little more about this is going to work for non-PIC code.  Up until now its been possible to write non-PIC static executable that runs the ctors itself via some arbitrary function. e.g.
> 
> ```
> int mystartfunc() {
>   __wasm_call_ctors();
>   return main()
> }
> ```
> 
> This part of the markLive is designed to keep `__wasm_call_ctors` alive even if the user never references it (since its to be exported in the PIC case).
> 
> So.. in the non-PIC case, even for shared-memory, I think we should let the normal GC process take its course.   If they user forgets to reference __wasm_call_ctors, then there is not way it can ever be called, so we might as well let it be GC'd.
> 
> But the dependency setup here is getting a little complicated.  Really what we want to say is something like:
> 
> "if CallCtors is alive then ApplyRelocs need to be too" and the same for InitMemory.  Perhaps we should add `Dependencies()` to SyntheticFunction?
> 
> For now I'm ok with the conservative approach of just keeping InitMemory alive as long as SharedMemory is present.
I looked into adding Dependencies, but because `markLive` happens before anything in Writer.cpp there didn't seem to be a good way to set that up. I simplified the logic in MarkLive.cpp though, now that I understand what it is doing more.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59343/new/

https://reviews.llvm.org/D59343





More information about the llvm-commits mailing list