[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BasicBlockGraph



hi,
i just had a look at BlockGraph.java (in toolkits.graph) and there are some
things i don't completely understand:

- in UnitGraph.java (line 162) there's the following comment:
// Add edges from the predecessors of begin statements directly to the
// handlers.
// This is necessary because sometimes the first statement of try block is
// not even fully executed before an exception is thrown.
but in the BlockGraph.java i haven't found anything treating this case.

- in BlockGraph.java (line 163) we have the following instruction-block:
====
    if(trapsBeginningHere != null) {
      Iterator iter = trapsBeginningHere.iterator();
      if(iter != null) {  // <========HERE
        while(iter.hasNext()) {
          trapsInScope.add(iter.next());
        }
      }
    }
====
can iter be null? i looked in the javadoc, and they didn't explicitly say
that the returned iterator is non-null, but as far as i know iter can't be
null.

- in BlockGraph.java (line 342) we have the following instruction-block:
====
   // this happens if the first unit of the method is under an exception
   // context.(ie first unit is a block and has no pred unit)
   if((blockTail =(Unit) mUnits.getPredOf(unit)) == null) {
        blockTail = blockHead;
   }


   block = new Block(blockHead, blockTail, mBody, indexInMethod++,
                          blockLength -1, this);
   block.setPreds((List) leaders.get(blockHead));
   basicBlockList.add(block);
   blockHead = unit;
   blockLength = 1;
====
when this happens (first unit is under exception context), wouldn't it be
better to skip the rest?
Now we have two blocks with the first unit: 
the first time we encounter unit0 and there's no getPredOf(unit0),
and a second time, when the first block really finishes.

- Finally some comments should be updated:
  the JavaDoc of ArrayRefBlockGraph.java is exactly the same as for
  BriefBlockGraph.java.

mfg
 florian loitsch
-- 
People who think they know everything are very irritating to those of us who do.
- Anon.