Directory restructuring of object.h
Break object.h into constituent files.
Reduce number of #includes in other GC header files.
Introduce -inl.h files to avoid mirror files #include-ing each other.
Check invariants of verifier RegTypes for all constructors.
Change-Id: Iecf1171c02910ac152d52947330ef456df4043bc
diff --git a/src/dex_file.cc b/src/dex_file.cc
index 7398616..e67e767 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -30,7 +30,10 @@
#include "dex_file_verifier.h"
#include "globals.h"
#include "leb128.h"
-#include "object.h"
+#include "mirror/abstract_method-inl.h"
+#include "mirror/field.h"
+#include "mirror/field-inl.h"
+#include "mirror/string.h"
#include "os.h"
#include "safe_map.h"
#include "thread.h"
@@ -94,6 +97,14 @@
return DexFile::OpenFile(filename, location, true);
}
+int DexFile::GetPermissions() const {
+ if (mem_map_.get() == NULL) {
+ return 0;
+ } else {
+ return mem_map_->GetProtect();
+ }
+}
+
const DexFile* DexFile::OpenFile(const std::string& filename,
const std::string& location,
bool verify) {
@@ -146,7 +157,6 @@
const char* DexFile::kClassesDex = "classes.dex";
-// Open classes.dex from within a .zip, .jar, .apk, ...
const DexFile* DexFile::OpenZip(const std::string& filename,
const std::string& location) {
UniquePtr<ZipArchive> zip_archive(ZipArchive::Open(filename));
@@ -157,6 +167,16 @@
return DexFile::Open(*zip_archive.get(), location);
}
+const DexFile* DexFile::OpenMemory(const std::string& location,
+ uint32_t location_checksum,
+ MemMap* mem_map) {
+ return OpenMemory(mem_map->Begin(),
+ mem_map->Size(),
+ location,
+ location_checksum,
+ mem_map);
+}
+
const DexFile* DexFile::Open(const ZipArchive& zip_archive, const std::string& location) {
CHECK(!location.empty());
UniquePtr<ZipEntry> zip_entry(zip_archive.Find(kClassesDex));
@@ -584,7 +604,7 @@
return descriptor;
}
-int32_t DexFile::GetLineNumFromPC(const AbstractMethod* method, uint32_t rel_pc) const {
+int32_t DexFile::GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const {
// For native method, lineno should be -2 to indicate it is native. Note that
// "line number == -2" is how libcore tells from StackTraceElement.
if (method->GetCodeItemOffset() == 0) {
@@ -601,6 +621,12 @@
return context.line_num_;
}
+const DexFile::TryItem* DexFile::GetTryItems(const CodeItem& code_item, uint32_t offset) {
+ const uint16_t* insns_end_ = &code_item.insns_[code_item.insns_size_in_code_units_];
+ return reinterpret_cast<const TryItem*>
+ (RoundUp(reinterpret_cast<uint32_t>(insns_end_), 4)) + offset;
+}
+
int32_t DexFile::FindCatchHandlerOffset(const CodeItem &code_item, int32_t tries_size,
uint32_t address) {
// Note: Signed type is important for max and min.
@@ -900,8 +926,8 @@
}
EncodedStaticFieldValueIterator::EncodedStaticFieldValueIterator(const DexFile& dex_file,
- DexCache* dex_cache,
- ClassLoader* class_loader,
+ mirror::DexCache* dex_cache,
+ mirror::ClassLoader* class_loader,
ClassLinker* linker,
const DexFile::ClassDef& class_def)
: dex_file_(dex_file), dex_cache_(dex_cache), class_loader_(class_loader), linker_(linker),
@@ -976,7 +1002,7 @@
ptr_ += width;
}
-void EncodedStaticFieldValueIterator::ReadValueToField(Field* field) const {
+void EncodedStaticFieldValueIterator::ReadValueToField(mirror::Field* field) const {
switch (type_) {
case kBoolean: field->SetBoolean(field->GetDeclaringClass(), jval_.z); break;
case kByte: field->SetByte(field->GetDeclaringClass(), jval_.b); break;
@@ -988,12 +1014,12 @@
case kDouble: field->SetDouble(field->GetDeclaringClass(), jval_.d); break;
case kNull: field->SetObject(field->GetDeclaringClass(), NULL); break;
case kString: {
- String* resolved = linker_->ResolveString(dex_file_, jval_.i, dex_cache_);
+ mirror::String* resolved = linker_->ResolveString(dex_file_, jval_.i, dex_cache_);
field->SetObject(field->GetDeclaringClass(), resolved);
break;
}
case kType: {
- Class* resolved = linker_->ResolveType(dex_file_, jval_.i, dex_cache_, class_loader_);
+ mirror::Class* resolved = linker_->ResolveType(dex_file_, jval_.i, dex_cache_, class_loader_);
field->SetObject(field->GetDeclaringClass(), resolved);
break;
}