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

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

Issue 132963012: Pretenure call new support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 9 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 function assertKind(expected, obj, name_opt) { 75 function assertKind(expected, obj, name_opt) {
76 if (!support_smi_only_arrays && 76 if (!support_smi_only_arrays &&
77 expected == elements_kind.fast_smi_only) { 77 expected == elements_kind.fast_smi_only) {
78 expected = elements_kind.fast; 78 expected = elements_kind.fast;
79 } 79 }
80 assertEquals(expected, getKind(obj), name_opt); 80 assertEquals(expected, getKind(obj), name_opt);
81 } 81 }
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 retains the ability to
86 // use allocation site feedback. 86 // use allocation site feedback (if FLAG_allocation_site_pretenuring
87 // is on).
87 (function() { 88 (function() {
88 function bar(t, len) { 89 function bar(t, len) {
89 return new t(len); 90 return new t(len);
90 } 91 }
91 92
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 // TODO(mvstanton): re-enable when FLAG_allocation_site_pretenuring
99 b[0] = 3.5; 100 // is on in the build.
100 c = bar(Array, 10); 101 // assertKind(elements_kind.fast_double, b);
101 assertKind(elements_kind.fast_smi_only, c);
102 })(); 102 })();
103 103
104 104
105 // Test: ensure that crankshafted array constructor sites are deopted 105 // Test: ensure that crankshafted array constructor sites are deopted
106 // if another function is used. 106 // if another function is used.
107 (function() { 107 (function() {
108 function bar0(t) { 108 function bar0(t) {
109 return new t(); 109 return new t();
110 } 110 }
111 a = bar0(Array); 111 a = bar0(Array);
112 a[0] = 3.5; 112 a[0] = 3.5;
113 b = bar0(Array); 113 b = bar0(Array);
114 assertKind(elements_kind.fast_double, b); 114 assertKind(elements_kind.fast_double, b);
115 %OptimizeFunctionOnNextCall(bar0); 115 %OptimizeFunctionOnNextCall(bar0);
116 b = bar0(Array); 116 b = bar0(Array);
117 assertKind(elements_kind.fast_double, b); 117 assertKind(elements_kind.fast_double, b);
118 assertOptimized(bar0); 118 assertOptimized(bar0);
119 // bar0 should deopt 119 // bar0 should deopt
120 b = bar0(Object); 120 b = bar0(Object);
121 assertUnoptimized(bar0) 121 assertUnoptimized(bar0)
122 // When it's re-optimized, we should call through the full stub 122 // When it's re-optimized, we should call through the full stub
123 bar0(Array); 123 bar0(Array);
124 %OptimizeFunctionOnNextCall(bar0); 124 %OptimizeFunctionOnNextCall(bar0);
125 b = bar0(Array); 125 b = bar0(Array);
126 // We also lost our ability to record kind feedback, as the site 126 // This only makes sense to test if we allow crankshafting
127 // is megamorphic now. 127 if (4 != %GetOptimizationStatus(bar0)) {
128 assertKind(elements_kind.fast_smi_only, b); 128 // We also lost our ability to record kind feedback, as the site
129 assertOptimized(bar0); 129 // is megamorphic now.
130 b[0] = 3.5; 130 assertKind(elements_kind.fast_smi_only, b);
131 c = bar0(Array); 131 assertOptimized(bar0);
132 assertKind(elements_kind.fast_smi_only, c); 132 b[0] = 3.5;
133 c = bar0(Array);
134 assertKind(elements_kind.fast_smi_only, c);
135 }
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 }
142 a = bar(10); 145 a = bar(10);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // Try again 246 // Try again
244 %OptimizeFunctionOnNextCall(bar); 247 %OptimizeFunctionOnNextCall(bar);
245 a = bar(100); 248 a = bar(100);
246 assertOptimized(bar); 249 assertOptimized(bar);
247 assertTrue(isHoley(a)); 250 assertTrue(isHoley(a));
248 a = bar(0); 251 a = bar(0);
249 assertOptimized(bar); 252 assertOptimized(bar);
250 assertTrue(isHoley(a)); 253 assertTrue(isHoley(a));
251 })(); 254 })();
252 } 255 }
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