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

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

Issue 300693002: Revert "Customized support for feedback on calls to Array." and follow-up fixes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/array-constructor-feedback.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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Verify that basic elements kind feedback works for non-constructor 85 // Verify that basic elements kind feedback works for non-constructor
86 // array calls (as long as the call is made through an IC, and not 86 // array calls (as long as the call is made through an IC, and not
87 // a CallStub). 87 // a CallStub).
88 // (function (){
89 // function create0() {
90 // return Array();
91 // }
92
93 // // Calls through ICs need warm up through uninitialized, then
94 // // premonomorphic first.
95 // create0();
96 // create0();
97 // a = create0();
98 // assertKind(elements_kind.fast_smi_only, a);
99 // a[0] = 3.5;
100 // b = create0();
101 // assertKind(elements_kind.fast_double, b);
102
103 // function create1(arg) {
104 // return Array(arg);
105 // }
106
107 // create1(0);
108 // create1(0);
109 // a = create1(0);
110 // assertFalse(isHoley(a));
111 // assertKind(elements_kind.fast_smi_only, a);
112 // a[0] = "hello";
113 // b = create1(10);
114 // assertTrue(isHoley(b));
115 // assertKind(elements_kind.fast, b);
116
117 // a = create1(100000);
118 // assertKind(elements_kind.dictionary, a);
119
120 // function create3(arg1, arg2, arg3) {
121 // return Array(arg1, arg2, arg3);
122 // }
123
124 // create3();
125 // create3();
126 // a = create3(1,2,3);
127 // a[0] = 3.5;
128 // b = create3(1,2,3);
129 // assertKind(elements_kind.fast_double, b);
130 // assertFalse(isHoley(b));
131 // })();
132
133
134 // Verify that keyed calls work
135 // (function (){
136 // function create0(name) {
137 // return this[name]();
138 // }
139
140 // name = "Array";
141 // create0(name);
142 // create0(name);
143 // a = create0(name);
144 // a[0] = 3.5;
145 // b = create0(name);
146 // assertKind(elements_kind.fast_double, b);
147 // })();
148
149
150 // Verify that the IC can't be spoofed by patching
88 (function (){ 151 (function (){
89 function create0() { 152 function create0() {
90 return Array(); 153 return Array();
91 }
92
93 // Calls through ICs need warm up through uninitialized, then
94 // premonomorphic first.
95 create0();
96 a = create0();
97 assertKind(elements_kind.fast_smi_only, a);
98 a[0] = 3.5;
99 b = create0();
100 assertKind(elements_kind.fast_double, b);
101
102 function create1(arg) {
103 return Array(arg);
104 }
105
106 create1(0);
107 create1(0);
108 a = create1(0);
109 assertFalse(isHoley(a));
110 assertKind(elements_kind.fast_smi_only, a);
111 a[0] = "hello";
112 b = create1(10);
113 assertTrue(isHoley(b));
114 assertKind(elements_kind.fast, b);
115
116 a = create1(100000);
117 assertKind(elements_kind.dictionary, a);
118
119 function create3(arg1, arg2, arg3) {
120 return Array(arg1, arg2, arg3);
121 }
122
123 create3(1,2,3);
124 create3(1,2,3);
125 a = create3(1,2,3);
126 a[0] = 3.035;
127 assertKind(elements_kind.fast_double, a);
128 b = create3(1,2,3);
129 assertKind(elements_kind.fast_double, b);
130 assertFalse(isHoley(b));
131 })();
132
133
134 // Verify that keyed calls work
135 (function (){
136 function create0(name) {
137 return this[name]();
138 }
139
140 name = "Array";
141 create0(name);
142 create0(name);
143 a = create0(name);
144 a[0] = 3.5;
145 b = create0(name);
146 assertKind(elements_kind.fast_double, b);
147 })();
148
149
150 // Verify that crankshaft consumes type feedback.
151 (function (){
152 function create0() {
153 return Array();
154 } 154 }
155 155
156 create0(); 156 create0();
157 create0(); 157 create0();
158 a = create0(); 158 a = create0();
159 a[0] = 3.5; 159 assertKind(elements_kind.fast_smi_only, a);
160 %OptimizeFunctionOnNextCall(create0); 160 var oldArray = this.Array;
161 create0(); 161 this.Array = function() { return ["hi"]; };
162 create0();
163 b = create0(); 162 b = create0();
164 assertKind(elements_kind.fast_double, b); 163 assertEquals(["hi"], b);
165 assertOptimized(create0); 164 this.Array = oldArray;
165 })();
166 166
167 function create1(arg) { 167 // Verify that calls are still made through an IC after crankshaft,
168 return Array(arg); 168 // though the type information is reset.
169 } 169 // TODO(mvstanton): instead, consume the type feedback gathered up
170 // until crankshaft time.
171 // (function (){
172 // function create0() {
173 // return Array();
174 // }
170 175
171 create1(8); 176 // create0();
172 create1(8); 177 // create0();
173 a = create1(8); 178 // a = create0();
174 a[0] = 3.5; 179 // a[0] = 3.5;
175 %OptimizeFunctionOnNextCall(create1); 180 // %OptimizeFunctionOnNextCall(create0);
176 b = create1(8); 181 // create0();
177 assertKind(elements_kind.fast_double, b); 182 // // This test only makes sense if crankshaft is allowed
178 assertOptimized(create1); 183 // if (4 != %GetOptimizationStatus(create0)) {
184 // create0();
185 // b = create0();
186 // assertKind(elements_kind.fast_smi_only, b);
187 // b[0] = 3.5;
188 // c = create0();
189 // assertKind(elements_kind.fast_double, c);
190 // assertOptimized(create0);
191 // }
192 // })();
179 193
180 function createN(arg1, arg2, arg3) {
181 return Array(arg1, arg2, arg3);
182 }
183
184 createN(1, 2, 3);
185 createN(1, 2, 3);
186 a = createN(1, 2, 3);
187 a[0] = 3.5;
188 %OptimizeFunctionOnNextCall(createN);
189 b = createN(1, 2, 3);
190 assertKind(elements_kind.fast_double, b);
191 assertOptimized(createN);
192 })();
193 194
194 // Verify that cross context calls work 195 // Verify that cross context calls work
195 (function (){ 196 (function (){
196 var realmA = Realm.current(); 197 var realmA = Realm.current();
197 var realmB = Realm.create(); 198 var realmB = Realm.create();
198 assertEquals(0, realmA); 199 assertEquals(0, realmA);
199 assertEquals(1, realmB); 200 assertEquals(1, realmB);
200 201
201 function instanceof_check(type) { 202 function instanceof_check(type) {
202 assertTrue(type() instanceof type); 203 assertTrue(type() instanceof type);
203 assertTrue(type(5) instanceof type); 204 assertTrue(type(5) instanceof type);
204 assertTrue(type(1,2,3) instanceof type); 205 assertTrue(type(1,2,3) instanceof type);
205 } 206 }
206 207
207 var realmBArray = Realm.eval(realmB, "Array"); 208 var realmBArray = Realm.eval(realmB, "Array");
208 instanceof_check(Array); 209 instanceof_check(Array);
209 instanceof_check(Array); 210 instanceof_check(Array);
210 instanceof_check(Array); 211 instanceof_check(Array);
211 instanceof_check(realmBArray); 212 instanceof_check(realmBArray);
212 instanceof_check(realmBArray); 213 instanceof_check(realmBArray);
213 instanceof_check(realmBArray); 214 instanceof_check(realmBArray);
214 })(); 215 })();
215 } 216 }
OLDNEW
« no previous file with comments | « test/mjsunit/array-constructor-feedback.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698