OpcodeInfo.java revision 3908db51e682295bd5b76bf2555e675162922349
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package dalvik.bytecode;
18
19/**
20 * Information about Dalvik opcodes.
21 */
22public final class OpcodeInfo {
23    /**
24     * The maximum possible value of a Dalvik opcode.
25     *
26     * <p><b>Note:</b>: This is constant in any given VM incarnation,
27     * but it is subject to change over time, so it is not appropriate
28     * to represent as a compile-time constant value.</p>
29     */
30    public static final int MAXIMUM_VALUE;
31
32    /**
33     * The maximum possible "packed value" of a Dalvik opcode. The
34     * packed value of an opcode is a denser representation that is
35     * only used when reporting usage statistics. The mapping between
36     * packed opcode values and regular opcode values is
37     * implementation-specific and may vary over time.
38     *
39     * <p><b>Note:</b>: This is constant in any given VM incarnation,
40     * but it is subject to change over time, so it is not appropriate
41     * to represent as a compile-time constant value.</p>
42     *
43     * @see dalvik.system.VMDebug.getInstructionCount()
44     */
45    public static final int MAXIMUM_PACKED_VALUE;
46
47    static {
48        /*
49         * See note on the definition of MAXIMUM_VALUE, above, for
50         * why it's not assigned directly on the declaration line.
51         *
52         * IMPORTANT NOTE: This assignment is generated automatically
53         * by the opcode-gen tool. Any edits will get wiped out the
54         * next time the tool is run.
55         */
56        // BEGIN(libcore-maximum-values); GENERATED AUTOMATICALLY BY opcode-gen
57        MAXIMUM_VALUE = 65535;
58        MAXIMUM_PACKED_VALUE = 255;
59        // END(libcore-maximum-values)
60    }
61
62    /**
63     * This class is not instantiable.
64     */
65    private OpcodeInfo() {
66        // This space intentionally left blank.
67    }
68
69    /**
70     * Returns whether the given packed opcode value represents a
71     * method invocation operation. This includes most things that
72     * look like method invocation at the source level, but it notably
73     * excludes methods that are implemented directly in the VM as
74     * well as ones the VM knows to have empty implementations.
75     *
76     * @hide Unclear if this is useful enough to publish as supported API.
77     *
78     * @param opcode one of the values defined in {@link Opcodes}
79     */
80    public static native boolean isInvoke(int packedOpcode);
81}
82