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

Unified Diff: tests/standalone/javascript_int_overflow_test.dart

Issue 22640019: Fix for running with --throw_on_javascript_int_overflow: recognize pattern (a << b) & mask and test… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/javascript_int_overflow_test.dart
===================================================================
--- tests/standalone/javascript_int_overflow_test.dart (revision 26093)
+++ tests/standalone/javascript_int_overflow_test.dart (working copy)
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// VMOptions=--throw_on_javascript_int_overflow --optimization_counter_threshold=10
+// VMOptions=--throw_on_javascript_int_overflow --optimization_counter_threshold=10 --no-use-osr
import "package:expect/expect.dart";
@@ -54,6 +54,26 @@
return min_literal;
}
+
+int doNotThrow1(a, b) {
+ return (a << b) & 0xFFFFFFFF;
+}
+
+int doNotThrow2(a, b) {
+ return (a << b) & 0xFFFFFFFF;
+}
+
+
+int doNotThrow3(a, b) {
+ return (a << b) & 0x7FFFFFFF;
+}
+
+
+int doNotThrow4(a, b) {
+ return (a << b) & 0x7FFFFFFF;
+}
+
+
// We don't test for the _JavascriptIntegerOverflowError since it's not visible.
// It should not be visible since it doesn't exist on dart2js.
bool isJavascriptIntError(e) =>
@@ -116,4 +136,16 @@
Expect.throws(max_add_throws, isJavascriptIntError);
Expect.throws(min_sub_throws, isJavascriptIntError);
+
+ for (int i = 0; i < 20; i++) {
+ Expect.equals(0xAFAFA000, doNotThrow1(0xFAFAFA, 12));
+ Expect.equals(0x2FAFA000, doNotThrow3(0xFAFAFA, 12));
+ Expect.equals(0xABABA000, doNotThrow2(0xFAFAFAABABA, 12));
+ Expect.equals(0x2BABA000, doNotThrow4(0xFAFAFAABABA, 12));
+ }
+ for (int i = 0; i < 20; i++) {
+ Expect.equals(0xABABA000, doNotThrow1(0xFAFAFAABABA, 12));
+ Expect.equals(0x2BABA000, doNotThrow3(0xFAFAFAABABA, 12));
+ }
+
}
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698