diff options
-rw-r--r-- | runtime/Android.bp | 1 | ||||
-rw-r--r-- | runtime/dex_instruction_visitor.h | 72 | ||||
-rw-r--r-- | runtime/dex_instruction_visitor_test.cc | 69 | ||||
-rw-r--r-- | runtime/verifier/method_verifier.cc | 1 |
4 files changed, 0 insertions, 143 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp index 186996894e..8ee5498115 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -539,7 +539,6 @@ art_cc_test { "dex_file_test.cc", "dex_file_verifier_test.cc", "dex_instruction_test.cc", - "dex_instruction_visitor_test.cc", "dex_method_iterator_test.cc", "entrypoints/math_entrypoints_test.cc", "entrypoints/quick/quick_trampoline_entrypoints_test.cc", diff --git a/runtime/dex_instruction_visitor.h b/runtime/dex_instruction_visitor.h deleted file mode 100644 index 42af6a9c4f..0000000000 --- a/runtime/dex_instruction_visitor.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ -#define ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ - -#include "base/macros.h" -#include "dex_instruction.h" - -namespace art { - -template<typename T> -class DexInstructionVisitor { - public: - void Visit(const uint16_t* code, size_t size_in_bytes) { - T* derived = static_cast<T*>(this); - size_t size_in_code_units = size_in_bytes / sizeof(uint16_t); - size_t i = 0; - while (i < size_in_code_units) { - const Instruction* inst = Instruction::At(&code[i]); - switch (inst->Opcode()) { -#define INSTRUCTION_CASE(o, cname, p, f, i, a, v) \ - case Instruction::cname: { \ - derived->Do_ ## cname(inst); \ - break; \ - } -#include "dex_instruction_list.h" - DEX_INSTRUCTION_LIST(INSTRUCTION_CASE) -#undef DEX_INSTRUCTION_LIST -#undef INSTRUCTION_CASE - default: - CHECK(false); - } - i += inst->SizeInCodeUnits(); - } - } - - private: - // Specific handlers for each instruction. -#define INSTRUCTION_VISITOR(o, cname, p, f, i, a, v) \ - void Do_ ## cname(const Instruction* inst) { \ - T* derived = static_cast<T*>(this); \ - derived->Do_Default(inst); \ - } -#include "dex_instruction_list.h" - DEX_INSTRUCTION_LIST(INSTRUCTION_VISITOR) -#undef DEX_INSTRUCTION_LIST -#undef INSTRUCTION_VISITOR - - // The default instruction handler. - void Do_Default(const Instruction*) { - return; - } -}; - - -} // namespace art - -#endif // ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ diff --git a/runtime/dex_instruction_visitor_test.cc b/runtime/dex_instruction_visitor_test.cc deleted file mode 100644 index 5273084a9a..0000000000 --- a/runtime/dex_instruction_visitor_test.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dex_instruction_visitor.h" - -#include <memory> - -#include "gtest/gtest.h" - -namespace art { - -class TestVisitor : public DexInstructionVisitor<TestVisitor> {}; - -TEST(InstructionTest, Init) { - std::unique_ptr<TestVisitor> visitor(new TestVisitor); -} - -class CountVisitor : public DexInstructionVisitor<CountVisitor> { - public: - int count_; - - CountVisitor() : count_(0) {} - - void Do_Default(const Instruction*) { - ++count_; - } -}; - -TEST(InstructionTest, Count) { - CountVisitor v0; - const uint16_t c0[] = {}; - v0.Visit(c0, sizeof(c0)); - EXPECT_EQ(0, v0.count_); - - CountVisitor v1; - const uint16_t c1[] = { 0 }; - v1.Visit(c1, sizeof(c1)); - EXPECT_EQ(1, v1.count_); - - CountVisitor v2; - const uint16_t c2[] = { 0, 0 }; - v2.Visit(c2, sizeof(c2)); - EXPECT_EQ(2, v2.count_); - - CountVisitor v3; - const uint16_t c3[] = { 0, 0, 0, }; - v3.Visit(c3, sizeof(c3)); - EXPECT_EQ(3, v3.count_); - - CountVisitor v4; - const uint16_t c4[] = { 0, 0, 0, 0 }; - v4.Visit(c4, sizeof(c4)); - EXPECT_EQ(4, v4.count_); -} - -} // namespace art diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index cb9c6052a2..acc918d326 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -33,7 +33,6 @@ #include "dex_file-inl.h" #include "dex_instruction-inl.h" #include "dex_instruction_utils.h" -#include "dex_instruction_visitor.h" #include "experimental_flags.h" #include "gc/accounting/card_table-inl.h" #include "handle_scope-inl.h" |