-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test once ziglang/zig#12368 build available |
Hmm
|
|
If I change: const InstructionFunction = fn (*Interpreter, usize, []Instruction, *?WasmError) void; to const InstructionFunction = *const fn (*Interpreter, usize, []Instruction, *?WasmError) void; I then get:
|
49 tasks
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
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, |
(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); |
Looks like the issue is when allocating a table which is |
Sweet heavenly fire, it works! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
.always_tail
'd thedispatch
function. In that version I could quickly compare the difference betweeninline
/noinline
of thedispatch
function (respectively, whether every virtual instruction handler includes an indirect jump in its tail or whether there is a single indirect jump). TheSema
.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 declaredispatch
asinline
and instead of the@call
in each virtual instruction handler, let's call it directly.Follow ups
WasmError
out of the parameters and into the return type where it belongs.