summaryrefslogtreecommitdiffstats
path: root/runtime/oat_file.h
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-03-31 15:57:54 -0700
committerRichard Uhler <ruhler@google.com>2015-04-02 09:47:03 -0700
commit07b3c2351bb527ea91c084dc19434600af9ae66b (patch)
treeb286122b660ce16abae1e56c57b957b8c69c9531 /runtime/oat_file.h
parentdcff612c3a6e1427749771c4559f198fa480f709 (diff)
downloadart-07b3c2351bb527ea91c084dc19434600af9ae66b.tar.gz
art-07b3c2351bb527ea91c084dc19434600af9ae66b.tar.bz2
art-07b3c2351bb527ea91c084dc19434600af9ae66b.zip
Store OatDexFile instead of OatFile in DexFile.
This requires moving OatDexFile out of the OatFile class so that a forward class declaration can be used for OatDexFile. Bug: 19071355 Change-Id: Ibda85b78d0577e9e81073090616fc0f2fa526be3
Diffstat (limited to 'runtime/oat_file.h')
-rw-r--r--runtime/oat_file.h128
1 files changed, 66 insertions, 62 deletions
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index 51952f318c..2b9ef9da71 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -37,9 +37,12 @@ class ElfFile;
class MemMap;
class OatMethodOffsets;
class OatHeader;
+class OatDexFile;
-class OatFile {
+class OatFile FINAL {
public:
+ typedef art::OatDexFile OatDexFile;
+
// Opens an oat file contained within the given elf file. This is always opened as
// non-executable at the moment.
static OatFile* OpenWithElfFile(ElfFile* elf_file, const std::string& location,
@@ -90,9 +93,7 @@ class OatFile {
const OatHeader& GetOatHeader() const;
- class OatDexFile;
-
- class OatMethod {
+ class OatMethod FINAL {
public:
void LinkMethod(mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -156,7 +157,7 @@ class OatFile {
friend class OatClass;
};
- class OatClass {
+ class OatClass FINAL {
public:
mirror::Class::Status GetStatus() const {
return status_;
@@ -207,63 +208,8 @@ class OatFile {
const OatMethodOffsets* const methods_pointer_;
- friend class OatDexFile;
+ friend class art::OatDexFile;
};
-
- class OatDexFile {
- public:
- // Opens the DexFile referred to by this OatDexFile from within the containing OatFile.
- std::unique_ptr<const DexFile> OpenDexFile(std::string* error_msg) const;
-
- const OatFile* GetOatFile() const {
- return oat_file_;
- }
-
- // Returns the size of the DexFile refered to by this OatDexFile.
- size_t FileSize() const;
-
- // Returns original path of DexFile that was the source of this OatDexFile.
- const std::string& GetDexFileLocation() const {
- return dex_file_location_;
- }
-
- // Returns the canonical location of DexFile that was the source of this OatDexFile.
- const std::string& GetCanonicalDexFileLocation() const {
- return canonical_dex_file_location_;
- }
-
- // Returns checksum of original DexFile that was the source of this OatDexFile;
- uint32_t GetDexFileLocationChecksum() const {
- return dex_file_location_checksum_;
- }
-
- // Returns the OatClass for the class specified by the given DexFile class_def_index.
- OatClass GetOatClass(uint16_t class_def_index) const;
-
- // Returns the offset to the OatClass information. Most callers should use GetOatClass.
- uint32_t GetOatClassOffset(uint16_t class_def_index) const;
-
- ~OatDexFile();
-
- private:
- OatDexFile(const OatFile* oat_file,
- const std::string& dex_file_location,
- const std::string& canonical_dex_file_location,
- uint32_t dex_file_checksum,
- const uint8_t* dex_file_pointer,
- const uint32_t* oat_class_offsets_pointer);
-
- const OatFile* const oat_file_;
- const std::string dex_file_location_;
- const std::string canonical_dex_file_location_;
- const uint32_t dex_file_location_checksum_;
- const uint8_t* const dex_file_pointer_;
- const uint32_t* const oat_class_offsets_pointer_;
-
- friend class OatFile;
- DISALLOW_COPY_AND_ASSIGN(OatDexFile);
- };
-
const OatDexFile* GetOatDexFile(const char* dex_location,
const uint32_t* const dex_location_checksum,
bool exception_if_not_found = true) const
@@ -382,11 +328,69 @@ class OatFile {
mutable std::list<std::string> string_cache_ GUARDED_BY(secondary_lookup_lock_);
friend class OatClass;
- friend class OatDexFile;
+ friend class art::OatDexFile;
friend class OatDumper; // For GetBase and GetLimit
DISALLOW_COPY_AND_ASSIGN(OatFile);
};
+// OatDexFile should be an inner class of OatFile. Unfortunately, C++ doesn't
+// support forward declarations of inner classes, and we want to
+// forward-declare OatDexFile so that we can store an opaque pointer to an
+// OatDexFile in DexFile.
+class OatDexFile FINAL {
+ public:
+ // Opens the DexFile referred to by this OatDexFile from within the containing OatFile.
+ std::unique_ptr<const DexFile> OpenDexFile(std::string* error_msg) const;
+
+ const OatFile* GetOatFile() const {
+ return oat_file_;
+ }
+
+ // Returns the size of the DexFile refered to by this OatDexFile.
+ size_t FileSize() const;
+
+ // Returns original path of DexFile that was the source of this OatDexFile.
+ const std::string& GetDexFileLocation() const {
+ return dex_file_location_;
+ }
+
+ // Returns the canonical location of DexFile that was the source of this OatDexFile.
+ const std::string& GetCanonicalDexFileLocation() const {
+ return canonical_dex_file_location_;
+ }
+
+ // Returns checksum of original DexFile that was the source of this OatDexFile;
+ uint32_t GetDexFileLocationChecksum() const {
+ return dex_file_location_checksum_;
+ }
+
+ // Returns the OatClass for the class specified by the given DexFile class_def_index.
+ OatFile::OatClass GetOatClass(uint16_t class_def_index) const;
+
+ // Returns the offset to the OatClass information. Most callers should use GetOatClass.
+ uint32_t GetOatClassOffset(uint16_t class_def_index) const;
+
+ ~OatDexFile();
+
+ private:
+ OatDexFile(const OatFile* oat_file,
+ const std::string& dex_file_location,
+ const std::string& canonical_dex_file_location,
+ uint32_t dex_file_checksum,
+ const uint8_t* dex_file_pointer,
+ const uint32_t* oat_class_offsets_pointer);
+
+ const OatFile* const oat_file_;
+ const std::string dex_file_location_;
+ const std::string canonical_dex_file_location_;
+ const uint32_t dex_file_location_checksum_;
+ const uint8_t* const dex_file_pointer_;
+ const uint32_t* const oat_class_offsets_pointer_;
+
+ friend class OatFile;
+ DISALLOW_COPY_AND_ASSIGN(OatDexFile);
+};
+
} // namespace art
#endif // ART_RUNTIME_OAT_FILE_H_