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

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

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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/parallel-initial-prototype-change.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 --smi-only-arrays --expose-gc
29 // Flags: --track-allocation-sites --noalways-opt 29 // Flags: --notrack_allocation_sites
30
31 // 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
33 // end up going generic.
34 // Flags: --stress-runs=2
30 35
31 // Test element kind of objects. 36 // Test element kind of objects.
32 // Since --smi-only-arrays affects builtins, its default setting at compile 37 // Since --smi-only-arrays affects builtins, its default setting at compile
33 // 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
34 // 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
35 // in this test case. Depending on whether smi-only arrays are actually 40 // in this test case. Depending on whether smi-only arrays are actually
36 // enabled, this test takes the appropriate code path to check smi-only arrays. 41 // enabled, this test takes the appropriate code path to check smi-only arrays.
37 42
38 // support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); 43 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
39 support_smi_only_arrays = true;
40 optimize_constructed_arrays = true;
41 44
42 if (support_smi_only_arrays) { 45 if (support_smi_only_arrays) {
43 print("Tests include smi-only arrays."); 46 print("Tests include smi-only arrays.");
44 } else { 47 } else {
45 print("Tests do NOT include smi-only arrays."); 48 print("Tests do NOT include smi-only arrays.");
46 } 49 }
47 50
48 if (optimize_constructed_arrays) {
49 print("Tests include constructed array optimizations.");
50 } else {
51 print("Tests do NOT include constructed array optimizations.");
52 }
53
54 var elements_kind = { 51 var elements_kind = {
55 fast_smi_only : 'fast smi only elements', 52 fast_smi_only : 'fast smi only elements',
56 fast : 'fast elements', 53 fast : 'fast elements',
57 fast_double : 'fast double elements', 54 fast_double : 'fast double elements',
58 dictionary : 'dictionary elements', 55 dictionary : 'dictionary elements',
59 external_byte : 'external byte elements', 56 external_byte : 'external byte elements',
60 external_unsigned_byte : 'external unsigned byte elements', 57 external_unsigned_byte : 'external unsigned byte elements',
61 external_short : 'external short elements', 58 external_short : 'external short elements',
62 external_unsigned_short : 'external unsigned short elements', 59 external_unsigned_short : 'external unsigned short elements',
63 external_int : 'external int elements', 60 external_int : 'external int elements',
64 external_unsigned_int : 'external unsigned int elements', 61 external_unsigned_int : 'external unsigned int elements',
65 external_float : 'external float elements', 62 external_float : 'external float elements',
66 external_double : 'external double elements', 63 external_double : 'external double elements',
67 external_pixel : 'external pixel elements' 64 external_pixel : 'external pixel elements'
68 } 65 }
69 66
70 function getKind(obj) { 67 function getKind(obj) {
71 if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; 68 if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only;
72 if (%HasFastObjectElements(obj)) return elements_kind.fast; 69 if (%HasFastObjectElements(obj)) return elements_kind.fast;
73 if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; 70 if (%HasFastDoubleElements(obj)) return elements_kind.fast_double;
74 if (%HasDictionaryElements(obj)) return elements_kind.dictionary; 71 if (%HasDictionaryElements(obj)) return elements_kind.dictionary;
75 } 72 // Every external kind is also an external array.
76 73 assertTrue(%HasExternalArrayElements(obj));
77 function isHoley(obj) { 74 if (%HasExternalByteElements(obj)) {
78 if (%HasFastHoleyElements(obj)) return true; 75 return elements_kind.external_byte;
79 return false; 76 }
77 if (%HasExternalUnsignedByteElements(obj)) {
78 return elements_kind.external_unsigned_byte;
79 }
80 if (%HasExternalShortElements(obj)) {
81 return elements_kind.external_short;
82 }
83 if (%HasExternalUnsignedShortElements(obj)) {
84 return elements_kind.external_unsigned_short;
85 }
86 if (%HasExternalIntElements(obj)) {
87 return elements_kind.external_int;
88 }
89 if (%HasExternalUnsignedIntElements(obj)) {
90 return elements_kind.external_unsigned_int;
91 }
92 if (%HasExternalFloatElements(obj)) {
93 return elements_kind.external_float;
94 }
95 if (%HasExternalDoubleElements(obj)) {
96 return elements_kind.external_double;
97 }
98 if (%HasExternalPixelElements(obj)) {
99 return elements_kind.external_pixel;
100 }
80 } 101 }
81 102
82 function assertKind(expected, obj, name_opt) { 103 function assertKind(expected, obj, name_opt) {
83 if (!support_smi_only_arrays && 104 if (!support_smi_only_arrays &&
84 expected == elements_kind.fast_smi_only) { 105 expected == elements_kind.fast_smi_only) {
85 expected = elements_kind.fast; 106 expected = elements_kind.fast;
86 } 107 }
87 assertEquals(expected, getKind(obj), name_opt); 108 assertEquals(expected, getKind(obj), name_opt);
88 } 109 }
89 110
90 if (support_smi_only_arrays && optimize_constructed_arrays) { 111 // long-running loop forces OSR.
91 function bar0(t) { 112 for (var i = 0; i < 1000000; i++) { }
92 return new t(); 113
114 if (support_smi_only_arrays) {
115 function construct_smis() {
116 try {} catch (e) {} // TODO(titzer): DisableOptimization
117 var a = [0, 0, 0];
118 a[0] = 0; // Send the COW array map to the steak house.
119 assertKind(elements_kind.fast_smi_only, a);
120 return a;
121 }
122 function construct_doubles() {
123 try {} catch (e) {} // TODO(titzer): DisableOptimization
124 var a = construct_smis();
125 a[0] = 1.5;
126 assertKind(elements_kind.fast_double, a);
127 return a;
93 } 128 }
94 129
95 a = bar0(Array); 130 // Test transition chain SMI->DOUBLE->FAST (crankshafted function will
96 a[0] = 3.5; 131 // transition to FAST directly).
97 b = bar0(Array); 132 function convert_mixed(array, value, kind) {
98 assertKind(elements_kind.fast_double, b); 133 try {} catch (e) {} // TODO(titzer): DisableOptimization
99 %OptimizeFunctionOnNextCall(bar0); 134 array[1] = value;
100 b = bar0(Array); 135 assertKind(kind, array);
101 assertKind(elements_kind.fast_double, b); 136 assertEquals(value, array[1]);
102 assertTrue(2 != %GetOptimizationStatus(bar0)); 137 }
103 // bar0 should deopt 138 smis = construct_smis();
104 b = bar0(Object); 139 convert_mixed(smis, 1.5, elements_kind.fast_double);
105 assertTrue(1 != %GetOptimizationStatus(bar0)); 140
141 doubles = construct_doubles();
142 convert_mixed(doubles, "three", elements_kind.fast);
143
144 convert_mixed(construct_smis(), "three", elements_kind.fast);
145 convert_mixed(construct_doubles(), "three", elements_kind.fast);
146
147 smis = construct_smis();
148 doubles = construct_doubles();
149 convert_mixed(smis, 1, elements_kind.fast);
150 convert_mixed(doubles, 1, elements_kind.fast);
151 assertTrue(%HaveSameMap(smis, doubles));
106 } 152 }
153
154 // Throw away type information in the ICs for next stress run.
155 gc();
OLDNEW
« no previous file with comments | « test/mjsunit/opt-elements-kind.js ('k') | test/mjsunit/parallel-initial-prototype-change.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698