diff options
author | mikaelpeltier <mikaelpeltier@google.com> | 2014-07-17 16:30:12 +0200 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2014-07-21 09:41:43 +0200 |
commit | 34ac540acf533af328e8a3868e9e66878c5746ac (patch) | |
tree | c461e766e04b778787743e36dfe0e547a56a51e2 | |
parent | cd2b0996ce34ca29538fbd324fc66588b040e258 (diff) | |
download | android_dalvik-34ac540acf533af328e8a3868e9e66878c5746ac.tar.gz android_dalvik-34ac540acf533af328e8a3868e9e66878c5746ac.tar.bz2 android_dalvik-34ac540acf533af328e8a3868e9e66878c5746ac.zip |
Fix bad debug info due to 64-bit registers alignment
- Registers of LocalStart and LocalSnapshot must also be shift when it is required.
Bug: 16344305
(cherry picked from commit 32631e6ee656840701f76e0d736290bfcd4aab7e)
Change-Id: Ic437ed4102ad0fbeccc069df0f44cb2d774ff27d
-rw-r--r-- | dx/src/com/android/dx/dex/code/DalvInsn.java | 13 | ||||
-rw-r--r-- | dx/src/com/android/dx/dex/code/LocalSnapshot.java | 7 | ||||
-rw-r--r-- | dx/src/com/android/dx/dex/code/LocalStart.java | 7 | ||||
-rw-r--r-- | dx/src/com/android/dx/dex/code/OutputFinisher.java | 6 | ||||
-rw-r--r-- | dx/src/com/android/dx/ssa/RegisterMapper.java | 23 |
5 files changed, 55 insertions, 1 deletions
diff --git a/dx/src/com/android/dx/dex/code/DalvInsn.java b/dx/src/com/android/dx/dex/code/DalvInsn.java index 41fcbdca8..49a2f30f1 100644 --- a/dx/src/com/android/dx/dex/code/DalvInsn.java +++ b/dx/src/com/android/dx/dex/code/DalvInsn.java @@ -19,9 +19,11 @@ package com.android.dx.dex.code; import com.android.dx.rop.code.RegisterSpec; import com.android.dx.rop.code.RegisterSpecList; import com.android.dx.rop.code.SourcePosition; +import com.android.dx.ssa.RegisterMapper; import com.android.dx.util.AnnotatedOutput; import com.android.dx.util.Hex; import com.android.dx.util.TwoColumnOutput; + import java.util.BitSet; /** @@ -381,6 +383,17 @@ public abstract class DalvInsn { } /** + * Returns an instance that is just like this one, except that the + * register list is mapped by using {@code mapper}. + * + * @param mapper {@code non-null;} used to map registers + * @return {@code non-null;} an appropriately-constructed instance + */ + public DalvInsn withMapper(RegisterMapper mapper) { + return withRegisters(mapper.map(getRegisters())); + } + + /** * Gets the size of this instruction, in 16-bit code units. * * @return {@code >= 0;} the code size of this instruction diff --git a/dx/src/com/android/dx/dex/code/LocalSnapshot.java b/dx/src/com/android/dx/dex/code/LocalSnapshot.java index baeab4caf..863a0ef5c 100644 --- a/dx/src/com/android/dx/dex/code/LocalSnapshot.java +++ b/dx/src/com/android/dx/dex/code/LocalSnapshot.java @@ -20,6 +20,7 @@ import com.android.dx.rop.code.RegisterSpec; import com.android.dx.rop.code.RegisterSpecList; import com.android.dx.rop.code.RegisterSpecSet; import com.android.dx.rop.code.SourcePosition; +import com.android.dx.ssa.RegisterMapper; /** * Pseudo-instruction which is used to hold a snapshot of the @@ -93,4 +94,10 @@ public final class LocalSnapshot extends ZeroSizeInsn { return sb.toString(); } + + /** {@inheritDoc} */ + @Override + public DalvInsn withMapper(RegisterMapper mapper) { + return new LocalSnapshot(getPosition(), mapper.map(locals)); + } } diff --git a/dx/src/com/android/dx/dex/code/LocalStart.java b/dx/src/com/android/dx/dex/code/LocalStart.java index 9a17c5bec..0566cb515 100644 --- a/dx/src/com/android/dx/dex/code/LocalStart.java +++ b/dx/src/com/android/dx/dex/code/LocalStart.java @@ -19,6 +19,7 @@ package com.android.dx.dex.code; import com.android.dx.rop.code.RegisterSpec; import com.android.dx.rop.code.RegisterSpecList; import com.android.dx.rop.code.SourcePosition; +import com.android.dx.ssa.RegisterMapper; /** * Pseudo-instruction which is used to introduce a new local variable. That @@ -95,4 +96,10 @@ public final class LocalStart extends ZeroSizeInsn { protected String listingString0(boolean noteIndices) { return "local-start " + localString(local); } + + /** {@inheritDoc} */ + @Override + public DalvInsn withMapper(RegisterMapper mapper) { + return new LocalStart(getPosition(), mapper.map(local)); + } } diff --git a/dx/src/com/android/dx/dex/code/OutputFinisher.java b/dx/src/com/android/dx/dex/code/OutputFinisher.java index a1fc721df..b2eb43fb0 100644 --- a/dx/src/com/android/dx/dex/code/OutputFinisher.java +++ b/dx/src/com/android/dx/dex/code/OutputFinisher.java @@ -870,6 +870,8 @@ public final class OutputFinisher { for (int i = 0; i < insnSize; i++) { DalvInsn insn = insns.get(i); + // Since there is no need to replace CodeAddress since it does not use registers, skips it to + // avoid to update all TargetInsn that contain a reference to CodeAddress if (!(insn instanceof CodeAddress)) { insns.set(i, insn.withRegisterOffset(delta)); } @@ -892,8 +894,10 @@ public final class OutputFinisher { for (int i = 0; i < insnSize; i++) { DalvInsn insn = insns.get(i); + // Since there is no need to replace CodeAddress since it does not use registers, skips it to + // avoid to update all TargetInsn that contain a reference to CodeAddress if (!(insn instanceof CodeAddress)) { - insns.set(i, insn.withRegisters(mapper.map(insn.getRegisters()))); + insns.set(i, insn.withMapper(mapper)); } } } diff --git a/dx/src/com/android/dx/ssa/RegisterMapper.java b/dx/src/com/android/dx/ssa/RegisterMapper.java index 3099000a7..c105f1c51 100644 --- a/dx/src/com/android/dx/ssa/RegisterMapper.java +++ b/dx/src/com/android/dx/ssa/RegisterMapper.java @@ -18,6 +18,7 @@ package com.android.dx.ssa; import com.android.dx.rop.code.RegisterSpec; import com.android.dx.rop.code.RegisterSpecList; +import com.android.dx.rop.code.RegisterSpecSet; /** * Represents a mapping between two register numbering schemes. @@ -57,4 +58,26 @@ public abstract class RegisterMapper { // Return the old sources if nothing has changed. return newSources.equals(sources) ? sources : newSources; } + + /** + * + * @param sources old register set + * @return new mapped register set, or old if nothing has changed. + */ + public final RegisterSpecSet map(RegisterSpecSet sources) { + int sz = sources.getMaxSize(); + RegisterSpecSet newSources = new RegisterSpecSet(getNewRegisterCount()); + + for (int i = 0; i < sz; i++) { + RegisterSpec registerSpec = sources.get(i); + if (registerSpec != null) { + newSources.put(map(registerSpec)); + } + } + + newSources.setImmutable(); + + // Return the old sources if nothing has changed. + return newSources.equals(sources) ? sources : newSources; + } } |