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 | |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 106 |
108 function assertKind(expected, obj, name_opt) { | 107 function assertKind(expected, obj, name_opt) { |
109 if (!support_smi_only_arrays && | 108 if (!support_smi_only_arrays && |
110 expected == elements_kind.fast_smi_only) { | 109 expected == elements_kind.fast_smi_only) { |
111 expected = elements_kind.fast; | 110 expected = elements_kind.fast; |
112 } | 111 } |
113 assertEquals(expected, getKind(obj), name_opt); | 112 assertEquals(expected, getKind(obj), name_opt); |
114 } | 113 } |
115 | 114 |
116 %NeverOptimizeFunction(construct_smis); | 115 %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 |
117 function construct_smis() { | 128 function construct_smis() { |
118 var a = [0, 0, 0]; | 129 var a = make_array(); |
119 a[0] = 0; // Send the COW array map to the steak house. | 130 a[0] = 0; // Send the COW array map to the steak house. |
120 assertKind(elements_kind.fast_smi_only, a); | 131 assertKind(elements_kind.fast_smi_only, a); |
121 return a; | 132 return a; |
122 } | 133 } |
123 | 134 |
124 %NeverOptimizeFunction(construct_doubles); | 135 %NeverOptimizeFunction(construct_doubles); |
125 function construct_doubles() { | 136 function construct_doubles() { |
126 var a = construct_smis(); | 137 var a = construct_smis(); |
127 a[0] = 1.5; | 138 a[0] = 1.5; |
128 assertKind(elements_kind.fast_double, a); | 139 assertKind(elements_kind.fast_double, a); |
(...skipping 28 matching lines...) Expand all Loading... |
157 assertTrue(%HaveSameMap(smis, doubles)); | 168 assertTrue(%HaveSameMap(smis, doubles)); |
158 } | 169 } |
159 | 170 |
160 test1(); | 171 test1(); |
161 gc(); // clear IC state | 172 gc(); // clear IC state |
162 test1(); | 173 test1(); |
163 gc(); // clear IC state | 174 gc(); // clear IC state |
164 %OptimizeFunctionOnNextCall(test1); | 175 %OptimizeFunctionOnNextCall(test1); |
165 test1(); | 176 test1(); |
166 gc(); // clear IC state | 177 gc(); // clear IC state |
OLD | NEW |