Bug 1303122: Don't re-add an already seen bounds check if it's not redundant; r=luke

MozReview-Commit-ID: 4pthpbRTmpD

--HG--
extra : rebase_source : 97aba7dd3331da2b61524cf118c5e1933230e098
This commit is contained in:
Benjamin Bouvier 2016-09-15 21:35:13 +02:00
parent 8bcffcf0f7
commit b56f71f878
2 changed files with 31 additions and 4 deletions

View File

@ -28,3 +28,29 @@ let code = `(module
)`
evalText(code);
// Bounds check elimination.
assertEq(evalText(`(module
(memory 1)
(func (param $p i32) (local $l i32) (result i32)
(set_local $l (i32.const 0))
(if
(get_local $p)
(set_local $l
(i32.add
(get_local $l)
(i32.load8_s (get_local $p))
)
)
)
(set_local $l
(i32.add
(get_local $l)
(i32.load8_s (get_local $p))
)
)
(get_local $l)
)
(data 0 "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
(export "test" 0)
)`).exports["test"](3), 6);

View File

@ -44,11 +44,12 @@ jit::EliminateBoundsChecks(MIRGenerator* mir, MIRGraph& graph)
MWasmBoundsCheck* bc = def->toWasmBoundsCheck();
MDefinition* addr = def->getOperand(0);
LastSeenMap::AddPtr checkPtr = lastSeen.lookupForAdd(addr->id());
if (checkPtr && checkPtr->value()->block()->dominates(block)) {
bc->setRedundant(true);
LastSeenMap::AddPtr ptr = lastSeen.lookupForAdd(addr->id());
if (ptr) {
if (ptr->value()->block()->dominates(block))
bc->setRedundant(true);
} else {
if (!lastSeen.add(checkPtr, addr->id(), def))
if (!lastSeen.add(ptr, addr->id(), def))
return false;
}
break;