// Branch-sensitive analysis for certain comparisons may add more facts
// to the state for the successor on the true branch.
- HBasicBlock* pred_block = succ->predecessors()->at(0);
- HControlInstruction* end = pred_block->end();
- if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ &&
- pred_block->IsReachable()) {
+ HControlInstruction* end = succ->predecessors()->at(0)->end();
+ if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ) {
if (end->IsCompareMap()) {
// Learn on the true branch of if(CompareMap(x)).
HCompareMap* cmp = HCompareMap::cast(end);
void ReduceCompareMap(HCompareMap* instr) {
MapSet maps = FindMaps(instr->value()->ActualValue());
if (maps == NULL) return;
-
- TRACE(("CompareMap for #%d at B%d ",
- instr->value()->ActualValue()->id(), instr->block()->block_id()));
-
if (maps->Contains(instr->map())) {
if (maps->size() == 1) {
+ // TODO(titzer): replace with goto true branch
INC_STAT(compares_true_);
-
- TRACE(("replaced with goto B%d (true target)\n",
- instr->SuccessorAt(0)->block_id()));
-
- instr->block()->ReplaceControlWithGotoSuccessor(0);
- } else {
- TRACE(("can't be replaced with goto: ambiguous set of maps\n"));
}
} else {
+ // TODO(titzer): replace with goto false branch
INC_STAT(compares_false_);
- TRACE(("replaced with goto B%d (false target)\n",
- instr->SuccessorAt(1)->block_id()));
-
- instr->block()->ReplaceControlWithGotoSuccessor(1);
}
}
if (SkipNonDominatedBlock(root, block)) continue;
State* state = StateAt(block);
- if (block->IsReachable()) {
- if (block->IsLoopHeader()) {
- // Apply loop effects before analyzing loop body.
- ComputeLoopEffects(block)->Apply(state);
- } else {
- // Must have visited all predecessors before this block.
- CheckPredecessorCount(block);
- }
+ if (block->IsLoopHeader()) {
+ // Apply loop effects before analyzing loop body.
+ ComputeLoopEffects(block)->Apply(state);
+ } else {
+ // Must have visited all predecessors before this block.
+ CheckPredecessorCount(block);
+ }
- // Go through all instructions of the current block, updating the state.
- for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
- state = state->Process(it.Current(), zone_);
- }
+ // Go through all instructions of the current block, updating the state.
+ for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
+ state = state->Process(it.Current(), zone_);
}
// Propagate the block state forward to all successor blocks.
i = member->loop_information()->GetLastBackEdge()->block_id();
} else {
// Process all the effects of the block.
- if (member->IsUnreachable()) continue;
ASSERT(member->current_loop() == loop);
for (HInstructionIterator it(member); !it.Done(); it.Advance()) {
effects->Process(it.Current(), zone_);
void HInstruction::Unlink() {
ASSERT(IsLinked());
+ ASSERT(!IsControlInstruction()); // Must never move control instructions.
ASSERT(!IsBlockEntry()); // Doesn't make sense to delete these.
ASSERT(previous_ != NULL);
previous_->next_ = next_;
}
-void HBasicBlock::ReplaceControlWithGotoSuccessor(int succ) {
- ASSERT(IsFinished());
- ASSERT(end()->SuccessorCount() == 2); // Only this case is supported yet.
- ASSERT(succ < end()->SuccessorCount());
-
- int unreachable_succ = 1 - succ;
-
- // Replace control instruction with if (true) {succ} else {unreachable_succ}.
- HBranch* new_branch = HBranch::New(
- zone(),
- NULL,
- graph()->GetConstantTrue(),
- ToBooleanStub::Types(ToBooleanStub::BOOLEAN),
- end()->SuccessorAt(succ),
- end()->SuccessorAt(unreachable_succ));
-
- MarkSuccEdgeUnreachable(unreachable_succ);
-
- end()->DeleteAndReplaceWith(end()->ActualValue());
- new_branch->InsertAfter(last());
- end_ = new_branch;
-}
-
-
void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
ASSERT(IsLoopHeader());
}
-void HBasicBlock::MarkSuccEdgeUnreachable(int succ) {
- ASSERT(IsFinished());
- HBasicBlock* succ_block = end()->SuccessorAt(succ);
-
- ASSERT(succ_block->predecessors()->length() == 1);
- succ_block->MarkUnreachable();
-}
-
-
void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) {
if (HasPredecessor()) {
// Only loop header blocks can have a predecessor added after
bool Dominates(HBasicBlock* other) const;
int LoopNestingDepth() const;
- void ReplaceControlWithGotoSuccessor(int succ);
-
void SetInitialEnvironment(HEnvironment* env);
void ClearEnvironment() {
ASSERT(IsFinished());
int position);
private:
- void MarkSuccEdgeUnreachable(int succ);
void RegisterPredecessor(HBasicBlock* pred);
void AddDominatedBlock(HBasicBlock* block);