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

Side by Side Diff: test/mjsunit/elements-transition-hoisting.js

Issue 10532063: Optimistically assume that elements IC only transition once. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/elements-kind.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 function testDoubleConversion4(a) { 51 function testDoubleConversion4(a) {
52 var object = new Object(); 52 var object = new Object();
53 a[0] = 0; 53 a[0] = 0;
54 var count = 3; 54 var count = 3;
55 do { 55 do {
56 a[0] = object; 56 a[0] = object;
57 } while (--count > 0); 57 } while (--count > 0);
58 } 58 }
59 59
60 testDoubleConversion4(new Array(5)); 60 testDoubleConversion4(new Array(5));
61 testDoubleConversion4(new Array(5)); // Call twice to make sure that second
62 // store is a transition and not
63 // optimistically MONOMORPHIC
61 %OptimizeFunctionOnNextCall(testDoubleConversion4); 64 %OptimizeFunctionOnNextCall(testDoubleConversion4);
62 testDoubleConversion4(new Array(5)); 65 testDoubleConversion4(new Array(5));
63 testDoubleConversion4(new Array(5)); 66 testDoubleConversion4(new Array(5));
64 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4)); 67 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4));
65 68
66 // Make sure that non-element related map checks that are not preceded by 69 // Make sure that non-element related map checks that are not preceded by
67 // transitions in a loop still get hoisted in a way that doesn't generate a 70 // transitions in a loop still get hoisted in a way that doesn't generate a
68 // deopt in simple cases. 71 // deopt in simple cases.
69 function testExactMapHoisting(a) { 72 function testExactMapHoisting(a) {
70 var object = new Object(); 73 var object = new Object();
71 a.foo = 0; 74 a.foo = 0;
72 a[0] = 0; 75 a[0] = 0;
73 a[1] = 1; 76 a[1] = 1;
74 var count = 3; 77 var count = 3;
75 do { 78 do {
76 a.foo = object; // This map check should be hoistable 79 a.foo = object; // This map check should be hoistable
77 a[1] = object; 80 a[1] = object;
78 result = a.foo == object && a[1] == object; 81 result = a.foo == object && a[1] == object;
79 } while (--count > 0); 82 } while (--count > 0);
80 } 83 }
81 84
82 testExactMapHoisting(new Array(5)); 85 testExactMapHoisting(new Array(5));
86 testExactMapHoisting(new Array(5)); // Call twice to make sure that second
87 // store is a transition and not
88 // optimistically MONOMORPHIC
83 %OptimizeFunctionOnNextCall(testExactMapHoisting); 89 %OptimizeFunctionOnNextCall(testExactMapHoisting);
84 testExactMapHoisting(new Array(5)); 90 testExactMapHoisting(new Array(5));
85 testExactMapHoisting(new Array(5)); 91 testExactMapHoisting(new Array(5));
86 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting)); 92 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting));
87 93
88 // Make sure that non-element related map checks do NOT get hoisted if they 94 // Make sure that non-element related map checks do NOT get hoisted if they
89 // depend on an elements transition before them and it's not possible to hoist 95 // depend on an elements transition before them and it's not possible to hoist
90 // that transition. 96 // that transition.
91 function testExactMapHoisting2(a) { 97 function testExactMapHoisting2(a) {
92 var object = new Object(); 98 var object = new Object();
93 a.foo = 0; 99 a.foo = 0;
94 a[0] = 0; 100 a[0] = 0;
95 a[1] = 1; 101 a[1] = 1;
96 var count = 3; 102 var count = 3;
97 do { 103 do {
98 if (a.bar === undefined) { 104 if (a.bar === undefined) {
99 a[1] = 2.5; 105 a[1] = 2.5;
100 } 106 }
101 a.foo = object; // This map check should NOT be hoistable because it 107 a.foo = object; // This map check should NOT be hoistable because it
102 // includes a check for the FAST_ELEMENTS map as well as 108 // includes a check for the FAST_ELEMENTS map as well as
103 // the FAST_DOUBLE_ELEMENTS map, which depends on the 109 // the FAST_DOUBLE_ELEMENTS map, which depends on the
104 // double transition above in the if, which cannot be 110 // double transition above in the if, which cannot be
105 // hoisted. 111 // hoisted.
106 } while (--count > 0); 112 } while (--count > 0);
107 } 113 }
108 114
109 testExactMapHoisting2(new Array(5)); 115 testExactMapHoisting2(new Array(5));
116 testExactMapHoisting2(new Array(5)); // Call twice to make sure that second
117 // store is a transition and not
118 // optimistically MONOMORPHIC
110 %OptimizeFunctionOnNextCall(testExactMapHoisting2); 119 %OptimizeFunctionOnNextCall(testExactMapHoisting2);
111 testExactMapHoisting2(new Array(5)); 120 testExactMapHoisting2(new Array(5));
112 testExactMapHoisting2(new Array(5)); 121 testExactMapHoisting2(new Array(5));
113 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2)); 122 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2));
114 123
115 // Make sure that non-element related map checks do get hoisted if they use 124 // Make sure that non-element related map checks do get hoisted if they use
116 // the transitioned map for the check and all transitions that they depend 125 // the transitioned map for the check and all transitions that they depend
117 // upon can hoisted, too. 126 // upon can hoisted, too.
118 function testExactMapHoisting3(a) { 127 function testExactMapHoisting3(a) {
119 var object = new Object(); 128 var object = new Object();
120 a.foo = 0; 129 a.foo = 0;
121 a[0] = 0; 130 a[0] = 0;
122 a[1] = 1; 131 a[1] = 1;
123 var count = 3; 132 var count = 3;
124 do { 133 do {
125 a[1] = 2.5; 134 a[1] = 2.5;
126 a.foo = object; // This map check should be hoistable because all elements 135 a.foo = object; // This map check should be hoistable because all element s
127 // transitions in the loop can also be hoisted. 136 // transitions in the loop can also be hoisted.
128 } while (--count > 0); 137 } while (--count > 0);
129 } 138 }
130 139
131 var add_transition = new Array(5); 140 var add_transition = new Array(5);
132 add_transition.foo = 0; 141 add_transition.foo = 0;
133 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be created 142 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be create d
134 testExactMapHoisting3(new Array(5)); 143 testExactMapHoisting3(new Array(5));
144 testExactMapHoisting3(new Array(5)); // Call twice to make sure that second
145 // store is a transition and not
146 // optimistically MONOMORPHIC
135 %OptimizeFunctionOnNextCall(testExactMapHoisting3); 147 %OptimizeFunctionOnNextCall(testExactMapHoisting3);
136 testExactMapHoisting3(new Array(5)); 148 testExactMapHoisting3(new Array(5));
137 testExactMapHoisting3(new Array(5)); 149 testExactMapHoisting3(new Array(5));
138 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3)); 150 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3));
139 151
140 function testDominatingTransitionHoisting1(a) { 152 function testDominatingTransitionHoisting1(a) {
141 var object = new Object(); 153 var object = new Object();
142 a[0] = 0; 154 a[0] = 0;
143 var count = 3; 155 var count = 3;
144 do { 156 do {
145 if (a.baz != true) { 157 if (a.baz != true) {
146 a[1] = 2.5; 158 a[1] = 2.5;
147 } 159 }
148 a[0] = object; 160 a[0] = object;
149 } while (--count > 3); 161 } while (--count > 3);
150 } 162 }
151 163
152 testDominatingTransitionHoisting1(new Array(5)); 164 testDominatingTransitionHoisting1(new Array(5));
165 testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure
166 // that second store is a
167 // transition and not
168 // optimistically MONOMORPHI C
153 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); 169 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1);
154 testDominatingTransitionHoisting1(new Array(5)); 170 testDominatingTransitionHoisting1(new Array(5));
155 testDominatingTransitionHoisting1(new Array(5)); 171 testDominatingTransitionHoisting1(new Array(5));
156 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1)); 172 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1));
157 173
158 function testHoistingWithSideEffect(a) { 174 function testHoistingWithSideEffect(a) {
159 var object = new Object(); 175 var object = new Object();
160 a[0] = 0; 176 a[0] = 0;
161 var count = 3; 177 var count = 3;
162 do { 178 do {
163 assertTrue(true); 179 assertTrue(true);
164 a[0] = object; 180 a[0] = object;
165 } while (--count > 3); 181 } while (--count > 3);
166 } 182 }
167 183
168 testHoistingWithSideEffect(new Array(5)); 184 testHoistingWithSideEffect(new Array(5));
185 testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that
186 // second store is a transition and
187 // not optimistically MONOMORPHIC
169 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); 188 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect);
170 testHoistingWithSideEffect(new Array(5)); 189 testHoistingWithSideEffect(new Array(5));
171 testHoistingWithSideEffect(new Array(5)); 190 testHoistingWithSideEffect(new Array(5));
172 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); 191 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect));
173 192
174 function testStraightLineDupeElinination(a,b,c,d,e,f) { 193 function testStraightLineDupeElinination(a,b,c,d,e,f) {
175 var count = 3; 194 var count = 3;
176 do { 195 do {
177 assertTrue(true); 196 assertTrue(true);
178 a[0] = b; 197 a[0] = b;
179 a[1] = c; 198 a[1] = c;
180 a[2] = d; 199 a[2] = d;
181 assertTrue(true); 200 assertTrue(true);
182 a[3] = e; // TransitionElementsKind should be eliminated despite call. 201 a[3] = e; // TransitionElementsKind should be eliminated despite call.
183 a[4] = f; 202 a[4] = f;
184 } while (--count > 3); 203 } while (--count > 3);
185 } 204 }
186 205
187 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5); 206 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5);
188 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0); 207 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0);
189 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0); 208 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0);
190 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,.5,0,0,0); 209 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,.5,0,0,0);
191 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),.5,0,0,0,0); 210 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),.5,0,0,0,0);
192 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,0,.5); 211 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,0,.5);
193 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,.5,0); 212 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,.5,0);
194 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,.5,0,0); 213 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,.5,0,0);
195 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,.5,0,0,0); 214 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,.5,0,0,0);
196 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),.5,0,0,0,0); 215 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),.5,0,0,0,0);
197 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); 216 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0);
198 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); 217 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0);
199 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); 218 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0);
200 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); 219 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0);
201 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); 220 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5);
202 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); 221 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0);
203 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); 222 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0);
204 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); 223 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0);
205 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); 224 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0);
206 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); 225 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5);
207 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination); 226 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination);
208 testStraightLineDupeElinination(new Array(5)); 227 testStraightLineDupeElinination(new Array(5));
209 testStraightLineDupeElinination(new Array(5)); 228 testStraightLineDupeElinination(new Array(5));
210 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination)); 229 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination));
211 } 230 }
OLDNEW
« no previous file with comments | « test/mjsunit/elements-kind.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698