summaryrefslogtreecommitdiff
path: root/runtime/dex_instruction_test.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2017-09-19 16:58:28 -0700
committer Mathieu Chartier <mathieuc@google.com> 2017-09-19 18:03:15 -0700
commitbc61cb55af9f4543c3ecea4e68ba90630748876b (patch)
tree8c7516541ec425e5bae362895af877854ff12d60 /runtime/dex_instruction_test.cc
parent08601a494e87dfba9b06f9fdea37c9342e4896d1 (diff)
Fix DumpString to read the right amount of args
Previously it read too many args in the case where dex_file was null. Test: test-art-host Bug: 63756964 Change-Id: Ic7cef41ea29ec3717debf657f9a93c17e804f50e
Diffstat (limited to 'runtime/dex_instruction_test.cc')
-rw-r--r--runtime/dex_instruction_test.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/runtime/dex_instruction_test.cc b/runtime/dex_instruction_test.cc
index 95e4181a8e..3f7ac57cef 100644
--- a/runtime/dex_instruction_test.cc
+++ b/runtime/dex_instruction_test.cc
@@ -131,4 +131,41 @@ TEST(Instruction, PropertiesOf4rcc) {
ASSERT_FALSE(ins->HasVarArgs());
}
+static void Build35c(uint16_t* out,
+ Instruction::Code code,
+ uint16_t method_idx,
+ std::vector<uint16_t> args) {
+ out[0] = 0;
+ out[0] |= (args.size() << 12);
+ out[0] |= static_cast<uint16_t>(code);
+ out[1] = method_idx;
+ size_t i = 0;
+ out[2] = 0;
+ for (; i < 4 && i < args.size(); ++i) {
+ out[2] |= args[i] << (i * 4);
+ }
+ if (args.size() == 5) {
+ out[0] |= args[4] << 8;
+ }
+}
+
+static std::string DumpInst35c(Instruction::Code code,
+ uint16_t method_idx,
+ std::vector<uint16_t> args) {
+ uint16_t inst[6] = {};
+ Build35c(inst, code, method_idx, args);
+ return Instruction::At(inst)->DumpString(nullptr);
+}
+
+TEST(Instruction, DumpString) {
+ EXPECT_EQ(DumpInst35c(Instruction::FILLED_NEW_ARRAY, 1234, {3, 2}),
+ "filled-new-array {v3, v2}, type@1234");
+ EXPECT_EQ(DumpInst35c(Instruction::INVOKE_VIRTUAL, 1234, {3, 2, 1, 5, 6}),
+ "invoke-virtual {v3, v2, v1, v5, v6}, thing@1234");
+ EXPECT_EQ(DumpInst35c(Instruction::INVOKE_VIRTUAL_QUICK, 1234, {3, 2, 1, 5}),
+ "invoke-virtual-quick {v3, v2, v1, v5}, thing@1234");
+ EXPECT_EQ(DumpInst35c(Instruction::INVOKE_CUSTOM, 1234, {3, 2, 1}),
+ "invoke-custom {v3, v2, v1}, thing@1234");
+}
+
} // namespace art