diff options
author | Ben Cheng <bccheng@android.com> | 2011-05-11 16:55:48 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@android.com> | 2011-05-11 16:55:48 -0700 |
commit | fe108f779db4fb3bc720a92e69e58177983088c1 (patch) | |
tree | 90dc67e893dd992d4cbb89215272c1740027520b /vm/compiler/codegen/arm | |
parent | 313d430d5b3b96b45370ccddee52a6d88a799f35 (diff) | |
download | android_dalvik-fe108f779db4fb3bc720a92e69e58177983088c1.tar.gz android_dalvik-fe108f779db4fb3bc720a92e69e58177983088c1.tar.bz2 android_dalvik-fe108f779db4fb3bc720a92e69e58177983088c1.zip |
Fix a Thumb vs Thumb2 codegen bug.
A Thumb2 pc-relative load is slipped into the codegen stream even though
the selected platform is armv5te (eg the emulator).
Bug: 4399358
Change-Id: I61dd6853cad6c82de43f384814c903dd9f3ae302
Diffstat (limited to 'vm/compiler/codegen/arm')
-rw-r--r-- | vm/compiler/codegen/arm/Thumb/Factory.cpp | 32 | ||||
-rw-r--r-- | vm/compiler/codegen/arm/Thumb2/Factory.cpp | 32 |
2 files changed, 62 insertions, 2 deletions
diff --git a/vm/compiler/codegen/arm/Thumb/Factory.cpp b/vm/compiler/codegen/arm/Thumb/Factory.cpp index 7b51df160..9cdd75f46 100644 --- a/vm/compiler/codegen/arm/Thumb/Factory.cpp +++ b/vm/compiler/codegen/arm/Thumb/Factory.cpp @@ -110,6 +110,36 @@ static ArmLIR *loadConstant(CompilationUnit *cUnit, int rDest, int value) return loadConstantNoClobber(cUnit, rDest, value); } +/* + * Load a class pointer value into a fixed or temp register. Target + * register is clobbered, and marked inUse. + */ +static ArmLIR *loadClassPointer(CompilationUnit *cUnit, int rDest, int value) +{ + ArmLIR *res; + cUnit->hasClassLiterals = true; + if (dvmCompilerIsTemp(cUnit, rDest)) { + dvmCompilerClobber(cUnit, rDest); + dvmCompilerMarkInUse(cUnit, rDest); + } + ArmLIR *dataTarget = scanLiteralPool(cUnit->classPointerList, value, 0); + if (dataTarget == NULL) { + dataTarget = addWordData(cUnit, &cUnit->classPointerList, value); + /* Counts the number of class pointers in this translation */ + cUnit->numClassPointers++; + } + ArmLIR *loadPcRel = (ArmLIR *) dvmCompilerNew(sizeof(ArmLIR), true); + loadPcRel->opcode = kThumbLdrPcRel; + loadPcRel->generic.target = (LIR *) dataTarget; + loadPcRel->operands[0] = rDest; + setupResourceMasks(loadPcRel); + setMemRefType(loadPcRel, true, kLiteral); + loadPcRel->aliasInfo = dataTarget->operands[0]; + res = loadPcRel; + dvmCompilerAppendLIR(cUnit, (LIR *) loadPcRel); + return res; +} + static ArmLIR *opNone(CompilationUnit *cUnit, OpKind op) { ArmOpcode opcode = kThumbBkpt; @@ -661,7 +691,7 @@ static ArmLIR *loadBaseDispBody(CompilationUnit *cUnit, MIR *mir, int rBase, if (load2 != NULL && cUnit->heapMemOp) load2->flags.insertWrapper = true; #endif - return res; + return load; } static ArmLIR *loadBaseDisp(CompilationUnit *cUnit, MIR *mir, int rBase, diff --git a/vm/compiler/codegen/arm/Thumb2/Factory.cpp b/vm/compiler/codegen/arm/Thumb2/Factory.cpp index 80454508f..9c9ce1327 100644 --- a/vm/compiler/codegen/arm/Thumb2/Factory.cpp +++ b/vm/compiler/codegen/arm/Thumb2/Factory.cpp @@ -201,6 +201,36 @@ static ArmLIR *loadConstant(CompilationUnit *cUnit, int rDest, int value) return loadConstantNoClobber(cUnit, rDest, value); } +/* + * Load a class pointer value into a fixed or temp register. Target + * register is clobbered, and marked inUse. + */ +static ArmLIR *loadClassPointer(CompilationUnit *cUnit, int rDest, int value) +{ + ArmLIR *res; + cUnit->hasClassLiterals = true; + if (dvmCompilerIsTemp(cUnit, rDest)) { + dvmCompilerClobber(cUnit, rDest); + dvmCompilerMarkInUse(cUnit, rDest); + } + ArmLIR *dataTarget = scanLiteralPool(cUnit->classPointerList, value, 0); + if (dataTarget == NULL) { + dataTarget = addWordData(cUnit, &cUnit->classPointerList, value); + /* Counts the number of class pointers in this translation */ + cUnit->numClassPointers++; + } + ArmLIR *loadPcRel = (ArmLIR *) dvmCompilerNew(sizeof(ArmLIR), true); + loadPcRel->opcode = kThumb2LdrPcRel12; + loadPcRel->generic.target = (LIR *) dataTarget; + loadPcRel->operands[0] = rDest; + setupResourceMasks(loadPcRel); + setMemRefType(loadPcRel, true, kLiteral); + loadPcRel->aliasInfo = dataTarget->operands[0]; + res = loadPcRel; + dvmCompilerAppendLIR(cUnit, (LIR *) loadPcRel); + return res; +} + static ArmLIR *opNone(CompilationUnit *cUnit, OpKind op) { ArmOpcode opcode = kThumbBkpt; @@ -923,7 +953,7 @@ static ArmLIR *loadBaseDispBody(CompilationUnit *cUnit, MIR *mir, int rBase, if (cUnit->heapMemOp) load->flags.insertWrapper = true; #endif - return res; + return load; } static ArmLIR *loadBaseDisp(CompilationUnit *cUnit, MIR *mir, int rBase, |