Removes the Closure.clone() in sync* by adding an additional closure
around the rewritten sync* function body.
This is a re-worked version of the now reverted:
- https://dart-review.googlesource.com/c/sdk/+/136190
- https://dart-review.googlesource.com/c/sdk/+/144948
This CL includes changes from both the above CLs, in addition to:
- A new 'ShadowRewriter' transformer to do deep rewriting of
shadowed parameters.
Previous versions only rewrote the immediate sync* function, missing
references in nested rewritten functions.
Note: This CL is re-landing largely unchanged since the roll-blocking
issues suspected to be caused by this was later attributed to a
different set of changes.
I have independently re-run all failing external tests to verify
them passing for this CL.
Bug: https://github.com/dart-lang/sdk/issues/37753
Change-Id: Id1670a93961180e8558d7c7eca65fe7e9115f07b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145402
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Instead, this CL wraps sync*'s sync_op in an additional function
that captures local copies of the necessary closure state.
Notably this state includes the parameters of the original sync* function
as these also need to be cloned for each instance.
Note: a large number of .expect files have a small number of changes
due to the additional wrapper function, as well as some extra plumbing.
Bug: https://github.com/dart-lang/sdk/issues/37753
Change-Id: If099dbfe9e5d62979626b852386fd0173fc76de5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136190
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Only mark static fields with initializers as late in opted-in
libraries (static fields without initializers should be still
pre-initialized with null and not sentinel).
Change-Id: I1371757c383ca53cc6cc798a31395f039b8719d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141341
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
According to the NNBD feature specification, "a toplevel or static
variable with an initializer is evaluated as if it was marked late".
This change actually marks all static fields in opted-in libraries
as late, in order to make sure that the rest of the VM handles
such fields uniformly as late.
Without this change implicit getters for such fields were generated
as late, but type propagation didn't treat these fields as nullable,
so field initialization checks were removed if field has a non-nullable
type.
Change-Id: I95bc096fb1d304b112369428dbb29d346964383f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140767
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
This fixes some mirrors failures in NNBD legacy mode, since the CFE is
inserting more synthetic functions now, to handle interfacing between
libraries with different NNBD status.
Change-Id: Iad5cb2548ef118f842bf2eadf249d4dca9f38fa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139740
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
On 1/27/20, the nnbd specification changed weak and strong mode instance checks
to make them behave uniformly across legacy and opted-in libraries.
Therefore, it is not necessary anymore to propagate the library mode in
generated code to the runtime.
Change-Id: I42d3ddc6e9a921899aeac21be6374c7893a6d27c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138111
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
VM doesn't expect legacy nullability for Null type, so nullability
should be adjusted when writing AOT-specific inferred types attribute in
bytecode.
Change-Id: I58b09c9931f3cce6e70f661f1ba3e7e015e7f739
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127985
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This is done by collecting all frames on the current stack until an async/async* frame is hit
which has yielded before (i.e. is not in sync-async case).
From there on it finds the closure of the async/async* frame and starts traversing the listeners:
while (closure != null) {
yield_index = closure.context[Context::kAsyncJumpVarIndex]
pc = closure.function.code.pc_descriptors.LookupPcFromYieldIndex(yield_index);
<emit pc in frame>
closure = closure.context[Context::kAsyncCompleterVarIndex]._future._resultOrListeners.callback;
}
Bug: https://github.com/dart-lang/sdk/issues/37668
Change-Id: I97030d22e529bf8a74ecd30a8a2589cfe57ad330
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122644
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This CL changes the message template generator to add an extra
'isNonNullableByDefault' parameter to 'withArguments' for all
messages that include types, thus forcing the reporter to specify
whether the library that the message belongs to is opted in to NNBD.
When the message is formatted, a '?' is added to all nullable types
if the message is reported for an opt-in library.
Change-Id: I4e1861eba48043c570afad3f40bc3dccfd2e5668
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124984
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This fixes the case where a late local var initializer allocates
variables or temporaries. It's not clear where they should be
allocated, since the initializer could be called anywhere the late
variable is accessed. So we wrap the initializer in a closure, since
calling a closure only requires a single temporary.
So then we just need to allocate that temp everywhere the late var is
accessed. Since temporaries are associated with specific AST nodes,
we also need to add the ability to swap out the temporaries associated
with a node, so that we can use the getter's temp when the getter
visits the initializer.
This will also reduce code bloat for large initializers.
Bug: https://github.com/dart-lang/sdk/issues/38841
Change-Id: Ice8c16babc0e56368657088edf1b51b422ee0241
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125762
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Right now `Script::yield_positions()` is an array mapping function start
token positions to arrays. Those arrays contain token positions and are
indexed by yield index.
=> This `Script::yield_positions()` is not available in AOT mode.
The fast async stack implementation will need to be able to find out
where an async closure was suspended. It does so by looking at the
":await_jump_var", which contains the yield index. It then needs to
associate the yield index to token position of the yield.
This CL adds an entry into the PcDescriptors for every yield in a
async/async* function and removes `Script::yield_positions()`.
The entry will associate the yield index with the token position.
Flutter gallery total size impact for flutter-release:
- armv7: +0.016%
- armv8: +0.045%
Issue https://github.com/dart-lang/sdk/issues/37668
Change-Id: I0b2ce41e85d8f5d590201bf2fb091578d7379890
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125408
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Change Expression.getStaticType to take a StaticTypeContext instead
of a TypeEnvironment.
The StaticTypeContext provides access to the TypeEnvironment and the
current 'this type' as well as determining the nullability state of the
enclosing library.
This change is needed to support nnbd types for getStaticType and also
serves as a step towards supporting caching during static type
computations to avoid repeated computations of the same (complex)
expressions.
Change-Id: Ied974dff7f6f7c3c8f262aa80c8dea5c674662f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124683
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Promoted bounds are not reified and don't make any difference at run
time. However, promoted bounds are taken into account when comparing
DartType nodes (since 75dc8483ab).
As a result, types which are different only in promoted bounds are
treated as not equal and reusing of type arguments doesn't work for
such types, which results in failed assertions in the VM.
The solution is to erase promoted bounds from type parameter types in
bytecode generator.
Fixes https://github.com/dart-lang/sdk/issues/39240
Change-Id: Ifc39592aa4e87d6273dd7ccf3129a381791609ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124900
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>