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

Side by Side Diff: test/mjsunit/element-kind.js

Issue 7901016: Basic support for tracking smi-only arrays on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: deactivate by default Created 9 years, 3 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
« test/cctest/test-heap.cc ('K') | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 28 // Flags: --allow-natives-syntax --smi-only-arrays
29 // Test element kind of objects 29 // Test element kind of objects
30 30
31 var element_kind = { 31 var element_kind = {
32 fast_smi_only_elements : 0,
32 fast_elements : 1, 33 fast_elements : 1,
33 fast_double_elements : 2, 34 fast_double_elements : 2,
34 dictionary_elements : 3, 35 dictionary_elements : 3,
35 external_byte_elements : 4, 36 external_byte_elements : 4,
36 external_unsigned_byte_elements : 5, 37 external_unsigned_byte_elements : 5,
37 external_short_elements : 6, 38 external_short_elements : 6,
38 external_unsigned_short_elements : 7, 39 external_unsigned_short_elements : 7,
39 external_int_elements : 8, 40 external_int_elements : 8,
40 external_unsigned_int_elements : 9, 41 external_unsigned_int_elements : 9,
41 external_float_elements : 10, 42 external_float_elements : 10,
42 external_double_elements : 11, 43 external_double_elements : 11,
43 external_pixel_elements : 12 44 external_pixel_elements : 12
44 } 45 }
45 46
46 // We expect an object to only be of one element kind. 47 // We expect an object to only be of one element kind.
47 function assertKind(expected, obj){ 48 function assertKind(expected, obj){
49 assertEquals(expected == element_kind.fast_smi_only_elements,
50 %HasFastSmiOnlyElements(obj));
48 assertEquals(expected == element_kind.fast_elements, 51 assertEquals(expected == element_kind.fast_elements,
49 %HasFastElements(obj)); 52 %HasFastElements(obj));
50 assertEquals(expected == element_kind.fast_double_elements, 53 assertEquals(expected == element_kind.fast_double_elements,
51 %HasFastDoubleElements(obj)); 54 %HasFastDoubleElements(obj));
52 assertEquals(expected == element_kind.dictionary_elements, 55 assertEquals(expected == element_kind.dictionary_elements,
53 %HasDictionaryElements(obj)); 56 %HasDictionaryElements(obj));
54 assertEquals(expected == element_kind.external_byte_elements, 57 assertEquals(expected == element_kind.external_byte_elements,
55 %HasExternalByteElements(obj)); 58 %HasExternalByteElements(obj));
56 assertEquals(expected == element_kind.external_unsigned_byte_elements, 59 assertEquals(expected == element_kind.external_unsigned_byte_elements,
57 %HasExternalUnsignedByteElements(obj)); 60 %HasExternalUnsignedByteElements(obj));
(...skipping 15 matching lines...) Expand all
73 assertEquals(expected >= element_kind.external_byte_elements, 76 assertEquals(expected >= element_kind.external_byte_elements,
74 %HasExternalArrayElements(obj)); 77 %HasExternalArrayElements(obj));
75 } 78 }
76 79
77 var me = {}; 80 var me = {};
78 assertKind(element_kind.fast_elements, me); 81 assertKind(element_kind.fast_elements, me);
79 me.dance = 0xD15C0; 82 me.dance = 0xD15C0;
80 me.drink = 0xC0C0A; 83 me.drink = 0xC0C0A;
81 assertKind(element_kind.fast_elements, me); 84 assertKind(element_kind.fast_elements, me);
82 85
86 var too = [1,2,3];
87 assertKind(element_kind.fast_elements, too);
Jakob Kummerow 2011/09/16 16:30:34 Why fast_elements? Don't all arrays start off with
danno 2011/09/21 14:32:04 Done.
88 too.dance = 0xD15C0;
89 too.drink = 0xC0C0A;
90 assertKind(element_kind.fast_elements, too);
91
92 // Make sure the element kind transitions from smionly when a non-smi is stored.
83 var you = new Array(); 93 var you = new Array();
84 for(i = 0; i < 1337; i++) { 94 for(i = 0; i < 1337; i++) {
85 you[i] = i; 95 var val = i;
96 if (i == 1336) {
97 assertKind(element_kind.fast_smi_only_elements, you);
Yang 2011/09/19 14:00:15 This assert does not pass for me when using the ra
danno 2011/09/21 14:32:04 I just ran the test on my machine, and it works fo
98 val = new Object();
99 }
100 you[i] = val;
86 } 101 }
87 assertKind(element_kind.fast_elements, you); 102 assertKind(element_kind.fast_elements, you);
88 103
89 assertKind(element_kind.dictionary_elements, new Array(0xC0C0A)); 104 assertKind(element_kind.dictionary_elements, new Array(0xC0C0A));
90 105
91 // fast_double_elements not yet available 106 // fast_double_elements not yet available
92 107
93 108
94 assertKind(element_kind.external_byte_elements, new Int8Array(9001)); 109 assertKind(element_kind.external_byte_elements, new Int8Array(9001));
95 assertKind(element_kind.external_unsigned_byte_elements, new Uint8Array(007)); 110 assertKind(element_kind.external_unsigned_byte_elements, new Uint8Array(007));
96 assertKind(element_kind.external_short_elements, new Int16Array(666)); 111 assertKind(element_kind.external_short_elements, new Int16Array(666));
97 assertKind(element_kind.external_unsigned_short_elements, new Uint16Array(42)); 112 assertKind(element_kind.external_unsigned_short_elements, new Uint16Array(42));
98 assertKind(element_kind.external_int_elements, new Int32Array(0xF)); 113 assertKind(element_kind.external_int_elements, new Int32Array(0xF));
99 assertKind(element_kind.external_unsigned_int_elements, new Uint32Array(23)); 114 assertKind(element_kind.external_unsigned_int_elements, new Uint32Array(23));
100 assertKind(element_kind.external_float_elements, new Float32Array(7)); 115 assertKind(element_kind.external_float_elements, new Float32Array(7));
101 assertKind(element_kind.external_double_elements, new Float64Array(0)); 116 assertKind(element_kind.external_double_elements, new Float64Array(0));
102 assertKind(element_kind.external_pixel_elements, new PixelArray(512)); 117 assertKind(element_kind.external_pixel_elements, new PixelArray(512));
OLDNEW
« test/cctest/test-heap.cc ('K') | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698