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

Unified Diff: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart

Issue 2561533002: dart2js: Constant folding and specialization for remainder (Closed)
Patch Set: improve range analysis of remainder Created 3 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 | « pkg/compiler/lib/src/constants/constant_system.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
diff --git a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
index 60265b33444e1ee1201a65a2716be6f2decef7f0..9761f9daa87139fb0f7c6bcd482cb6a3c09167be 100644
--- a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
@@ -124,6 +124,20 @@ class JavaScriptAddOperation implements BinaryOperation {
apply(left, right) => _addOperation.apply(left, right);
}
+class JavaScriptRemainderOperation extends ArithmeticNumOperation {
+ String get name => 'remainder';
+
+ const JavaScriptRemainderOperation();
+
+ int foldInts(int left, int right) {
+ if (right == 0) return null;
+ return left.remainder(right);
+ }
+
+ num foldNums(num left, num right) => left.remainder(right);
+ apply(left, right) => left.remainder(right);
+}
+
class JavaScriptBinaryArithmeticOperation implements BinaryOperation {
final BinaryOperation dartArithmeticOperation;
@@ -233,6 +247,7 @@ class JavaScriptConstantSystem extends ConstantSystem {
const JavaScriptBinaryArithmeticOperation(const MultiplyOperation());
final negate = const JavaScriptNegateOperation();
final not = const NotOperation();
+ final remainder = const JavaScriptRemainderOperation();
final shiftLeft =
const JavaScriptBinaryBitOperation(const ShiftLeftOperation());
final shiftRight = const JavaScriptShiftRightOperation();
« no previous file with comments | « pkg/compiler/lib/src/constants/constant_system.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698