Fix OSR to ignore phis without merge index in loop entry.

This fixes a corner case introduced by escape analysis where phis are
introduced in OSR loop entry blocks that don't have a merge index and
hence cannot contain OSR values.

R=titzer@chromium.org
TEST=mjsunit/compiler/escape-analysis

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16484 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3f70c3b0
......@@ -117,8 +117,9 @@ void HOsrBuilder::FinishOsrValues() {
const ZoneList<HPhi*>* phis = osr_loop_entry_->phis();
for (int j = 0; j < phis->length(); j++) {
HPhi* phi = phis->at(j);
ASSERT(phi->HasMergedIndex());
osr_values_->at(phi->merged_index())->set_incoming_value(phi);
if (phi->HasMergedIndex()) {
osr_values_->at(phi->merged_index())->set_incoming_value(phi);
}
}
}
......
......@@ -200,3 +200,44 @@
check(27, 27); check(27, 27);
assertEquals(130, sum);
})();
// Test OSR into a loop with captured objects.
(function testOSR() {
function constructor() {
this.a = 23;
}
function osr1(length) {
assertEquals(23, (new constructor()).a);
var result = 0;
for (var i = 0; i < length; i++) {
result = (result + i) % 99;
}
return result;
}
function osr2(length) {
var result = 0;
for (var i = 0; i < length; i++) {
result = (result + i) % 99;
}
assertEquals(23, (new constructor()).a);
return result;
}
function osr3(length) {
var result = 0;
var o = new constructor();
for (var i = 0; i < length; i++) {
result = (result + i) % 99;
}
assertEquals(23, o.a);
return result;
}
function test(closure) {
assertEquals(45, closure(10));
assertEquals(45, closure(10));
assertEquals(10, closure(50000));
}
test(osr1);
test(osr2);
test(osr3);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment