Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for zig 0.10 (stage 2) #139

Merged
merged 15 commits into from
Sep 2, 2022
Merged

Update for zig 0.10 (stage 2) #139

merged 15 commits into from
Sep 2, 2022

Conversation

malcolmstill
Copy link
Owner

@malcolmstill malcolmstill commented Aug 19, 2022

Description

  • Update for zig 0.10 (stage 2)
  • For the moment I am just going to target stage 2. If I run into difficulties I can think about also supporting stage 1 for a while.
  • The most important thing to note for future reference: in zig 0.9.1 I .always_tail'd the dispatch function. In that version I could quickly compare the difference between inline / noinline of the dispatch function (respectively, whether every virtual instruction handler includes an indirect jump in its tail or whether there is a single indirect jump). The Sema .always_tail type check asks whether the function signatures are the same. This equality seems to include the calling convention; inline fn dispatch having .Inline calling convention where the other .always_tail functions do not include the calling convention, so the check fails. This is potentially a bug (i.e. the compiler should / could make the equals true if the args + params are the same disregarding if some functions are .Inline). But for the moment, let's declare dispatch as inline and instead of the @call in each virtual instruction handler, let's call it directly.

Follow ups

  • My next trick is cleaning up the code by being able to move the WasmError out of the parameters and into the return type where it belongs.

@malcolmstill
Copy link
Owner Author

@malcolmstill
Copy link
Owner Author

Test once ziglang/zig#12368 build available

@malcolmstill
Copy link
Owner Author

Hmm

➜  fib git:(malcolm/zig-0.10) ✗ ~/Downloads/zig-0.10-stage2/zig build
/Users/klltkr/foxwren/examples/fib/src/fib.zig:20:16: error: variable of type 'store.ArrayListStore' must be const or comptime
    var store: Store = Store.init(alloc);
               ^~~~~
/Users/klltkr/foxwren/src/store.zig:30:25: note: struct requires comptime because of this field
    functions: ArrayList(Function),
               ~~~~~~~~~^~~~~~~~~~
/Users/klltkr/Downloads/zig-0.10-stage2/lib/zig/std/array_list.zig:41:16: note: struct requires comptime because of this field (2 times)
        items: Slice,
               ^~~~~
/Users/klltkr/foxwren/src/function.zig:49:20: note: union requires comptime because of this field
    host_function: struct {
                   ^~~~~~
/Users/klltkr/foxwren/src/function.zig:50:15: note: struct requires comptime because of this field
        func: fn (*Interpreter) WasmError!void,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/function.zig:50:15: note: use '*const fn(*interpreter.Interpreter) error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}!void' for a function pointer type
        func: fn (*Interpreter) WasmError!void,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/store.zig:35:25: note: struct requires comptime because of this field
    instances: ArrayList(Instance),
               ~~~~~~~~~^~~~~~~~~~
/Users/klltkr/foxwren/src/instance.zig:36:12: note: struct requires comptime because of this field
    store: *Store,
           ^~~~~~

@malcolmstill
Copy link
Owner Author

        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:1684:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:60: error: values of type '[256]fn(*interpreter.Interpreter, usize, []instruction.Instruction, *?error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}) void' must be comptime known, but index value is runtime known
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                           ^~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: note: use '*const fn(*interpreter.Interpreter, usize, []instruction.Instruction, *?error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}) void' for a function pointer type
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:1692:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:60: error: values of type '[256]fn(*interpreter.Interpreter, usize, []instruction.Instruction, *?error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}) void' must be comptime known, but index value is runtime known
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                           ^~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: note: use '*const fn(*interpreter.Interpreter, usize, []instruction.Instruction, *?error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}) void' for a function pointer type
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:1700:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:60: error: values of type '[256]fn(*interpreter.Interpreter, usize, []instruction.Instruction, *?error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}) void' must be comptime known, but index value is runtime known
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                           ^~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: note: use '*const fn(*interpreter.Interpreter, usize, []instruction.Instruction, *?error{BadFunctionIndex,BadGlobalIndex,BadInstanceIndex,BadMemoryIndex,BadTableIndex,CheckStackSpace,ControlStackOverflow,ControlStackUnderflow,DivisionByZero,FunctionIndexOutOfBounds,GlobalIndexOutOfBounds,IndirectCallTypeMismatch,InvalidConversion,LabelStackOverflow,LabelStackUnderflow,MemoryIndexOutOfBounds,NegativeDenominator,NotImplemented,OperandStackOverflow,OperandStackUnderflow,OutOfBoundsMemoryAccess,Overflow,StackOverflow,StackUnderflow,TableIndexOutOfBounds,Trap,TrapUnreachable,UndefinedElement}) void' for a function pointer type
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

@malcolmstill
Copy link
Owner Author

If I change:

const InstructionFunction = fn (*Interpreter, usize, []Instruction, *?WasmError) void;

to

const InstructionFunction = *const fn (*Interpreter, usize, []Instruction, *?WasmError) void;

I then get:

...
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2282:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2290:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2298:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2306:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2314:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2322:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2330:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2338:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2346:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2354:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2362:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2370:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2378:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2386:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
                                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:2394:16: note: called from here
        return @call(.{ .modifier = .always_tail }, dispatch, .{ self, ip + 1, code, err });
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/klltkr/foxwren/src/interpreter.zig:73:59: error: modifier 'always_tail' requires a comptime-known function
        return @call(.{ .modifier = .always_tail }, lookup[@enumToInt(next_instr)], .{ self, next_ip, code, err });
...

    unable to perform tail call: type of function being called '{}' does not match type of calling function '{}'

The problem that seems to give with 0.10 stage2 is that I had been inlining
the dispatch call, but also calling that with .always_tail. This was nice
in that I could easily switch between inline dispatch and noinline dispatch
to compare the two. With the type check that now fails, because the inline
dispatch function type includes the fact that its calling convention is .Noinline
which is not _exactly_ the same as all of the instruction handlers.

To get around this for the moment I will just opt for only using inline.
I then need to just directly call dispatch (not with @call .always_tail).

The reason I can't now quickly check out switching dispatch to noinline
is that it will work yes, but it will cause stack frame allocations
which we absolutely do not want.

If Sema remains unchanged, one we might handle both is by having some
compile time flag that can be set that will directly call inline dispatch
in the case of wanting inline, and calling a noinline dispatch via @call
.always_tail if that's what we want.

The other alternative is that Sema is wrong and that instead of comparing
the complete function type (including calling convention) it should only
compare arg types and return types, in other words don't consider the
calling convention
@malcolmstill
Copy link
Owner Author

Progress, but now:

(trap): /Users/klltkr/foxwren-fix-vendored/test/testsuite/elem.wast:353
Unexpected error: error.BadFunctionIndex
(trap) invoke = call-7 at /Users/klltkr/foxwren-fix-vendored/test/testsuite/elem.wast:353
error: TestsuiteExpectedUndefinedElement
/home/runner/work/foxwren/foxwren/src/module.zig:644:33: 0x425ce2 in decodeElementSection (testrunner)
            const parsed_code = try self.parseConstantCode(self.module[expr_start .. expr_start + meta.offset + 1], .I32);
                                ^
/home/runner/work/foxwren/foxwren/src/module.zig:160:25: 0x42838d in decodeSection (testrunner)
            .Element => try self.decodeElementSection(),
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:101:29: 0x428e06 in decode (testrunner)
                    else => return err,
                            ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:37:37: 0x406115 in readNoEof (testrunner)
                index += amt;
                                    ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:238:13: 0x4065ec in readBytesNoEof__anon_8581 (testrunner)
        pub fn readByteSigned(self: Self) !i8 {
            ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:286:27: 0x406674 in readInt__anon_8580 (testrunner)
        }
                          ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:345:25: 0x406764 in readEnum__anon_8564 (testrunner)
        /// an enum tag, casts the integer to the enum tag and returns it. Otherwise, returns an error.
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:140:21: 0x427fc1 in decodeSection (testrunner)
            else => return err,
                    ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:37:37: 0x406115 in readNoEof (testrunner)
                index += amt;
                                    ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:238:13: 0x4065ec in readBytesNoEof__anon_8581 (testrunner)
        pub fn readByteSigned(self: Self) !i8 {
            ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:286:27: 0x406674 in readInt__anon_8580 (testrunner)
        }
                          ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:345:25: 0x406764 in readEnum__anon_8564 (testrunner)
        /// an enum tag, casts the integer to the enum tag and returns it. Otherwise, returns an error.
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:140:21: 0x427fc1 in decodeSection (testrunner)
            else => return err,
                    ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:37:37: 0x406115 in readNoEof (testrunner)
                index += amt;
                                    ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:238:13: 0x4065ec in readBytesNoEof__anon_8581 (testrunner)
        pub fn readByteSigned(self: Self) !i8 {
            ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:286:27: 0x406674 in readInt__anon_8580 (testrunner)
        }
                          ^
/opt/hostedtoolcache/zig/zig-linux-x86_64-0.10.0-dev.3844+f7784a081/x64/lib/std/io/reader.zig:345:25: 0x406764 in readEnum__anon_8564 (testrunner)
        /// an enum tag, casts the integer to the enum tag and returns it. Otherwise, returns an error.
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:140:21: 0x427fc1 in decodeSection (testrunner)
            else => return err,
                    ^
/home/runner/work/foxwren/foxwren/src/interpreter.zig:2602:22: 0x42ad19 in invoke (testrunner)
        if (err) |e| return e;
                     ^
/home/runner/work/foxwren/foxwren/src/instance.zig:315:17: 0x44da63 in invoke__anon_9639 (testrunner)
                try interp.invoke(f.start);
                ^
/home/runner/work/foxwren/foxwren/test/src/testrunner.zig:458:37: 0x3fd9f4 in main (testrunner)
                                    return error.TestsuiteExpectedUndefinedElement;
                                    ^
/home/runner/work/foxwren/foxwren/src/module.zig:160:25: 0x42838d in decodeSection (testrunner)
            .Element => try self.decodeElementSection(),
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:101:29: 0x428e06 in decode (testrunner)
                    else => return err,
                            ^
/home/runner/work/foxwren/foxwren/src/module.zig:836:25: 0x4228db in parseConstantCode (testrunner)
                else => return error.ValidatorConstantExpressionRequired,
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:644:33: 0x425ce2 in decodeElementSection (testrunner)
            const parsed_code = try self.parseConstantCode(self.module[expr_start .. expr_start + meta.offset + 1], .I32);
                                ^
/home/runner/work/foxwren/foxwren/src/module.zig:160:25: 0x42838d in decodeSection (testrunner)
            .Element => try self.decodeElementSection(),
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:101:29: 0x428e06 in decode (testrunner)
                    else => return err,
                            ^
/home/runner/work/foxwren/foxwren/src/module.zig:836:25: 0x4228db in parseConstantCode (testrunner)
                else => return error.ValidatorConstantExpressionRequired,
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:644:33: 0x425ce2 in decodeElementSection (testrunner)
            const parsed_code = try self.parseConstantCode(self.module[expr_start .. expr_start + meta.offset + 1], .I32);
                                ^
/home/runner/work/foxwren/foxwren/src/module.zig:160:25: 0x42838d in decodeSection (testrunner)
            .Element => try self.decodeElementSection(),
                        ^
/home/runner/work/foxwren/foxwren/src/module.zig:101:29: 0x428e06 in decode (testrunner)
                    else => return err,
                            ^
/home/runner/work/foxwren/foxwren/src/module.zig:836:25: 0x4228db in parseConstantCode (testrunner)
                else => return error.ValidatorConstantExpressionRequired,

@malcolmstill malcolmstill changed the title Update for zig 0.10 Update for zig 0.10 (stage 2) Sep 2, 2022
@malcolmstill
Copy link
Owner Author

(trap): /Users/klltkr/foxwren-fix-vendored/test/testsuite/elem.wast:353
warning: handle = 43, self.functions.items.len = 46
warning: handle = 12297829382473034410, self.functions.items.len = 46
Unexpected error: error.BadFunctionIndex
(trap) invoke = call-7 at /Users/klltkr/foxwren-fix-vendored/test/testsuite/elem.wast:353
error: TestsuiteExpectedUndefinedElement
/home/klltkr/foxwren/src/module.zig:644:33: 0x426578 in decodeElementSection (testrunner)
            const parsed_code = try self.parseConstantCode(self.module[expr_start .. expr_start + meta.offset + 1], .I32);

@malcolmstill
Copy link
Owner Author

Looks like the issue is when allocating a table which is []?usize we're not getting, as default, null values.

@malcolmstill
Copy link
Owner Author

Sweet heavenly fire, it works!

@malcolmstill malcolmstill merged commit 02d4a40 into master Sep 2, 2022
@malcolmstill malcolmstill deleted the malcolm/zig-0.10 branch September 2, 2022 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant