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

Side by Side Diff: test/mjsunit/array-constructor-feedback.js

Issue 162903004: Add a premonomorphic state to the call target cache. Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 6 years, 10 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') | 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 if (support_smi_only_arrays) { 83 if (support_smi_only_arrays) {
84 84
85 // Test: If a call site goes megamorphic, it loses the ability to 85 // Test: If a call site goes megamorphic, it loses the ability to
86 // use allocation site feedback. 86 // use allocation site feedback.
87 (function() { 87 (function() {
88 function bar(t, len) { 88 function bar(t, len) {
89 return new t(len); 89 return new t(len);
90 } 90 }
91 91
92 bar(Array, 10); // Skip premonomorphic state.
92 a = bar(Array, 10); 93 a = bar(Array, 10);
93 a[0] = 3.5; 94 a[0] = 3.5;
94 b = bar(Array, 1); 95 b = bar(Array, 1);
95 assertKind(elements_kind.fast_double, b); 96 assertKind(elements_kind.fast_double, b);
96 c = bar(Object, 3); 97 c = bar(Object, 3);
97 b = bar(Array, 10); 98 b = bar(Array, 10);
98 assertKind(elements_kind.fast_smi_only, b); 99 assertKind(elements_kind.fast_smi_only, b);
99 b[0] = 3.5; 100 b[0] = 3.5;
100 c = bar(Array, 10); 101 c = bar(Array, 10);
101 assertKind(elements_kind.fast_smi_only, c); 102 assertKind(elements_kind.fast_smi_only, c);
102 })(); 103 })();
103 104
104 105
105 // Test: ensure that crankshafted array constructor sites are deopted 106 // Test: ensure that crankshafted array constructor sites are deopted
106 // if another function is used. 107 // if another function is used.
107 (function() { 108 (function() {
108 function bar0(t) { 109 function bar0(t) {
109 return new t(); 110 return new t();
110 } 111 }
112
113 bar0(Array); // Skip premonomorphic state.
111 a = bar0(Array); 114 a = bar0(Array);
112 a[0] = 3.5; 115 a[0] = 3.5;
113 b = bar0(Array); 116 b = bar0(Array);
114 assertKind(elements_kind.fast_double, b); 117 assertKind(elements_kind.fast_double, b);
115 %OptimizeFunctionOnNextCall(bar0); 118 %OptimizeFunctionOnNextCall(bar0);
116 b = bar0(Array); 119 b = bar0(Array);
117 assertKind(elements_kind.fast_double, b); 120 assertKind(elements_kind.fast_double, b);
118 assertOptimized(bar0); 121 assertOptimized(bar0);
119 // bar0 should deopt 122 // bar0 should deopt
120 b = bar0(Object); 123 b = bar0(Object);
(...skipping 11 matching lines...) Expand all
132 assertKind(elements_kind.fast_smi_only, c); 135 assertKind(elements_kind.fast_smi_only, c);
133 })(); 136 })();
134 137
135 138
136 // Test: Ensure that inlined array calls in crankshaft learn from deopts 139 // Test: Ensure that inlined array calls in crankshaft learn from deopts
137 // based on the move to a dictionary for the array. 140 // based on the move to a dictionary for the array.
138 (function() { 141 (function() {
139 function bar(len) { 142 function bar(len) {
140 return new Array(len); 143 return new Array(len);
141 } 144 }
145
146 bar(10); // Skip premonomorphic state.
142 a = bar(10); 147 a = bar(10);
143 a[0] = "a string"; 148 a[0] = "a string";
144 a = bar(10); 149 a = bar(10);
145 assertKind(elements_kind.fast, a); 150 assertKind(elements_kind.fast, a);
146 %OptimizeFunctionOnNextCall(bar); 151 %OptimizeFunctionOnNextCall(bar);
147 a = bar(10); 152 a = bar(10);
148 assertKind(elements_kind.fast, a); 153 assertKind(elements_kind.fast, a);
149 assertOptimized(bar); 154 assertOptimized(bar);
150 // bar should deopt because the length is too large. 155 // bar should deopt because the length is too large.
151 a = bar(100000); 156 a = bar(100000);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 })(); 188 })();
184 189
185 190
186 // Test: When a method with array constructor is crankshafted, the type 191 // Test: When a method with array constructor is crankshafted, the type
187 // feedback for elements kind is baked in. Verify that transitions don't 192 // feedback for elements kind is baked in. Verify that transitions don't
188 // change it anymore 193 // change it anymore
189 (function() { 194 (function() {
190 function bar() { 195 function bar() {
191 return new Array(); 196 return new Array();
192 } 197 }
198
199 bar(); // Skip premonomorphic state.
193 a = bar(); 200 a = bar();
194 bar(); 201 bar();
195 %OptimizeFunctionOnNextCall(bar); 202 %OptimizeFunctionOnNextCall(bar);
196 b = bar(); 203 b = bar();
197 // This only makes sense to test if we allow crankshafting 204 // This only makes sense to test if we allow crankshafting
198 if (4 != %GetOptimizationStatus(bar)) { 205 if (4 != %GetOptimizationStatus(bar)) {
199 assertOptimized(bar); 206 assertOptimized(bar);
200 %DebugPrint(3); 207 %DebugPrint(3);
201 b[0] = 3.5; 208 b[0] = 3.5;
202 c = bar(); 209 c = bar();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // Try again 250 // Try again
244 %OptimizeFunctionOnNextCall(bar); 251 %OptimizeFunctionOnNextCall(bar);
245 a = bar(100); 252 a = bar(100);
246 assertOptimized(bar); 253 assertOptimized(bar);
247 assertTrue(isHoley(a)); 254 assertTrue(isHoley(a));
248 a = bar(0); 255 a = bar(0);
249 assertOptimized(bar); 256 assertOptimized(bar);
250 assertTrue(isHoley(a)); 257 assertTrue(isHoley(a));
251 })(); 258 })();
252 } 259 }
OLDNEW
« no previous file with comments | « test/mjsunit/allocation-site-info.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698