|
201 | 201 | /// 2) and 3): The same as 2) and 3) in Emscripten SjLj. |
202 | 202 | /// (setjmpTable/setjmpTableSize initialization + setjmp callsite |
203 | 203 | /// transformation) |
| 204 | +/// functionInvocationId |
| 205 | +/// |
| 206 | +/// 2) In the function entry that calls setjmp, initialize |
| 207 | +/// functionInvocationId as follows: |
| 208 | +/// |
| 209 | +/// functionInvocationId = alloca() |
| 210 | +/// |
| 211 | +/// 3) Lower |
| 212 | +/// setjmp(env) |
| 213 | +/// into |
| 214 | +/// __wasm_setjmp(env, label, functionInvocationId) |
| 215 | +/// |
| 216 | +/// A BB with setjmp is split into two after setjmp call in order to |
| 217 | +/// make the post-setjmp BB the possible destination of longjmp BB. |
204 | 218 | /// |
205 | 219 | /// 4) Create a catchpad with a wasm.catch() intrinsic, which returns the value |
206 | 220 | /// thrown by __wasm_longjmp function. In Emscripten library, we have this |
|
232 | 246 | /// function, we jump to the beginning of the function, which contains a switch |
233 | 247 | /// to each post-setjmp BB. Again, in Emscripten SjLj, this switch is added for |
234 | 248 | /// every longjmpable callsite; in Wasm SjLj we do this only once at the top of |
235 | | -/// the function. (after setjmpTable/setjmpTableSize initialization) |
| 249 | +/// the function. (after functionInvocationId initialization) |
236 | 250 | /// |
237 | 251 | /// The below is the pseudocode for what we have described |
238 | 252 | /// |
239 | 253 | /// entry: |
240 | | -/// Initialize setjmpTable and setjmpTableSize |
| 254 | +/// Initialize functionInvocationId |
241 | 255 | /// |
242 | 256 | /// setjmp.dispatch: |
243 | 257 | /// switch %label { |
|
260 | 274 | /// %longjmp.args = wasm.catch() ;; struct __WasmLongjmpArgs |
261 | 275 | /// %env = load 'env' field from __WasmLongjmpArgs |
262 | 276 | /// %val = load 'val' field from __WasmLongjmpArgs |
263 | | -/// %label = testSetjmp(mem[%env], setjmpTable, setjmpTableSize); |
| 277 | +/// %label = __wasm_setjmp_test(%env, functionInvocationId); |
264 | 278 | /// if (%label == 0) |
265 | 279 | /// __wasm_longjmp(%env, %val) |
266 | 280 | /// catchret to %setjmp.dispatch |
267 | 281 | /// |
268 | | -/// * Wasm setjmp / longjmp handling (with -experimental-wasm-enable-alt-sjlj) |
269 | | -/// |
270 | | -/// The translation is basically same as what we do for |
271 | | -/// "Wasm setjmp / longjmp handling" w/o -experimental-wasm-enable-alt-sjlj. |
272 | | -/// |
273 | | -/// The differences are: |
274 | | -/// |
275 | | -/// - We do not use malloc'ed tables. |
276 | | -/// |
277 | | -/// - On the entry of setjmp-calling functions, we initialize a pointer |
278 | | -/// to identify the function invocation using alloc(). |
279 | | -/// |
280 | | -/// - We use simpler ABI functions with different names. |
281 | | -/// |
282 | 282 | ///===----------------------------------------------------------------------===// |
283 | 283 |
|
284 | 284 | #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" |
|
0 commit comments