jameysharp opened PR #8515 from jameysharp:data-const-expr
to bytecodealliance:main
:
This shouldn't change any behavior currently, but prepares us for supporting extended constant expressions.
I want to think about this a bit more before merging it but here's a draft for @fitzgen or anyone else who wants to take a look.
jameysharp edited PR #8515:
This shouldn't change any behavior currently, but prepares us for supporting extended constant expressions.
I want to think about this a bit more before merging it but here's a draft for @fitzgen or anyone else who wants to take a look. This is basically the same change as #8514 but for memories instead of tables, and the existing code was more complicated for this case.
jameysharp updated PR #8515.
jameysharp updated PR #8515.
fitzgen submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
nitpicky suggestion, take it or leave it: I'd personally rename this
InitMemoryAtRunTime
and the other impl asInitMemoryAtCompileTime
. I think it is a little more clear but maybe it is just me.
fitzgen created PR review comment:
It might be better to turn
ConstEvalContext
into a trait -- I initially did that but then every use site was the same so I made it concrete. But if it were a trait, then we could use aResult
for getting globals and funcrefs and return anErr
when they aren't available at compile time. This would allow both reusingeval
here so you don't have to do this matching (nor in the other PR, iirc) and also support const expression offsets like(i32.add (i32.const 3) (i32.const 5))
for compile-time heap image computation.
jameysharp submitted PR review.
jameysharp created PR review comment:
I wasn't entirely happy with the names I picked and considered doing something like you suggest. So it's not hard to convince me on this one!
jameysharp submitted PR review.
jameysharp created PR review comment:
It turns out it's easy to turn
ConstEvalContext
into a trait, but it's not useful without bigger changes that I haven't been able to figure out yet.
ConstExprEvaluator
can only be used within the wasmtime crate, because it relies onValRaw
. Everything that does const evaluation in that crate already has access to anInstance
. All the places that need const evaluation before instantiation are in wasmtime-environ or wasmtime-types.I tried factoring out a type-specific, integer-only const-evaluator that can live in wasmtime-types alongside
ConstExpr
andConstOp
. But the general-purpose const-evaluator is still necessary for initializing globals and I'm not real happy with duplicating this functionality.Maybe we need a trait in wasmtime-types that
Val
orValRaw
can implement?
jameysharp updated PR #8515.
jameysharp updated PR #8515.
jameysharp has marked PR #8515 as ready for review.
jameysharp requested elliottt for a review on PR #8515.
jameysharp requested wasmtime-core-reviewers for a review on PR #8515.
jameysharp commented on PR #8515:
I've decided it's more complicated than I want to tackle in this PR to make const-eval available at compile time, so I hope to come back to that later. I've renamed types as @fitzgen suggested (though I decided I liked
AtInstantiation
better thanAtRunTime
).And I've spent a couple days thinking about this and decided I don't have particularly better ideas for anything in here, so I've marked it ready for review now.
jameysharp edited PR #8515:
This shouldn't change any behavior currently, but prepares us for supporting extended constant expressions.
~I want to think about this a bit more before merging it but here's a draft for @fitzgen or anyone else who wants to take a look.~ This is ready for review. This is basically the same change as #8514 but for memories instead of tables, and the existing code was more complicated for this case.
elliottt requested fitzgen for a review on PR #8515.
fitzgen submitted PR review.
fitzgen created PR review comment:
Maybe we need a trait in wasmtime-types that
Val
orValRaw
can implement?Yeah I think we'll have to do something roughly like this.
fitzgen submitted PR review.
fitzgen merged PR #8515.
Last updated: Dec 23 2024 at 12:05 UTC