github-actions[bot] commented on Issue #2143:
Subscribe to Label Action
cc @bnjbvr
<details>
This issue or pull request has been labeled: "cranelift", "cranelift:wasm"Thus the following users have been cc'd because of the following labels:
- bnjbvr: cranelift
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
ggreif commented on Issue #2143:
Suggested additional reviewer: @osa1
ggreif commented on Issue #2143:
I think it is better to squash all the commits before a merge and adding a better overall commit message.
ggreif commented on Issue #2143:
@yurydelendik Thanks for the review. I can't see where I have introduced O(n^2). The insertion of
LandingPad
s is linear in the number of parts, just like the removal of uninteresting ones. Post-translation, building of theold_to_new
should be linear (modulo HashMap internals) and the backpatching too.I have contemplated about remembering the offset of every part that is pushed, but the parts are not 1:1 preserved in the transformation. With floating
LandingPad
s this is not a problem. Attaching an original offset to every part is also tricky, because the translation process would have trouble doing the bookkeeping of offsets.Regarding
frame_base
, yes, this is a hole still, but I need a better understanding whatframe_base
is for. Is it for the location expressions that guide into structure members?
yurydelendik commented on Issue #2143:
I can't see where I have introduced O(n^2).
It is near
filter_map(.. any()/all() ..).collect()
and someold_to_new
operations.I need a better understanding what
frame_base
is forThis expression is coming from
DW_AT_frame_base
. (Discard my idea about offsetting, I was incorrect there) It shall be inlined during eachDW_OP_fbreg
operation.
yurydelendik commented on Issue #2143:
Attaching an original offset to every part is also tricky, because the translation process would have trouble doing the bookkeeping of offsets.
FWIW I am also thinking about having
parts: Vec<(CompiledExpressionPart, usize)>,
-- this will take care of bookkeeping. Though you will need to track parts last offset instead of first -- it is the same thing for this logic.
ggreif commented on Issue #2143:
Well, I get quadratic behaviour only when assuming # jumps are proportional to the # of
DW_OP
s. Similarly,old_to_new
is bounded by the # of jumps times two. But in principle you are right.Is it realistic that
DW_AT_frame_base
has jumps in it? Should be just bail if so?
ggreif edited a comment on Issue #2143:
Well, I get quadratic behaviour only when assuming # jumps are proportional to the # of
DW_OP
s. Similarly,old_to_new
is bounded by the # of jumps times two. But in principle you are right.Is it realistic that
DW_AT_frame_base
has jumps in it? Should we just bail if so?
yurydelendik commented on Issue #2143:
Is it realistic that DW_AT_frame_base has jumps in it? Should we just bail if so?
Yes, let's assume DW_AT_frame_base has no jumps, otherwise let's bail.
ggreif commented on Issue #2143:
FWIW I am also thinking about having
parts: Vec<(CompiledExpressionPart, usize)>,
-- this will take care of bookkeeping. Though you will need to track parts last offset instead of first -- it is the same thing for this logic.I tried to go down that route, but got quickly lost in the
build_with_locals
bowels, string atranges_builder
and co.
ggreif edited a comment on Issue #2143:
FWIW I am also thinking about having
parts: Vec<(CompiledExpressionPart, usize)>,
-- this will take care of bookkeeping. Though you will need to track parts last offset instead of first -- it is the same thing for this logic.I tried to go down that route, but got quickly lost in the
build_with_locals
bowels, staring atranges_builder
and co.
yurydelendik commented on Issue #2143:
I feel a little bit intimidated by the
old_to_new
logic here. I hope there is a chance you can adapt my proposal at https://github.com/yurydelendik/wasmtime/tree/ggreif/main with this PR. (If not I will still try my best but it is too hard)
ggreif commented on Issue #2143:
I am happy to look into your proposal (tomorrow, it is really late here)! Meanwhile the keys of
old_to_new
are the byte offsets for theDW_OP
s before translation and the values in the map are the corresponding jump sources and targets of the in terms of the expanded location expression offsets. For everyCode
block preceded by aLandingPad
I also add a few key->value mappings corresponding to the potential internal operation offsets. After the key->value map is fully built, I visit eachjump_arc
and look it up to obtain the translated jump arc. Since the source of the translated jump arc is directly behind the 3 byteDW_OP_bra/skip
, we know how to backpatch the jump displacement.
ggreif edited a comment on Issue #2143:
I am happy to look into your proposal (tomorrow, it is really late here)! Meanwhile the keys of
old_to_new
are the byte offsets for theDW_OP
s before translation and the values in the map are the corresponding jump sources and targets of the in terms of the expanded location expression offsets. For everyCode
block preceded by aLandingPad
I also add a few key->value mappings corresponding to the potential internal operation offsets. After the key->value map is fully built, I visit eachjump_arc
and look it up to obtain the translated jump arc. Since the source of the translated jump arc is directly behind the 3 byteDW_OP_bra/skip
, I know how to find the jump operation and then backpatch the jump displacement.
ggreif commented on Issue #2143:
I looked into your branch. You draw global ids from a static supply, which eliminates a bunch of offset complexity, and adds machinery in different other places. I still don't see where the pre-translation ids meet the post-translation ones. I'll look harder.
ggreif edited a comment on Issue #2143:
I looked into your branch. You draw global ids from a static supply, which eliminates a bunch of offset complexity, and adds machinery in different other places. I still don't see where the pre-translation ids meet the post-translation ones. I'll look harder.
I think I understand now. Feel free to file a PR against this branch.
ggreif edited a comment on Issue #2143:
I looked into your branch. You draw global ids from a static supply, which eliminates a bunch of offset complexity, and adds machinery in different other places. I still don't see where the pre-translation ids meet the post-translation ones. I'll look harder.
I think I understand now. You run a pre-pass on the original expression to fish for potential landing sites.
Feel free to file a PR against this branch.
ggreif edited a comment on Issue #2143:
I looked into your branch. You draw global ids from a static supply, which eliminates a bunch of offset complexity, and adds machinery in different other places. I still don't see where the pre-translation ids meet the post-translation ones. I'll look harder.
I think I understand now. You run a pre-pass on the original expression to fish for potential landing sites.
Feel free to file a PR against this branch.Done: https://github.com/ggreif/wasmtime/pull/1, ping me when you think I can merge.
yurydelendik commented on Issue #2143:
Thank you for the patch
Last updated: Nov 22 2024 at 17:03 UTC