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

Side by Side Diff: test/mjsunit/compiler/assignment-deopt.js

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 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
« no previous file with comments | « test/mjsunit/compiler/assignment.js ('k') | test/mjsunit/compiler/binary-ops.js » ('j') | 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 2010 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 // Test deopt with count operation on parameter.
29 var max_smi = 1073741823;
30 var o = {x:0};
31
32 function assign1(x) { x += 1; o.x = x; }
33 assign1(max_smi);
34 assertEquals(max_smi + 1, o.x);
35
36 assign1(1.1);
37 assertEquals(2.1, o.x);
38
39
40 // Test deopt with count operation on named property.
41 function assign2(p) { p.x += 1 }
42
43 o.x = "42";
44 assign2(o);
45 assertEquals("421", o.x);
46
47 var s = max_smi - 10000;
48 o.x = s;
49 for(var i = 0; i < 20000; i++) {
50 assign2(o);
51 }
52 assertEquals(max_smi + 10000, o.x);
53
54
55 // Test deopt with count operation on keyed property.
56 function assign3(a, b) { a[b] += 1; }
57
58 o = ["42"];
59 assign3(o, 0);
60 assertEquals("421", o[0]);
61
62 var s = max_smi - 10000;
63 o[0] = s;
64 for(var i = 0; i < 20000; i++) {
65 assign3(o, 0);
66 }
67 assertEquals(max_smi + 10000, o[0]);
68
69 assign3(o,"0");
70
71 assertEquals(max_smi + 10001, o[0]);
72
73 // Test bailout when accessing a non-existing array element.
74 o[0] = 0;
75 for(var i = 0; i < 10000; i++) {
76 assign3(o, 0);
77 }
78 assign3(o,1);
79
80 // Test bailout with count operation in a value context.
81 function assign5(x,y) { return (x += 1) + y; }
82 for (var i = 0; i < 10000; ++i) assertEquals(4, assign5(2, 1));
83 assertEquals(4.1, assign5(2, 1.1));
84 assertEquals(4.1, assign5(2.1, 1));
85
86 function assign7(o,y) { return (o.x += 1) + y; }
87 o = {x:0};
88 for (var i = 0; i < 10000; ++i) {
89 o.x = 42;
90 assertEquals(44, assign7(o, 1));
91 }
92 o.x = 42;
93 assertEquals(44.1, assign7(o, 1.1));
94 o.x = 42.1;
95 assertEquals(44.1, assign7(o, 1));
96
97 function assign9(o,y) { return (o[0] += 1) + y; }
98 q = [0];
99 for (var i = 0; i < 10000; ++i) {
100 q[0] = 42;
101 assertEquals(44, assign9(q, 1));
102 }
103 q[0] = 42;
104 assertEquals(44.1, assign9(q, 1.1));
105 q[0] = 42.1;
106 assertEquals(44.1, assign9(q, 1));
107
108 // Test deopt because of a failed map check on the load.
109 function assign10(p) { return p.x += 1 }
110 var g1 = {x:0};
111 var g2 = {y:0, x:42};
112 for (var i = 0; i < 10000; ++i) {
113 g1.x = 42;
114 assertEquals(43, assign10(g1));
115 assertEquals(43, g1.x);
116 }
117 assertEquals(43, assign10(g2));
118 assertEquals(43, g2.x);
119
120 // Test deopt because of a failed map check on the store.
121 // The binary operation changes the map as a side effect.
122 o = {x:0};
123 var g3 = { valueOf: function() { o.y = "bar"; return 42; }};
124 function assign11(p) { return p.x += 1; }
125
126 for (var i = 0; i < 10000; i++) {
127 o.x = "a";
128 assign11(o);
129 }
130 assertEquals("a11", assign11(o));
131 o.x = g3;
132 assertEquals(43, assign11(o));
133 assertEquals("bar", o.y);
134
135 o = [0];
136 var g4 = { valueOf: function() { o.y = "bar"; return 42; }};
137 function assign12(p) { return p[0] += 1; }
138
139 for (var i = 0; i < 1000000; i++) {
140 o[0] = "a";
141 assign12(o);
142 }
143 assertEquals("a11", assign12(o));
144 o[0] = g4;
145 assertEquals(43, assign12(o));
146 assertEquals("bar", o.y);
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/assignment.js ('k') | test/mjsunit/compiler/binary-ops.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698