Replies: 2 comments 13 replies
-
I agree with the first two points, but I was thinking about the third one somewhat differently. Specifically, the task of a source map would be to map an operation to source location, probably bypassing the need to map operations to instructions. The way this could work is as follows: Every cycle in the VM (i.e., when we execute a program via execute_iter) can be uniquely identified by the path in the MAST and operation index. To provide this info, we'd need to add something like
For MAST path, we don't actually need to store the full path - probably hash of the path (using a fast hash function - i.e., BLAKE3 with 160-bit output) will be sufficient. For example, for a program:
MAST paths for blocks would be:
Then, for example, when we execute
And then the source map would tell us that |
Beta Was this translation helpful? Give feedback.
-
We might want an optional context that will provide mappings from a In
The All of the above must be bound to source locations. It means they shouldn't necessarily map from an operation, having the We also have another exception: Considering this exception treatment for We aim to minimize the execution overhead for blocks that doesn't contain locations. The compilation time for As suggested, we could have a map from a
Both procedures above will contain the same span The suggestion above mentions using the MAST path to index the locations, and that might work, but we don't have such ability yet. We could introduce a
In the example above, we have a We do have some exceptions to such case, such as when we have an The initial main change would be on
|
Beta Was this translation helpful? Give feedback.
-
A [CodeBlock] is either a pointer to a list of [CodeBlock] (Join, Split, Loop, Call, Proxy), or a list of [Operation] (Span). It is indexed by its [Digest] root.
A function
F(CodeBlock::Span) |-> x
will also map the [CodeBlock] itself.A mapping from the root of a [CodeBlock::Span] to a list of code locations, given a span is a ordered list of operations, will ultimately map any operation of a [CodeBlock] into a unique [SourceLocation]. This of course extends to any recursion of the other variants of [CodeBlock]. We, therefore, given
F
, map any [Operation] of a [CodeBlock] to a unique [SourceLocation].In order to create such map, we need to:
And, whenever we create a list of [Operation] for a [CodeBlock::Span], we link the root of such span to the list of [SourceLocation].
The PR #861 introduces the foundation that will unblock [1].
To unblock [2], we need an efficient mapping from an [Instruction] to a [SourceLocation]. This must be done efficiently to avoid unnecessary increase of the memory space for the compilation. A sequence of parsed [Instruction]s is represented as [ProgramAst], that is a sequence of [Node]; [Node] behaves similarly to [CodeBlock], so we can use a similar approach: map a unique identifier of [ProgramAst] into a ordered list of [SourceLocation] to achieve a
Instruction |-> SourceLocation
mapping.From [2], we extend this mapping to [AssemblyContext], and transpose the
Instruction |-> SourceLocation
toOperation |-> SourceLocation
. This is trivial because every instruction always compiles to one or more [Operation]; we just take the instruction map and extend for the [Operation] count created for a [CodeBlock::Span].Beta Was this translation helpful? Give feedback.
All reactions