Skip to content

Commit

Permalink
Reland "[ddc] Clean up old async logic in ddc compiler."
Browse files Browse the repository at this point in the history
This is a reland of commit 34de757

Original change's description:
> [ddc] Clean up old async logic in ddc compiler.
>
> This removes any remaining code that was used for async functions.
>
> Change-Id: I3ffa391caf0befa13b67159c35b36daee6f810dc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372040
> Reviewed-by: Mark Zhou <[email protected]>
> Reviewed-by: Nicholas Shahan <[email protected]>
> Commit-Queue: Nate Biggs <[email protected]>
> Reviewed-by: Bob Nystrom <[email protected]>

Change-Id: I3d9d69809825265359074d5637325c227f2e0857
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376001
Reviewed-by: Bob Nystrom <[email protected]>
Commit-Queue: Nate Biggs <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
  • Loading branch information
natebiggs authored and Commit Queue committed Jul 30, 2024
1 parent 8bd3690 commit e9c7b2b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 57 deletions.
21 changes: 1 addition & 20 deletions pkg/dev_compiler/lib/src/compiler/js_metalet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// TODO(jmesserly): import from its own package
import '../js_ast/js_ast.dart';
import 'js_names.dart' show TemporaryId;
import 'js_utils.dart' show YieldFinder;

/// A synthetic `let*` node, similar to that found in Scheme.
///
Expand Down Expand Up @@ -134,15 +133,6 @@ class MetaLet extends Expression {
return _finishStatement(statements);
}

@override
Block toYieldStatement({bool star = false}) {
var statements = body
.map((e) =>
e == body.last ? e.toYieldStatement(star: star) : e.toStatement())
.toList();
return _finishStatement(statements);
}

@override
T accept<T>(NodeVisitor<T> visitor) {
// TODO(jmesserly): we special case visitors from js_ast.Template, because
Expand Down Expand Up @@ -187,16 +177,7 @@ class MetaLet extends Expression {
}

Expression _toInvokedFunction(Block block) {
var finder = YieldFinder();
block.accept(finder);
if (!finder.hasYield) {
return Call(ArrowFun([], block), []);
}
// If we have a yield, it's more tricky. We'll create a `function*`, which
// we `yield*` to immediately invoke. We also may need to bind this:
Expression fn = Fun([], block, isGenerator: true);
if (finder.hasThis) fn = js.call('#.bind(this)', fn);
return Yield(Call(fn, []), star: true);
return Call(ArrowFun([], block), []);
}

Block _finishStatement(List<Statement> statements) {
Expand Down
31 changes: 0 additions & 31 deletions pkg/dev_compiler/lib/src/compiler/js_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,6 @@ class _IdentifierFinder extends BaseVisitorVoid {
}
}

class YieldFinder extends BaseVisitorVoid {
bool hasYield = false;
bool hasThis = false;
bool _nestedFunction = false;

@override
void visitThis(This node) {
hasThis = true;
}

@override
void visitFunctionExpression(FunctionExpression node) {
var savedNested = _nestedFunction;
_nestedFunction = true;
super.visitFunctionExpression(node);
_nestedFunction = savedNested;
}

@override
void visitYield(Yield node) {
if (!_nestedFunction) hasYield = true;
super.visitYield(node);
}

@override
void visitNode(Node node) {
if (hasYield && hasThis) return; // found both, nothing more to do.
super.visitNode(node);
}
}

/// Given the function [fn], returns a function declaration statement, binding
/// `this` and `super` if necessary (using an arrow function).
Statement toBoundFunctionStatement(Fun fn, Identifier name) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/dev_compiler/lib/src/js_ast/nodes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,6 @@ abstract class Expression extends Node {
@override
Statement toReturn() => Return(this);

// TODO(jmesserly): make this return a Yield?
Statement toYieldStatement({bool star = false}) =>
ExpressionStatement(Yield(this, star: star));

Expression toVoidExpression() => this;
Expression toAssignExpression(Expression left, [String? op]) =>
Assignment.compound(left, op, this);
Expand Down
2 changes: 0 additions & 2 deletions tests/language/language_dartdevc.status
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Sections in this file should contain "$compiler == ddc".

[ $compiler == ddc ]
async_star/async_star_await_for_test: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/51086
async_star/throw_in_catch_test: Skip # Times out. Issue 29920
closure/cycles_test: Pass, Slow # Long test to pressure GC, periodically times out
external_abstract_fields/external_fields_test: SkipByDesign # Non-JS-interop external members are not supported
inference_update_2/external_field_test: SkipByDesign # Non-JS-interop external members are not supported
Expand Down

0 comments on commit e9c7b2b

Please sign in to comment.