Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 14211008: Add support for rethrow and start treating throw <expr> as an expression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use ?:. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index cb9a7dd8c0f4b13e042f849f0047fb6b79765711..667f84007d3ea8eaad1d3c8171761197aefeebda 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -3951,6 +3951,17 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
open(newBlock);
}
+ visitRethrow(Rethrow node) {
+ HInstruction exception = rethrowableException;
+ if (exception == null) {
+ exception = graph.addConstantNull(constantSystem);
+ compiler.internalError(
+ 'rethrowableException should not be null', node: node);
+ }
+ handleInTryStatement();
+ closeAndGotoExit(new HThrow(exception, isRethrow: true));
+ }
+
visitReturn(Return node) {
if (identical(node.getBeginToken().stringValue, 'native')) {
native.handleSsaNative(this, node.expression);
@@ -3976,27 +3987,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
visitThrow(Throw node) {
- if (node.expression == null) {
- HInstruction exception = rethrowableException;
- if (exception == null) {
- exception = graph.addConstantNull(constantSystem);
- compiler.internalError(
- 'rethrowableException should not be null', node: node);
- }
- handleInTryStatement();
- closeAndGotoExit(new HThrow(exception, isRethrow: true));
- } else {
- visit(node.expression);
+ visit(node.expression);
+ if (isReachable) {
handleInTryStatement();
- if (inliningStack.isEmpty) {
- closeAndGotoExit(new HThrow(pop()));
- } else if (isReachable) {
- // We don't close the block when we are inlining, because we could be
- // inside an expression, and it is rather complicated to close the
- // block at an arbitrary place in an expression.
- add(new HThrowExpression(pop()));
- isReachable = false;
- }
+ push(new HThrowExpression(pop()));
+ isReachable = false;
}
}
@@ -4972,6 +4967,11 @@ class InlineWeeder extends Visitor {
tooDifficult = true;
}
+ void visitRethrow(Rethrow node) {
+ if (!registerNode()) return;
+ tooDifficult = true;
+ }
+
void visitReturn(Return node) {
if (!registerNode()) return;
if (seenReturn
@@ -4991,9 +4991,9 @@ class InlineWeeder extends Visitor {
void visitThrow(Throw node) {
if (!registerNode()) return;
- // We can't inline rethrows and we don't want to handle throw after a return
- // even if it is in an "if".
- if (seenReturn || node.expression == null) tooDifficult = true;
+ // For now, we don't want to handle throw after a return even if
+ // it is in an "if".
+ if (seenReturn) tooDifficult = true;
}
}

Powered by Google App Engine
This is Rietveld 408576698