Prune useless entries from dex to pc map
Step one of the change. Limit entries in the table to native
code safepoint locations (which generally are the return PC
addresses of any call that might trigger a stack walk and the
start addresses of all catch blocks).
Previously, the mapping_table described ranges. No longer. Any
native PC located within compiled Dex code that is found in a
stack walk should have an exact match in the table.
In future CLs we'll add data compression (probably uLeb128) and
may add inflation on first use to a faster access map (instead of
the current linear search).
Note that this CL introduces somewhat of a regression in the
capabilities of oat-dump. Because the mapping table no longer
associates each native intruction with its Dex counter-part, the
native code disassembly no longer includes interspersed Dex
disassembly.
Note also that as of this CL, the compiler is adopting the 100-char
line length limit used in the rest of Art. The 80-char limit
should still be used in any code that we expect to upstream to
llvm.
Change-Id: I1beca4d57c41e8161bf746bc62abbce08d5bcb4d
diff --git a/src/compiler/codegen/MethodBitcode.cc b/src/compiler/codegen/MethodBitcode.cc
index 8d62750..c4e1b9d 100644
--- a/src/compiler/codegen/MethodBitcode.cc
+++ b/src/compiler/codegen/MethodBitcode.cc
@@ -29,7 +29,9 @@
#include <llvm/Support/Casting.h>
#include <llvm/Support/InstIterator.h>
-static const char* kLabelFormat = "L0x%x_%d";
+static const char* kLabelFormat = "%c0x%x_%d";
+static const char kNormalBlock = 'L';
+static const char kCatchBlock = 'C';
namespace art {
extern const RegLocation badLoc;
@@ -1975,8 +1977,8 @@
bool entryBlock = (bb->blockType == kEntryBlock);
llvm::BasicBlock* llvmBB =
llvm::BasicBlock::Create(*cUnit->context, entryBlock ? "entry" :
- StringPrintf(kLabelFormat, offset, bb->id),
- cUnit->func);
+ StringPrintf(kLabelFormat, bb->catchEntry ? kCatchBlock :
+ kNormalBlock, offset, bb->id), cUnit->func);
if (entryBlock) {
cUnit->entryBB = llvmBB;
cUnit->placeholderBB =
@@ -2857,17 +2859,27 @@
bool isEntry = (bb == &cUnit->func->getEntryBlock());
// Define the starting label
LIR* blockLabel = cUnit->blockToLabelMap.Get(bb);
- // Extract the starting offset from the block's name
+ // Extract the type and starting offset from the block's name
+ char blockType = kNormalBlock;
if (!isEntry) {
const char* blockName = bb->getName().str().c_str();
int dummy;
- sscanf(blockName, kLabelFormat, &blockLabel->operands[0], &dummy);
+ sscanf(blockName, kLabelFormat, &blockType, &blockLabel->operands[0], &dummy);
+ cUnit->currentDalvikOffset = blockLabel->operands[0];
+ } else {
+ cUnit->currentDalvikOffset = 0;
}
// Set the label kind
blockLabel->opcode = kPseudoNormalBlockLabel;
// Insert the label
oatAppendLIR(cUnit, blockLabel);
+ LIR* headLIR = NULL;
+
+ if (blockType == kCatchBlock) {
+ headLIR = newLIR0(cUnit, kPseudoSafepointPC);
+ }
+
// Free temp registers and reset redundant store tracking */
oatResetRegPool(cUnit);
oatResetDefTracking(cUnit);
@@ -2875,10 +2887,7 @@
//TODO: restore oat incoming liveness optimization
oatClobberAllRegs(cUnit);
- LIR* headLIR = NULL;
-
if (isEntry) {
- cUnit->currentDalvikOffset = 0;
RegLocation* argLocs = (RegLocation*)
oatNew(cUnit, sizeof(RegLocation) * cUnit->numIns, true, kAllocMisc);
llvm::Function::arg_iterator it(cUnit->func->arg_begin());