Example #1
0
  // allocate PRegs that are used & defined solely within this BB
  void BB::slowAllocateTempRegisters(BitVector** hardwired, PRegBList* tempRegs,
                                     BitVectorBList* lives) {
    // clear temporary data structures
    tempRegs->clear();
    lives->clear();
    fint i;
    for (i = 0; i < NumTempRegs; i++) {
      hardwired[i]->setLength(nnodes);
      hardwired[i]->clear();
    }

    for (i = 0; i < duInfo.info->length(); i++) {
      // collect temp regs and hardwired temp regs
      PReg* r = duInfo.info->nth(i)->reg;
      if (r->isLocalTo(this)) {
        assert(r->dus.first()->index == i, "should be the same");
        if (r->isUnused()) {
          // unused register - ignore
        } else {
          DUInfo* info = duInfo.info->nth(r->dus.first()->index);
          tempRegs->append(r);
          BitVector* bv = new BitVector(nnodes);
          lives->append(bv);
          fint firstUse = 0, lastUse = nnodes - 1;
          duInfo.info->nth(i)->getLiveRange(firstUse, lastUse);
          bv->addFromTo(firstUse, lastUse);
        }
      } else if (isTempReg(r->loc)) {
        fint firstUse = 0, lastUse = nnodes - 1;
        if (!r->incorrectDU()) {
          duInfo.info->nth(i)->getLiveRange(firstUse, lastUse);
        } else {
          // can't really compute live range since the temp might be non-local
          // so assume it's live from first node til the end
        }
        hardwired[RegToTempNo[r->loc]]->addFromTo(firstUse, lastUse);
      }
    }

    // now, tempRegs holds all temp regs, and lives contains each register's
    // live range (one bit per node, 1 = reg is live); hardwired contains
    // the ranges where temp regs are already taken (e.g. for NLR, calls, etc)

    // cycle through the temp registers to (hopefully) allow more optimizations
    // later (e.g. scheduling)
    fint lastTemp = 0;
#   define nextTemp(n) (n == NumTempRegs - 1) ? 0 : n + 1

    for (i = 0; i < tempRegs->length(); i++) {
      // try to allocate tempRegs[i] to a temp register
      PReg* r = tempRegs->nth(i);
      if (r->loc != UnAllocated) {
        assert(r->regClass == 0, "should have been cleared");
        continue;
      }
      BitVector* liveRange = lives->nth(i);
      for (fint tempNo = lastTemp, ntries = 0; ntries < NumTempRegs;
           tempNo = nextTemp(tempNo), ntries++) {
        if (liveRange->isDisjointFrom(hardwired[tempNo])) {
          Location temp = TempRegs[tempNo];
          doAlloc(r, temp);
          hardwired[tempNo]->unionWith(liveRange);
          lastTemp = nextTemp(tempNo);
          break;
        }
      }
      if ( r->loc == UnAllocated
      && (PrintSICTempRegisterAllocation   
          ||   WizardMode  &&  TARGET_ARCH != I386_ARCH /* happens normally in I386; few regs */ )) {
        lprintf("*could NOT find temp assignment for local %s in BB%ld\n",
               r->name(), (void*)id());
      } else if (r->loc == UnAllocated) {
        if (PrintSICTempRegisterAllocation) lprintf("out of temp regs");
      }
      r->regClass = 0;
    }
  }
Example #2
0
  void do_it(InlinedScope* s) {
    GrowableArray<NonTrivialNode*>* tests = s->typeTests();
    int len = tests->length();
    for (int i = 0; i < len; i++) {
      NonTrivialNode* n = tests->at(i);
      assert(n->doesTypeTests(), "shouldn't be in list");
      if (n->deleted) continue;
      if (n->hasUnknownCode()) continue;	  // can't optimize - expects other klasses, so would get uncommon trap at run-time
      if (!theLoop->isInLoop(n)) continue;	  // not in this loop
      GrowableArray<PReg*> regs(4);
      GrowableArray<GrowableArray<klassOop>*> klasses(4);
      n->collectTypeTests(regs, klasses);
      for (int j = 0; j < regs.length(); j++) {
	PReg* r = regs.at(j);
	if (theLoop->defsInLoop(r) == 0) {
	  // this test can be hoisted
	  if (CompilerDebug || PrintLoopOpts) cout(PrintLoopOpts)->print("*moving type test of %s at N%d out of loop\n", r->name(), n->id());
	  hoistableTests->append(new HoistedTypeTest(n, r, klasses.at(j)));
	}
      }
    }
  }
Example #3
0
void InlinedScope::generateDebugInfo() {
  // Generate debug info for the common parts of methods and blocks

  if (PrintDebugInfoGeneration) {
    if (isMethodScope()) {
      std->print_cr("self: %s", _self->preg()->name());
    } else {
      std->print_cr("no receiver (block method)");
    }
  }

  ScopeDescRecorder* rec = theCompiler->scopeDescRecorder();
  int len, i;

  if (!isLite()) {
    // temporaries
    if (hasTemporaries()) {
      len = _temporaries->length();
      for (i = 0; i < len; i++) {
        PReg* preg = _temporaries->at(i)->preg();
        rec->addTemporary(_scopeInfo, i, preg->createLogicalAddress());
	if (PrintDebugInfoGeneration) std->print_cr("temp[%2d]: %s", i, preg->name());
      }
    }
    // float temporaries
    if (hasFloatTemporaries()) {
      len = _floatTemporaries->length();
      for (i = 0; i < len; i++) {
        PReg* preg = _floatTemporaries->at(i)->preg();
        rec->addTemporary(_scopeInfo, i, preg->createLogicalAddress());
	if (PrintDebugInfoGeneration) std->print_cr("float[%2d]: %s", i, preg->name());
      }
    }
    // context temporaries
    if (allocatesInterpretedContext()) {
      len = _contextTemporaries->length();
      for (i = 0; i < len; i++) {
        PReg* preg = _contextTemporaries->at(i)->preg();
        rec->addContextTemporary(_scopeInfo, i, preg->createLogicalAddress());
	if (PrintDebugInfoGeneration) std->print_cr("c_temp[%2d]: %s", i, preg->name());
      }
    }
    // expr stack
    len = _exprStackElems->length();
    for (i = 0; i < len; i++) {
      Expr* elem = _exprStackElems->at(i);
      if (elem != NULL) {
        PReg* r = elem->preg()->cpReg();
        if (r->scope()->isSenderOrSame(this)) {
	  // Note: Is it still needed to create this info here, since the
	  //       PReg locations may change over time and thus produce more
	  //       debug info than actually needed for the new backend. Discuss
	  //       this with Lars.
          rec->addExprStack(_scopeInfo, i, r->createLogicalAddress());
          if (PrintDebugInfoGeneration) std->print_cr("expr[%2d]: %s", i, r->name());
        } else {
  	  // r's scope is too low (i.e. it's not actually live anymore)
	  // this can only happen if the expression is discarded; thus it's safe not to describe this entry
	  // Urs 5/96
	  // fix this: should check that bci (i) is statement end (or r is NoPReg)
        }
      }
    }
  }

  // subscopes
  len = _subScopes->length();
  for (i = 0; i < len; i++) {
    InlinedScope* s = _subScopes->at(i);
    if (PrintDebugInfoGeneration) std->print_cr("Subscope %d (id = %d):", i, s->scopeID());
    s->generateDebugInfo();
  }
}