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

Side by Side Diff: test/mjsunit/generated-transition-stub.js

Issue 19776006: Fix %NeverOptimizeFunction runtime call. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add assert for safety. Created 7 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/elide-double-hole-check-9.js ('k') | test/mjsunit/never-optimize.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 --compiled_transitions 28 // Flags: --allow-natives-syntax --compiled_transitions
29 29
30 %NeverOptimize(); 30 %NeverOptimizeFunction(test);
31 function test() {
31 32
32 var iteration_count = 1; 33 var iteration_count = 1;
33 34
34 function transition1(a, i, v) { 35 function transition1(a, i, v) {
35 a[i] = v; 36 a[i] = v;
37 }
38
39 //
40 // Test PACKED SMI -> PACKED DOUBLE
41 //
42
43 var a1 = [0, 1, 2, 3, 4];
44 transition1(a1, 0, 2.5);
45 var a2 = [0, 1, 2, 3, 4];
46 transition1(a2, 0, 2.5);
47 assertFalse(%HasFastHoleyElements(a2));
48 %OptimizeFunctionOnNextCall(transition1);
49
50 var a3 = [0, 1, 2, 3, 4];
51 assertTrue(%HasFastSmiElements(a3));
52 transition1(a3, 0, 2.5);
53 assertFalse(%HasFastHoleyElements(a3));
54 assertEquals(4, a3[4]);
55 assertEquals(2.5, a3[0]);
56
57 // Test handling of hole.
58 var a4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
59 a4.length = 7;
60 assertTrue(%HasFastSmiElements(a4));
61 transition1(a4, 0, 2.5);
62 assertFalse(%HasFastHoleyElements(a4));
63 assertEquals(2.5, a4[0]);
64 assertEquals(undefined, a4[8]);
65
66 // Large array should deopt to runtimea
67 for (j = 0; j < iteration_count; ++j) {
68 a5 = new Array();
69 for (i = 0; i < 0x40000; ++i) {
70 a5[i] = 0;
71 }
72 assertTrue(%HasFastSmiElements(a5) || %HasFastDoubleElements(a5));
73 transition1(a5, 0, 2.5);
74 assertEquals(2.5, a5[0]);
75 }
76
77 //
78 // Test HOLEY SMI -> HOLEY DOUBLE
79 //
80
81 function transition2(a, i, v) {
82 a[i] = v;
83 }
84
85 var b1 = [0, 1, 2, , 4];
86 transition2(b1, 0, 2.5);
87 var b2 = [0, 1, 2, , 4];
88 transition2(b2, 0, 2.5);
89 assertTrue(%HasFastHoleyElements(b2));
90 %OptimizeFunctionOnNextCall(transition2);
91
92 var b3 = [0, 1, 2, , 4];
93 assertTrue(%HasFastSmiElements(b3));
94 assertTrue(%HasFastHoleyElements(b3));
95 transition2(b3, 0, 2.5);
96 assertTrue(%HasFastHoleyElements(b3));
97 assertEquals(4, b3[4]);
98 assertEquals(2.5, b3[0]);
99
100 // Large array should deopt to runtime
101 for (j = 0; j < iteration_count; ++j) {
102 b4 = [0, ,0];
103 for (i = 3; i < 0x40000; ++i) {
104 b4[i] = 0;
105 }
106 assertTrue(%HasFastSmiElements(b4));
107 transition2(b4, 0, 2.5);
108 assertEquals(2.5, b4[0]);
109 }
110
111 //
112 // Test PACKED DOUBLE -> PACKED OBJECT
113 //
114
115 function transition3(a, i, v) {
116 a[i] = v;
117 }
118
119 var c1 = [0, 1, 2, 3.5, 4];
120 transition3(c1, 0, new Object());
121 var c2 = [0, 1, 2, 3.5, 4];
122 transition3(c2, 0, new Object());
123 assertTrue(%HasFastObjectElements(c2));
124 assertTrue(!%HasFastHoleyElements(c2));
125 %OptimizeFunctionOnNextCall(transition3);
126
127 var c3 = [0, 1, 2, 3.5, 4];
128 assertTrue(%HasFastDoubleElements(c3));
129 assertTrue(!%HasFastHoleyElements(c3));
130 transition3(c3, 0, new Array());
131 assertTrue(!%HasFastHoleyElements(c3));
132 assertTrue(%HasFastObjectElements(c3));
133 assertEquals(4, c3[4]);
134 assertEquals(0, c3[0].length);
135
136 // Large array under the deopt threshold should be able to trigger GC without
137 // causing crashes.
138 for (j = 0; j < iteration_count; ++j) {
139 c4 = [0, 2.5, 0];
140 for (i = 3; i < 0xa000; ++i) {
141 c4[i] = 0;
142 }
143 assertTrue(%HasFastDoubleElements(c4));
144 assertTrue(!%HasFastHoleyElements(c4));
145 transition3(c4, 0, new Array(5));
146 assertTrue(!%HasFastHoleyElements(c4));
147 assertTrue(%HasFastObjectElements(c4));
148 assertEquals(5, c4[0].length);
149 }
150
151 // Large array should deopt to runtime
152 for (j = 0; j < iteration_count; ++j) {
153 c5 = [0, 2.5, 0];
154 for (i = 3; i < 0x40000; ++i) {
155 c5[i] = 0;
156 }
157 assertTrue(%HasFastDoubleElements(c5));
158 assertTrue(!%HasFastHoleyElements(c5));
159 transition3(c5, 0, new Array(5));
160 assertTrue(!%HasFastHoleyElements(c5));
161 assertTrue(%HasFastObjectElements(c5));
162 assertEquals(5, c5[0].length);
163 }
164
165 //
166 // Test HOLEY DOUBLE -> HOLEY OBJECT
167 //
168
169 function transition4(a, i, v) {
170 a[i] = v;
171 }
172
173 var d1 = [0, 1, , 3.5, 4];
174 transition4(d1, 0, new Object());
175 var d2 = [0, 1, , 3.5, 4];
176 transition4(d2, 0, new Object());
177 assertTrue(%HasFastObjectElements(d2));
178 assertTrue(%HasFastHoleyElements(d2));
179 %OptimizeFunctionOnNextCall(transition4);
180
181 var d3 = [0, 1, , 3.5, 4];
182 assertTrue(%HasFastDoubleElements(d3));
183 assertTrue(%HasFastHoleyElements(d3));
184 transition4(d3, 0, new Array());
185 assertTrue(%HasFastHoleyElements(d3));
186 assertTrue(%HasFastObjectElements(d3));
187 assertEquals(4, d3[4]);
188 assertEquals(0, d3[0].length);
189
190 // Large array under the deopt threshold should be able to trigger GC without
191 // causing crashes.
192 for (j = 0; j < iteration_count; ++j) {
193 d4 = [, 2.5, ,];
194 for (i = 3; i < 0xa000; ++i) {
195 d4[i] = 0;
196 }
197 assertTrue(%HasFastDoubleElements(d4));
198 assertTrue(%HasFastHoleyElements(d4));
199 transition4(d4, 0, new Array(5));
200 assertTrue(%HasFastHoleyElements(d4));
201 assertTrue(%HasFastObjectElements(d4));
202 assertEquals(5, d4[0].length);
203 assertEquals(undefined, d4[2]);
204 }
205
206 // Large array should deopt to runtime
207 for (j = 0; j < iteration_count; ++j) {
208 d5 = [, 2.5, ,];
209 for (i = 3; i < 0x40000; ++i) {
210 d5[i] = 0;
211 }
212 assertTrue(%HasFastDoubleElements(d5));
213 assertTrue(%HasFastHoleyElements(d5));
214 transition4(d5, 0, new Array(5));
215 assertTrue(%HasFastHoleyElements(d5));
216 assertTrue(%HasFastObjectElements(d5));
217 assertEquals(5, d5[0].length);
218 assertEquals(undefined, d5[2]);
219 }
220
36 } 221 }
37 222 test();
38 //
39 // Test PACKED SMI -> PACKED DOUBLE
40 //
41
42 var a1 = [0, 1, 2, 3, 4];
43 transition1(a1, 0, 2.5);
44 var a2 = [0, 1, 2, 3, 4];
45 transition1(a2, 0, 2.5);
46 assertFalse(%HasFastHoleyElements(a2));
47 %OptimizeFunctionOnNextCall(transition1);
48
49 var a3 = [0, 1, 2, 3, 4];
50 assertTrue(%HasFastSmiElements(a3));
51 transition1(a3, 0, 2.5);
52 assertFalse(%HasFastHoleyElements(a3));
53 assertEquals(4, a3[4]);
54 assertEquals(2.5, a3[0]);
55
56 // Test handling of hole.
57 var a4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
58 a4.length = 7;
59 assertTrue(%HasFastSmiElements(a4));
60 transition1(a4, 0, 2.5);
61 assertFalse(%HasFastHoleyElements(a4));
62 assertEquals(2.5, a4[0]);
63 assertEquals(undefined, a4[8]);
64
65 // Large array should deopt to runtimea
66 for (j = 0; j < iteration_count; ++j) {
67 a5 = new Array();
68 for (i = 0; i < 0x40000; ++i) {
69 a5[i] = 0;
70 }
71 assertTrue(%HasFastSmiElements(a5) || %HasFastDoubleElements(a5));
72 transition1(a5, 0, 2.5);
73 assertEquals(2.5, a5[0]);
74 }
75
76 //
77 // Test HOLEY SMI -> HOLEY DOUBLE
78 //
79
80 function transition2(a, i, v) {
81 a[i] = v;
82 }
83
84 var b1 = [0, 1, 2, , 4];
85 transition2(b1, 0, 2.5);
86 var b2 = [0, 1, 2, , 4];
87 transition2(b2, 0, 2.5);
88 assertTrue(%HasFastHoleyElements(b2));
89 %OptimizeFunctionOnNextCall(transition2);
90
91 var b3 = [0, 1, 2, , 4];
92 assertTrue(%HasFastSmiElements(b3));
93 assertTrue(%HasFastHoleyElements(b3));
94 transition2(b3, 0, 2.5);
95 assertTrue(%HasFastHoleyElements(b3));
96 assertEquals(4, b3[4]);
97 assertEquals(2.5, b3[0]);
98
99 // Large array should deopt to runtime
100 for (j = 0; j < iteration_count; ++j) {
101 b4 = [0, ,0];
102 for (i = 3; i < 0x40000; ++i) {
103 b4[i] = 0;
104 }
105 assertTrue(%HasFastSmiElements(b4));
106 transition2(b4, 0, 2.5);
107 assertEquals(2.5, b4[0]);
108 }
109
110 //
111 // Test PACKED DOUBLE -> PACKED OBJECT
112 //
113
114 function transition3(a, i, v) {
115 a[i] = v;
116 }
117
118 var c1 = [0, 1, 2, 3.5, 4];
119 transition3(c1, 0, new Object());
120 var c2 = [0, 1, 2, 3.5, 4];
121 transition3(c2, 0, new Object());
122 assertTrue(%HasFastObjectElements(c2));
123 assertTrue(!%HasFastHoleyElements(c2));
124 %OptimizeFunctionOnNextCall(transition3);
125
126 var c3 = [0, 1, 2, 3.5, 4];
127 assertTrue(%HasFastDoubleElements(c3));
128 assertTrue(!%HasFastHoleyElements(c3));
129 transition3(c3, 0, new Array());
130 assertTrue(!%HasFastHoleyElements(c3));
131 assertTrue(%HasFastObjectElements(c3));
132 assertEquals(4, c3[4]);
133 assertEquals(0, c3[0].length);
134
135 // Large array under the deopt threshold should be able to trigger GC without
136 // causing crashes.
137 for (j = 0; j < iteration_count; ++j) {
138 c4 = [0, 2.5, 0];
139 for (i = 3; i < 0xa000; ++i) {
140 c4[i] = 0;
141 }
142 assertTrue(%HasFastDoubleElements(c4));
143 assertTrue(!%HasFastHoleyElements(c4));
144 transition3(c4, 0, new Array(5));
145 assertTrue(!%HasFastHoleyElements(c4));
146 assertTrue(%HasFastObjectElements(c4));
147 assertEquals(5, c4[0].length);
148 }
149
150 // Large array should deopt to runtime
151 for (j = 0; j < iteration_count; ++j) {
152 c5 = [0, 2.5, 0];
153 for (i = 3; i < 0x40000; ++i) {
154 c5[i] = 0;
155 }
156 assertTrue(%HasFastDoubleElements(c5));
157 assertTrue(!%HasFastHoleyElements(c5));
158 transition3(c5, 0, new Array(5));
159 assertTrue(!%HasFastHoleyElements(c5));
160 assertTrue(%HasFastObjectElements(c5));
161 assertEquals(5, c5[0].length);
162 }
163
164 //
165 // Test HOLEY DOUBLE -> HOLEY OBJECT
166 //
167
168 function transition4(a, i, v) {
169 a[i] = v;
170 }
171
172 var d1 = [0, 1, , 3.5, 4];
173 transition4(d1, 0, new Object());
174 var d2 = [0, 1, , 3.5, 4];
175 transition4(d2, 0, new Object());
176 assertTrue(%HasFastObjectElements(d2));
177 assertTrue(%HasFastHoleyElements(d2));
178 %OptimizeFunctionOnNextCall(transition4);
179
180 var d3 = [0, 1, , 3.5, 4];
181 assertTrue(%HasFastDoubleElements(d3));
182 assertTrue(%HasFastHoleyElements(d3));
183 transition4(d3, 0, new Array());
184 assertTrue(%HasFastHoleyElements(d3));
185 assertTrue(%HasFastObjectElements(d3));
186 assertEquals(4, d3[4]);
187 assertEquals(0, d3[0].length);
188
189 // Large array under the deopt threshold should be able to trigger GC without
190 // causing crashes.
191 for (j = 0; j < iteration_count; ++j) {
192 d4 = [, 2.5, ,];
193 for (i = 3; i < 0xa000; ++i) {
194 d4[i] = 0;
195 }
196 assertTrue(%HasFastDoubleElements(d4));
197 assertTrue(%HasFastHoleyElements(d4));
198 transition4(d4, 0, new Array(5));
199 assertTrue(%HasFastHoleyElements(d4));
200 assertTrue(%HasFastObjectElements(d4));
201 assertEquals(5, d4[0].length);
202 assertEquals(undefined, d4[2]);
203 }
204
205 // Large array should deopt to runtime
206 for (j = 0; j < iteration_count; ++j) {
207 d5 = [, 2.5, ,];
208 for (i = 3; i < 0x40000; ++i) {
209 d5[i] = 0;
210 }
211 assertTrue(%HasFastDoubleElements(d5));
212 assertTrue(%HasFastHoleyElements(d5));
213 transition4(d5, 0, new Array(5));
214 assertTrue(%HasFastHoleyElements(d5));
215 assertTrue(%HasFastObjectElements(d5));
216 assertEquals(5, d5[0].length);
217 assertEquals(undefined, d5[2]);
218 }
OLDNEW
« no previous file with comments | « test/mjsunit/elide-double-hole-check-9.js ('k') | test/mjsunit/never-optimize.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698