当前位置: 首页>>代码示例>>C++>>正文


C++ BasicBlock::add_normal_predecessor方法代码示例

本文整理汇总了C++中BasicBlock::add_normal_predecessor方法的典型用法代码示例。如果您正苦于以下问题:C++ BasicBlock::add_normal_predecessor方法的具体用法?C++ BasicBlock::add_normal_predecessor怎么用?C++ BasicBlock::add_normal_predecessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BasicBlock的用法示例。


在下文中一共展示了BasicBlock::add_normal_predecessor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: compute_liveness


//.........这里部分代码省略.........
  // Create an array to store the bci->BasicBlock mapping.
  _block_map = new (arena()) GrowableArray<BasicBlock*>(arena(), method_len, method_len, NULL);

  _block_count = mblocks->num_blocks();
  _block_list = (BasicBlock **) arena()->Amalloc(sizeof(BasicBlock *) * _block_count);

  // Used for patching up jsr/ret control flow.
  GrowableArray<BasicBlock*>* jsr_exit_list = new GrowableArray<BasicBlock*>(5);
  GrowableArray<BasicBlock*>* ret_list = new GrowableArray<BasicBlock*>(5);

  // generate our block list from ciMethodBlocks
  for (int blk = 0; blk < _block_count; blk++) {
    ciBlock *cib = mblocks->block(blk);
     int start_bci = cib->start_bci();
    _block_list[blk] = new (arena()) BasicBlock(this, start_bci, cib->limit_bci());
    _block_map->at_put(start_bci, _block_list[blk]);
#ifdef COMPILER1
    // mark all bcis where a new basic block starts
    _bci_block_start.set_bit(start_bci);
#endif // COMPILER1
  }
  // fill in the predecessors of blocks
  ciBytecodeStream bytes(method());

  for (int blk = 0; blk < _block_count; blk++) {
    BasicBlock *current_block = _block_list[blk];
    int bci =  mblocks->block(blk)->control_bci();

    if (bci == ciBlock::fall_through_bci) {
      int limit = current_block->limit_bci();
      if (limit < method_len) {
        BasicBlock *next = _block_map->at(limit);
        assert( next != NULL, "must be a block immediately following this one.");
        next->add_normal_predecessor(current_block);
      }
      continue;
    }
    bytes.reset_to_bci(bci);
    Bytecodes::Code code = bytes.next();
    BasicBlock *dest;

    // Now we need to interpret the instruction's effect
    // on control flow.
    assert (current_block != NULL, "we must have a current block");
    switch (code) {
      case Bytecodes::_ifeq:
      case Bytecodes::_ifne:
      case Bytecodes::_iflt:
      case Bytecodes::_ifge:
      case Bytecodes::_ifgt:
      case Bytecodes::_ifle:
      case Bytecodes::_if_icmpeq:
      case Bytecodes::_if_icmpne:
      case Bytecodes::_if_icmplt:
      case Bytecodes::_if_icmpge:
      case Bytecodes::_if_icmpgt:
      case Bytecodes::_if_icmple:
      case Bytecodes::_if_acmpeq:
      case Bytecodes::_if_acmpne:
      case Bytecodes::_ifnull:
      case Bytecodes::_ifnonnull:
        // Two way branch.  Set predecessors at each destination.
        dest = _block_map->at(bytes.next_bci());
        assert(dest != NULL, "must be a block immediately following this one.");
        dest->add_normal_predecessor(current_block);
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:66,代码来源:methodLiveness.cpp

示例2: init_basic_blocks

void MethodLiveness::init_basic_blocks() {
  bool bailout = false;

  int method_len = method()->code_size();

  // Create an array to store the bci->BasicBlock mapping.
  _block_map = new (arena()) GrowableArray<BasicBlock*>(arena(), method_len, method_len, NULL);

  _block_list = new (arena()) GrowableArray<BasicBlock*>(arena(), 128, 0, NULL);

  // Used for patching up jsr/ret control flow.
  GrowableArray<BasicBlock*>* jsr_exit_list = new GrowableArray<BasicBlock*>(5);
  GrowableArray<BasicBlock*>* ret_list = new GrowableArray<BasicBlock*>(5);

  // Make blocks begin at all exception handling instructions.
  {
    ciExceptionHandlerStream handlers(method());
    for (; !handlers.is_done(); handlers.next()) {
      ciExceptionHandler* handler = handlers.handler();
      int handler_bci = handler->handler_bci();
      make_block_at(handler_bci, NULL);
    }
  }

  BasicBlock *current_block = NULL;

  ciByteCodeStream bytes(method());
  Bytecodes::Code code;
  while ((code = bytes.next()) != ciByteCodeStream::EOBC && !bailout) {
    int bci = bytes.cur_bci();

    // Should we start a new block here?
    BasicBlock *other = _block_map->at(bci);
    if (other == NULL) {
      // This bci has not yet been marked as the start of
      // a new basic block.  If current_block is NULL, then
      // we are beginning a new block.  Otherwise, we continue
      // with the old block.
      if (current_block == NULL) {
        // Make a new block with no predecessors.
        current_block = make_block_at(bci, NULL);
      }

      // Mark this index as belonging to the current block.
      _block_map->at_put(bci, current_block);
    } else {
      // This bci has been marked as the start of a new basic
      // block.
      if (current_block != NULL) {
        other->add_normal_predecessor(current_block);
        current_block->set_limit_bci(bci);
      }
      current_block = other;
    }

    // Now we need to interpret the instruction's effect
    // on control flow.
    switch (code) {
      assert (current_block != NULL, "we must have a current block");

      case Bytecodes::_ifeq:
      case Bytecodes::_ifne:
      case Bytecodes::_iflt:
      case Bytecodes::_ifge:
      case Bytecodes::_ifgt:
      case Bytecodes::_ifle:
      case Bytecodes::_if_icmpeq:
      case Bytecodes::_if_icmpne:
      case Bytecodes::_if_icmplt:
      case Bytecodes::_if_icmpge:
      case Bytecodes::_if_icmpgt:
      case Bytecodes::_if_icmple:
      case Bytecodes::_if_acmpeq:
      case Bytecodes::_if_acmpne:
      case Bytecodes::_ifnull:   
      case Bytecodes::_ifnonnull:
        // Two way branch.  Make a new block at each destination.
        make_block_at(bytes.next_bci(), current_block);
        make_block_at(bytes.get_dest(), current_block);
        current_block->set_limit_bci(bytes.next_bci());
        current_block = NULL;
        break;

      case Bytecodes::_goto:
        make_block_at(bytes.get_dest(), current_block);
        current_block->set_limit_bci(bytes.next_bci());
        current_block = NULL;
        break;
      case Bytecodes::_goto_w:         
        make_block_at(bytes.get_far_dest(), current_block);
        current_block->set_limit_bci(bytes.next_bci());
        current_block = NULL;
        break;
      case Bytecodes::_tableswitch:  
        {
          Bytecode_tableswitch *tableswitch =
            Bytecode_tableswitch_at(bytes.cur_bcp());

          int len = tableswitch->length();        
        
//.........这里部分代码省略.........
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:101,代码来源:methodLiveness.cpp


注:本文中的BasicBlock::add_normal_predecessor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。