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

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

Issue 143633007: A64: Synchronize with r18764. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
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/array-constructor-feedback.js ('k') | test/mjsunit/array-literal-feedback.js » ('j') | 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 17 matching lines...) Expand all
28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
29 // Flags: --noalways-opt 29 // Flags: --noalways-opt
30 30
31 // Test element kind of objects. 31 // Test element kind of objects.
32 // Since --smi-only-arrays affects builtins, its default setting at compile 32 // Since --smi-only-arrays affects builtins, its default setting at compile
33 // time sticks if built with snapshot. If --smi-only-arrays is deactivated 33 // time sticks if built with snapshot. If --smi-only-arrays is deactivated
34 // by default, only a no-snapshot build actually has smi-only arrays enabled 34 // by default, only a no-snapshot build actually has smi-only arrays enabled
35 // in this test case. Depending on whether smi-only arrays are actually 35 // in this test case. Depending on whether smi-only arrays are actually
36 // enabled, this test takes the appropriate code path to check smi-only arrays. 36 // enabled, this test takes the appropriate code path to check smi-only arrays.
37 37
38 // Reset the GC stress mode to be off. Needed because AllocationMementos only
39 // live for one gc, so a gc that happens in certain fragile areas of the test
40 // can break assumptions.
41 %SetFlags("--gc-interval=-1")
42
43 // support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); 38 // support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
44 support_smi_only_arrays = true; 39 support_smi_only_arrays = true;
45 40
46 if (support_smi_only_arrays) { 41 if (support_smi_only_arrays) {
47 print("Tests include smi-only arrays."); 42 print("Tests include smi-only arrays.");
48 } else { 43 } else {
49 print("Tests do NOT include smi-only arrays."); 44 print("Tests do NOT include smi-only arrays.");
50 } 45 }
51 46
52 var elements_kind = { 47 var elements_kind = {
(...skipping 30 matching lines...) Expand all
83 expected = elements_kind.fast; 78 expected = elements_kind.fast;
84 } 79 }
85 assertEquals(expected, getKind(obj), name_opt); 80 assertEquals(expected, getKind(obj), name_opt);
86 } 81 }
87 82
88 if (support_smi_only_arrays) { 83 if (support_smi_only_arrays) {
89 84
90 // Verify that basic elements kind feedback works for non-constructor 85 // Verify that basic elements kind feedback works for non-constructor
91 // 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
92 // a CallStub). 87 // a CallStub).
93 (function (){ 88 // (function (){
94 function create0() { 89 // function create0() {
95 return Array(); 90 // return Array();
96 } 91 // }
97 92
98 // Calls through ICs need warm up through uninitialized, then 93 // // Calls through ICs need warm up through uninitialized, then
99 // premonomorphic first. 94 // // premonomorphic first.
100 create0(); 95 // create0();
101 create0(); 96 // create0();
102 a = create0(); 97 // a = create0();
103 assertKind(elements_kind.fast_smi_only, a); 98 // assertKind(elements_kind.fast_smi_only, a);
104 a[0] = 3.5; 99 // a[0] = 3.5;
105 b = create0(); 100 // b = create0();
106 assertKind(elements_kind.fast_double, b); 101 // assertKind(elements_kind.fast_double, b);
107 102
108 function create1(arg) { 103 // function create1(arg) {
109 return Array(arg); 104 // return Array(arg);
110 } 105 // }
111 106
112 create1(0); 107 // create1(0);
113 create1(0); 108 // create1(0);
114 a = create1(0); 109 // a = create1(0);
115 assertFalse(isHoley(a)); 110 // assertFalse(isHoley(a));
116 assertKind(elements_kind.fast_smi_only, a); 111 // assertKind(elements_kind.fast_smi_only, a);
117 a[0] = "hello"; 112 // a[0] = "hello";
118 b = create1(10); 113 // b = create1(10);
119 assertTrue(isHoley(b)); 114 // assertTrue(isHoley(b));
120 assertKind(elements_kind.fast, b); 115 // assertKind(elements_kind.fast, b);
121 116
122 a = create1(100000); 117 // a = create1(100000);
123 assertKind(elements_kind.dictionary, a); 118 // assertKind(elements_kind.dictionary, a);
124 119
125 function create3(arg1, arg2, arg3) { 120 // function create3(arg1, arg2, arg3) {
126 return Array(arg1, arg2, arg3); 121 // return Array(arg1, arg2, arg3);
127 } 122 // }
128 123
129 create3(); 124 // create3();
130 create3(); 125 // create3();
131 a = create3(1,2,3); 126 // a = create3(1,2,3);
132 a[0] = 3.5; 127 // a[0] = 3.5;
133 b = create3(1,2,3); 128 // b = create3(1,2,3);
134 assertKind(elements_kind.fast_double, b); 129 // assertKind(elements_kind.fast_double, b);
135 assertFalse(isHoley(b)); 130 // assertFalse(isHoley(b));
136 })(); 131 // })();
137 132
138 133
139 // Verify that keyed calls work 134 // Verify that keyed calls work
140 (function (){ 135 // (function (){
141 function create0(name) { 136 // function create0(name) {
142 return this[name](); 137 // return this[name]();
143 } 138 // }
144 139
145 name = "Array"; 140 // name = "Array";
146 create0(name); 141 // create0(name);
147 create0(name); 142 // create0(name);
148 a = create0(name); 143 // a = create0(name);
149 a[0] = 3.5; 144 // a[0] = 3.5;
150 b = create0(name); 145 // b = create0(name);
151 assertKind(elements_kind.fast_double, b); 146 // assertKind(elements_kind.fast_double, b);
152 })(); 147 // })();
153 148
154 149
155 // Verify that the IC can't be spoofed by patching 150 // Verify that the IC can't be spoofed by patching
156 (function (){ 151 (function (){
157 function create0() { 152 function create0() {
158 return Array(); 153 return Array();
159 } 154 }
160 155
161 create0(); 156 create0();
162 create0(); 157 create0();
163 a = create0(); 158 a = create0();
164 assertKind(elements_kind.fast_smi_only, a); 159 assertKind(elements_kind.fast_smi_only, a);
165 var oldArray = this.Array; 160 var oldArray = this.Array;
166 this.Array = function() { return ["hi"]; }; 161 this.Array = function() { return ["hi"]; };
167 b = create0(); 162 b = create0();
168 assertEquals(["hi"], b); 163 assertEquals(["hi"], b);
169 this.Array = oldArray; 164 this.Array = oldArray;
170 })(); 165 })();
171 166
172 // Verify that calls are still made through an IC after crankshaft, 167 // Verify that calls are still made through an IC after crankshaft,
173 // though the type information is reset. 168 // though the type information is reset.
174 // TODO(mvstanton): instead, consume the type feedback gathered up 169 // TODO(mvstanton): instead, consume the type feedback gathered up
175 // until crankshaft time. 170 // until crankshaft time.
176 (function (){ 171 // (function (){
177 function create0() { 172 // function create0() {
178 return Array(); 173 // return Array();
179 } 174 // }
180 175
181 create0(); 176 // create0();
182 create0(); 177 // create0();
183 a = create0(); 178 // a = create0();
184 a[0] = 3.5; 179 // a[0] = 3.5;
185 %OptimizeFunctionOnNextCall(create0); 180 // %OptimizeFunctionOnNextCall(create0);
186 create0(); 181 // create0();
187 // This test only makes sense if crankshaft is allowed 182 // // This test only makes sense if crankshaft is allowed
188 if (4 != %GetOptimizationStatus(create0)) { 183 // if (4 != %GetOptimizationStatus(create0)) {
189 create0(); 184 // create0();
190 b = create0(); 185 // b = create0();
191 assertKind(elements_kind.fast_smi_only, b); 186 // assertKind(elements_kind.fast_smi_only, b);
192 b[0] = 3.5; 187 // b[0] = 3.5;
193 c = create0(); 188 // c = create0();
194 assertKind(elements_kind.fast_double, c); 189 // assertKind(elements_kind.fast_double, c);
195 assertOptimized(create0); 190 // assertOptimized(create0);
196 } 191 // }
197 })(); 192 // })();
198 193
199 194
200 // Verify that cross context calls work 195 // Verify that cross context calls work
201 (function (){ 196 (function (){
202 var realmA = Realm.current(); 197 var realmA = Realm.current();
203 var realmB = Realm.create(); 198 var realmB = Realm.create();
204 assertEquals(0, realmA); 199 assertEquals(0, realmA);
205 assertEquals(1, realmB); 200 assertEquals(1, realmB);
206 201
207 function instanceof_check(type) { 202 function instanceof_check(type) {
208 assertTrue(type() instanceof type); 203 assertTrue(type() instanceof type);
209 assertTrue(type(5) instanceof type); 204 assertTrue(type(5) instanceof type);
210 assertTrue(type(1,2,3) instanceof type); 205 assertTrue(type(1,2,3) instanceof type);
211 } 206 }
212 207
213 var realmBArray = Realm.eval(realmB, "Array"); 208 var realmBArray = Realm.eval(realmB, "Array");
214 instanceof_check(Array); 209 instanceof_check(Array);
215 instanceof_check(Array); 210 instanceof_check(Array);
216 instanceof_check(Array); 211 instanceof_check(Array);
217 instanceof_check(realmBArray); 212 instanceof_check(realmBArray);
218 instanceof_check(realmBArray); 213 instanceof_check(realmBArray);
219 instanceof_check(realmBArray); 214 instanceof_check(realmBArray);
220 })(); 215 })();
221 } 216 }
OLDNEW
« no previous file with comments | « test/mjsunit/array-constructor-feedback.js ('k') | test/mjsunit/array-literal-feedback.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698