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

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

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

Powered by Google App Engine
This is Rietveld 408576698