|
1 | 1 | mergeInto(LibraryManager.library, {
|
2 |
| - test_dyncalls_vijdf__deps: ['$getDynCaller', '$bindDynCall', '$wbind', '$wbindArray'], |
| 2 | + test_dyncalls_vijdf__deps: [ |
| 3 | +#if WASM_DYNCALLS |
| 4 | + '$getDynCaller', '$bindDynCall', |
| 5 | +#endif |
| 6 | + '$wbind', '$wbindArray'], |
3 | 7 | test_dyncalls_vijdf: function(funcPtr) {
|
4 |
| -#if WASM_BIGINT != 2 |
| 8 | +#if WASM_DYNCALLS |
5 | 9 | // 1. Directly access a function pointer via a static signature (32-bit ABI)
|
6 | 10 | // (this is the fastest way to call a function pointer when the signature is statically known in WASM_BIGINT==0 builds)
|
7 | 11 | dynCall_vijdf(funcPtr, 1, /*lo=*/2, /*hi=*/3, 4, 5); // Available only in WASM_BIGINT != 2 builds
|
8 | 12 |
|
9 | 13 | // 2. Access a function pointer using the convenience/legacy 'dynCall' function (32-bit ABI)
|
10 | 14 | // (this form should never be used, it is suboptimal for performance, but provided for legacy compatibility)
|
11 |
| - dynCall('vijdf', funcPtr, [3, /*lo=*/4, /*hi=*/5, 6, 7]); // Available only in WASM_BIGINT != 2 builds |
| 15 | + dynCall('vijdf', funcPtr, [2, /*lo=*/3, /*hi=*/4, 5, 6]); // Available only in WASM_BIGINT != 2 builds |
12 | 16 |
|
13 | 17 | // 3. Obtain a dynamic function caller to a given signature and call it with .apply() (32-bit ABI)
|
14 | 18 | // (this form should be used when dealing with a dynamic input signature problem with varying length of function args, and funcPtr + args are fused together in one array)
|
15 |
| - getDynCaller('vijdf').apply(null, [funcPtr, 4, /*lo=*/5, /*hi=*/6, 7, 8]); // Available only in WASM_BIGINT != 2 builds |
| 19 | + getDynCaller('vijdf').apply(null, [funcPtr, 3, /*lo=*/4, /*hi=*/5, 6, 7]); // Available only in WASM_BIGINT != 2 builds |
16 | 20 |
|
17 | 21 | // 4. Obtain a function wrapper to given function pointer and call it by submitting args in an array (32-bit ABI)
|
18 | 22 | // (this form should be used when dealing with a dynamic input signature problem with varying length of function args, but funcPtr and args params are dealt with separately)
|
19 | 23 | bindDynCall('vijdf', funcPtr)([4, /*lo=*/5, /*hi=*/6, 7, 8]); // Available only in WASM_BIGINT != 2 builds
|
| 24 | +#else |
| 25 | + // Appease test runner and output the same text if not building with WASM_DYNCALLS enabled. |
| 26 | + wbind(funcPtr)(1, BigInt(2) | (BigInt(3) << BigInt(32)), 4, 5); |
| 27 | + wbind(funcPtr)(2, BigInt(3) | (BigInt(4) << BigInt(32)), 5, 6); |
| 28 | + wbind(funcPtr)(3, BigInt(4) | (BigInt(5) << BigInt(32)), 6, 7); |
| 29 | + wbind(funcPtr)(4, BigInt(5) | (BigInt(6) << BigInt(32)), 7, 8); |
20 | 30 | #endif
|
21 | 31 |
|
22 | 32 | #if WASM_BIGINT
|
23 | 33 | // 5. Directly access a function pointer via a static signature (64-bit ABI)
|
24 | 34 | // (this is the fastest way to call a function pointer when the signature is statically known in WASM_BIGINT>0 builds)
|
25 |
| - wbind(funcPtr)(2, BigInt(3) | (BigInt(4) << BigInt(32)), 5, 6); // Available in all builds, but in WASM_BIGINT==0 builds cannot be used to call int64 signatures |
| 35 | + wbind(funcPtr)(5, BigInt(6) | (BigInt(7) << BigInt(32)), 8, 9); // Available in all builds, but in WASM_BIGINT==0 builds cannot be used to call int64 signatures |
26 | 36 |
|
27 | 37 | // 6. Obtain an array form access to the specified signature. (64-bit ABI)
|
28 | 38 | // (this form should be used when dealing with a dynamic input signature problem with varying length of function args)
|
29 |
| - wbindArray(funcPtr)([5, BigInt(6) | (BigInt(7) << BigInt(32)), 8, 9]); // Available in all builds, but in WASM_BIGINT==0 builds cannot be used to call int64 signatures |
| 39 | + wbindArray(funcPtr)([6, BigInt(7) | (BigInt(8) << BigInt(32)), 9, 10]); // Available in all builds, but in WASM_BIGINT==0 builds cannot be used to call int64 signatures |
| 40 | +#else |
| 41 | + // Appease test runner and output the same text if not building with WASM_BIGINT enabled. |
| 42 | + dynCall_vijdf(funcPtr, 5, /*lo=*/6, /*hi=*/7, 8, 9); |
| 43 | + dynCall_vijdf(funcPtr, 6, /*lo=*/7, /*hi=*/8, 9, 10); |
30 | 44 | #endif
|
31 | 45 | },
|
32 | 46 |
|
33 | 47 | test_dyncalls_iii: function(funcPtr) {
|
34 |
| -#if WASM_BIGINT != 2 |
| 48 | +#if WASM_DYNCALLS |
35 | 49 | // 1. Directly access a function pointer via a static signature (32-bit ABI)
|
36 | 50 | // (this is the fastest way to call a function pointer when the signature is statically known in WASM_BIGINT==0 builds)
|
37 | 51 | var ret = dynCall_iii(funcPtr, 1, 2); // Available only in WASM_BIGINT != 2 builds
|
38 | 52 | console.log('iii returned ' + ret);
|
39 | 53 |
|
40 | 54 | // 2. Access a function pointer using the convenience/legacy 'dynCall' function (32-bit ABI)
|
41 | 55 | // (this form should never be used, it is suboptimal for performance, but provided for legacy compatibility)
|
42 |
| - var ret = dynCall('iii', funcPtr, [3, 4]); // Available only in WASM_BIGINT != 2 builds |
| 56 | + var ret = dynCall('iii', funcPtr, [2, 3]); // Available only in WASM_BIGINT != 2 builds |
43 | 57 | console.log('iii returned ' + ret);
|
44 | 58 |
|
45 | 59 | // 3. Obtain a dynamic function caller to a given signature and call it with .apply() (32-bit ABI)
|
46 | 60 | // (this form should be used when dealing with a dynamic input signature problem with varying length of function args, and funcPtr + args are fused together in one array)
|
47 |
| - var ret = getDynCaller('iii').apply(null, [funcPtr, 4, 5]); // Available only in WASM_BIGINT != 2 builds |
| 61 | + var ret = getDynCaller('iii').apply(null, [funcPtr, 3, 4]); // Available only in WASM_BIGINT != 2 builds |
48 | 62 | console.log('iii returned ' + ret);
|
49 | 63 |
|
50 | 64 | // 4. Obtain a function wrapper to given function pointer and call it by submitting args in an array (32-bit ABI)
|
51 | 65 | // (this form should be used when dealing with a dynamic input signature problem with varying length of function args, but funcPtr and args params are dealt with separately)
|
52 |
| - var ret = bindDynCall('iii', funcPtr)([5, 6]); // Available only in WASM_BIGINT != 2 builds |
| 66 | + var ret = bindDynCall('iii', funcPtr)([4, 5]); // Available only in WASM_BIGINT != 2 builds |
53 | 67 | console.log('iii returned ' + ret);
|
| 68 | +#else |
| 69 | + // Appease test runner and output the same text if not building with WASM_DYNCALLS enabled. |
| 70 | + console.log('iii returned ' + wbind(funcPtr)(1, 2)); |
| 71 | + console.log('iii returned ' + wbind(funcPtr)(2, 3)); |
| 72 | + console.log('iii returned ' + wbind(funcPtr)(3, 4)); |
| 73 | + console.log('iii returned ' + wbind(funcPtr)(4, 5)); |
54 | 74 | #endif
|
55 | 75 |
|
56 | 76 | // 5. Directly access a function pointer via a static signature (64-bit ABI)
|
57 | 77 | // (this is the fastest way to call a function pointer when the signature is statically known in WASM_BIGINT>0 builds)
|
58 |
| - var ret = wbind(funcPtr)(2, 3); // Available in all builds, but in WASM_BIGINT==0 builds cannot be used to call int64 signatures |
| 78 | + var ret = wbind(funcPtr)(5, 6); // Available in all builds, but in WASM_BIGINT==0 builds cannot be used to call int64 signatures |
59 | 79 | console.log('iii returned ' + ret);
|
60 | 80 |
|
61 | 81 | // 6. Obtain an array form access to the specified signature. (64-bit ABI)
|
|
0 commit comments