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

Side by Side Diff: test/mjsunit/elements-transition.js

Issue 8241003: Elements kind conversion in generated code (ia32). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Applied suggested changes. Created 9 years, 2 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/elements-kind.js ('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 --smi-only-arrays
29
30 support_smi_only_arrays = %HasFastSmiOnlyElements([]);
31
32 if (support_smi_only_arrays) {
33 function test(test_double, test_object, set, length) {
34 // We apply the same operations to two identical arrays. The first array
35 // triggers an IC miss, upon which the conversion stub is generated, but the
36 // actual conversion is done in runtime. The second array, arriving at
37 // the previously patched IC, is then converted using the conversion stub.
38 var array_1 = new Array(length);
39 var array_2 = new Array(length);
40
41 assertTrue(%HasFastSmiOnlyElements(array_1));
42 assertTrue(%HasFastSmiOnlyElements(array_2));
43 for (var i = 0; i < length; i++) {
44 if (i == length - 8 && test_double) {
45 set(array_1, i, 0.5);
46 set(array_2, i, 0.5);
47 assertTrue(%HasFastDoubleElements(array_1));
48 assertTrue(%HasFastDoubleElements(array_2));
49 } else if (i == length - 5 && test_object) {
50 set(array_1, i, 'object');
51 set(array_2, i, 'object');
52 assertTrue(%HasFastElements(array_1));
53 assertTrue(%HasFastElements(array_2));
54 } else {
55 set(array_1, i, 2*i+1);
56 set(array_2, i, 2*i+1);
57 }
58 }
59
60 for (var i = 0; i < length; i++) {
61 if (i == length - 8 && test_double) {
62 assertEquals(0.5, array_1[i]);
63 assertEquals(0.5, array_2[i]);
64 } else if (i == length - 5 && test_object) {
65 assertEquals('object', array_1[i]);
66 assertEquals('object', array_2[i]);
67 } else {
68 assertEquals(2*i+1, array_1[i]);
69 assertEquals(2*i+1, array_2[i]);
70 }
71 }
72 }
73
74 test(false, false, function(a,i,v){ a[i] = v; }, 100);
75 test(true, false, function(a,i,v){ a[i] = v; }, 100);
76 test(false, true, function(a,i,v){ a[i] = v; }, 100);
77 test(true, true, function(a,i,v){ a[i] = v; }, 100);
78
79 test(false, false, function(a,i,v){ a[i] = v; }, 10000);
80 test(true, false, function(a,i,v){ a[i] = v; }, 10000);
81 test(false, true, function(a,i,v){ a[i] = v; }, 10000);
82 test(true, true, function(a,i,v){ a[i] = v; }, 10000);
83 }
OLDNEW
« no previous file with comments | « test/mjsunit/elements-kind.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698