-
Notifications
You must be signed in to change notification settings - Fork 97
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
[WIP] [PoC] Trying to change object layout #1931
Conversation
E.add_static env StaticBytes.[ | ||
I32 Tagged.(int_of_tag Closure); | ||
I32 Tagged.(int_of_tag Closure); (* tag *) | ||
I32 0l; (* link *) | ||
I32 (E.add_fun_ptr env fi); | ||
I32 0l | ||
] |
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 would suggest to introduce a Tagged.add_static
so that you can write
Tagged.add_static env Closure [
I32 (E.add_fun_ptr env fi);
I32 0l
]
here and similar in other places. That’s a quick and worthwhile refactoring you can quickly do in a PR agaist master, and will simplify work like this.
I.e.: Clean up and refactor the code (with self-contained simple PRs) until this PR works :-)
Unless this goes in a very different direction than what you envision in the long run, of course.
A bit hard to debug, I guess I’d have to go through all lines that you didn’t change and check these – hard to do that with a PR… |
I don’t see a clear connection between the failing test cases you list yet. Maybe text and ropes? |
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.
Not updated (can’t comment on unchanged lines)
TAG_BITS64 => Words(3),
Also
But most importantly, it seems you didn’t update |
Currently debugging a bug in object field reads. Reproducer:
Output:
The first line is incorrect (it should print "true" not "false"), but if I peek at the object internals it looks right. So I think there's a bug when reading the field. |
Could also be a confusion between shifted and unshifted |
That also doesn't work as expected. This prints
|
Found it .. fix coming. |
Amusingly the last commit fixed dozens of tests that were working fine previously. I think the commit is correct and revealed bugs in other places. |
Hard to parse run.sh output, but I think literally every "run-drun" test is broken now. It's probably just one bug in a very commonly executed code. "run" tests are running fine now. |
I think remaining of the bugs are in serialization and deserialization code. |
Sigh.. this is really tiresome, especially without a debugger. @nomeata do you know the locations where we're allocating heap objects in serialization and deserialization code? |
They are all in the |
The PR description is not up to date, is it? It seems that mut-field-bound.wasm-run nested-lexpr.wasm-run objects5.wasm-run are passing here. |
Minimal example of failing code:
produces
(but oddly not on |
I might have found it: --- a/src/codegen/compile.ml
+++ b/src/codegen/compile.ml
@@ -5577,7 +5577,7 @@ module AllocHow = struct
let (ae1, i) = VarEnv.add_direct_local env ae name in
(ae1, G.nop)
| StoreHeap ->
- let (ae1, i) = VarEnv.add_local_with_offset env ae name 1l in
+ let (ae1, i) = VarEnv.add_local_with_offset env ae name 2l in
let alloc_code =
Tagged.obj env Tagged.MutBox [ compile_unboxed_zero ] ^^
G.i (LocalSet (nr i)) in
@@ -6979,7 +6979,7 @@ and compile_exp (env : E.t) ae exp =
code1 ^^ set_i ^^ orTrap env code2 ^^ get_j
(* Async-wait lowering support features *)
| DeclareE (name, _, e) ->
- let (ae1, i) = VarEnv.add_local_with_offset env ae name 1l in
+ let (ae1, i) = VarEnv.add_local_with_offset env ae name 2l in
let sr, code = compile_exp env ae1 e in
sr,
Tagged.obj env Tagged.MutBox [ compile_unboxed_zero ] ^^ now more stuff works. I am unsure about
now, and will have to think about it, but not today. |
This one looks fun! Double-Candid-Encoding somehow? --- caller.drun-run (expected)
+++ caller.drun-run (actual)
@@ -6,7 +6,7 @@
ingress Completed: Reply: 0x4449444c0000
Ok: Reply: 0x4449444c0000
ingress Completed: Reply: 0x4449444c000168010a0100000000000000fe01
-Ok: Reply: 0x4449444c0001680112010000000000000000000000000000000001
+Ok: Reply: 0x4449444c00016801134449444c000168010a0100000000000000fe01
Ok: Reply: 0x4449444c000179edff70f1
Ok: Reply: 0x4449444c00017d0a
Ok: Reply: 0x4449444c016e7b01000101 Facts:
|
the “HeapInd” way of handling variables (a local that points to a MutBox, used for captured mutable data) was overly general, and that caused bugs in @osa1’s refactorings in #1931. I think I had fancy plans here, but right now I am not using any other `offset` than `MutBox.field`, so let’s simplify the code accordingly.
which means more of #1931 might work
the “HeapInd” way of handling variables (a local that points to a MutBox, used for captured mutable data) was overly general, and that caused bugs in @osa1’s refactorings in #1931. I think I had fancy plans here, but right now I am not using any other `offset` than `MutBox.field`, so let’s simplify the code accordingly.
In terms of gas, 3 tests regressed and the mean change is +1.9%. |
Native uses of alloc_array are duplicated in the native test files. Those will be removed when the tests are ported to Rust.
this is easier to build on all platforms, compared to building for 32bits. It also means we are testing things closer to what we really run.
Run the RTS tests in wasmtime/WASI
This was a useful experiment, and it is still green … still, is this worth keeping, or should we closeit? |
I think we can close it. All hard-coded offset/size values found during development of this are replaced with |
No description provided.