• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016, 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.code;
5 
6 import com.android.tools.r8.dex.Constants;
7 import com.android.tools.r8.dex.IndexedItemCollection;
8 import com.android.tools.r8.graph.ObjectToOffsetMapping;
9 import com.android.tools.r8.naming.ClassNameMapper;
10 import java.nio.ShortBuffer;
11 
12 public abstract class Format31t extends Base3Format {
13 
14   public final int AA;
15   protected /* offset */ int BBBBBBBB;
16 
17   // vAA | op | +BBBBlo | +BBBBhi
Format31t(int high, BytecodeStream stream)18   Format31t(int high, BytecodeStream stream) {
19     super(stream);
20     AA = high;
21     BBBBBBBB = readSigned32BitValue(stream);
22   }
23 
Format31t(int register, int payloadOffset)24   Format31t(int register, int payloadOffset) {
25     assert 0 <= register && register <= Constants.U8BIT_MAX;
26     AA = register;
27     BBBBBBBB = payloadOffset;
28   }
29 
write(ShortBuffer dest, ObjectToOffsetMapping mapping)30   public void write(ShortBuffer dest, ObjectToOffsetMapping mapping) {
31     writeFirst(AA, dest);
32     assert (getOffset() + BBBBBBBB) % 2 == 0;
33     write32BitValue(BBBBBBBB, dest);
34   }
35 
hasPayload()36   public boolean hasPayload() {
37     return true;
38   }
39 
getPayloadOffset()40   public int getPayloadOffset() {
41     return BBBBBBBB;
42   }
43 
setPayloadOffset(int offset)44   public void setPayloadOffset(int offset) {
45     BBBBBBBB = offset;
46   }
47 
hashCode()48   public final int hashCode() {
49     return ((BBBBBBBB << 8) | AA) ^ getClass().hashCode();
50   }
51 
equals(Object other)52   public final boolean equals(Object other) {
53     if (other == null || (this.getClass() != other.getClass())) {
54       return false;
55     }
56     Format31t o = (Format31t) other;
57     return o.AA == AA && o.BBBBBBBB == BBBBBBBB;
58   }
59 
toString(ClassNameMapper naming)60   public String toString(ClassNameMapper naming) {
61     return formatString("v" + AA + ", +" + BBBBBBBB + " (" + (getOffset() + BBBBBBBB) + ")");
62   }
63 
64   @Override
collectIndexedItems(IndexedItemCollection indexedItems)65   public void collectIndexedItems(IndexedItemCollection indexedItems) {
66     // No references.
67   }
68 }
69