OLD | NEW |
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 |
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 | |
30 | 29 |
31 // Limit the number of stress runs to reduce polymorphism it defeats some of the | 30 // Limit the number of stress runs to reduce polymorphism it defeats some of the |
32 // assumptions made about how elements transitions work because transition stubs | 31 // assumptions made about how elements transitions work because transition stubs |
33 // end up going generic. | 32 // end up going generic. |
34 // Flags: --stress-runs=2 | 33 // Flags: --stress-runs=2 |
35 | 34 |
36 // Test element kind of objects. | 35 // Test element kind of objects. |
37 // Since --smi-only-arrays affects builtins, its default setting at compile | 36 // Since --smi-only-arrays affects builtins, its default setting at compile |
38 // time sticks if built with snapshot. If --smi-only-arrays is deactivated | 37 // time sticks if built with snapshot. If --smi-only-arrays is deactivated |
39 // by default, only a no-snapshot build actually has smi-only arrays enabled | 38 // by default, only a no-snapshot build actually has smi-only arrays enabled |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 assertEquals(expected, getKind(obj), name_opt); | 112 assertEquals(expected, getKind(obj), name_opt); |
114 } | 113 } |
115 | 114 |
116 // long-running loop forces OSR. | 115 // long-running loop forces OSR. |
117 %NeverOptimizeFunction(construct_smis); | 116 %NeverOptimizeFunction(construct_smis); |
118 %NeverOptimizeFunction(construct_doubles); | 117 %NeverOptimizeFunction(construct_doubles); |
119 %NeverOptimizeFunction(convert_mixed); | 118 %NeverOptimizeFunction(convert_mixed); |
120 for (var i = 0; i < 1000000; i++) { } | 119 for (var i = 0; i < 1000000; i++) { } |
121 | 120 |
122 if (support_smi_only_arrays) { | 121 if (support_smi_only_arrays) { |
| 122 // This code exists to eliminate the learning influence of AllocationSites |
| 123 // on the following tests. |
| 124 var __sequence = 0; |
| 125 function make_array_string() { |
| 126 this.__sequence = this.__sequence + 1; |
| 127 return "/* " + this.__sequence + " */ [0, 0, 0];" |
| 128 } |
| 129 function make_array() { |
| 130 return eval(make_array_string()); |
| 131 } |
| 132 |
123 function construct_smis() { | 133 function construct_smis() { |
124 var a = [0, 0, 0]; | 134 var a = make_array(); |
125 a[0] = 0; // Send the COW array map to the steak house. | 135 a[0] = 0; // Send the COW array map to the steak house. |
126 assertKind(elements_kind.fast_smi_only, a); | 136 assertKind(elements_kind.fast_smi_only, a); |
127 return a; | 137 return a; |
128 } | 138 } |
129 function construct_doubles() { | 139 function construct_doubles() { |
130 var a = construct_smis(); | 140 var a = construct_smis(); |
131 a[0] = 1.5; | 141 a[0] = 1.5; |
132 assertKind(elements_kind.fast_double, a); | 142 assertKind(elements_kind.fast_double, a); |
133 return a; | 143 return a; |
134 } | 144 } |
(...skipping 16 matching lines...) Expand all Loading... |
151 | 161 |
152 smis = construct_smis(); | 162 smis = construct_smis(); |
153 doubles = construct_doubles(); | 163 doubles = construct_doubles(); |
154 convert_mixed(smis, 1, elements_kind.fast); | 164 convert_mixed(smis, 1, elements_kind.fast); |
155 convert_mixed(doubles, 1, elements_kind.fast); | 165 convert_mixed(doubles, 1, elements_kind.fast); |
156 assertTrue(%HaveSameMap(smis, doubles)); | 166 assertTrue(%HaveSameMap(smis, doubles)); |
157 } | 167 } |
158 | 168 |
159 // Throw away type information in the ICs for next stress run. | 169 // Throw away type information in the ICs for next stress run. |
160 gc(); | 170 gc(); |
OLD | NEW |