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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/optimizers.dart

Issue 1364703004: dart2js cps: LICM, GVN, and constify for interceptors in one pass. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.cps_ir.optimizers; 5 library dart2js.cps_ir.optimizers;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 import '../constants/values.dart'; 8 import '../constants/values.dart';
9 9
10 export 'type_propagation.dart' show TypePropagator; 10 export 'type_propagation.dart' show TypePropagator;
11 export 'scalar_replacement.dart' show ScalarReplacer; 11 export 'scalar_replacement.dart' show ScalarReplacer;
12 export 'redundant_phi.dart' show RedundantPhiEliminator; 12 export 'redundant_phi.dart' show RedundantPhiEliminator;
13 export 'redundant_join.dart' show RedundantJoinEliminator; 13 export 'redundant_join.dart' show RedundantJoinEliminator;
14 export 'shrinking_reductions.dart' show ShrinkingReducer, ParentVisitor; 14 export 'shrinking_reductions.dart' show ShrinkingReducer, ParentVisitor;
15 export 'mutable_ssa.dart' show MutableVariableEliminator; 15 export 'mutable_ssa.dart' show MutableVariableEliminator;
16 export 'insert_refinements.dart' show InsertRefinements; 16 export 'insert_refinements.dart' show InsertRefinements;
17 export 'remove_refinements.dart' show RemoveRefinements; 17 export 'remove_refinements.dart' show RemoveRefinements;
18 export 'loop_invariant_code_motion.dart' show LoopInvariantCodeMotion;
19 export 'share_interceptors.dart' show ShareInterceptors; 18 export 'share_interceptors.dart' show ShareInterceptors;
20 19
21 /// An optimization pass over the CPS IR. 20 /// An optimization pass over the CPS IR.
22 abstract class Pass { 21 abstract class Pass {
23 /// Applies optimizations to root, rewriting it in the process. 22 /// Applies optimizations to root, rewriting it in the process.
24 void rewrite(FunctionDefinition root); 23 void rewrite(FunctionDefinition root);
25 24
26 String get passName; 25 String get passName;
27 } 26 }
28 27
29 // Shared code between optimizations 28 // Shared code between optimizations
30 29
31 /// Returns true if [value] is false, null, 0, -0, NaN, or the empty string. 30 /// Returns true if [value] is false, null, 0, -0, NaN, or the empty string.
32 bool isFalsyConstant(ConstantValue value) { 31 bool isFalsyConstant(ConstantValue value) {
33 return value.isFalse || 32 return value.isFalse ||
34 value.isNull || 33 value.isNull ||
35 value.isZero || 34 value.isZero ||
36 value.isMinusZero || 35 value.isMinusZero ||
37 value.isNaN || 36 value.isNaN ||
38 value is StringConstantValue && value.primitiveValue.isEmpty; 37 value is StringConstantValue && value.primitiveValue.isEmpty;
39 } 38 }
40 39
41 /// Returns true if [value] satisfies a branching condition with the 40 /// Returns true if [value] satisfies a branching condition with the
42 /// given strictness. 41 /// given strictness.
43 /// 42 ///
44 /// For non-strict, this is the opposite of [isFalsyConstant]. 43 /// For non-strict, this is the opposite of [isFalsyConstant].
45 bool isTruthyConstant(ConstantValue value, {bool strict: false}) { 44 bool isTruthyConstant(ConstantValue value, {bool strict: false}) {
46 return strict ? value.isTrue : !isFalsyConstant(value); 45 return strict ? value.isTrue : !isFalsyConstant(value);
47 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698