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

Side by Side Diff: test/mjsunit/apply.js

Issue 417953004: Revert 22595: "Keep new arrays allocated with 'new Array(N)' in fast mode" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/allocation-site-info.js ('k') | test/mjsunit/array-constructor-feedback.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --allow-natives-syntax
29
30 function f0() { 28 function f0() {
31 return this; 29 return this;
32 } 30 }
33 31
34 function f1(a) { 32 function f1(a) {
35 return a; 33 return a;
36 } 34 }
37 35
38 assertSame(this, f0.apply(), "1-0"); 36 assertSame(this, f0.apply(), "1-0");
39 37
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 107
110 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string"); 108 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string");
111 109
112 function al() { 110 function al() {
113 assertEquals(Object(345), this); 111 assertEquals(Object(345), this);
114 return arguments.length + arguments[arguments.length - 1]; 112 return arguments.length + arguments[arguments.length - 1];
115 } 113 }
116 114
117 for (var j = 1; j < 0x40000000; j <<= 1) { 115 for (var j = 1; j < 0x40000000; j <<= 1) {
118 try { 116 try {
119 var a = %NormalizeElements([]); 117 var a = new Array(j);
120 a.length = j;
121 a[j - 1] = 42; 118 a[j - 1] = 42;
122 assertEquals(42 + j, al.apply(345, a)); 119 assertEquals(42 + j, al.apply(345, a));
123 } catch (e) { 120 } catch (e) {
124 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1); 121 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1);
125 for (; j < 0x40000000; j <<= 1) { 122 for (; j < 0x40000000; j <<= 1) {
126 var caught = false; 123 var caught = false;
127 try { 124 try {
128 a = %NormalizeElements([]); 125 a = new Array(j);
129 a.length = j;
130 a[j - 1] = 42; 126 a[j - 1] = 42;
131 al.apply(345, a); 127 al.apply(345, a);
132 assertUnreachable("Apply of array with length " + a.length + 128 assertUnreachable("Apply of array with length " + a.length +
133 " should have thrown"); 129 " should have thrown");
134 } catch (e) { 130 } catch (e) {
135 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != - 1); 131 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != - 1);
136 caught = true; 132 caught = true;
137 } 133 }
138 assertTrue(caught, "exception not caught"); 134 assertTrue(caught, "exception not caught");
139 } 135 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 "moreseper-prime"); 190 "moreseper-prime");
195 191
196 delete(Array.prototype["1"]); 192 delete(Array.prototype["1"]);
197 193
198 // Check correct handling of non-array argument lists. 194 // Check correct handling of non-array argument lists.
199 assertSame(this, f0.apply(this, {}), "non-array-1"); 195 assertSame(this, f0.apply(this, {}), "non-array-1");
200 assertSame(this, f0.apply(this, { length:1 }), "non-array-2"); 196 assertSame(this, f0.apply(this, { length:1 }), "non-array-2");
201 assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3"); 197 assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3");
202 assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4"); 198 assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4");
203 assertEquals("foo", f1.apply(this, { length:1, 0:"foo" }), "non-array-5"); 199 assertEquals("foo", f1.apply(this, { length:1, 0:"foo" }), "non-array-5");
OLDNEW
« no previous file with comments | « test/mjsunit/allocation-site-info.js ('k') | test/mjsunit/array-constructor-feedback.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698