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

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

Issue 397593008: Keep new arrays allocated with 'new Array(N)' in fast mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix slow test Created 6 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 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
28 function f0() { 30 function f0() {
29 return this; 31 return this;
30 } 32 }
31 33
32 function f1(a) { 34 function f1(a) {
33 return a; 35 return a;
34 } 36 }
35 37
36 assertSame(this, f0.apply(), "1-0"); 38 assertSame(this, f0.apply(), "1-0");
37 39
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 109
108 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string"); 110 assertEquals("bar42foofishhorse", s.apply("bar", arr), "apply to string");
109 111
110 function al() { 112 function al() {
111 assertEquals(Object(345), this); 113 assertEquals(Object(345), this);
112 return arguments.length + arguments[arguments.length - 1]; 114 return arguments.length + arguments[arguments.length - 1];
113 } 115 }
114 116
115 for (var j = 1; j < 0x40000000; j <<= 1) { 117 for (var j = 1; j < 0x40000000; j <<= 1) {
116 try { 118 try {
117 var a = new Array(j); 119 var a = %NormalizeElements([]);
120 a.length = j;
118 a[j - 1] = 42; 121 a[j - 1] = 42;
119 assertEquals(42 + j, al.apply(345, a)); 122 assertEquals(42 + j, al.apply(345, a));
120 } catch (e) { 123 } catch (e) {
121 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1); 124 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != -1);
122 for (; j < 0x40000000; j <<= 1) { 125 for (; j < 0x40000000; j <<= 1) {
123 var caught = false; 126 var caught = false;
124 try { 127 try {
125 a = new Array(j); 128 a = %NormalizeElements([]);
129 a.length = j;
126 a[j - 1] = 42; 130 a[j - 1] = 42;
127 al.apply(345, a); 131 al.apply(345, a);
128 assertUnreachable("Apply of array with length " + a.length + 132 assertUnreachable("Apply of array with length " + a.length +
129 " should have thrown"); 133 " should have thrown");
130 } catch (e) { 134 } catch (e) {
131 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != - 1); 135 assertTrue(e.toString().indexOf("Maximum call stack size exceeded") != - 1);
132 caught = true; 136 caught = true;
133 } 137 }
134 assertTrue(caught, "exception not caught"); 138 assertTrue(caught, "exception not caught");
135 } 139 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 "moreseper-prime"); 194 "moreseper-prime");
191 195
192 delete(Array.prototype["1"]); 196 delete(Array.prototype["1"]);
193 197
194 // Check correct handling of non-array argument lists. 198 // Check correct handling of non-array argument lists.
195 assertSame(this, f0.apply(this, {}), "non-array-1"); 199 assertSame(this, f0.apply(this, {}), "non-array-1");
196 assertSame(this, f0.apply(this, { length:1 }), "non-array-2"); 200 assertSame(this, f0.apply(this, { length:1 }), "non-array-2");
197 assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3"); 201 assertEquals(void 0, f1.apply(this, { length:1 }), "non-array-3");
198 assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4"); 202 assertEquals(void 0, f1.apply(this, { 0:"foo" }), "non-array-4");
199 assertEquals("foo", f1.apply(this, { length:1, 0:"foo" }), "non-array-5"); 203 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