-
Notifications
You must be signed in to change notification settings - Fork 1.7k
VM: Implement support for constants being evaluated by front end #36220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/cc @aartbik @alexmarkov who should own this issue? |
I marked us both as owner for now. Alex probably wants to do the bytecode side. I can help with the other stuff after consulting with Alex. |
Rationale: The constant evaluator deals with two sorts of offsets, the true offset into the kernel data, and the offset of a constant relative to the start of the constant table (compensated for a variable-size int prefix at the true base). The DAG test was comparing the latter against the former (which was always true, since the true offsets are much larger). This fixes this omission. #36220 Change-Id: I71f37bfb2bd3432e52d5086e89a62115f0cacacd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97421 Commit-Queue: Aart Bik <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
Any updates on this issue? |
I am not aware of blocking VM work. For JIT, we could lazily instead of eagerly evaluate the constants in the constant table (which becomes larger) to reduce compile-time, and I have a prototype CL for that. For AOT, I don't think anything is not working, and removing code would be just a cleanup. I let Alex comment on bytecode status. |
I think this issue can be taken off from the 2.3 milestone list, it is more for clean up work to remove the redundant constant expressions evaluation code from the AOT and bytecode paths once CFE has solid support for constant expressions evaluation. |
Rationale: Previously all constants were read from the constants table, whether they were needed (at that point or at all) or not. This CL replaces that eager reading with a lazy reading that makes the raw bytes of the constants table available through KernelProgramInfo and attaches a hashmap to KernelProgramInfo, which maps offsets into the constant table to evaluated constants. The maps starts empty and on a miss, the constant is evaluated, but no sooner than when it it needed. #36220 Change-Id: Ief4df3d70c950c4beb61d896632ce06cfd12d525 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99088 Commit-Queue: Aart Bik <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
Lazy constant reading has been submitted. Items and ideas to follow up on: (1) by setting the raw-bytes array and hash map from the start, we may be able to completely avoid the "pending" and "delayed" data structures; we should be evaluate every constant when needed first |
Approved fails to follow-up on:
|
A fix for the cyclic test crash is pending (see https://dart-review.googlesource.com/c/sdk/+/107000). As for the constant inference, the difference is right after canonicalize: v16 <- Constant(#Closure: (Null) => Null from Function 'constFunction': static.) T{_Closure}
vs.
v16 <- Constant(#Closure: (dynamic) => dynamic from Function 'constFunction': static.) T{_Closure}
|
Rationale: Due to the cycle breaking reading of VM annotations, we should be prepared to see a class loaded inside class loading wrap-up. #36220 Change-Id: I46665989e489ada8ed2414a57a789b9c2d9c9f7a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107000 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Aart Bik <[email protected]>
The canonicalize difference happens in LoadFieldInstr::Canonicalize() with the following code if (Evaluate(instance()->BoundConstant(), &result)) {
if (result.IsSmi() || result.IsOld()) {
return flow_graph->GetConstant(result);
}
} with Evaluate() returning the different values v15 <- Constant(#Instance of 'C<Null>') T{C}
Instance of 'C<Null>'
Closure: (Null) => Null from Function 'constFunction': static.
v15 <- Constant(#Instance of 'C<Null>') T{C}
Instance of 'C<Null>'
Closure: (dynamic) => dynamic from Function 'constFunction': static.
Indeed, this is a difference already at constant evaluation level:
|
Fix for crash confirmed: The following tests are now succeeding:
Fix for the failure is pending at https://dart-review.googlesource.com/c/sdk/+/107064 |
Rationale: As shown in the comment, I was already not sure about what argument to use. Clearly one of the two type arguments is not needed. This fixes the language_2/const_inference_test failure that was temporarily approved. #36220 Change-Id: I3dd8ddf0e3cf0e992164c005b08ffd59306041f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107064 Reviewed-by: Aart Bik <[email protected]> Commit-Queue: Aart Bik <[email protected]> Auto-Submit: Aart Bik <[email protected]>
Confirmed fixes for all vm bots. Sample. below. The following tests are now succeeding:
|
Rationale: Only look for "external" and "pragma" to avoid cyclic or unloaded class evaluation #37533 #36220 Change-Id: I78ef5dcd2c7e7dee0d196394320e994f8aa8a695 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109300 Commit-Queue: Aart Bik <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
@a-siva any actionable items left for this? |
I think there are no more known items, let me close it. If we find bugs we can open new issues for the failures. |
This is the tracker issue for implementing support in the VM for constants being evaluated by the front end
Language tracking issue: dart-lang/language#60
Frontend implementation tracking issue: #35079
The text was updated successfully, but these errors were encountered: