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

Side by Side Diff: test/mjsunit/osr-elements-kind.js

Issue 397253002: Remove experimental flags that are now required (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback 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/opt-elements-kind.js ('k') | test/mjsunit/packed-elements.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 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 --expose-gc
29 29
30 // 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
31 // assumptions made about how elements transitions work because transition stubs 31 // assumptions made about how elements transitions work because transition stubs
32 // end up going generic. 32 // end up going generic.
33 // Flags: --stress-runs=2 33 // Flags: --stress-runs=2
34 34
35 // Test element kind of objects.
36 // 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 // by default, only a no-snapshot build actually has smi-only arrays enabled
39 // in this test case. Depending on whether smi-only arrays are actually
40 // enabled, this test takes the appropriate code path to check smi-only arrays.
41
42 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
43
44 if (support_smi_only_arrays) {
45 print("Tests include smi-only arrays.");
46 } else {
47 print("Tests do NOT include smi-only arrays.");
48 }
49
50 var elements_kind = { 35 var elements_kind = {
51 fast_smi_only : 'fast smi only elements', 36 fast_smi_only : 'fast smi only elements',
52 fast : 'fast elements', 37 fast : 'fast elements',
53 fast_double : 'fast double elements', 38 fast_double : 'fast double elements',
54 dictionary : 'dictionary elements', 39 dictionary : 'dictionary elements',
55 external_byte : 'external byte elements', 40 external_byte : 'external byte elements',
56 external_unsigned_byte : 'external unsigned byte elements', 41 external_unsigned_byte : 'external unsigned byte elements',
57 external_short : 'external short elements', 42 external_short : 'external short elements',
58 external_unsigned_short : 'external unsigned short elements', 43 external_unsigned_short : 'external unsigned short elements',
59 external_int : 'external int elements', 44 external_int : 'external int elements',
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 78 }
94 if (%HasExternalDoubleElements(obj)) { 79 if (%HasExternalDoubleElements(obj)) {
95 return elements_kind.external_double; 80 return elements_kind.external_double;
96 } 81 }
97 if (%HasExternalPixelElements(obj)) { 82 if (%HasExternalPixelElements(obj)) {
98 return elements_kind.external_pixel; 83 return elements_kind.external_pixel;
99 } 84 }
100 } 85 }
101 86
102 function assertKind(expected, obj, name_opt) { 87 function assertKind(expected, obj, name_opt) {
103 if (!support_smi_only_arrays &&
104 expected == elements_kind.fast_smi_only) {
105 expected = elements_kind.fast;
106 }
107 assertEquals(expected, getKind(obj), name_opt); 88 assertEquals(expected, getKind(obj), name_opt);
108 } 89 }
109 90
110 // long-running loop forces OSR. 91 // long-running loop forces OSR.
111 %NeverOptimizeFunction(construct_smis); 92 %NeverOptimizeFunction(construct_smis);
112 %NeverOptimizeFunction(construct_doubles); 93 %NeverOptimizeFunction(construct_doubles);
113 %NeverOptimizeFunction(convert_mixed); 94 %NeverOptimizeFunction(convert_mixed);
114 for (var i = 0; i < 1000000; i++) { } 95 for (var i = 0; i < 1000000; i++) { }
115 96
116 if (support_smi_only_arrays) { 97 // This code exists to eliminate the learning influence of AllocationSites
117 // This code exists to eliminate the learning influence of AllocationSites 98 // on the following tests.
118 // on the following tests. 99 var __sequence = 0;
119 var __sequence = 0; 100 function make_array_string() {
120 function make_array_string() { 101 this.__sequence = this.__sequence + 1;
121 this.__sequence = this.__sequence + 1; 102 return "/* " + this.__sequence + " */ [0, 0, 0];"
122 return "/* " + this.__sequence + " */ [0, 0, 0];" 103 }
123 } 104 function make_array() {
124 function make_array() { 105 return eval(make_array_string());
125 return eval(make_array_string()); 106 }
126 }
127 107
128 function construct_smis() { 108 function construct_smis() {
129 var a = make_array(); 109 var a = make_array();
130 a[0] = 0; // Send the COW array map to the steak house. 110 a[0] = 0; // Send the COW array map to the steak house.
131 assertKind(elements_kind.fast_smi_only, a); 111 assertKind(elements_kind.fast_smi_only, a);
132 return a; 112 return a;
133 } 113 }
134 function construct_doubles() { 114 function construct_doubles() {
135 var a = construct_smis(); 115 var a = construct_smis();
136 a[0] = 1.5; 116 a[0] = 1.5;
137 assertKind(elements_kind.fast_double, a); 117 assertKind(elements_kind.fast_double, a);
138 return a; 118 return a;
139 } 119 }
140 120
141 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will 121 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will
142 // transition to FAST directly). 122 // transition to FAST directly).
143 function convert_mixed(array, value, kind) { 123 function convert_mixed(array, value, kind) {
144 array[1] = value; 124 array[1] = value;
145 assertKind(kind, array); 125 assertKind(kind, array);
146 assertEquals(value, array[1]); 126 assertEquals(value, array[1]);
147 } 127 }
148 smis = construct_smis(); 128 smis = construct_smis();
149 convert_mixed(smis, 1.5, elements_kind.fast_double); 129 convert_mixed(smis, 1.5, elements_kind.fast_double);
150 130
151 doubles = construct_doubles(); 131 doubles = construct_doubles();
152 convert_mixed(doubles, "three", elements_kind.fast); 132 convert_mixed(doubles, "three", elements_kind.fast);
153 133
154 convert_mixed(construct_smis(), "three", elements_kind.fast); 134 convert_mixed(construct_smis(), "three", elements_kind.fast);
155 convert_mixed(construct_doubles(), "three", elements_kind.fast); 135 convert_mixed(construct_doubles(), "three", elements_kind.fast);
156 136
157 smis = construct_smis(); 137 smis = construct_smis();
158 doubles = construct_doubles(); 138 doubles = construct_doubles();
159 convert_mixed(smis, 1, elements_kind.fast); 139 convert_mixed(smis, 1, elements_kind.fast);
160 convert_mixed(doubles, 1, elements_kind.fast); 140 convert_mixed(doubles, 1, elements_kind.fast);
161 assertTrue(%HaveSameMap(smis, doubles)); 141 assertTrue(%HaveSameMap(smis, doubles));
162 }
163 142
164 // Throw away type information in the ICs for next stress run. 143 // Throw away type information in the ICs for next stress run.
165 gc(); 144 gc();
OLDNEW
« no previous file with comments | « test/mjsunit/opt-elements-kind.js ('k') | test/mjsunit/packed-elements.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698