1 // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file 2 // for details. All rights reserved. Use of this source code is governed by a 3 // BSD-style license that can be found in the LICENSE file. 4 package com.android.tools.r8.ir.code; 5 6 import com.android.tools.r8.errors.Unreachable; 7 import com.android.tools.r8.graph.DebugLocalInfo; 8 import com.android.tools.r8.ir.conversion.DexBuilder; 9 import com.android.tools.r8.utils.InternalOptions; 10 import com.android.tools.r8.utils.StringUtils; 11 import it.unimi.dsi.fastutil.ints.Int2ReferenceMap; 12 13 public class DebugLocalsChange extends Instruction { 14 15 private final Int2ReferenceMap<DebugLocalInfo> ending; 16 private final Int2ReferenceMap<DebugLocalInfo> starting; 17 DebugLocalsChange( Int2ReferenceMap<DebugLocalInfo> ending, Int2ReferenceMap<DebugLocalInfo> starting)18 public DebugLocalsChange( 19 Int2ReferenceMap<DebugLocalInfo> ending, Int2ReferenceMap<DebugLocalInfo> starting) { 20 super(null); 21 this.ending = ending; 22 this.starting = starting; 23 } 24 getEnding()25 public Int2ReferenceMap<DebugLocalInfo> getEnding() { 26 return ending; 27 } 28 getStarting()29 public Int2ReferenceMap<DebugLocalInfo> getStarting() { 30 return starting; 31 } 32 33 @Override isDebugLocalsChange()34 public boolean isDebugLocalsChange() { 35 return true; 36 } 37 38 @Override asDebugLocalsChange()39 public DebugLocalsChange asDebugLocalsChange() { 40 return this; 41 } 42 43 @Override buildDex(DexBuilder builder)44 public void buildDex(DexBuilder builder) { 45 builder.addNop(this); 46 } 47 48 @Override identicalNonValueParts(Instruction other)49 public boolean identicalNonValueParts(Instruction other) { 50 assert other.isDebugLocalsChange(); 51 return false; 52 } 53 54 @Override compareNonValueParts(Instruction other)55 public int compareNonValueParts(Instruction other) { 56 assert other.isDebugLocalsChange(); 57 return 0; 58 } 59 60 @Override maxInValueRegister()61 public int maxInValueRegister() { 62 throw new Unreachable(); 63 } 64 65 @Override maxOutValueRegister()66 public int maxOutValueRegister() { 67 throw new Unreachable(); 68 } 69 70 @Override canBeDeadCode(IRCode code, InternalOptions options)71 public boolean canBeDeadCode(IRCode code, InternalOptions options) { 72 return false; 73 } 74 75 @Override toString()76 public String toString() { 77 StringBuilder builder = new StringBuilder(super.toString()); 78 builder.append("ending: "); 79 StringUtils.append(builder, ending.int2ReferenceEntrySet()); 80 builder.append(", starting: "); 81 StringUtils.append(builder, starting.int2ReferenceEntrySet()); 82 return builder.toString(); 83 } 84 } 85