Debian Codegraph @

js/src/jit-test/tests/debug/wasm-14.js

raw
1 // |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled(); skip-if: true
2 // An extension of wasm-10.js, testing that wasm GC objects are inspectable in locals.
3
4 // As of bug 1825098, this test is disabled. (skip-if: true)
5 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1836320
6
7 load(libdir + "wasm.js");
8
9 function monitorLocalValues(wast, lib, expected) {
10 function setupFrame(frame) {
11 var locals = {};
12 framesLocals.push(locals);
13 frame.environment.names().forEach(n => {
14 locals[n] = [frame.environment.getVariable(n)];
15 });
16 frame.onStep = function () {
17 frame.environment.names().forEach(n => {
18 var prevValues = locals[n];
19 if (!prevValues) {
20 locals[n] = prevValues = [void 0];
21 }
22 var value = frame.environment.getVariable(n);
23 if (prevValues[prevValues.length - 1] !== value) {
24 prevValues.push(value);
25 }
26 });
27 }
28 }
29 var framesLocals = [];
30 wasmRunWithDebugger(wast, lib,
31 function ({dbg}) {
32 dbg.onEnterFrame = function(frame) {
33 if (frame.type == "wasmcall") {
34 setupFrame(frame);
35 }
36 }
37 },
38 function ({error}) {
39 assertEq(error, undefined);
40 }
41 );
42 assertEq(framesLocals.length, expected.length);
43 for (var i = 0; i < framesLocals.length; i++) {
44 var frameLocals = framesLocals[i];
45 var expectedLocals = expected[i];
46 var localsNames = Object.keys(frameLocals);
47 assertEq(localsNames.length, Object.keys(expectedLocals).length);
48 for (const n of localsNames) {
49 const actualValues = frameLocals[n];
50 const expectedValues = expectedLocals[n];
51 for (let j = 0; j < expectedValues.length; j++) {
52 const actual = actualValues[j];
53 const expected = expectedValues[j];
54 if (expected === null) {
55 assertEq(actual, null, `values differed at index ${j}`);
56 } else {
57 for (const key of Object.keys(expected)) {
58 const actualField = actual.getProperty(key).return;
59 const expectedField = expected[key];
60 assertEq(actualField, expectedField, `values differed for key "${key}"`);
61 }
62 }
63 }
64 }
65 }
66 }
67
68 monitorLocalValues(
69 `(module
70 (type (struct i32 i64))
71 (func (export "test")
72 (local (ref null 0))
73 (local.set 0 (struct.new 0 (i32.const 1) (i64.const 2)))
74 )
75 )`,
76 undefined,
77 [{var0: [null, {0: 1, 1: 2n}]}]
78 );
79 monitorLocalValues(
80 `(module
81 (type (array i32))
82 (func (export "test")
83 (local (ref null 0))
84 (i64.const 3)
85 (local.set 0 (array.new 0 (i32.const 123) (i32.const 2)))
86 drop
87 )
88 )`,
89 undefined,
90 [{var0: [null, {length: 2, 0: 123, 1: 123}]}]
91 );