1b1994897Sopenharmony_ci# 2022-08-18-isa-changelog
2b1994897Sopenharmony_ci
3b1994897Sopenharmony_ciThis document describes change log with the following modifications:
4b1994897Sopenharmony_ci
5b1994897Sopenharmony_ci* ISA refactoring
6b1994897Sopenharmony_ci* Function Kind and Header index
7b1994897Sopenharmony_ci* MethodId, StringId and LiteralArrayId
8b1994897Sopenharmony_ci* LiteralArrayIndex refactoring
9b1994897Sopenharmony_ci
10b1994897Sopenharmony_ci## ISA refactoring
11b1994897Sopenharmony_ciThe bytecode size and runtime performance have been suffering for a long time as the all the
12b1994897Sopenharmony_ciecmascript specific bytecode are prefixed and their opcode were encoded with two bytes.
13b1994897Sopenharmony_ci1. We delete all original java specific opcodes and delete java specific opcode prefix.
14b1994897Sopenharmony_ci2. We remove the prefix of ecmascript specific opcodes, such that most of the bytecode opcode can be encoded with one byte.
15b1994897Sopenharmony_ci3. We add prefix "deprecated" and keep the many old isa as "deprecated"-prefixed opcodes (for compatibility). These prefixed opcode will be deleted once we do not need to concern compatibility.
16b1994897Sopenharmony_ci4. We add prefix "throw" and make all throwing opcodes be prefixed by "throw".
17b1994897Sopenharmony_ci5. We add prefix "wide" to support opcodes which need larger immediate number.
18b1994897Sopenharmony_ci6. We adjust the format of some opcodes (about immediate number and accumulator), so that the bytecode can be more compact.
19b1994897Sopenharmony_ci7. We change the semantics of some opcodes.
20b1994897Sopenharmony_ci8. We add 8-bit or 16-bit imm as inline cache slot for some specific opcodes.
21b1994897Sopenharmony_ci
22b1994897Sopenharmony_ci## Function Kind and Header index
23b1994897Sopenharmony_ciAs we merge some "define-function" opcodes as one opcode, in function we add one field which records the function kind,
24b1994897Sopenharmony_cisuch that runtime can distinguish the "define-function" operations of different kinds.
25b1994897Sopenharmony_ciWe also add header index in function such that runtime can access IndexHeader more efficiently.
26b1994897Sopenharmony_ciWe reuse the field 32-bit field `access_flags_` to encode Function Kind and Header index.
27b1994897Sopenharmony_ciThis will not introduce compatibility issue because the later 24-bit of `access_flags_` is unused indeed.
28b1994897Sopenharmony_ciNow the layout is:
29b1994897Sopenharmony_ci
30b1994897Sopenharmony_ci|<- 16-bit header index ->|<- 8-bit function kind ->|<- 8-bit original access flag ->|
31b1994897Sopenharmony_ci
32b1994897Sopenharmony_ci## MethodId, StringId and LiteralArrayId
33b1994897Sopenharmony_ciTo adapt runtime design, we put string and literal array into the index header of methods,
34b1994897Sopenharmony_cisuch that the instructions can get consective indexes for methodId, stringId and literalarrayId.
35b1994897Sopenharmony_ciThis will help runtime to build constant pool more efficiently.
36b1994897Sopenharmony_ciAs the method number in a class is not limited, we release the constraint that all methodId,
37b1994897Sopenharmony_cistringId and literalarrayId in a class should be put in a same index header.
38b1994897Sopenharmony_ciInstead, we only ask that all methodId, stringId and literalarrayId in a method should be put in one index header.
39b1994897Sopenharmony_ciAs we use 16-bit to encode methodId, stringId and literalarrayId, the number of these Ids in one method cannot exceed 65536 for now.
40b1994897Sopenharmony_ciThis released constraint suits for most of application scenarios.
41b1994897Sopenharmony_ci
42b1994897Sopenharmony_ci## LiteralArrayIndex refactoring
43b1994897Sopenharmony_ci1. We deprecate the usage of global literalarray index.
44b1994897Sopenharmony_ci2. We use offset to reference literalarray.
45b1994897Sopenharmony_ci3. In bytecode, we still use 16-bit literalarrayId rather than offset.
46b1994897Sopenharmony_ci4. The layout of literalarrays can be random.
47b1994897Sopenharmony_ci5. The literalarray which is referenced by TypeSummary contains the offsets of all type-literalarray.
48