Ensure consistency between markedNodes and the IslandCollection result.

When building reference-chip with --partitionIslands, we were getting
a Java NoSuchElementException when we tried to move nodes between
islands, because some of the markedNodes were not in the
IslandCollection result.
Reorganize the code so those collections are more likely to be kept in
sync.
Verify that entries exist for the source and destination islands
before attempting to modify them - generate a ChiselError instead of
an exception.
Use needShadow() in emitRefHi() if allocateOnlyNeededShadowRegisters.

Issue #315 indicates we were dropping the fact that a shadow register
had been used (ad was required) in the clock_hi() code. Change the
logic so we use needShadow() if appropriate.
Move determineRequiredShadowRegisters() so it doesn't break up the
emit methods.
Merge pull request #317 from ucb-bar/partition315

Two fixes for issue #315 --allocateOnlyNeededShadowRegisters breaks code, eats a register