b3fbb59d60
In the old scheme, sync* generators would have an entry and a
body. The entry contained typed checks and the body had injected code
to call a 'factory' helper method to construct the _SyncStarIterable.
It was necessary to pass the element type to the body to be passed to
the factory.
int foo(T a, T b) sync* {yield f(a); yield f(b);}
is compiled to something like
foo(a, b) {
T._as(a); T._as(b);
return foo$body(a, b, type$.int);
}
foo$body(a, b, R) {
return _syncStarFactory(function(){BODY}, R);
}
When type checks were disabled (`-O3`), it was often possible to
generate a single function by merging these as there were no checks.
The new scheme keeps the entry and body separate, and constructs the
_SyncStarIterable in the entry:
foo(a, b) {
T._as(a); T._as(b);
return _syncStarFactory(foo$body(a, b), type$.int);
}
foo$body(a, b) {
return function(){BODY};
}
This keeps the typed Dart 'level' distinct from the untyped JavaScript
level.
The new scheme is a bit more verbose but has the advantage that the
call to `_syncStarFactory` can be inlined and optimized.
Change-Id: I13802d9c9eefd9323841670d059b75a81569d6cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296140
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>