Status: Accepted
Owner: [email protected]
Labels: Type-Bug Priority-Medium
New issue 2450 by [email protected]: Sink spill stores out of loop when
possible
http://code.google.com/p/v8/issues/detail?id=2450
Currently we schedule spill stores eagerly (value is immediately stored
into the spill slot after it is produced).
This negatively impacts code quality for the tight loops that are followed
by code with a high register pressure (e.g. calls).
For example:
function test() {
var sum = 0;
var start = Date.now();
for (var i = 0; i < 1000; i++) {
sum += i;
}
var end = Date.now();
return { result: sum, time: (end - start) };
}
test();
test();
%OptimizeFunctionOnNextCall(test);
test();
will result in the following code emitted for the loop:
;;; B2 - LOOP entry
0x3e52bda3 99 8955e4 mov [ebp+0xe4],edx
0x3e52bda6 102 894de8 mov [ebp+0xe8],ecx
;;; @27: gap.
;;; @28: gap.
;;; @29: cmp-id-and-branch. <#29>
0x3e52bda9 105 81f9e8030000 cmp ecx,0x3e8
0x3e52bdaf 111 0f8d1d000000 jnl 146 (0x3e52bdd2)
;;; @34: label. <#36>
;;; B4
;;; @35: gap.
;;; @36: stack-check. <#38>
0x3e52bdb5 117 3b2554e7410a cmp esp,[0xa41e754]
0x3e52bdbb 123 0f82be010000 jc 575 (0x3e52bf7f)
;;; @37: gap.
0x3e52bdc1 129 89d3 mov ebx,edx
;;; @38: add-i. <#39>
0x3e52bdc3 131 03d9 add ebx,ecx
0x3e52bdc5 133 0f8071c26a15 jo 0x53bd803c ;;
deoptimization bailout 6
;;; @39: gap.
;;; @40: add-i. <#42>
0x3e52bdcb 139 83c101 add ecx,0x1
;;; @41: gap.
;;; @42: gap.
0x3e52bdce 142 89da mov edx,ebx
;;; @43: goto. <#44>
0x3e52bdd0 144 ebd1 jmp 99 (0x3e52bda3)
Notice unnecessary spill stores for the phis that are generated at the loop
entry. Value is actually never restored from the spill slot inside the loop
body itself. Such spill stores should be sunk down to the loop exit.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev