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

Unified Diff: test/mjsunit/regress/regress-crbug-245480.js

Issue 16341004: Fix for bug 245480. Calling new Array(a) with a single argument could (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed an unnecessary function Created 7 years, 6 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/x64/lithium-codegen-x64.cc ('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-crbug-245480.js
diff --git a/test/mjsunit/regress/regress-2612.js b/test/mjsunit/regress/regress-crbug-245480.js
similarity index 52%
copy from test/mjsunit/regress/regress-2612.js
copy to test/mjsunit/regress/regress-crbug-245480.js
index 06db07733d393f5327be977c56d2b764fbe1f0b1..4769486403cc43c39b243b499c763eadaaed9578 100644
--- a/test/mjsunit/regress/regress-2612.js
+++ b/test/mjsunit/regress/regress-crbug-245480.js
@@ -25,52 +25,66 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax --nodead-code-elimination
-// Flags: --nofold-constants --nouse-gvn
+// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
+// Flags: --track-allocation-sites --noalways-opt
-// Create a function to get a long series of removable simulates.
-// f() {
-// var _0 = <random>, _1 = <random>, ... _1000 = <random>,
-// _1001 = <random var> + <random var>,
-// _1002 = <random var> + <random var>,
-// ...
-// _99999 = <random var> + <random var>,
-// x = 1;
-// return _0;
-// }
+// Test element kind of objects.
+// Since --smi-only-arrays affects builtins, its default setting at compile
+// time sticks if built with snapshot. If --smi-only-arrays is deactivated
+// by default, only a no-snapshot build actually has smi-only arrays enabled
+// in this test case. Depending on whether smi-only arrays are actually
+// enabled, this test takes the appropriate code path to check smi-only arrays.
-var seed = 1;
+// support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
+support_smi_only_arrays = true;
-function rand() {
- seed = seed * 171 % 1337 + 17;
- return (seed % 1000) / 1000;
+if (support_smi_only_arrays) {
+ print("Tests include smi-only arrays.");
+} else {
+ print("Tests do NOT include smi-only arrays.");
}
-function randi(max) {
- seed = seed * 131 % 1773 + 13;
- return seed % max;
+function isHoley(obj) {
+ if (%HasFastHoleyElements(obj)) return true;
+ return false;
}
-function varname(i) {
- return "_" + i;
+function assertHoley(obj, name_opt) {
+ assertEquals(true, isHoley(obj), name_opt);
}
-var source = "var ";
-
-for (var i = 0; i < 1000; i++) {
- source += [varname(i), "=", rand(), ","].join("");
+function assertNotHoley(obj, name_opt) {
+ assertEquals(false, isHoley(obj), name_opt);
}
-for (var i = 1000; i < 100000; i++) {
- source += [varname(i), "=",
- varname(randi(i)), "+",
- varname(randi(i)), ","].join("");
+if (support_smi_only_arrays) {
+ function create_array(arg) {
+ return new Array(arg);
+ }
+
+ obj = create_array(0);
+ assertNotHoley(obj);
+ create_array(0);
+ %OptimizeFunctionOnNextCall(create_array);
+ obj = create_array(10);
+ assertHoley(obj);
}
-source += "x=1; return _0;"
-var f = new Function(source);
+// The code below would assert in debug or crash in release
+function f(length) {
+ return new Array(length)
+}
-f();
+f(0);
+f(0);
%OptimizeFunctionOnNextCall(f);
-f();
+var a = f(10);
+
+function g(a) {
+ return a[0];
+}
+var b = [0];
+g(b);
+g(b);
+assertEquals(undefined, g(a));
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698