Bug 168264

Summary: WebAssembly: make code position independent
Product: WebKit Reporter: JF Bastien <jfbastien>
Component: JavaScriptCoreAssignee: Saam Barati <saam>
Status: RESOLVED FIXED    
Severity: Normal CC: fpizlo, ggaren, jfbastien, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 169611, 169773, 170207, 170210, 170261, 170312, 170488, 170573, 170632    
Bug Blocks: 166480, 166481    

Description JF Bastien 2017-02-13 16:14:09 PST
We'll want to be able to save a WebAssembly.Module's code in IndexDB (#166481) and postMessage (#166480) the WebAssembly.Module cheaply to other workers without having to patch pointers and duplicate physical pages used for code. This allows us to instantiate the same module waaayyy better.

Right now our implementation has some pointers baked in: &VM.topInstance, and functions for back traces. We'll want to do away with this.

The easiest and fastest thing is probably to store the topInstance in a TLS slot, and then change it when entering js->wasm, doing wasm->wasm calls, and when in a worker (nothing to do here really, it's the same mechanism).
Comment 1 JF Bastien 2017-03-13 13:59:17 PDT
There's also code in the trap handling which needs to be updated. It has ([codebegin, codeend) + VM) structures, and the signal handlers have thunks.
Comment 2 Radar WebKit Bug Importer 2017-03-29 17:23:38 PDT
<rdar://problem/31335594>
Comment 3 Saam Barati 2017-04-13 19:12:02 PDT
This is done as of:
https://trac.webkit.org/changeset/215353/webkit