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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_fragment.dart

Issue 1573693002: dart2js cps: Hoist loop-invariant branches from loop entry. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove self-import Created 4 years, 11 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 | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_fragment.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
index cc06b498c2f77e038b62b7ce2b03870a4900de10..7e62fa5f7066885056dc925b13754bfa4039e0ee 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
@@ -189,31 +189,39 @@ class CpsFragment {
/// Branch on [condition].
///
- /// Returns a new fragment for the 'then' branch.
+ /// Returns a new fragment for the 'then' branch, or the 'else' branch
+ /// if [negate] is true.
///
- /// The 'else' branch becomes the new hole.
- CpsFragment ifTruthy(Primitive condition) {
+ /// The other branch becomes the new hole.
+ CpsFragment branch(Primitive condition,
+ {bool negate: false,
+ bool strict: false}) {
Continuation trueCont = new Continuation(<Parameter>[]);
Continuation falseCont = new Continuation(<Parameter>[]);
put(new LetCont.two(trueCont, falseCont,
- new Branch.loose(condition, trueCont, falseCont)));
- context = falseCont;
- return new CpsFragment(sourceInformation, trueCont);
+ new Branch(condition, trueCont, falseCont, strict: strict)));
+ if (negate) {
+ context = trueCont;
+ return new CpsFragment(sourceInformation, falseCont);
+ } else {
+ context = falseCont;
+ return new CpsFragment(sourceInformation, trueCont);
+ }
}
/// Branch on [condition].
///
+ /// Returns a new fragment for the 'then' branch.
+ ///
+ /// The 'else' branch becomes the new hole.
+ CpsFragment ifTruthy(Primitive condition) => branch(condition);
+
+ /// Branch on [condition].
+ ///
/// Returns a new fragment for the 'else' branch.
///
/// The 'then' branch becomes the new hole.
- CpsFragment ifFalsy(Primitive condition) {
- Continuation trueCont = new Continuation(<Parameter>[]);
- Continuation falseCont = new Continuation(<Parameter>[]);
- put(new LetCont.two(trueCont, falseCont,
- new Branch.loose(condition, trueCont, falseCont)));
- context = trueCont;
- return new CpsFragment(sourceInformation, falseCont);
- }
+ CpsFragment ifFalsy(Primitive condition) => branch(condition, negate: true);
/// Create a new empty continuation and bind it here.
///
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698