diff options
-rw-r--r-- | runtime/Android.bp | 1 | ||||
-rw-r--r-- | runtime/dex_method_iterator.h | 143 | ||||
-rw-r--r-- | runtime/dex_method_iterator_test.cc | 49 |
3 files changed, 0 insertions, 193 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp index db9707f290..06e83b9102 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -555,7 +555,6 @@ art_cc_test { "dex_file_test.cc", "dex_file_verifier_test.cc", "dex_instruction_test.cc", - "dex_method_iterator_test.cc", "entrypoints/math_entrypoints_test.cc", "entrypoints/quick/quick_trampoline_entrypoints_test.cc", "entrypoints_order_test.cc", diff --git a/runtime/dex_method_iterator.h b/runtime/dex_method_iterator.h deleted file mode 100644 index a44bc16287..0000000000 --- a/runtime/dex_method_iterator.h +++ /dev/null @@ -1,143 +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_METHOD_ITERATOR_H_ -#define ART_RUNTIME_DEX_METHOD_ITERATOR_H_ - -#include <vector> - -#include "dex_file-inl.h" - -namespace art { - -class DexMethodIterator { - public: - explicit DexMethodIterator(const std::vector<const DexFile*>& dex_files) - : dex_files_(dex_files), - found_next_(false), - dex_file_index_(0), - class_def_index_(0), - class_def_(nullptr), - class_data_(nullptr), - direct_method_(false) { - CHECK_NE(0U, dex_files_.size()); - } - - bool HasNext() { - if (found_next_) { - return true; - } - while (true) { - // End of DexFiles, we are done. - if (dex_file_index_ == dex_files_.size()) { - return false; - } - if (class_def_index_ == GetDexFileInternal().NumClassDefs()) { - // End of this DexFile, advance and retry. - class_def_index_ = 0; - dex_file_index_++; - continue; - } - if (class_def_ == nullptr) { - class_def_ = &GetDexFileInternal().GetClassDef(class_def_index_); - } - if (class_data_ == nullptr) { - class_data_ = GetDexFileInternal().GetClassData(*class_def_); - if (class_data_ == nullptr) { - // empty class, such as a marker interface - // End of this class, advance and retry. - class_def_ = nullptr; - class_def_index_++; - continue; - } - } - if (it_.get() == nullptr) { - it_.reset(new ClassDataItemIterator(GetDexFileInternal(), class_data_)); - GetIterator().SkipAllFields(); - direct_method_ = true; - } - if (direct_method_ && GetIterator().HasNextDirectMethod()) { - // Found method - found_next_ = true; - return true; - } - direct_method_ = false; - if (GetIterator().HasNextVirtualMethod()) { - // Found method - found_next_ = true; - return true; - } - // End of this class, advance and retry. - DCHECK(!GetIterator().HasNext()); - it_.reset(nullptr); - class_data_ = nullptr; - class_def_ = nullptr; - class_def_index_++; - } - } - - void Next() { - found_next_ = false; - if (it_.get() != nullptr) { - // Advance to next method if we currently are looking at a class. - GetIterator().Next(); - } - } - - const DexFile& GetDexFile() { - CHECK(HasNext()); - return GetDexFileInternal(); - } - - uint32_t GetMemberIndex() { - CHECK(HasNext()); - return GetIterator().GetMemberIndex(); - } - - InvokeType GetInvokeType() { - CHECK(HasNext()); - CHECK(class_def_ != nullptr); - return GetIterator().GetMethodInvokeType(*class_def_); - } - - private: - ClassDataItemIterator& GetIterator() const { - CHECK(it_.get() != nullptr); - return *it_.get(); - } - - const DexFile& GetDexFileInternal() const { - CHECK_LT(dex_file_index_, dex_files_.size()); - const DexFile* dex_file = dex_files_[dex_file_index_]; - CHECK(dex_file != nullptr); - return *dex_file; - } - - const std::vector<const DexFile*>& dex_files_; - - bool found_next_; - - uint32_t dex_file_index_; - uint32_t class_def_index_; - const DexFile::ClassDef* class_def_; - const uint8_t* class_data_; - std::unique_ptr<ClassDataItemIterator> it_; - bool direct_method_; -}; - -} // namespace art - -#endif // ART_RUNTIME_DEX_METHOD_ITERATOR_H_ diff --git a/runtime/dex_method_iterator_test.cc b/runtime/dex_method_iterator_test.cc deleted file mode 100644 index e83829bb46..0000000000 --- a/runtime/dex_method_iterator_test.cc +++ /dev/null @@ -1,49 +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_method_iterator.h" - -#include "base/stl_util.h" -#include "common_runtime_test.h" -#include "oat_file.h" -#include "scoped_thread_state_change-inl.h" -#include "thread-current-inl.h" - -namespace art { - -class DexMethodIteratorTest : public CommonRuntimeTest { -}; - -TEST_F(DexMethodIteratorTest, Basic) { - ScopedObjectAccess soa(Thread::Current()); - std::vector<const DexFile*> dex_files; - CHECK_NE(boot_class_path_.size(), 0U); - for (size_t i = 0; i < boot_class_path_.size(); ++i) { - dex_files.push_back(boot_class_path_[i]); - } - DexMethodIterator it(dex_files); - while (it.HasNext()) { - const DexFile& dex_file = it.GetDexFile(); - InvokeType invoke_type = it.GetInvokeType(); - uint32_t method_idx = it.GetMemberIndex(); - if ((false)) { - LOG(INFO) << invoke_type << " " << dex_file.PrettyMethod(method_idx); - } - it.Next(); - } -} - -} // namespace art |