OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc | 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc |
| 29 // Flags: --notrack_allocation_sites |
29 | 30 |
30 // Limit the number of stress runs to reduce polymorphism it defeats some of the | 31 // Limit the number of stress runs to reduce polymorphism it defeats some of the |
31 // assumptions made about how elements transitions work because transition stubs | 32 // assumptions made about how elements transitions work because transition stubs |
32 // end up going generic. | 33 // end up going generic. |
33 // Flags: --stress-runs=2 | 34 // Flags: --stress-runs=2 |
34 | 35 |
35 // Test element kind of objects. | 36 // Test element kind of objects. |
36 // Since --smi-only-arrays affects builtins, its default setting at compile | 37 // Since --smi-only-arrays affects builtins, its default setting at compile |
37 // time sticks if built with snapshot. If --smi-only-arrays is deactivated | 38 // time sticks if built with snapshot. If --smi-only-arrays is deactivated |
38 // by default, only a no-snapshot build actually has smi-only arrays enabled | 39 // by default, only a no-snapshot build actually has smi-only arrays enabled |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 107 |
107 function assertKind(expected, obj, name_opt) { | 108 function assertKind(expected, obj, name_opt) { |
108 if (!support_smi_only_arrays && | 109 if (!support_smi_only_arrays && |
109 expected == elements_kind.fast_smi_only) { | 110 expected == elements_kind.fast_smi_only) { |
110 expected = elements_kind.fast; | 111 expected = elements_kind.fast; |
111 } | 112 } |
112 assertEquals(expected, getKind(obj), name_opt); | 113 assertEquals(expected, getKind(obj), name_opt); |
113 } | 114 } |
114 | 115 |
115 %NeverOptimizeFunction(construct_smis); | 116 %NeverOptimizeFunction(construct_smis); |
116 | |
117 // This code exists to eliminate the learning influence of AllocationSites | |
118 // on the following tests. | |
119 var __sequence = 0; | |
120 function make_array_string() { | |
121 this.__sequence = this.__sequence + 1; | |
122 return "/* " + this.__sequence + " */ [0, 0, 0];" | |
123 } | |
124 function make_array() { | |
125 return eval(make_array_string()); | |
126 } | |
127 | |
128 function construct_smis() { | 117 function construct_smis() { |
129 var a = make_array(); | 118 var a = [0, 0, 0]; |
130 a[0] = 0; // Send the COW array map to the steak house. | 119 a[0] = 0; // Send the COW array map to the steak house. |
131 assertKind(elements_kind.fast_smi_only, a); | 120 assertKind(elements_kind.fast_smi_only, a); |
132 return a; | 121 return a; |
133 } | 122 } |
134 | 123 |
135 %NeverOptimizeFunction(construct_doubles); | 124 %NeverOptimizeFunction(construct_doubles); |
136 function construct_doubles() { | 125 function construct_doubles() { |
137 var a = construct_smis(); | 126 var a = construct_smis(); |
138 a[0] = 1.5; | 127 a[0] = 1.5; |
139 assertKind(elements_kind.fast_double, a); | 128 assertKind(elements_kind.fast_double, a); |
(...skipping 28 matching lines...) Expand all Loading... |
168 assertTrue(%HaveSameMap(smis, doubles)); | 157 assertTrue(%HaveSameMap(smis, doubles)); |
169 } | 158 } |
170 | 159 |
171 test1(); | 160 test1(); |
172 gc(); // clear IC state | 161 gc(); // clear IC state |
173 test1(); | 162 test1(); |
174 gc(); // clear IC state | 163 gc(); // clear IC state |
175 %OptimizeFunctionOnNextCall(test1); | 164 %OptimizeFunctionOnNextCall(test1); |
176 test1(); | 165 test1(); |
177 gc(); // clear IC state | 166 gc(); // clear IC state |
OLD | NEW |