Пример #1
0
void dvmInitializeSSAConversion(CompilationUnit *cUnit)
{
	int i;
	int numDalvikReg = cUnit->pCodeItem->item->registersSize;
	
	cUnit->ssaToDalvikMap = dvmCompilerNew(sizeof(GrowableList), false);
	dvmInitGrowableList(cUnit->ssaToDalvikMap, numDalvikReg);
	
	cUnit->numSSARegs = numDalvikReg;
	LOG(">>>>>>>>>>>>>>>The function is %s<<<<<<<<<<<<<<<<<<\n", __func__);
	LOG("cUnit->numSSARegs is %d\n", cUnit->numSSARegs);

	for(i = 0; i < numDalvikReg; i++) {
		dvmInsertGrowableList(cUnit->ssaToDalvikMap, (void *)ENCODE_REG_SUB(i, 0));
	}
	
	cUnit->dalvikToSSAMap = dvmCompilerNew(sizeof(int) * numDalvikReg, false);
	for (i = 0; i < numDalvikReg; i++) {  
		cUnit->dalvikToSSAMap[i] = i; 
	}

/*  这里暂时作用不知道,所以删除
	for (i = 0; i < cUnit->numBlocks; i++) { 
		BasicBlock *bb = cUnit->blockList[i]; 
		if (bb->blockType == kDalvikByteCode || 
			bb->blockType == kTraceEntryBlock) { 
			bb->dataFlowInfo = dvmCompilerNew(sizeof(BasicBlockDataFlow), true); 
		}
	}	
*/
}
Пример #2
0
/* Sort the blocks by the Depth-First-Search pre-order */
static void computeDFSOrder(CompilationUnit *cUnit) {
    /* Initialize or reset the DFS order list */
    if (cUnit->dfsOrder.elemList == NULL) {
        dvmInitGrowableList(&cUnit->dfsOrder, cUnit->numBlocks);
    } else {
        /* Just reset the used length on the counter */
        cUnit->dfsOrder.numUsed = 0;
    }

    dvmCompilerDataFlowAnalysisDispatcher(cUnit, dvmCompilerClearVisitedFlag,
                                          kAllNodes,
                                          false /* isIterative */);

    recordDFSPreOrder(cUnit, cUnit->entryBlock);
    cUnit->numReachableBlocks = cUnit->dfsOrder.numUsed;
}
Пример #3
0
/* Compute dominators, immediate dominator, and dominance fronter */
static void computeDominators(CompilationUnit *cUnit) {
    int numReachableBlocks = cUnit->numReachableBlocks;
    int numTotalBlocks = cUnit->blockList.numUsed;

    /* Initialize domination-related data structures */
    dvmCompilerDataFlowAnalysisDispatcher(cUnit, initializeDominationInfo,
                                          kReachableNodes,
                                          false /* isIterative */);

    /* Set the dominator for the root node */
    dvmClearAllBits(cUnit->entryBlock->dominators);
    dvmSetBit(cUnit->entryBlock->dominators, cUnit->entryBlock->id);

    if (cUnit->tempBlockV == NULL) {
        cUnit->tempBlockV = dvmCompilerAllocBitVector(numTotalBlocks,
                                                      false /* expandable */);
    } else {
        dvmClearAllBits(cUnit->tempBlockV);
    }
    dvmCompilerDataFlowAnalysisDispatcher(cUnit, computeBlockDominators,
                                          kPreOrderDFSTraversal,
                                          true /* isIterative */);

    cUnit->entryBlock->iDom = NULL;
    dvmCompilerDataFlowAnalysisDispatcher(cUnit, computeImmediateDominator,
                                          kReachableNodes,
                                          false /* isIterative */);

    /*
     * Now go ahead and compute the post order traversal based on the
     * iDominated sets.
     */
    if (cUnit->domPostOrderTraversal.elemList == NULL) {
        dvmInitGrowableList(&cUnit->domPostOrderTraversal, numReachableBlocks);
    } else {
        cUnit->domPostOrderTraversal.numUsed = 0;
    }

    computeDomPostOrderTraversal(cUnit, cUnit->entryBlock);
    assert(cUnit->domPostOrderTraversal.numUsed ==
           (unsigned) cUnit->numReachableBlocks);

    /* Now compute the dominance frontier for each block */
    dvmCompilerDataFlowAnalysisDispatcher(cUnit, computeDominanceFrontier,
                                          kPostOrderDOMTraversal,
                                          false /* isIterative */);
}