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

Side by Side Diff: test/mjsunit/compiler/escape-analysis.js

Issue 21055011: First implementation of allocation elimination in Hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years, 4 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 | « src/zone.h ('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 2013 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 --use-escape-analysis
29
30
31 // Test stores on a join path.
32 (function testJoin() {
33 function constructor() {
34 this.a = 0;
35 }
36 function join(mode, expected) {
37 var object = new constructor();
38 if (mode) {
39 object.a = 1;
40 } else {
41 object.a = 2;
42 }
43 assertEquals(expected, object.a);
44 }
45 join(true, 1); join(true, 1);
46 join(false, 2); join(false, 2);
47 %OptimizeFunctionOnNextCall(join);
48 join(true, 1); join(false, 2);
49 })();
50
51
52 // Test loads and stores inside a loop.
53 (function testLoop() {
54 function constructor() {
55 this.a = 0;
56 this.b = 23;
57 }
58 function loop() {
59 var object = new constructor();
60 for (var i = 1; i < 10; i++) {
61 object.a = object.a + i;
62 assertEquals(i*(i+1)/2, object.a);
63 assertEquals(23, object.b);
64 }
65 assertEquals(45, object.a);
66 assertEquals(23, object.b);
67 }
68 loop(); loop();
69 %OptimizeFunctionOnNextCall(loop);
70 loop(); loop();
71 })();
72
73
74 // Test loads and stores inside nested loop.
75 (function testNested() {
76 function constructor() {
77 this.a = 0;
78 this.b = 0;
79 this.c = 23;
80 }
81 function nested() {
82 var object = new constructor();
83 for (var i = 1; i < 10; i++) {
84 object.a = object.a + i;
85 assertEquals(i*(i+1)/2, object.a);
86 assertEquals((i-1)*6, object.b);
87 assertEquals(23, object.c);
88 for (var j = 1; j < 4; j++) {
89 object.b = object.b + j;
90 assertEquals(i*(i+1)/2, object.a);
91 assertEquals((i-1)*6+j*(j+1)/2, object.b);
92 assertEquals(23, object.c);
93 }
94 assertEquals(i*(i+1)/2, object.a);
95 assertEquals(i*6, object.b);
96 assertEquals(23, object.c);
97 }
98 assertEquals(45, object.a);
99 assertEquals(54, object.b);
100 assertEquals(23, object.c);
101 }
102 nested(); nested();
103 %OptimizeFunctionOnNextCall(nested);
104 nested(); nested();
105 })();
106
107
108 // Test deoptimization with captured objects in local variables.
109 (function testDeoptLocal() {
110 var deopt = { deopt:false };
111 function constructor1() {
112 this.a = 1.0;
113 this.b = 2.3;
114 this.c = 3.0;
115 }
116 function constructor2(o) {
117 this.d = o;
118 this.e = 4.5;
119 }
120 function func() {
121 var o1 = new constructor1();
122 var o2 = new constructor2(o1);
123 deopt.deopt;
124 assertEquals(1.0, o1.a);
125 assertEquals(2.3, o2.d.b);
126 assertEquals(3.0, o2.d.c);
127 assertEquals(4.5, o2.e);
128 }
129 func(); func();
130 %OptimizeFunctionOnNextCall(func);
131 func(); func();
132 delete deopt.deopt;
133 func(); func();
134 })();
OLDNEW
« no previous file with comments | « src/zone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698