-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
cranelift: Allow call
and call_indirect
in runtests
#4667
cranelift: Allow call
and call_indirect
in runtests
#4667
Conversation
call
and call_indirect
in runtests
Subscribe to Label Actioncc @fitzgen
This issue or pull request has been labeled: "cranelift", "fuzzing"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
7c02c28
to
1d90fef
Compare
@jameysharp @cfallin I think this is ready, would you be able to review it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had opportunity to give this a thorough review yet, but I've skimmed it, and at a high level I think it's a good idea. Not only does this PR allow us to test cases we can't test today, but it sounds like it can run the tests faster (by reusing compilation results and by short-circuiting unnecessary work sooner).
So far my only complaint is that the 16-character limit on function names forces changing a lot of tests, when I would think it'd be better to just increase the limit on name length. At a quick glance I didn't see where that length limit comes from. Does making that limit bigger have any effect on other uses of Cranelift, or is it just a limitation of the filetest infrastructure?
; run: %rmw_add_big_i16(0x12345678, 0, 0x1111) == 0x23455678 | ||
; run: %rmw_add_big_i16(0x12345678, 0, 0xffff) == 0x12335678 | ||
; run: %rmw_add_big_i16(0x12345678, 2, 0x1111) == 0x12346789 | ||
; run: %rmw_add_big_i16(0x12345678, 2, 0xffff) == 0x12345677 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell me if I have this right: these tests only worked before because the actual function name was ignored, so it didn't matter that the run
comments said little
when the function declaration said big
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, test run
(used to) ignore the actual name of the function.
We have had similar issues when we started adding test interpret
to the runtests, since it calls functions by their ExternalName
, however the interpreter also isn't used in this file.
Historically at least, the limit was to keep the size of |
Maybe the test-runner should keep a mapping between heap-allocated names and the "pair of u32" representation, just like an embedder would? |
I think this would be a good idea, if we can remove Edit: Had a look around the code, and we probably also need to change the parser and a few other things for this. |
I can confirm it's currently 20 bytes with I've just done an experiment, reducing the length limit of test-case names to 6 bytes, so it fits inside an 8-byte With that experimental setup, the smaller So I think this is totally worth doing, but... don't get your hopes up for much improvement in memory usage or compile speed. 😁 I was really curious which way this would go, and it was fun doing the quick experiment. |
That's... not as much as I hoped for 😄. Thanks for checking anyway! I started working on this refactor a couple days ago (in progress branch), but it's going to touch a lot of stuff and I don't think its going to be ready anytime soon. @jameysharp Would it be ok to merge this with the test renames? I'd like to build on this to fix #4758 but its going to take a while if I have to do the refactor first and I'd prefer to use that time to fix the other fuzz issues. |
I was hesitant, but actually yeah, renaming the test functions to fit within the limit is fine. Let's just plan that later we'll do a partial revert to get the more descriptive test names back. One alternative that comes to mind is to leave the I'm happy enough either way though. That said, I haven't had a chance to review this more carefully yet, so I'm not ready to merge it. Maybe @cfallin can get it into his review queue but he's got a lot on his plate. So maybe we can chat in #4758 about whether there are easier ways to fix the immediate bug there. |
I've filed #4766 to track this refactor.
Thanks for picking this up! I didn't even consider that as an option, but its a great middle step and solves the immediate issue.
👍 |
Changes the ordering of runtests to run per target and then per function. This change doesn't do a lot by itself, but helps future refactorings of runtests.
With the upcoming changes to the runtest infrastructure we require unique ExtNames for all tests. Note that for test names we have a 16 character limit on test names, and must be unique within those 16 characters.
TestFileCompiler allows us to compile the entire file once, and then call the trampolines for each test. The previous code was compiling the function for each invocation of a test.
The JIT internally only deals with User functions, and cannot link test name funcs. This also caches trampolines by signature.
It looks like we forgot to delete it when it was moved to `i128-bricmp-overflow`, and since it didn't have a run invocation it was never compiled. However, s390x does not support this, and panics when lowering.
073818f
to
1eb3ac8
Compare
These weren't auto reverted by the previous revert.
c84a961
to
ad7f62d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks correct to me -- thanks for this refactor, as I think it'll be a really useful feature!
The function-renaming business is a little subtle but I don't have any easy suggestions for cleaning it up. It does seem like the "right" answer would be for cranelift-jit
to keep a symbol table and support resolving references to testcase names, but that's probably just as complex as this change; and if it does eventually grow that for other reasons then we can remove the renaming layer here.
Well, darn. This seems to have broken
|
Okay, I'm reasonably convinced that "Undeclared function u0:0 is referenced by u0:1" has the same root cause as #4757 and #4758, although it's a different symptom. Previously these undefined functions caused failures if the interpreter tried to actually call them, or if the JIT tried to compile a call instruction referencing them. Now the new code also fails if there's a function signature declared, even if that function is never called. I've opened PR #4795 for the other error. It's a small fix. |
This fixes bytecodealliance#4757, fixes bytecodealliance#4758, and fixes new fuzzbugs that are probably coming after we merged bytecodealliance#4667.
👋 Hey,
This is an in progress PR just to share my current ideas for where to take the runtest suite.
It is based on top of #4453 and rewrites a lot of the code, but I felt it would be easier to review as a separate PR.
This PR does a number of things.
cranelift-jit
in runtests #4453)ExtName::User
so that they are callable in JIT.call
andcall_indirect
!TODO (for a future PR):
test interpreter
so that we can also enablecall
tests therecall
's in the fuzzer