Stream: git-wasmtime

Topic: wasmtime / PR #2388 MachInst backends: handle SourceLocs ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 22:44):

cfallin opened PR #2388 from sourceloc to main:

In existing MachInst backends, many instructions -- any that can trap or
result in a relocation -- carry SourceLoc values in order to propagate
the location-in-original-source to use to describe resulting traps or
relocation errors.

This is quite tedious, and also error-prone: it is likely that the
necessary plumbing will be missed in some cases, and in any case, it's
unnecessarily verbose.

This PR factors out the SourceLoc handling so that it is tracked
during emission as part of the EmitState, and plumbed through
automatically by the machine-independent framework. Instruction emission
code that directly emits trap or relocation records can query the
current location as necessary. Then we only need to ensure that memory
references and trap instructions, at their (one) emission point rather
than their (many) lowering/generation points, are wired up correctly.

This does have the side-effect that some loads and stores that do not
correspond directly to user code's heap accesses will have unnecessary
but harmless trap metadata. For example, the load that fetches a code
offset from a jump table will have a 'heap out of bounds' trap record
attached to it; but because it is bounds-checked, and will never
actually trap if the lowering is correct, this should be harmless. The
simplicity improvement here seemed more worthwhile to me than plumbing
through a "corresponds to user-level load/store" bit, because the latter
is a bit complex when we allow for op merging.

Closes #2290: though it does not implement a full "metadata" scheme as
described in that issue, this seems simpler overall.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 22:44):

cfallin requested abrown for a review on PR #2388.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 23:35):

abrown submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 23:35):

abrown submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 23:35):

abrown created PR Review Comment:

                sink.add_trap(srcloc, trap_info);

This avoids unnecessary let code = ...; possibly rename the Udf field to trap_code.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 23:47):

cfallin updated PR #2388 from sourceloc to main:

In existing MachInst backends, many instructions -- any that can trap or
result in a relocation -- carry SourceLoc values in order to propagate
the location-in-original-source to use to describe resulting traps or
relocation errors.

This is quite tedious, and also error-prone: it is likely that the
necessary plumbing will be missed in some cases, and in any case, it's
unnecessarily verbose.

This PR factors out the SourceLoc handling so that it is tracked
during emission as part of the EmitState, and plumbed through
automatically by the machine-independent framework. Instruction emission
code that directly emits trap or relocation records can query the
current location as necessary. Then we only need to ensure that memory
references and trap instructions, at their (one) emission point rather
than their (many) lowering/generation points, are wired up correctly.

This does have the side-effect that some loads and stores that do not
correspond directly to user code's heap accesses will have unnecessary
but harmless trap metadata. For example, the load that fetches a code
offset from a jump table will have a 'heap out of bounds' trap record
attached to it; but because it is bounds-checked, and will never
actually trap if the lowering is correct, this should be harmless. The
simplicity improvement here seemed more worthwhile to me than plumbing
through a "corresponds to user-level load/store" bit, because the latter
is a bit complex when we allow for op merging.

Closes #2290: though it does not implement a full "metadata" scheme as
described in that issue, this seems simpler overall.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 23:47):

cfallin submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2020 at 23:47):

cfallin created PR Review Comment:

Good point, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2020 at 01:05):

cfallin merged PR #2388.


Last updated: Nov 22 2024 at 17:03 UTC