From a0e180632411f7fe0edf454e571c42209ee7b540 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 13 Apr 2012 15:59:59 -0700 Subject: Add a SafeMap equivalent to std::map but without the error-prone operator[]. Change-Id: Iae5ba2091c55a34dbd1005cf3d25fce2a8d5c1f9 --- src/compiler/Frontend.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/compiler/Frontend.cc') diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc index 309bcf82d8..dbaf323a2d 100644 --- a/src/compiler/Frontend.cc +++ b/src/compiler/Frontend.cc @@ -136,8 +136,7 @@ BasicBlock *splitBlock(CompilationUnit* cUnit, unsigned int codeOffset, bottomBlock->lastMIRInsn = origBlock->lastMIRInsn; /* Add it to the quick lookup cache */ - cUnit->blockMap.insert(std::make_pair(bottomBlock->startOffset, - bottomBlock)); + cUnit->blockMap.Put(bottomBlock->startOffset, bottomBlock); /* Handle the taken path */ bottomBlock->taken = origBlock->taken; @@ -211,7 +210,7 @@ BasicBlock *findBlock(CompilationUnit* cUnit, unsigned int codeOffset, GrowableList* blockList = &cUnit->blockList; BasicBlock* bb; unsigned int i; - std::map::iterator it; + SafeMap::iterator it; it = cUnit->blockMap.find(codeOffset); if (it != cUnit->blockMap.end()) { @@ -239,7 +238,7 @@ BasicBlock *findBlock(CompilationUnit* cUnit, unsigned int codeOffset, bb = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++); oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bb); bb->startOffset = codeOffset; - cUnit->blockMap.insert(std::make_pair(bb->startOffset, bb)); + cUnit->blockMap.Put(bb->startOffset, bb); return bb; } @@ -853,7 +852,7 @@ CompiledMethod* oatCompileMethod(Compiler& compiler, curBlock->startOffset = 0; oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) curBlock); /* Add first block to the fast lookup cache */ - cUnit->blockMap.insert(std::make_pair(curBlock->startOffset, curBlock)); + cUnit->blockMap.Put(curBlock->startOffset, curBlock); entryBlock->fallThrough = curBlock; oatInsertGrowableList(cUnit.get(), curBlock->predecessors, (intptr_t)entryBlock); -- cgit v1.2.3-59-g8ed1b