ggreif opened PR #2143 from main
to main
:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
target
is informational only, never used
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
This is hard-coded to be little-endian for now.
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
Please don't look just yet.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
This I'll submit separately.
ggreif submitted PR Review.
ggreif created PR Review Comment:
Dito, refactoring.
yurydelendik created PR Review Comment:
Let's make
jump_arcs
as field ofCompiledExpression
(from_label
will have empty map)
yurydelendik submitted PR Review.
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
Can we avoid this clone?
ggreif submitted PR Review.
ggreif created PR Review Comment:
Due to different macro expansions, sometimes this becomes a dead write. Can we suppress the warning in this particular cases?
ggreif edited PR Review Comment.
ggreif submitted PR Review.
ggreif created PR Review Comment:
TODO: Go through all
DW_OP_*
and check if they are mentioned here.
ggreif updated PR #2143 from main
to main
:
Please don't look just yet.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
See #2154.
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record theLandingPad
's translated positions into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newExpressionPart
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
We now mention all possibilities, but bail out on some, below. We are strictly doing a better job now than before.
ggreif submitted PR Review.
ggreif created PR Review Comment:
Done, thanks for the tip, it simplified matters considerably!
ggreif submitted PR Review.
ggreif created PR Review Comment:
Actually these might be pass-through, as they would push a Wasm bytecode address, which can be
DW_OP_deref
-ed. Will leave them here until we have a real use case though. It is hard to predict heap addresses at DWARF generation time.
ggreif edited PR Review Comment.
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is done.
Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
it is hard code to read without comment, perhaps
let found = old_to_new.iter().find(|(_, new)| new == code_buf.len()); if let Some((old, new)) = found.cloned() { // update old_to_new ...
ggreif submitted PR Review.
ggreif created PR Review Comment:
I tried to have
in &mut old_to_new
but the borrow checker didn't like it. Modifying an iterated-over container is a bad idea, I suppose :-)
ggreif submitted PR Review.
ggreif created PR Review Comment:
It causes CI failures, too.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
I recommend removing
unread_bytes
as a local and add it as a "parameter" to the push! macro
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
Added better comment, since I cannot locate any encoding hint in the context that would let me decide cleanly. For that we would need a
gimli
-stylewriter
. Another refactor to tackle sometime.
ggreif edited PR Review Comment.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
indeed. If I understand the logic, you are searching for
new == code.buf.len()
. Means you need to use findold_to_new.iter().find(|(_, new)| new == code_buf.len()).cloned()
. Then you can modify old_to_new based on found (if)old
. No?
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
As suggested (elsewhere?) this could be a
find
followed byinsert
s on success.
ggreif edited PR Review Comment.
ggreif submitted PR Review.
ggreif created PR Review Comment:
remove
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
Done.
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation.
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
Done!
ggreif submitted PR Review.
ggreif created PR Review Comment:
Done.
ggreif submitted PR Review.
ggreif created PR Review Comment:
This is a nice use case for https://doc.rust-lang.org/std/primitive.bool.html#method.then
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
ggreif has marked PR #2143 as ready for review.
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif requested yurydelendik for a review on PR #2143.
ggreif submitted PR Review.
ggreif created PR Review Comment:
Leaving here the _nightly_-depending diff
$ git diff diff --git a/crates/debug/src/lib.rs b/crates/debug/src/lib.rs index 259c86975..901b171de 100644 --- a/crates/debug/src/lib.rs +++ b/crates/debug/src/lib.rs @@ -1,6 +1,7 @@ //! Debug utils for WebAssembly using Cranelift. #![allow(clippy::cast_ptr_alignment)] +#![feature(bool_to_option)] use anyhow::{bail, ensure, Error}; use object::{RelocationEncoding, RelocationKind}; diff --git a/crates/debug/src/transform/expression.rs b/crates/debug/src/transform/expression.rs index ceee274f3..002bacd33 100644 --- a/crates/debug/src/transform/expression.rs +++ b/crates/debug/src/transform/expression.rs @@ -340,10 +340,10 @@ impl CompiledExpression { for part in &self.parts { match part { CompiledExpressionPart::Code(c) => { - if let Some((old, new)) = old_to_new - .iter() - .find(|(_, new)| *new == &code_buf.len()) - .map(|(old, new)| (*old, *new)) + if let Some((old, new)) = + old_to_new.iter().find_map(|(old, new)| { + (*new == code_buf.len()).then(|| (*old, *new)) + }) { // when `new` comes from the preceding LandingPad for i in 1..c.len() {
for posterity :-)
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
Removed.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
use
to_le_bytes
andcopy_from_slice
?
ggreif submitted PR Review.
ggreif created PR Review Comment:
Does that allow me to position in the array?
ggreif submitted PR Review.
ggreif created PR Review Comment:
N/m, I have it: https://doc.rust-lang.org/book/ch04-03-slices.html
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently?Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
Done.
yurydelendik submitted PR Review.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
is
combined
== to result ofparts.pop()
? so you don't have to clone
yurydelendik submitted PR Review.
ggreif submitted PR Review.
ggreif created PR Review Comment:
What I'd really like to do is:
if let (CompiledExpressionPart::Code(cc2), Some(CompiledExpressionPart::Code(cc1))) = (&part, parts.last()) { cc1.extend_from_slice(cc2); } else { parts.push(CompiledExpressionPart::LandingPad { original_pos: (expr.0.len().into_u64() - $unread) as usize, }); parts.push(part) }
But for that
Code
needs to carry a mutable vector.
I tried various other ways of getting rid of the.clone()
but I guess my Rust-fu is not strong enough for that. I'd love to see your idea written out though. Indeed the.pop()
removes theCode
which hascc1
in it, and then it gets appended bycc2
and. pushed back as a freshCode
.
ggreif edited PR Review Comment.
yurydelendik submitted PR Review.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
You are not wrong above, just use
parts.last_mut()
instead of.last()
.
ggreif submitted PR Review.
ggreif created PR Review Comment:
Success!
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
I think this and above test cases are incorrect. Can you verify that?
ggreif submitted PR Review.
ggreif created PR Review Comment:
The parsing tests pass
test transform::expression::tests::test_debug_parse_expressions ... ok
The tests themselves are not intended to make sense, if that is what you mean. The example in the PR description is an actual location expression with its translation.
ggreif submitted PR Review.
ggreif created PR Review Comment:
The
original_pos: 5
appearing twice is probably which is confusing. It confused me too. But actually it makes sense. The jump goes from 5 to 7. TheLandingPad
beforeCode
just orients it and tells that there are potential jump targets inCode
(pre-translation) pos 6:DW_OP_lit0
, pos 7:DW_OP_stack_value
.
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at all relevant positions:
- immediately after a
Jump
- at actual
Jump
targets- before
Code
chunks when the jump target goes properly into an inner bytecode position.
LandingPad
s are identified by the bytecode instruction offset _before_ translation.Additionally we now parse the
Jump
instructions. Uponwrite
ing we record everyLandingPad
's translated position into a relocation map and using that we are able to recompute the target distance for every jump-like instruction.Since we don't know in advance if we will need
LandingPad
s, we speculatively add all, and clean up after parsing is concluded. At this point the map from jump sources to destinations is complete.Caveat: Currently we make no attempt to gracefully degrade when jump targets point into a multibyte operation (i.e. an illegal jump target).
Progress:
- relocation of branch edges works
- open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTarget
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get correspondingJumpTarget
token.We bail in two situations:
frame_
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTarget
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get correspondingJumpTarget
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif edited PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).
Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif requested yurydelendik for a review on PR #2143.
yurydelendik submitted PR Review.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
can we revert this change?
yurydelendik created PR Review Comment:
// Looks hacky but it is fast; does not need to be really exact.
yurydelendik created PR Review Comment:
// Create somewhat unique hash data -- using part of
yurydelendik created PR Review Comment:
// Internal hash_data test (theoretically can fail intermittently).
yurydelendik updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).
Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
yurydelendik deleted PR Review Comment.
yurydelendik deleted PR Review Comment.
yurydelendik deleted PR Review Comment.
ggreif submitted PR Review.
ggreif created PR Review Comment:
parts.push(CompiledExpressionPart::Code(code_chunk)); code_chunk = Vec::new();
like this?
ggreif deleted PR Review Comment.
ggreif submitted PR Review.
ggreif created PR Review Comment:
parts.push(CompiledExpressionPart::Code(code_chunk)); code_chunk = Vec::new();
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
ggreif edited PR Review Comment.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
Can
push!(
stay? I was thinking aboutcode_chunk.clone()
andcode_chunk = Vec::new()
stuff.
ggreif edited PR Review Comment.
ggreif submitted PR Review.
ggreif created PR Review Comment:
I hope to keep
push!(
(see above), but no idea how to fix the warning without artificially reading thecode_chunk
after the last macro invocation.
ggreif edited PR Review Comment.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
I see. Yeah, it just needs
if !code_chunk.is_empty() {
withoutcode_chunk = Vec::new()
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).
Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
I did something that works. But I feel dense and am not sure if this is what you meant. Please feel free to fix.
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).
Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
// Discarding out-of-bounds jumps (also some of falsely detected ops)
ggreif updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).
Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
yurydelendik updated PR #2143 from main
to main
:
The fundamental problem is that the target distance of jump-like operations may change in the DWARF expression translation process. Intervening
DW_OP_deref
will expand to about 10 bytes, for example.So the jumps must be relocated. We approach this task by inserting artificial
LandingPad
markers (newCompiledExpressionParts
constructors) into the parsed vector at actualJump
targets.
LandingPad
s are identified byJumpTargetMarker
tokens which are generated on the fly.Additionally we now parse the
Jump
instructions. These also get their correspondingJumpTargetMarker
token.We bail in two situations:
frame_base
is too complicated (i.e. itself containsJump
)- some jump distance in the original expression is fishy.
Open problem: the
need_deref
flag. What when different branches want to set the flag differently? Probably not a biggie as long as all control-flow paths end e.g. withDW_OP_stack_value
(or without).
Example:
DW_AT_location (DW_OP_WASM_location 0x0 +1, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +3, DW_OP_plus_uconst 0x5, DW_OP_deref, DW_OP_stack_value)
gets transformed into:
DW_AT_location (DW_OP_breg6 RBP-36, DW_OP_deref, DW_OP_dup, DW_OP_lit1, DW_OP_and, DW_OP_bra +5, DW_OP_lit1, DW_OP_shr, DW_OP_skip +19, DW_OP_plus_uconst 0x5, DW_OP_breg6 RBP-56, DW_OP_deref, DW_OP_consts +152, DW_OP_plus, DW_OP_deref, DW_OP_swap, DW_OP_const4u 0xffffffff, DW_OP_and, DW_OP_plus, DW_OP_deref, DW_OP_stack_value)
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
ggreif submitted PR Review.
ggreif created PR Review Comment:
I see, thanks!
yurydelendik merged PR #2143.
Last updated: Dec 23 2024 at 12:05 UTC