Source location information
Paul Sandoz
paul.sandoz at oracle.com
Tue Apr 2 20:31:51 UTC 2024
Same here.
Yes, we should also capture the source file location information. In general a model might be produced by transforming two or more models from different sources. To avoid repetition we might need some dominance rule.
What if operations are intermixed between those with and without location information? For those without should we infer the location from the nearest dominating operation with location? That may be problematic if non-dependent operations are shuffled around. I suppose that inference is up to the consumer of such models? Maybe we only need to state requirements for the models produced by the source compiler and the lowering behavior to core operations (from which we can then generate bytecode)?
Transformation-wise, supporting location for copying an operation is easy (and trivially so for removal). What about replacement? Should any replacing operations get the location of the operation being replaced unless they explicitly have location? I must admit I don’t like way such specifics might impact transformation.
API-wise it may be challenging to support operation construction without and with location information. Don’t want to pollute all the operation factory methods with an optional parameter.
Paul.
> On Apr 2, 2024, at 1:45 AM, Gary Frost <gary.frost at oracle.com> wrote:
>
> I prefer the former form, where we tag the op with location info
>
> func @"f" @loc="11:5" (%0 : int, %1 : int)int -> {
> %2 : Var<int> = var %0 @"a" @loc="11:18";
> %3 : Var<int> = var %1 @"b" @loc="11:25";
> ....
> };
>
> Over the latter form
>
> func @"f" (%0 : int, %1 : int)int -> {
> line @"11:18";
> %2 : Var<int> = var %0 @"a";
> line @"11:25";
> %3 : Var<int> = var %1 @"b";
> }
>
> As it is more obvious to me how we might handle transformations. Otherwise we need to track 'prev-sibling' nodes in the tree...
>
> Q. though. Don't we also need to capture the 'source file' somehow.... Can we do this from the model?
>
> Maybe the func level @loc also includes the source ?
>
> func @"f" @loc="SourceFile.java:11:5" (%0 : int, %1 : int)int -> {
> %2 : Var<int> = var %0 @"a" @loc="11:18";
> %3 : Var<int> = var %1 @"b" @loc="11:25";
> ....
> };
>
> From: babylon-dev <babylon-dev-retn at openjdk.org> on behalf of Paul Sandoz <paul.sandoz at oracle.com>
> Sent: Friday, March 29, 2024 8:29 PM
> To: babylon-dev at openjdk.org <babylon-dev at openjdk.org>
> Subject: Source location information
> Hi,
>
> Attached is a document discussing support for source location in code models. It briefly presents some possible approaches and requirements, and does not (yet) choose a specific approach and describe in more detail (because I don’t know what that should be).
>
> Paul.
More information about the babylon-dev
mailing list