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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1320673004: dart2js: Make functions that appear to be unreachable throw. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index f9d87f94304cfb42add3c17338ba54c19881a5c1..2866837447c79a1985ee7a63e4c1af588224b0d0 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -1623,6 +1623,22 @@ class SsaBuilder extends ast.Visitor
sourceInformation: sourceInformationBuilder.buildIf(function.body));
}
}
+ if (const bool.fromEnvironment('unreachable-throw') == true) {
+ var emptyParameters = parameters.values.where((p) =>
+ p.instructionType.isEmpty && !p.instructionType.isNullable);
+ if (emptyParameters.length > 0) {
+ String message = compiler.enableMinification
+ ? 'unreachable'
+ : 'unreachable: ${functionElement} because: ${emptyParameters}';
+ // TODO(sra): Use a library function that throws a proper error object.
+ push(new HForeignCode(
+ js.js.parseForeignJS('throw "$message"'),
+ backend.dynamicType,
+ <HInstruction>[],
+ isStatement: true));
+ return closeFunction();
+ }
+ }
function.body.accept(this);
return closeFunction();
}
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698