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/polymorph-arrays.js

Issue 6894003: Better support for 'polymorphic' JS and external arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback and merge Created 9 years, 7 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
(Empty)
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 // Flags: --allow-natives-syntax
29
30 function init_array(a) {
31 for (var i = 0; i < 10; ++i ){
32 a[i] = i;
33 }
34 }
35
36 function f1(a, i) {
37 a[i+4] = a[a+5];
38 return (a[i] + a[i+1]);
39 }
40
41 // Check smi checks and monomorphic ICs for object arrays.
42 var object_array = new Object();
43 init_array(object_array);
44 assertEquals(3, f1(object_array, 1));
45 assertEquals(NaN, f1(1, 1));
46 assertEquals(NaN, f1(object_array, new Object()));
47 assertEquals(0, f1(new PixelArray(10), 1));
48
49 function f2(a, i) {
50 a[i+4] = a[a+5];
51 return (a[i] + a[i+1]);
52 }
53
54 // Check smi checks and monomorphic ICs for JS arrays.
55 var js_array = new Array();
56 init_array(js_array);
57 assertEquals(3, f2(js_array, 1));
58 assertEquals(NaN, f2(1, 1));
59 assertEquals(NaN, f2(js_array, new Object()));
60 assertEquals(0, f2(new PixelArray(10), 1));
61
62 function f3(a, i) {
63 a[i+4] = a[a+5];
64 return (a[i] + a[i+1]);
65 }
66
67 // Check smi checks and monomorphic ICs for simple external arrays.
68 var int_array = new Int32Array(10);
69 init_array(int_array);
70 assertEquals(3, f3(int_array, 1));
71 assertEquals(NaN, f3(1, 1));
72 assertEquals(NaN, f3(int_array, new Object()));
73 assertEquals(0, f4(new PixelArray(10), 1));
74
75 function f4(a, i) {
76 a[i+4] = a[a+5];
77 return (a[i] + a[i+1]);
78 }
79
80 // Check smi checks for simple megamorphic array ICs.
81 var int_array_2 = new Int8Array(10);
82 var js_array_2 = new Array();
83 var object_array_2 = new Object();
84 init_array(int_array_2);
85 init_array(js_array_2);
86 init_array(object_array_2);
87 assertEquals(3, f4(int_array_2, 1));
88 assertEquals(3, f4(js_array_2, 1));
89 assertEquals(3, f4(object_array_2, 1));
90 assertEquals(NaN, f4(1, 1));
91 assertEquals(NaN, f4(int_array, new Object()));
92 assertEquals(0, f4(new PixelArray(10), 1));
93
94 function f5(a, i) {
95 a[i+4] = a[a+5];
96 return (a[i] + a[i+1]);
97 }
98
99 // Check megamorphic array ICs that exceed the maximum allowed polymorphism
100 var int8_array_3 = new Int8Array(10);
101 var uint8_array_3 = new Uint8Array(10);
102 var int16_array_3 = new Int16Array(10);
103 var uint16_array_3 = new Uint16Array(10);
104 var int32_array_3 = new Int32Array(10);
105 var uint32_array_3 = new Uint32Array(10);
106 var js_array_3 = new Array();
107 var object_array_3 = new Object();
108 init_array(int8_array_3);
109 init_array(uint8_array_3);
110 init_array(int16_array_3);
111 init_array(uint16_array_3);
112 init_array(int32_array_3);
113 init_array(uint32_array_3);
114 init_array(js_array_3);
115 init_array(object_array_3);
116 assertEquals(3, f5(int8_array_3, 1));
117 assertEquals(3, f5(uint8_array_3, 1));
118 assertEquals(3, f5(int16_array_3, 1));
119 assertEquals(3, f5(uint16_array_3, 1));
120 assertEquals(3, f5(int32_array_3, 1));
121 assertEquals(3, f5(uint32_array_3, 1));
122 assertEquals(3, f5(js_array_3, 1));
123 assertEquals(3, f5(object_array_3, 1));
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