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

Side by Side Diff: test/mjsunit/polymorph-arrays.js

Issue 417953004: Revert 22595: "Keep new arrays allocated with 'new Array(N)' in fast mode" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/es7/object-observe.js ('k') | test/mjsunit/regress/regress-2790.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 19 matching lines...) Expand all
30 for (var i = 0; i < 10; ++i ){ 30 for (var i = 0; i < 10; ++i ){
31 a[i] = i; 31 a[i] = i;
32 } 32 }
33 } 33 }
34 34
35 function init_sparse_array(a) { 35 function init_sparse_array(a) {
36 for (var i = 0; i < 10; ++i ){ 36 for (var i = 0; i < 10; ++i ){
37 a[i] = i; 37 a[i] = i;
38 } 38 }
39 a[5000000] = 256; 39 a[5000000] = 256;
40 return %NormalizeElements(a); 40 assertTrue(%HasDictionaryElements(a));
41 } 41 }
42 42
43 function testPolymorphicLoads() { 43 function testPolymorphicLoads() {
44 function make_polymorphic_load_function() { 44 function make_polymorphic_load_function() {
45 function load(a, i) { 45 function load(a, i) {
46 return a[i]; 46 return a[i];
47 } 47 }
48 48
49 var object_array = new Object; 49 var object_array = new Object;
50 var sparse_object_array = new Object; 50 var sparse_object_array = new Object;
51 var js_array = new Array(10); 51 var js_array = new Array(10);
52 var sparse_js_array = %NormalizeElements([]); 52 var sparse_js_array = new Array(5000001);
53 53
54 init_array(object_array); 54 init_array(object_array);
55 init_array(js_array); 55 init_array(js_array);
56 init_sparse_array(sparse_object_array); 56 init_sparse_array(sparse_object_array);
57 init_sparse_array(sparse_js_array); 57 init_sparse_array(sparse_js_array);
58 58
59 assertEquals(1, load(object_array, 1)); 59 assertEquals(1, load(object_array, 1));
60 assertEquals(1, load(js_array, 1)); 60 assertEquals(1, load(js_array, 1));
61 assertEquals(1, load(sparse_object_array, 1)); 61 assertEquals(1, load(sparse_object_array, 1));
62 assertEquals(1, load(sparse_js_array, 1)); 62 assertEquals(1, load(sparse_js_array, 1));
63 63
64 return load; 64 return load;
65 } 65 }
66 66
67 var object_array = new Object; 67 var object_array = new Object;
68 var sparse_object_array = new Object; 68 var sparse_object_array = new Object;
69 var js_array = new Array(10); 69 var js_array = new Array(10);
70 var sparse_js_array = %NormalizeElements([]); 70 var sparse_js_array = new Array(5000001);
71 71
72 init_array(object_array); 72 init_array(object_array);
73 init_array(js_array); 73 init_array(js_array);
74 init_sparse_array(sparse_object_array); 74 init_sparse_array(sparse_object_array);
75 init_sparse_array(sparse_js_array); 75 init_sparse_array(sparse_js_array);
76 76
77 load = make_polymorphic_load_function(); 77 load = make_polymorphic_load_function();
78 assertEquals(undefined, load(js_array, new Object())); 78 assertEquals(undefined, load(js_array, new Object()));
79 load = make_polymorphic_load_function(); 79 load = make_polymorphic_load_function();
80 assertEquals(undefined, load(object_array, new Object())); 80 assertEquals(undefined, load(object_array, new Object()));
(...skipping 26 matching lines...) Expand all
107 107
108 function testPolymorphicStores() { 108 function testPolymorphicStores() {
109 function make_polymorphic_store_function() { 109 function make_polymorphic_store_function() {
110 function store(a, i, val) { 110 function store(a, i, val) {
111 a[i] = val; 111 a[i] = val;
112 } 112 }
113 113
114 var object_array = new Object; 114 var object_array = new Object;
115 var sparse_object_array = new Object; 115 var sparse_object_array = new Object;
116 var js_array = new Array(10); 116 var js_array = new Array(10);
117 var sparse_js_array = []; 117 var sparse_js_array = new Array(5000001);
118 sparse_js_array.length = 5000001;
119 118
120 init_array(object_array); 119 init_array(object_array);
121 init_array(js_array); 120 init_array(js_array);
122 init_sparse_array(sparse_object_array); 121 init_sparse_array(sparse_object_array);
123 init_sparse_array(sparse_js_array); 122 init_sparse_array(sparse_js_array);
124 123
125 store(object_array, 1, 256); 124 store(object_array, 1, 256);
126 store(js_array, 1, 256); 125 store(js_array, 1, 256);
127 store(sparse_object_array, 1, 256); 126 store(sparse_object_array, 1, 256);
128 store(sparse_js_array, 1, 256); 127 store(sparse_js_array, 1, 256);
129 128
130 return store; 129 return store;
131 } 130 }
132 131
133 var object_array = new Object; 132 var object_array = new Object;
134 var sparse_object_array = new Object; 133 var sparse_object_array = new Object;
135 var js_array = new Array(10); 134 var js_array = new Array(10);
136 var sparse_js_array = %NormalizeElements([]); 135 var sparse_js_array = new Array(5000001);
137 sparse_js_array.length = 5000001;
138 136
139 init_array(object_array); 137 init_array(object_array);
140 init_array(js_array); 138 init_array(js_array);
141 init_sparse_array(sparse_object_array); 139 init_sparse_array(sparse_object_array);
142 init_sparse_array(sparse_js_array); 140 init_sparse_array(sparse_js_array);
143 141
144 store = make_polymorphic_store_function(); 142 store = make_polymorphic_store_function();
145 store(object_array, 2, 257); 143 store(object_array, 2, 257);
146 store = make_polymorphic_store_function(); 144 store = make_polymorphic_store_function();
147 store(js_array, 2, 257); 145 store(js_array, 2, 257);
(...skipping 22 matching lines...) Expand all
170 store(sparse_js_array, 3, 258); 168 store(sparse_js_array, 3, 258);
171 169
172 assertEquals(258, object_array[3]); 170 assertEquals(258, object_array[3]);
173 assertEquals(258, js_array[3]); 171 assertEquals(258, js_array[3]);
174 assertEquals(258, sparse_js_array[3]); 172 assertEquals(258, sparse_js_array[3]);
175 assertEquals(258, sparse_object_array[3]); 173 assertEquals(258, sparse_object_array[3]);
176 } 174 }
177 175
178 testPolymorphicLoads(); 176 testPolymorphicLoads();
179 testPolymorphicStores(); 177 testPolymorphicStores();
OLDNEW
« no previous file with comments | « test/mjsunit/es7/object-observe.js ('k') | test/mjsunit/regress/regress-2790.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698