Commit 16a0fbd5 authored by Ben Visness's avatar Ben Visness Committed by rvandermeulen@mozilla.com
Browse files

Bug 1962634: Add missing types to uncheckedReadValType. a=RyanVM

This method is only called by the debugger, and was missing various
reference types.

Original Revision: https://phabricator.services.mozilla.com/D246752

Differential Revision: https://phabricator.services.mozilla.com/D249599
parent e50686a2
Loading
Loading
Loading
Loading
+38 −0
Changes for js/src/jit-test/tests/wasm/gc/bug-1962634.js: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
// |jit-test| skip-if: !wasmDebuggingEnabled()

const f = newGlobal({ newCompartment: true });
f.g = this;
f.eval(`
  Debugger(g).onEnterFrame = function(frame) { frame.environment }
`);

const types = [
  "anyref", "(ref any)",
  "eqref", "(ref eq)",
  "i31ref", "(ref i31)",
  "structref", "(ref struct)",
  "arrayref", "(ref array)",
  "nullref", "(ref none)",

  "funcref", "(ref func)",
  "nullfuncref", "(ref nofunc)",

  "externref", "(ref extern)",
  "nullexternref", "(ref noextern)",

  "exnref", "(ref exn)",
  "nullexnref", "(ref noexn)",

  "(ref null $s)", "(ref $s)",
];

for (const type of types) {
  const m = new WebAssembly.Module(wasmTextToBinary(`(module
    (type $s (struct))
    (func (export "test")
      (local ${type})
    )
  )`));
  const { test } = new WebAssembly.Instance(m).exports;
  test();
}
+9 −0
Changes for js/src/wasm/WasmBinary.h: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -659,9 +659,18 @@ class Decoder {
inline ValType Decoder::uncheckedReadValType(const TypeContext& types) {
  uint8_t code = uncheckedReadFixedU8();
  switch (code) {
    case uint8_t(TypeCode::AnyRef):
    case uint8_t(TypeCode::EqRef):
    case uint8_t(TypeCode::I31Ref):
    case uint8_t(TypeCode::StructRef):
    case uint8_t(TypeCode::ArrayRef):
    case uint8_t(TypeCode::NullAnyRef):
    case uint8_t(TypeCode::FuncRef):
    case uint8_t(TypeCode::NullFuncRef):
    case uint8_t(TypeCode::ExternRef):
    case uint8_t(TypeCode::NullExternRef):
    case uint8_t(TypeCode::ExnRef):
    case uint8_t(TypeCode::NullExnRef):
      return RefType::fromTypeCode(TypeCode(code), true);
    case uint8_t(TypeCode::Ref):
    case uint8_t(TypeCode::NullableRef): {