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

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: 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
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..4805bfcea9929ec1490378c341e626cce8cc080b 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_fragment.dart
@@ -10,6 +10,7 @@ import '../universe/selector.dart' show Selector;
import '../types/types.dart' show TypeMask;
import '../io/source_information.dart';
import '../elements/elements.dart';
+import 'cps_fragment.dart';
Siggi Cherem (dart-lang) 2016/01/08 23:51:34 remove self import?
asgerf 2016/01/11 19:07:07 I must have been confused when I wrote that
/// Builds a CPS fragment that can be plugged into another CPS term.
///
@@ -189,31 +190,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') | pkg/compiler/lib/src/cps_ir/loop_invariant_branch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698