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

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

Issue 1699833002: dart2js cps: Specialize shift-right calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase Created 4 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index a338379d6d2aaeffdd316b76202c54fbc917de52..00cbfb1d37122a703f688baf094c626d8d9af4e8 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -1270,6 +1270,22 @@ class TransformingVisitor extends DeepRecursiveVisitor {
return cps;
}
+ Selector renameToOptimizedSelector(String name) {
+ return new Selector.call(
+ new Name(name, backend.helpers.interceptorsLibrary),
+ node.selector.callStructure);
+ }
+
+ /// Replaces the call with a call to [name] with the same inputs.
+ InvokeMethod makeRenamedInvoke(String name) {
+ return new InvokeMethod(node.receiver.definition,
+ renameToOptimizedSelector(name),
+ node.mask,
+ node.arguments.map((ref) => ref.definition).toList(),
+ sourceInformation: node.sourceInformation,
+ callingConvention: node.callingConvention);
+ }
+
TypeMask successType =
typeSystem.receiverTypeFor(node.selector, node.dartReceiver.type);
@@ -1326,10 +1342,20 @@ class TransformingVisitor extends DeepRecursiveVisitor {
// Try to insert a shift-right operator. JavaScript's right shift is
// consistent with Dart's only for left operands in the unsigned
// 32-bit range.
- if (opname == '>>' &&
- lattice.isDefinitelyUint32(left, allowNull: true) &&
- lattice.isDefinitelyIntInRange(right, min: 0, max: 31)) {
- return makeBinary(BuiltinOperator.NumShr, guard: checkIsNumber);
+ if (opname == '>>') {
+ if (lattice.isDefinitelyUint32(left, allowNull: true) &&
+ lattice.isDefinitelyIntInRange(right, min: 0, max: 31)) {
+ return makeBinary(BuiltinOperator.NumShr, guard: checkIsNumber);
+ } else if (lattice.isDefinitelyUint(left) &&
+ lattice.isDefinitelyUint(right)) {
+ return makeRenamedInvoke('_shrBothPositive');
+ } else if (lattice.isDefinitelyUint(left) &&
+ lattice.isDefinitelyNum(right)) {
+ return makeRenamedInvoke('_shrReceiverPositive');
+ } else if (lattice.isDefinitelyNum(left) &&
+ lattice.isDefinitelyUint(right)) {
+ return makeRenamedInvoke('_shrOtherPositive');
+ }
}
// Try to use remainder for '%'. Both operands must be non-negative
// and the divisor must be non-zero.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698