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

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

Issue 7992003: Porting r9392 to x64 (smi-only arrays). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: save one memory access. 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
« src/x64/stub-cache-x64.cc ('K') | « src/x64/stub-cache-x64.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
(...skipping 29 matching lines...) Expand all
40 external_short_elements : 6, 40 external_short_elements : 6,
41 external_unsigned_short_elements : 7, 41 external_unsigned_short_elements : 7,
42 external_int_elements : 8, 42 external_int_elements : 8,
43 external_unsigned_int_elements : 9, 43 external_unsigned_int_elements : 9,
44 external_float_elements : 10, 44 external_float_elements : 10,
45 external_double_elements : 11, 45 external_double_elements : 11,
46 external_pixel_elements : 12 46 external_pixel_elements : 12
47 } 47 }
48 48
49 // We expect an object to only be of one element kind. 49 // We expect an object to only be of one element kind.
50 function assertKind(expected, obj){ 50 function assertKind(expected, obj) {
51 if (support_smi_only_arrays) { 51 if (support_smi_only_arrays) {
52 assertEquals(expected == element_kind.fast_smi_only_elements, 52 assertEquals(expected == element_kind.fast_smi_only_elements,
53 %HasFastSmiOnlyElements(obj)); 53 %HasFastSmiOnlyElements(obj));
54 assertEquals(expected == element_kind.fast_elements, 54 assertEquals(expected == element_kind.fast_elements,
55 %HasFastElements(obj)); 55 %HasFastElements(obj));
56 } else { 56 } else {
57 assertEquals(expected == element_kind.fast_elements || 57 assertEquals(expected == element_kind.fast_elements ||
58 expected == element_kind.fast_smi_only_elements, 58 expected == element_kind.fast_smi_only_elements,
59 %HasFastElements(obj)); 59 %HasFastElements(obj));
60 } 60 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 var too = [1,2,3]; 94 var too = [1,2,3];
95 assertKind(element_kind.fast_smi_only_elements, too); 95 assertKind(element_kind.fast_smi_only_elements, too);
96 too.dance = 0xD15C0; 96 too.dance = 0xD15C0;
97 too.drink = 0xC0C0A; 97 too.drink = 0xC0C0A;
98 assertKind(element_kind.fast_smi_only_elements, too); 98 assertKind(element_kind.fast_smi_only_elements, too);
99 99
100 // Make sure the element kind transitions from smionly when a non-smi is stored. 100 // Make sure the element kind transitions from smionly when a non-smi is stored.
101 var you = new Array(); 101 var you = new Array();
102 assertKind(element_kind.fast_smi_only_elements, you); 102 assertKind(element_kind.fast_smi_only_elements, you);
103 for(i = 0; i < 1337; i++) { 103 for (var i = 0; i < 1337; i++) {
104 var val = i; 104 var val = i;
105 if (i == 1336) { 105 if (i == 1336) {
106 assertKind(element_kind.fast_smi_only_elements, you); 106 assertKind(element_kind.fast_smi_only_elements, you);
107 val = new Object(); 107 val = new Object();
108 } 108 }
109 you[i] = val; 109 you[i] = val;
110 } 110 }
111 assertKind(element_kind.fast_elements, you); 111 assertKind(element_kind.fast_elements, you);
112 112
113 assertKind(element_kind.dictionary_elements, new Array(0xC0C0A)); 113 assertKind(element_kind.dictionary_elements, new Array(0xDECAF));
114 114
115 // fast_double_elements not yet available 115 var fast_double_array = new Array(0xDECAF);
116 116 for (var i = 0; i < 0xDECAF; i++) fast_double_array[i] = i / 2;
117 assertKind(element_kind.fast_double_elements, fast_double_array);
William Hesse 2011/09/23 13:25:22 Why is the test for fast double elements in the ch
Yang 2011/09/23 14:19:12 Yes, this should have been a separate CL. Kind of
117 118
118 assertKind(element_kind.external_byte_elements, new Int8Array(9001)); 119 assertKind(element_kind.external_byte_elements, new Int8Array(9001));
119 assertKind(element_kind.external_unsigned_byte_elements, new Uint8Array(007)); 120 assertKind(element_kind.external_unsigned_byte_elements, new Uint8Array(007));
120 assertKind(element_kind.external_short_elements, new Int16Array(666)); 121 assertKind(element_kind.external_short_elements, new Int16Array(666));
121 assertKind(element_kind.external_unsigned_short_elements, new Uint16Array(42)); 122 assertKind(element_kind.external_unsigned_short_elements, new Uint16Array(42));
122 assertKind(element_kind.external_int_elements, new Int32Array(0xF)); 123 assertKind(element_kind.external_int_elements, new Int32Array(0xF));
123 assertKind(element_kind.external_unsigned_int_elements, new Uint32Array(23)); 124 assertKind(element_kind.external_unsigned_int_elements, new Uint32Array(23));
124 assertKind(element_kind.external_float_elements, new Float32Array(7)); 125 assertKind(element_kind.external_float_elements, new Float32Array(7));
125 assertKind(element_kind.external_double_elements, new Float64Array(0)); 126 assertKind(element_kind.external_double_elements, new Float64Array(0));
126 assertKind(element_kind.external_pixel_elements, new PixelArray(512)); 127 assertKind(element_kind.external_pixel_elements, new PixelArray(512));
OLDNEW
« src/x64/stub-cache-x64.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698