1f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 2f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project 3f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 4f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * you may not use this file except in compliance with the License. 6f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * You may obtain a copy of the License at 7f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 8f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 10f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * See the License for the specific language governing permissions and 14f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * limitations under the License. 15f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 16f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 17f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Projectpackage com.android.dx.rop.code; 18f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 19f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Projectimport com.android.dx.util.Hex; 20f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 21f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/** 22f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * All the register-based opcodes, and related utilities. 23de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * 2499409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * <p><b>Note:</b> Opcode descriptions use a rough pseudocode. {@code r} 2599409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * is the result register, {@code x} is the first argument, 2699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code y} is the second argument, and {@code z} is the 27f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * third argument. The expression which describes 28f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * the operation uses Java-ish syntax but is preceded by type indicators for 29f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * each of the values. 30f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 31f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Projectpublic final class RegOps { 3299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code nop()} */ 33f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int NOP = 1; 34f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 3599409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any type; r,x: T :: r = x;} */ 36f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MOVE = 2; 37f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 3899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any type; r,param(x): T :: r = param(x)} */ 39f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MOVE_PARAM = 3; 40f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 41f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 4299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: Throwable; r: T :: r = caught_exception}. 43f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * <b>Note:</b> This opcode should only ever be used in the 44f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * first instruction of a block, and such blocks must be 45f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * the start of an exception handler. 46f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 47f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MOVE_EXCEPTION = 4; 48f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 4999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any type; r, literal: T :: r = literal;} */ 50f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int CONST = 5; 51f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 5299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code goto label} */ 53f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int GOTO = 6; 54f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 55f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 5699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: int or Object; x,y: T :: if (x == y) goto 5799409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * label} 58f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 59f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int IF_EQ = 7; 60f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 61f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 6299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: int or Object; x,y: T :: if (x != y) goto 6399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * label} 64f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 65f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int IF_NE = 8; 66f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 6799409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x,y: int :: if (x < y) goto label} */ 68f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int IF_LT = 9; 69f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 7099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x,y: int :: if (x >= y) goto label} */ 71f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int IF_GE = 10; 72f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 7399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x,y: int :: if (x <= y) goto label} */ 74f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int IF_LE = 11; 75f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 7699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x,y: int :: if (x > y) goto label} */ 77f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int IF_GT = 12; 78f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 7999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x: int :: goto table[x]} */ 80f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int SWITCH = 13; 81f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 8299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any numeric type; r,x,y: T :: r = x + y} */ 83f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int ADD = 14; 84f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 8599409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any numeric type; r,x,y: T :: r = x - y} */ 86f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int SUB = 15; 87f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 8899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any numeric type; r,x,y: T :: r = x * y} */ 89f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MUL = 16; 90f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 9199409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any numeric type; r,x,y: T :: r = x / y} */ 92f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int DIV = 17; 93f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 94f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 9599409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any numeric type; r,x,y: T :: r = x % y} 96de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * (Java-style remainder) 97f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 98f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int REM = 18; 99f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 10099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any numeric type; r,x: T :: r = -x} */ 101f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int NEG = 19; 102f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 10399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any integral type; r,x,y: T :: r = x & y} */ 104f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int AND = 20; 105f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 10699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any integral type; r,x,y: T :: r = x | y} */ 107f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int OR = 21; 108f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 10999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any integral type; r,x,y: T :: r = x ^ y} */ 110f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int XOR = 22; 111f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 112f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 11399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any integral type; r,x: T; y: int :: r = x << y} 114f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 115f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int SHL = 23; 116f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 117f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 11899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any integral type; r,x: T; y: int :: r = x >> y} 119de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * (signed right-shift) 120f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 121f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int SHR = 24; 122f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 123f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 12499409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any integral type; r,x: T; y: int :: r = x >>> y} 125de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * (unsigned right-shift) 126f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 127f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int USHR = 25; 128f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 12999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any integral type; r,x: T :: r = ~x} */ 130f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int NOT = 26; 131f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 132f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 13399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any numeric type; r: int; x,y: T :: r = (x == y) ? 0 13499409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * : (x > y) ? 1 : -1} (Java-style "cmpl" where a NaN is 135f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * considered "less than" all other values; also used for integral 136de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * comparisons) 137f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 138f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int CMPL = 27; 139f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 140f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 14199409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any floating point type; r: int; x,y: T :: r = (x == y) ? 0 14299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * : (x < y) ? -1 : 1} (Java-style "cmpg" where a NaN is 143de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * considered "greater than" all other values) 144f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 145f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int CMPG = 28; 146f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 147f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 14899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any numeric type; U: any numeric type; r: T; x: U :: 14999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * r = (T) x} (numeric type conversion between the four 150de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * "real" numeric types) 151f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 152f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int CONV = 29; 153f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 154f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 15599409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code r,x: int :: r = (x << 24) >> 24} (Java-style 156de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * convert int to byte) 157f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 158f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int TO_BYTE = 30; 159f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 160f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 161de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * {@code r,x: int :: r = x & 0xffff} (Java-style convert int to char) 162f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 163f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int TO_CHAR = 31; 164f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 165f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 16699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code r,x: int :: r = (x << 16) >> 16} (Java-style 167de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * convert int to short) 168f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 169f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int TO_SHORT = 32; 170f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 17199409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: return type for the method; x: T; return x} */ 172f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int RETURN = 33; 173f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 17499409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any type; r: int; x: T[]; :: r = x.length} */ 175f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int ARRAY_LENGTH = 34; 176f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 17799409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x: Throwable :: throw(x)} */ 178f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int THROW = 35; 179f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 18099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x: Object :: monitorenter(x)} */ 181f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MONITOR_ENTER = 36; 182f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 18399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code x: Object :: monitorexit(x)} */ 184f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MONITOR_EXIT = 37; 185f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 18699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any type; r: T; x: T[]; y: int :: r = x[y]} */ 187f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int AGET = 38; 188f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 18999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any type; x: T; y: T[]; z: int :: x[y] = z} */ 190f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int APUT = 39; 191f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 192f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 19399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any non-array object type :: r = 194de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * alloc(T)} (allocate heap space for an object) 195f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 196f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int NEW_INSTANCE = 40; 197f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 19899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: any array type; r: T; x: int :: r = new T[x]} */ 199f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int NEW_ARRAY = 41; 200f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 201f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 20299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any array type; r: T; x: int; v0..vx: T :: r = new T[x] 20399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {v0, ..., vx}} 204f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 205f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int FILLED_NEW_ARRAY = 42; 206f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 207f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 20899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any object type; x: Object :: (T) x} (can 209de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * throw {@code ClassCastException}) 210f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 211f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int CHECK_CAST = 43; 212f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 213f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 21499409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any object type; x: Object :: x instanceof T} 215f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 216f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int INSTANCE_OF = 44; 217f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 218f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 21999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any type; r: T; x: Object; f: instance field spec of 22099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * type T :: r = x.f} 221f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 222f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int GET_FIELD = 45; 223f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 224f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 22599409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any type; r: T; f: static field spec of type T :: r = 226de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * f} 227f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 228f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int GET_STATIC = 46; 229f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 230f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 23199409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any type; x: T; y: Object; f: instance field spec of type 232de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * T :: y.f = x} 233f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 234f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int PUT_FIELD = 47; 235f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 236f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 23799409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: any type; f: static field spec of type T; x: T :: f = x} 238f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 239f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int PUT_STATIC = 48; 240f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 241f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 24299409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code Tr, T0, T1...: any types; r: Tr; m: static method spec; 24399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * y0: T0; y1: T1 ... :: r = m(y0, y1, ...)} (call static 244de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * method) 245f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 246f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int INVOKE_STATIC = 49; 247f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 248f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 24999409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code Tr, T0, T1...: any types; r: Tr; x: Object; m: instance method 25099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * spec; y0: T0; y1: T1 ... :: r = x.m(y0, y1, ...)} (call normal 251de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * virtual method) 252f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 253f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int INVOKE_VIRTUAL = 50; 254f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 255f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 25699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code Tr, T0, T1...: any types; r: Tr; x: Object; m: instance method 25799409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * spec; y0: T0; y1: T1 ... :: r = x.m(y0, y1, ...)} (call 258de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * superclass virtual method) 259f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 260f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int INVOKE_SUPER = 51; 261f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 262f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 26399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code Tr, T0, T1...: any types; r: Tr; x: Object; m: instance method 26499409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * spec; y0: T0; y1: T1 ... :: r = x.m(y0, y1, ...)} (call 265de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * direct/special method) 266f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 267f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int INVOKE_DIRECT = 52; 268f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 269f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 27099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code Tr, T0, T1...: any types; r: Tr; x: Object; m: interface 271f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * (instance) method spec; y0: T0; y1: T1 ... :: r = x.m(y0, y1, 272de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * ...)} (call interface method) 273f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 274f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int INVOKE_INTERFACE = 53; 275f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 276f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 27799409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T0: any type; name: local variable name :: mark(name,T0)} 27899409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * (mark beginning or end of local variable name) 279f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 280f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MARK_LOCAL = 54; 281f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 282f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 28399409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: Any type; r: T :: r = return_type}. 284f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * <b>Note:</b> This opcode should only ever be used in the 285f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * first instruction of a block following an invoke-*. 286f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 287f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MOVE_RESULT = 55; 288f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 289f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 29099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * {@code T: Any type; r: T :: r = return_type}. 291f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * <b>Note:</b> This opcode should only ever be used in the 292f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * first instruction of a block following a non-invoke throwing insn 293f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 294f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int MOVE_RESULT_PSEUDO = 56; 295f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 29699409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project /** {@code T: Any primitive type; v0..vx: T :: {v0, ..., vx}} */ 297f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static final int FILL_ARRAY_DATA = 57; 298f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 299f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 300f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * This class is uninstantiable. 301f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 302f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project private RegOps() { 303f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project // This space intentionally left blank. 304f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project } 305f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 306f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 307f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Gets the name of the given opcode. 308de75089fb7216d19e9c22cce4dc62a49513477d3Carl Shapiro * 309675b642510ed79e8a7a3f23126dfac7679fd65b9Dan Bornstein * @param opcode the opcode 31099409883d9c4c0ffb49b070ce307bb33a9dfe9f1The Android Open Source Project * @return {@code non-null;} its name 311f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 312f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static String opName(int opcode) { 313f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project switch (opcode) { 314f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case NOP: return "nop"; 315f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MOVE: return "move"; 316f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MOVE_PARAM: return "move-param"; 317f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MOVE_EXCEPTION: return "move-exception"; 318f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case CONST: return "const"; 319f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case GOTO: return "goto"; 320f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case IF_EQ: return "if-eq"; 321f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case IF_NE: return "if-ne"; 322f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case IF_LT: return "if-lt"; 323f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case IF_GE: return "if-ge"; 324f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case IF_LE: return "if-le"; 325f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case IF_GT: return "if-gt"; 326f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case SWITCH: return "switch"; 327f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case ADD: return "add"; 328f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case SUB: return "sub"; 329f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MUL: return "mul"; 330f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case DIV: return "div"; 331f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case REM: return "rem"; 332f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case NEG: return "neg"; 333f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case AND: return "and"; 334f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case OR: return "or"; 335f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case XOR: return "xor"; 336f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case SHL: return "shl"; 337f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case SHR: return "shr"; 338f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case USHR: return "ushr"; 339f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case NOT: return "not"; 340f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case CMPL: return "cmpl"; 341f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case CMPG: return "cmpg"; 342f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case CONV: return "conv"; 343f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case TO_BYTE: return "to-byte"; 344f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case TO_CHAR: return "to-char"; 345f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case TO_SHORT: return "to-short"; 346f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RETURN: return "return"; 347f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case ARRAY_LENGTH: return "array-length"; 348f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case THROW: return "throw"; 349f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MONITOR_ENTER: return "monitor-enter"; 350f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MONITOR_EXIT: return "monitor-exit"; 351f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case AGET: return "aget"; 352f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case APUT: return "aput"; 353f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case NEW_INSTANCE: return "new-instance"; 354f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case NEW_ARRAY: return "new-array"; 355f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case FILLED_NEW_ARRAY: return "filled-new-array"; 356f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case CHECK_CAST: return "check-cast"; 357f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case INSTANCE_OF: return "instance-of"; 358f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case GET_FIELD: return "get-field"; 359f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case GET_STATIC: return "get-static"; 360f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case PUT_FIELD: return "put-field"; 361f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case PUT_STATIC: return "put-static"; 362f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case INVOKE_STATIC: return "invoke-static"; 363f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case INVOKE_VIRTUAL: return "invoke-virtual"; 364f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case INVOKE_SUPER: return "invoke-super"; 365f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case INVOKE_DIRECT: return "invoke-direct"; 366f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case INVOKE_INTERFACE: return "invoke-interface"; 367f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MOVE_RESULT: return "move-result"; 368f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case MOVE_RESULT_PSEUDO: return "move-result-pseudo"; 369f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case FILL_ARRAY_DATA: return "fill-array-data"; 370f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project } 371f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 372f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return "unknown-" + Hex.u1(opcode); 373f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project } 374f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 375f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project /** 376f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Given an IF_* RegOp, returns the right-to-left flipped version. For 377f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * example, IF_GT becomes IF_LT. 378f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 379f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * @param opcode An IF_* RegOp 380f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * @return flipped IF Regop 381f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 382f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project public static int flippedIfOpcode(final int opcode) { 383f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project switch (opcode) { 384f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RegOps.IF_EQ: 385f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RegOps.IF_NE: 386f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return opcode; 387f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RegOps.IF_LT: 388f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return RegOps.IF_GT; 389f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RegOps.IF_GE: 390f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return RegOps.IF_LE; 391f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RegOps.IF_LE: 392f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return RegOps.IF_GE; 393f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project case RegOps.IF_GT: 394f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return RegOps.IF_LT; 395f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project default: 396f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project throw new RuntimeException("Unrecognized IF regop: " + opcode); 397f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project } 398f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project } 399f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project} 400