Skip to content

Commit 9c21d8e

Browse files
committed
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp: comment
1 parent ff285f7 commit 9c21d8e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@
201201
/// 2) and 3): The same as 2) and 3) in Emscripten SjLj.
202202
/// (setjmpTable/setjmpTableSize initialization + setjmp callsite
203203
/// 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.
204218
///
205219
/// 4) Create a catchpad with a wasm.catch() intrinsic, which returns the value
206220
/// thrown by __wasm_longjmp function. In Emscripten library, we have this
@@ -232,12 +246,12 @@
232246
/// function, we jump to the beginning of the function, which contains a switch
233247
/// to each post-setjmp BB. Again, in Emscripten SjLj, this switch is added for
234248
/// 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)
236250
///
237251
/// The below is the pseudocode for what we have described
238252
///
239253
/// entry:
240-
/// Initialize setjmpTable and setjmpTableSize
254+
/// Initialize functionInvocationId
241255
///
242256
/// setjmp.dispatch:
243257
/// switch %label {
@@ -260,25 +274,11 @@
260274
/// %longjmp.args = wasm.catch() ;; struct __WasmLongjmpArgs
261275
/// %env = load 'env' field from __WasmLongjmpArgs
262276
/// %val = load 'val' field from __WasmLongjmpArgs
263-
/// %label = testSetjmp(mem[%env], setjmpTable, setjmpTableSize);
277+
/// %label = __wasm_setjmp_test(%env, functionInvocationId);
264278
/// if (%label == 0)
265279
/// __wasm_longjmp(%env, %val)
266280
/// catchret to %setjmp.dispatch
267281
///
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-
///
282282
///===----------------------------------------------------------------------===//
283283

284284
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"

0 commit comments

Comments
 (0)