summaryrefslogtreecommitdiff
path: root/startop/view_compiler/dex_builder.cc
diff options
context:
space:
mode:
authorEric Holk <eholk@google.com>2019-07-26 09:37:46 -0700
committerEric Holk <eholk@google.com>2019-07-26 09:46:18 -0700
commit70445d0d89cb2b730e148cdb92e580585c1ef9c6 (patch)
tree0d5d2895a2921aa644d35ec65c6d5a76e7c09ccc /startop/view_compiler/dex_builder.cc
parent3092f99ae63f12f5c18d40f21616c98f2b6c62af (diff)
[viewcompiler] Add support for static field put to DexBuilder
Bug: 111895153 Change-Id: I12b38fa520790debec545d7d1f6b3522a65ce03b
Diffstat (limited to 'startop/view_compiler/dex_builder.cc')
-rw-r--r--startop/view_compiler/dex_builder.cc37
1 files changed, 30 insertions, 7 deletions
diff --git a/startop/view_compiler/dex_builder.cc b/startop/view_compiler/dex_builder.cc
index 66bc698e2136..09f9c04d9e2c 100644
--- a/startop/view_compiler/dex_builder.cc
+++ b/startop/view_compiler/dex_builder.cc
@@ -105,6 +105,9 @@ std::ostream& operator<<(std::ostream& out, const Instruction::Op& opcode) {
case Instruction::Op::kGetStaticField:
out << "kGetStaticField";
return out;
+ case Instruction::Op::kSetStaticField:
+ out << "kSetStaticField";
+ return out;
}
}
@@ -380,6 +383,7 @@ void MethodBuilder::EncodeInstruction(const Instruction& instruction) {
case Instruction::Op::kCheckCast:
return EncodeCast(instruction);
case Instruction::Op::kGetStaticField:
+ case Instruction::Op::kSetStaticField:
return EncodeStaticFieldOp(instruction);
}
}
@@ -536,13 +540,32 @@ void MethodBuilder::EncodeCast(const Instruction& instruction) {
}
void MethodBuilder::EncodeStaticFieldOp(const Instruction& instruction) {
- CHECK_EQ(Instruction::Op::kGetStaticField, instruction.opcode());
- CHECK(instruction.dest().has_value());
- CHECK(instruction.dest()->is_variable());
- CHECK_EQ(0, instruction.args().size());
-
- Encode21c(
- ::art::Instruction::SGET, RegisterValue(*instruction.dest()), instruction.index_argument());
+ switch (instruction.opcode()) {
+ case Instruction::Op::kGetStaticField: {
+ CHECK(instruction.dest().has_value());
+ CHECK(instruction.dest()->is_variable());
+ CHECK_EQ(0, instruction.args().size());
+
+ Encode21c(::art::Instruction::SGET,
+ RegisterValue(*instruction.dest()),
+ instruction.index_argument());
+ break;
+ }
+ case Instruction::Op::kSetStaticField: {
+ CHECK(!instruction.dest().has_value());
+ const auto& args = instruction.args();
+ CHECK_EQ(1, args.size());
+ CHECK(args[0].is_variable());
+
+ Encode21c(::art::Instruction::SPUT,
+ RegisterValue(args[0]),
+ instruction.index_argument());
+ break;
+ }
+ default: {
+ LOG(FATAL) << "Unsupported static field operation";
+ }
+ }
}
size_t MethodBuilder::RegisterValue(const Value& value) const {