xref: /aosp_15_r20/dalvik/opcode-gen/README.txt (revision 055d459012065f78d96b68be8421640240ddf631)
1*055d4590SKeyi Gui# Copyright (C) 2010 The Android Open Source Project
2*055d4590SKeyi Gui#
3*055d4590SKeyi Gui# Licensed under the Apache License, Version 2.0 (the "License");
4*055d4590SKeyi Gui# you may not use this file except in compliance with the License.
5*055d4590SKeyi Gui# You may obtain a copy of the License at
6*055d4590SKeyi Gui#
7*055d4590SKeyi Gui#      http://www.apache.org/licenses/LICENSE-2.0
8*055d4590SKeyi Gui#
9*055d4590SKeyi Gui# Unless required by applicable law or agreed to in writing, software
10*055d4590SKeyi Gui# distributed under the License is distributed on an "AS IS" BASIS,
11*055d4590SKeyi Gui# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*055d4590SKeyi Gui# See the License for the specific language governing permissions and
13*055d4590SKeyi Gui# limitations under the License.
14*055d4590SKeyi Gui
15*055d4590SKeyi Gui---------------------------------------------------------------------
16*055d4590SKeyi GuiNotes on updating the sets of defined opcodes and instruction formats
17*055d4590SKeyi Gui---------------------------------------------------------------------
18*055d4590SKeyi Gui
19*055d4590SKeyi Gui##########
20*055d4590SKeyi Gui
21*055d4590SKeyi GuiIf you want to add, delete, or change opcodes:
22*055d4590SKeyi Gui
23*055d4590SKeyi Gui* Update the file bytecode.txt, in this directory.
24*055d4590SKeyi Gui
25*055d4590SKeyi Gui* Run the regen-all script, in this directory. This will regenerate a
26*055d4590SKeyi Gui  number of tables, definitions, and declarations in the code, in
27*055d4590SKeyi Gui  dalvik/dx, dalvik/libdex, and libcore/dalvik.
28*055d4590SKeyi Gui
29*055d4590SKeyi Gui* Implement/update the opcode in C in vm/mterp/c/...
30*055d4590SKeyi Gui  * Verify new code by running with "dalvik.vm.execution-mode = int:portable"
31*055d4590SKeyi Gui    or "-Xint:portable".
32*055d4590SKeyi Gui
33*055d4590SKeyi Gui* Implement/update the instruction in assembly in vm/mterp/{arm*,x86*}/...
34*055d4590SKeyi Gui  * Verify by enabling the assembly (e.g. ARM) handler for that instruction
35*055d4590SKeyi Gui    in mterp/config-* and running "int:fast" as above.
36*055d4590SKeyi Gui
37*055d4590SKeyi Gui* Implement/update the instruction in
38*055d4590SKeyi Gui  vm/compiler/codegen/{arm,x86}/CodegenDriver.c.
39*055d4590SKeyi Gui
40*055d4590SKeyi Gui* Rebuild the interpreter code. See the notes in vm/mterp/ReadMe.txt for
41*055d4590SKeyi Gui  details.
42*055d4590SKeyi Gui
43*055d4590SKeyi Gui* Look in the directory vm/analysis at the files CodeVerify.c,
44*055d4590SKeyi Gui  DexVerify.c, and Optimize.c. You may need to update them to account
45*055d4590SKeyi Gui  for your changes.
46*055d4590SKeyi Gui  * If you change anything here, be sure to try running the system with
47*055d4590SKeyi Gui    the verifier enabled (which is in fact the default).
48*055d4590SKeyi Gui
49*055d4590SKeyi Gui##########
50*055d4590SKeyi Gui
51*055d4590SKeyi GuiIf you want to add, delete, or change instruction formats:
52*055d4590SKeyi Gui
53*055d4590SKeyi GuiThis is a more manual affair than changing opcodes.
54*055d4590SKeyi Gui
55*055d4590SKeyi Gui* Update the file bytecode.txt, and run regen-all, as per above.
56*055d4590SKeyi Gui
57*055d4590SKeyi Gui* Update the instruction format list in libdex/InstrUtils.h.
58*055d4590SKeyi Gui
59*055d4590SKeyi Gui* Update dexDecodeInstruction() in libdex/InstrUtils.c.
60*055d4590SKeyi Gui
61*055d4590SKeyi Gui* Update dumpInstruction() and its helper code in dexdump/DexDump.c.
62*055d4590SKeyi Gui
63*055d4590SKeyi Gui* Update the switch inside dvmCompilerMIR2LIR() in
64*055d4590SKeyi Gui  vm/compiler/codegen/{arm,x86}/CodegenDriver.c. (There may be other
65*055d4590SKeyi Gui  architectures to deal with too.)
66*055d4590SKeyi Gui
67*055d4590SKeyi Gui##########
68*055d4590SKeyi Gui
69*055d4590SKeyi GuiTesting your work:
70*055d4590SKeyi Gui
71*055d4590SKeyi GuiThe Dalvik VM tests (in the vm/tests directory) provide a convenient
72*055d4590SKeyi Guiway to test most of the above without doing any rebuilds. In
73*055d4590SKeyi Guiparticular, test 003-omnibus-opcodes will exercise most of the
74*055d4590SKeyi Guiopcodes.
75