v8/test/mjsunit/asm/do-while-false.js
titzer@chromium.org e4c6f9488e Implement graph trimming in ControlReducer.
Trimming the graph consists of breaking links from nodes that are not reachable from end to nodes that are reachable from end. Such dead nodes show up in the use lists of the live nodes and though mostly harmless, just clutter up the graph. They also can limit instruction selection opportunities, so it is good to get rid of them.

This CL is one half of the ControlReducer functionality, the other half
being branch folding.

R=bmeurer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/661923002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24694 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-10-17 11:51:57 +00:00

79 lines
1.4 KiB
JavaScript

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function Module() {
"use asm";
function d0() {
do { } while(false);
return 110;
}
function d1() {
do { return 111; } while(false);
return 112;
}
function d2() {
do { break; } while(false);
return 113;
}
function d3(a) {
a = a | 0;
do { if (a) return 114; } while(false);
return 115;
}
function d4(a) {
a = a | 0;
do { if (a) return 116; else break; } while(false);
return 117;
}
function d5(a) {
a = a | 0;
do { if (a) return 118; } while(false);
return 119;
}
function d6(a) {
a = a | 0;
do {
if (a == 0) return 120;
if (a == 1) break;
if (a == 2) return 122;
if (a == 3) continue;
if (a == 4) return 124;
} while(false);
return 125;
}
return {d0: d0, d1: d1, d2: d2, d3: d3, d4: d4, d5: d5, d6: d6};
}
var m = Module();
assertEquals(110, m.d0());
assertEquals(111, m.d1());
assertEquals(113, m.d2());
assertEquals(114, m.d3(1));
assertEquals(115, m.d3(0));
assertEquals(116, m.d4(1));
assertEquals(117, m.d4(0));
assertEquals(118, m.d5(1));
assertEquals(119, m.d5(0));
assertEquals(120, m.d6(0));
assertEquals(125, m.d6(1));
assertEquals(122, m.d6(2));
assertEquals(125, m.d6(3));
assertEquals(124, m.d6(4));
assertEquals(125, m.d6(5));