aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/regress/regress-9165.js
blob: 1de6e9db2a43b58c7ba5c23d00b9a9a8683b5ad9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --experimental-wasm-anyref

load("test/mjsunit/wasm/wasm-module-builder.js");

let kSig_r_i = makeSig([kWasmI32], [kWasmAnyRef]);

(function TestMergeOfAnyFuncIntoAnyRef() {
  print(arguments.callee.name);
  let builder = new WasmModuleBuilder();
  builder.addFunction("merge", kSig_r_i)
      .addLocals({anyref_count: 1, anyfunc_count: 1})
      .addBody([
        kExprGetLocal, 0,
        kExprI32Eqz,
        kExprIf, kWasmAnyRef,
          kExprGetLocal, 1,
        kExprElse,
          kExprGetLocal, 2,
        kExprEnd,
      ]).exportFunc();
  let instance = builder.instantiate();
  assertEquals(null, instance.exports.merge(0));
  assertEquals(null, instance.exports.merge(1));
})();

(function TestMergeOfAnyFuncIntoNullRef() {
  print(arguments.callee.name);
  let builder = new WasmModuleBuilder();
  builder.addFunction("merge", kSig_r_i)
      .addLocals({anyfunc_count: 1})
      .addBody([
        kExprGetLocal, 0,
        kExprI32Eqz,
        kExprIf, kWasmAnyRef,
          kExprRefNull,
        kExprElse,
          kExprGetLocal, 1,
        kExprEnd,
      ]).exportFunc();
  let instance = builder.instantiate();
  assertEquals(null, instance.exports.merge(0));
  assertEquals(null, instance.exports.merge(1));
})();