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

Side by Side Diff: test/mjsunit/compiler/dead-code5.js

Issue 14676011: Improve dead code elimination by transitively marking live code and removing all dead code. Replace… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename CanBeEliminated -> CannotBeEliminated, implement IsDeletable() for HPhi. Created 7 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
« no previous file with comments | « test/mjsunit/compiler/dead-code4.js ('k') | test/mjsunit/compiler/dead-code6.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 function F() { } 28 function dead1(a, b) {
29 29 a * b;
30 function GrowNamed(o) { 30 a << b;
31 o.a = 1; 31 a >> b;
32 o.b = 2; 32 a >>> b;
33 o.c = 3; 33 a | b;
34 o.d = 4; 34 a & b;
35 o.e = 5; 35 a ^ b;
36 o.f = 6; 36 return a;
37 } 37 }
38 38
39 function GrowKeyed(o) { 39 function dead2(a, b) {
40 var names = ['a','b','c','d','e','f']; 40 (a | 0) * b;
41 var i = 0; 41 (a | 0) << b;
42 o[names[i++]] = i; 42 (a | 0) >> b;
43 o[names[i++]] = i; 43 (a | 0) >>> b;
44 o[names[i++]] = i; 44 (a | 0) | b;
45 o[names[i++]] = i; 45 (a | 0) & b;
46 o[names[i++]] = i; 46 (a | 0) ^ b;
47 o[names[i++]] = i; 47 return a;
48 } 48 }
49 49
50 GrowNamed(new F()); 50 function dead3(a, b) {
51 GrowNamed(new F()); 51 a == 2 ? (a * b) : (b * a); // dead
52 GrowNamed(new F()); 52 return a;
53 GrowKeyed(new F()); 53 }
54 GrowKeyed(new F()); 54
55 GrowKeyed(new F()); 55 function dead4(a) {
56 var z = 3;
57 for (i = 0; i < 3; i++) {
58 z * 3; // dead
59 }
60 return a;
61 }
62
63 function dead5(a) {
64 var z = 3;
65 for (i = 0; i < 3; i++) {
66 z * 3; // dead
67 z++;
68 }
69 var w = z * a;
70 return a; // w is dead
71 }
72
73 assertTrue(dead1(33, 32) == 33);
74 assertTrue(dead2(33, 32) == 33);
75 assertTrue(dead3(33, 32) == 33);
76 assertTrue(dead4(33) == 33);
77 assertTrue(dead5(33) == 33);
78
79 assertTrue(dead1(34, 7) == 34);
80 assertTrue(dead2(34, 7) == 34);
81 assertTrue(dead3(34, 7) == 34);
82 assertTrue(dead4(34) == 34);
83 assertTrue(dead5(34) == 34);
84
85 assertTrue(dead1(3.4, 0.1) == 3.4);
86 assertTrue(dead2(3.4, 0.1) == 3.4);
87 assertTrue(dead3(3.4, 0.1) == 3.4);
88 assertTrue(dead4(3.4) == 3.4);
89 assertTrue(dead5(3.4) == 3.4);
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/dead-code4.js ('k') | test/mjsunit/compiler/dead-code6.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698