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

Unified Diff: test/mjsunit/regress/regress-447756.js

Issue 790813005: Map -0 to integer 0 for typed array constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « src/runtime.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-447756.js
diff --git a/test/mjsunit/regress/regress-447756.js b/test/mjsunit/regress/regress-447756.js
new file mode 100644
index 0000000000000000000000000000000000000000..1fc7518c13014184248d63c453bcf578165ea703
--- /dev/null
+++ b/test/mjsunit/regress/regress-447756.js
@@ -0,0 +1,48 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --allow-natives-syntax
+
+function TestConstructor(c) {
+ var a = new c(-0);
+ assertSame(Infinity, 1 / a.length);
+ assertSame(Infinity, 1 / a.byteLength);
+
+ var ab = new ArrayBuffer(-0);
+ assertSame(Infinity, 1 / ab.byteLength);
+
+ var a1 = new c(ab, -0, -0);
+ assertSame(Infinity, 1 / a1.length);
+ assertSame(Infinity, 1 / a1.byteLength);
+ assertSame(Infinity, 1 / a1.byteOffset);
+}
+
+var constructors =
+ [ Uint8Array, Int8Array, Uint8ClampedArray,
+ Uint16Array, Int16Array,
+ Uint32Array, Int32Array,
+ Float32Array, Float64Array ];
+for (var i = 0; i < constructors.length; i++) {
+ TestConstructor(constructors[i]);
+}
+
+
+function TestOptimizedCode() {
+ var a = new Uint8Array(-0);
+ assertSame(Infinity, 1 / a.length);
+ assertSame(Infinity, 1 / a.byteLength);
+
+ var ab = new ArrayBuffer(-0);
+ assertSame(Infinity, 1 / ab.byteLength);
+
+ var a1 = new Uint8Array(ab, -0, -0);
+ assertSame(Infinity, 1 / a1.length);
+ assertSame(Infinity, 1 / a1.byteLength);
+ assertSame(Infinity, 1 / a1.byteOffset);
+}
+
+%OptimizeFunctionOnNextCall(Uint8Array);
+for (var i = 0; i < 1000; i++) {
+ TestOptimizedCode();
+}
« no previous file with comments | « src/runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698