OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 function init_array(a) { | 29 function init_array(a) { |
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[200000] = 256; |
40 return %NormalizeElements(a); | 40 return %NormalizeElements(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; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = []; |
118 sparse_js_array.length = 5000001; | 118 sparse_js_array.length = 200001; |
119 | 119 |
120 init_array(object_array); | 120 init_array(object_array); |
121 init_array(js_array); | 121 init_array(js_array); |
122 init_sparse_array(sparse_object_array); | 122 init_sparse_array(sparse_object_array); |
123 init_sparse_array(sparse_js_array); | 123 init_sparse_array(sparse_js_array); |
124 | 124 |
125 store(object_array, 1, 256); | 125 store(object_array, 1, 256); |
126 store(js_array, 1, 256); | 126 store(js_array, 1, 256); |
127 store(sparse_object_array, 1, 256); | 127 store(sparse_object_array, 1, 256); |
128 store(sparse_js_array, 1, 256); | 128 store(sparse_js_array, 1, 256); |
129 | 129 |
130 return store; | 130 return store; |
131 } | 131 } |
132 | 132 |
133 var object_array = new Object; | 133 var object_array = new Object; |
134 var sparse_object_array = new Object; | 134 var sparse_object_array = new Object; |
135 var js_array = new Array(10); | 135 var js_array = new Array(10); |
136 var sparse_js_array = %NormalizeElements([]); | 136 var sparse_js_array = %NormalizeElements([]); |
137 sparse_js_array.length = 5000001; | 137 sparse_js_array.length = 200001; |
| 138 assertTrue(%HasDictionaryElements(sparse_js_array)); |
138 | 139 |
139 init_array(object_array); | 140 init_array(object_array); |
140 init_array(js_array); | 141 init_array(js_array); |
141 init_sparse_array(sparse_object_array); | 142 init_sparse_array(sparse_object_array); |
142 init_sparse_array(sparse_js_array); | 143 init_sparse_array(sparse_js_array); |
143 | 144 |
144 store = make_polymorphic_store_function(); | 145 store = make_polymorphic_store_function(); |
145 store(object_array, 2, 257); | 146 store(object_array, 2, 257); |
146 store = make_polymorphic_store_function(); | 147 store = make_polymorphic_store_function(); |
147 store(js_array, 2, 257); | 148 store(js_array, 2, 257); |
(...skipping 22 matching lines...) Expand all Loading... |
170 store(sparse_js_array, 3, 258); | 171 store(sparse_js_array, 3, 258); |
171 | 172 |
172 assertEquals(258, object_array[3]); | 173 assertEquals(258, object_array[3]); |
173 assertEquals(258, js_array[3]); | 174 assertEquals(258, js_array[3]); |
174 assertEquals(258, sparse_js_array[3]); | 175 assertEquals(258, sparse_js_array[3]); |
175 assertEquals(258, sparse_object_array[3]); | 176 assertEquals(258, sparse_object_array[3]); |
176 } | 177 } |
177 | 178 |
178 testPolymorphicLoads(); | 179 testPolymorphicLoads(); |
179 testPolymorphicStores(); | 180 testPolymorphicStores(); |
OLD | NEW |