MCPcopy Index your code
hub / github.com/nodejs/node / testCallBinopVoid

Function testCallBinopVoid

deps/v8/test/mjsunit/wasm/ffi.js:244–304  ·  view source on GitHub ↗
(type, func, check)

Source from the content-addressed store, hash-verified

242testCallFFI(returnValue(objWithValueOf), checkReturn(198));
243
244function testCallBinopVoid(type, func, check) {
245 var passed_length = -1;
246 var passed_a = -1;
247 var passed_b = -1;
248 var args_a = -1;
249 var args_b = -1;
250
251 ffi = {"": {func: function(a, b) {
252 passed_length = arguments.length;
253 passed_a = a;
254 passed_b = b;
255 args_a = arguments[0];
256 args_b = arguments[1];
257 }}};
258
259 var builder = new WasmModuleBuilder();
260
261 builder.addImport("", "func", makeSig_v_xx(type));
262 builder.addFunction("main", makeSig_r_xx(kWasmI32, type))
263 .addBody([
264 kExprLocalGet, 0, // --
265 kExprLocalGet, 1, // --
266 kExprCallFunction, 0, // --
267 kExprI32Const, 33 // --
268 ]) // --
269 .exportFunc()
270
271 var main = builder.instantiate(ffi).exports.main;
272
273 print("testCallBinopVoid", type);
274
275 for (var i = 0; i < 100000; i += 10003.1) {
276 var a = 22.5 + i, b = 10.5 + i;
277 var r = main(a, b);
278 assertEquals(33, r);
279 assertEquals(2, passed_length);
280 var expected_a, expected_b;
281 switch (type) {
282 case kWasmI32: {
283 expected_a = a | 0;
284 expected_b = b | 0;
285 break;
286 }
287 case kWasmF32: {
288 expected_a = Math.fround(a);
289 expected_b = Math.fround(b);
290 break;
291 }
292 case kWasmF64: {
293 expected_a = a;
294 expected_b = b;
295 break;
296 }
297 }
298
299 assertEquals(expected_a, args_a);
300 assertEquals(expected_b, args_b);
301 assertEquals(expected_a, passed_a);

Callers 1

ffi.jsFile · 0.70

Calls 10

addImportMethod · 0.95
addFunctionMethod · 0.95
instantiateMethod · 0.95
makeSig_v_xxFunction · 0.70
makeSig_r_xxFunction · 0.70
mainFunction · 0.70
printFunction · 0.50
assertEqualsFunction · 0.50
exportFuncMethod · 0.45
addBodyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…