OSDN Git Service

Dump the current code stream when the assembler fails on size issues.
authorBen Cheng <bccheng@android.com>
Wed, 23 Mar 2011 21:37:40 +0000 (14:37 -0700)
committerBen Cheng <bccheng@android.com>
Thu, 24 Mar 2011 19:05:24 +0000 (12:05 -0700)
Since the assembler is very robust and will recover from such problems,
adding the verbose/noisy mode will make it easier to detect overly
aggressive optimizations that don't actually work.

Example:

D/dalvikvm( 2348): Assembler abort #1 on 1
D/dalvikvm( 2348): kThumbBCond@16: delta=260
                 :

Instruction at 0x16 is a conditional branch:
D/dalvikvm( 2348): 0x16 (0016): beq     0x0000001a (L0xb6c0c)
                 :

Label at L0xb6c0c is a PC reconstruction cell:
D/dalvikvm( 2348): L0xb6c0c:
D/dalvikvm( 2348): -------- reconstruct dalvik PC : 0x401854d6 @ +0x002b
D/dalvikvm( 2348): 0x11e (011e): ldr     r0, [r15pc, #0]
D/dalvikvm( 2348): 0x122 (0122): b       0x00000126 (L0xb685c)

where 0x11e - 0x16 - 4 = 260

Change-Id: Icbc3dae581949f5976722e24e38f04ec882c7d79

vm/compiler/codegen/arm/ArchUtility.c
vm/compiler/codegen/arm/Assemble.c

index 961a2e1..fb28e26 100644 (file)
@@ -349,6 +349,7 @@ void dvmDumpLIRInsn(LIR *arg, unsigned char *baseAddr)
             LOGD("%p (%04x): .align4\n", baseAddr + offset, offset);
             break;
         case kArmPseudoPCReconstructionCell:
+            LOGD("L%p:\n", lir);
             LOGD("-------- reconstruct dalvik PC : 0x%04x @ +0x%04x\n", dest,
                  lir->operands[1]);
             break;
index 17fef2b..0e919c4 100644 (file)
@@ -958,8 +958,18 @@ static AssemblerStatus assembleInstructions(CompilationUnit *cUnit,
                 dvmCompilerAbort(cUnit);
             }
             if ((lir->opcode == kThumb2LdrPcRel12) && (delta > 4091)) {
+                if (cUnit->printMe) {
+                    LOGD("kThumb2LdrPcRel12@%x: delta=%d", lir->generic.offset,
+                         delta);
+                    dvmCompilerCodegenDump(cUnit);
+                }
                 return kRetryHalve;
             } else if (delta > 1020) {
+                if (cUnit->printMe) {
+                    LOGD("kThumbLdrPcRel@%x: delta=%d", lir->generic.offset,
+                         delta);
+                    dvmCompilerCodegenDump(cUnit);
+                }
                 return kRetryHalve;
             }
             if (lir->opcode == kThumb2Vldrs) {
@@ -1002,6 +1012,11 @@ static AssemblerStatus assembleInstructions(CompilationUnit *cUnit,
             intptr_t target = targetLIR->generic.offset;
             int delta = target - pc;
             if ((lir->opcode == kThumbBCond) && (delta > 254 || delta < -256)) {
+                if (cUnit->printMe) {
+                    LOGD("kThumbBCond@%x: delta=%d", lir->generic.offset,
+                         delta);
+                    dvmCompilerCodegenDump(cUnit);
+                }
                 return kRetryHalve;
             }
             lir->operands[0] = delta >> 1;