001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.jikesrvm.compilers.opt.bc2ir;
014
015import org.jikesrvm.compilers.opt.ir.BasicBlock;
016
017/**
018 * Extend BasicBlockLE to support inlining during IR generation.
019 */
020final class InliningBlockLE extends BasicBlockLE {
021  final GenerationContext gc;
022  final BasicBlockLE epilogueBBLE;
023
024  InliningBlockLE(GenerationContext c, BasicBlockLE bble) {
025    super(0);
026    gc = c;
027    epilogueBBLE = bble;
028  }
029
030  @Override
031  public String toString() {
032    return "(Inline method " + gc.getMethod() + ")";
033  }
034
035  /**
036   * delete the outgoing CFG edges from all
037   * basic blocks in the callee (gc.cfg).
038   * This is used when the BBLE preceeding the inlined
039   * method block needs to be regenerated, thus forcing
040   * us to discard the callee IR (which may contains
041   * control flow links to the caller IR because of exception handlers).
042   * <p>
043   * TODO: One might be able to do this more efficiently by
044   * keeping track of the exposed edges in the generation context
045   * and commiting them once the top level generation
046   * completes.  Probably not worth it, since we expect this
047   * method to be called very infrequently.
048   */
049  void deleteAllOutEdges() {
050    for (BasicBlock bb = gc.getCfg().firstInCodeOrder(); bb != null; bb = bb.nextBasicBlockInCodeOrder()) {
051      bb.deleteOut();
052    }
053  }
054}