summaryrefslogtreecommitdiff
path: root/startop/view_compiler/dex_builder.h
diff options
context:
space:
mode:
authorOrion Hodson <oth@google.com>2019-10-31 15:25:33 +0000
committerOrion Hodson <oth@google.com>2019-11-01 11:38:56 +0000
commit59d07201d90329e4657f89b4107f06aa2b890ab7 (patch)
tree181b3727880c2aa91cd350432c18a6f901d6399b /startop/view_compiler/dex_builder.h
parent0d6c308c39e3c53225f2db0e9e25a52d4a281abd (diff)
Switch to slicer DEX opcode definitions
Removes dependency on art/libdexfile and uses equivalent definitions from the dexter/slicer library. Bug: 133140750 Bug: 142948359 Test: m Test: atest dex-builder-test \ view-compiler-tests \ android.view.cts.PrecompiledLayoutTest Change-Id: I49562ac4867254ecde287b828f76d23cb5132dd0
Diffstat (limited to 'startop/view_compiler/dex_builder.h')
-rw-r--r--startop/view_compiler/dex_builder.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/startop/view_compiler/dex_builder.h b/startop/view_compiler/dex_builder.h
index 3924e77fab59..3ae37ce1f762 100644
--- a/startop/view_compiler/dex_builder.h
+++ b/startop/view_compiler/dex_builder.h
@@ -24,7 +24,9 @@
#include <unordered_map>
#include <vector>
-#include "dex/dex_instruction.h"
+#include "android-base/logging.h"
+
+#include "slicer/dex_bytecode.h"
#include "slicer/dex_ir.h"
#include "slicer/writer.h"
@@ -364,11 +366,11 @@ class MethodBuilder {
// Encodes a return instruction. For instructions with no return value, the opcode field is
// ignored. Otherwise, this specifies which return instruction will be used (return,
// return-object, etc.)
- void EncodeReturn(const Instruction& instruction, ::art::Instruction::Code opcode);
+ void EncodeReturn(const Instruction& instruction, ::dex::Opcode opcode);
void EncodeMove(const Instruction& instruction);
- void EncodeInvoke(const Instruction& instruction, ::art::Instruction::Code opcode);
- void EncodeBranch(art::Instruction::Code op, const Instruction& instruction);
+ void EncodeInvoke(const Instruction& instruction, ::dex::Opcode opcode);
+ void EncodeBranch(::dex::Opcode op, const Instruction& instruction);
void EncodeNew(const Instruction& instruction);
void EncodeCast(const Instruction& instruction);
void EncodeFieldOp(const Instruction& instruction);
@@ -377,17 +379,18 @@ class MethodBuilder {
// https://source.android.com/devices/tech/dalvik/instruction-formats for documentation of
// formats.
- inline void Encode10x(art::Instruction::Code opcode) {
+ inline void Encode10x(::dex::Opcode opcode) {
// 00|op
- buffer_.push_back(opcode);
+ static_assert(sizeof(uint8_t) == sizeof(::dex::Opcode));
+ buffer_.push_back(static_cast<uint8_t>(opcode));
}
- inline void Encode11x(art::Instruction::Code opcode, uint8_t a) {
+ inline void Encode11x(::dex::Opcode opcode, uint8_t a) {
// aa|op
buffer_.push_back((a << 8) | opcode);
}
- inline void Encode11n(art::Instruction::Code opcode, uint8_t a, int8_t b) {
+ inline void Encode11n(::dex::Opcode opcode, uint8_t a, int8_t b) {
// b|a|op
// Make sure the fields are in bounds (4 bits for a, 4 bits for b).
@@ -398,13 +401,13 @@ class MethodBuilder {
buffer_.push_back(((b & 0xf) << 12) | (a << 8) | opcode);
}
- inline void Encode21c(art::Instruction::Code opcode, uint8_t a, uint16_t b) {
+ inline void Encode21c(::dex::Opcode opcode, uint8_t a, uint16_t b) {
// aa|op|bbbb
buffer_.push_back((a << 8) | opcode);
buffer_.push_back(b);
}
- inline void Encode22c(art::Instruction::Code opcode, uint8_t a, uint8_t b, uint16_t c) {
+ inline void Encode22c(::dex::Opcode opcode, uint8_t a, uint8_t b, uint16_t c) {
// b|a|op|bbbb
CHECK(IsShortRegister(a));
CHECK(IsShortRegister(b));
@@ -412,13 +415,13 @@ class MethodBuilder {
buffer_.push_back(c);
}
- inline void Encode32x(art::Instruction::Code opcode, uint16_t a, uint16_t b) {
+ inline void Encode32x(::dex::Opcode opcode, uint16_t a, uint16_t b) {
buffer_.push_back(opcode);
buffer_.push_back(a);
buffer_.push_back(b);
}
- inline void Encode35c(art::Instruction::Code opcode, size_t a, uint16_t b, uint8_t c, uint8_t d,
+ inline void Encode35c(::dex::Opcode opcode, size_t a, uint16_t b, uint8_t c, uint8_t d,
uint8_t e, uint8_t f, uint8_t g) {
// a|g|op|bbbb|f|e|d|c
@@ -433,7 +436,7 @@ class MethodBuilder {
buffer_.push_back((f << 12) | (e << 8) | (d << 4) | c);
}
- inline void Encode3rc(art::Instruction::Code opcode, size_t a, uint16_t b, uint16_t c) {
+ inline void Encode3rc(::dex::Opcode opcode, size_t a, uint16_t b, uint16_t c) {
CHECK_LE(a, 255);
buffer_.push_back((a << 8) | opcode);
buffer_.push_back(b);