js/src/jit-test/tests/basic/testReallyDeepNestedExit.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 function reallyDeepNestedExit(schedule)
michael@0 2 {
michael@0 3 var c = 0, j = 0;
michael@0 4 for (var i = 0; i < 5; i++) {
michael@0 5 for (j = 0; j < 4; j++) {
michael@0 6 c += (schedule[i*4 + j] == 1) ? 1 : 2;
michael@0 7 }
michael@0 8 }
michael@0 9 return c;
michael@0 10 }
michael@0 11 function testReallyDeepNestedExit()
michael@0 12 {
michael@0 13 var c = 0;
michael@0 14 var schedule1 = new Array(5*4);
michael@0 15 var schedule2 = new Array(5*4);
michael@0 16 for (var i = 0; i < 5*4; i++) {
michael@0 17 schedule1[i] = 0;
michael@0 18 schedule2[i] = 0;
michael@0 19 }
michael@0 20 /**
michael@0 21 * First innermost compile: true branch runs through.
michael@0 22 * Second '': false branch compiles new loop edge.
michael@0 23 * First outer compile: expect true branch.
michael@0 24 * Second '': hit false branch.
michael@0 25 */
michael@0 26 schedule1[0*4 + 3] = 1;
michael@0 27 var schedules = [schedule1,
michael@0 28 schedule2,
michael@0 29 schedule1,
michael@0 30 schedule2,
michael@0 31 schedule2];
michael@0 32
michael@0 33 for (var i = 0; i < 5; i++) {
michael@0 34 c += reallyDeepNestedExit(schedules[i]);
michael@0 35 }
michael@0 36 return c;
michael@0 37 }
michael@0 38 assertEq(testReallyDeepNestedExit(), 198);

mercurial