summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-02-28 15:21:07 +0000
committerNicolas Geoffray <ngeoffray@google.com>2014-03-04 16:30:48 +0000
commit9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40 (patch)
tree847912709f811adda0fa63e89e4bf8af27769f2e /runtime
parent093aad184b4451639951a7e012d9b55cbf8c8a07 (diff)
downloadart-9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40.zip
art-9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40.tar.gz
art-9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40.tar.bz2
Remove oat file location in the image.
The oat file is now always in the same directory, and has the same name as the image file. Only difference is the extension. This also removes the need for host-prefix. Change-Id: I16d1f7aeb1d58372d41921694664e9c321afc1ad
Diffstat (limited to 'runtime')
-rw-r--r--runtime/class_linker.cc6
-rw-r--r--runtime/common_runtime_test.h9
-rw-r--r--runtime/gc/space/image_space.cc14
-rw-r--r--runtime/gc/space/image_space.h2
-rw-r--r--runtime/image.cc2
-rw-r--r--runtime/image.h11
-rw-r--r--runtime/native/dalvik_system_DexFile.cc4
-rw-r--r--runtime/parsed_options.cc2
-rw-r--r--runtime/parsed_options.h1
-rw-r--r--runtime/parsed_options_test.cc2
-rw-r--r--runtime/runtime.cc3
-rw-r--r--runtime/runtime.h17
12 files changed, 29 insertions, 44 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 6550532..8366e71 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -824,13 +824,11 @@ bool ClassLinker::VerifyOatFileChecksums(const OatFile* oat_file,
if (!image_check) {
ScopedObjectAccess soa(Thread::Current());
- mirror::String* oat_location = image_header.GetImageRoot(ImageHeader::kOatLocation)->AsString();
- std::string image_file(oat_location->ToModifiedUtf8());
- *error_msg = StringPrintf("oat file '%s' mismatch (0x%x, %d) with '%s' (0x%x, %" PRIdPTR ")",
+ *error_msg = StringPrintf("oat file '%s' mismatch (0x%x, %d) with (0x%x, %" PRIdPTR ")",
oat_file->GetLocation().c_str(),
oat_file->GetOatHeader().GetImageFileLocationOatChecksum(),
oat_file->GetOatHeader().GetImageFileLocationOatDataBegin(),
- image_file.c_str(), image_oat_checksum, image_oat_data_begin);
+ image_oat_checksum, image_oat_data_begin);
}
if (!dex_check) {
*error_msg = StringPrintf("oat file '%s' mismatch (0x%x) with '%s' (0x%x)",
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index e2ecf4b..cef0703 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -19,6 +19,7 @@
#include <dirent.h>
#include <dlfcn.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -63,6 +64,14 @@ class ScratchFile {
file_.reset(new File(fd, GetFilename()));
}
+ ScratchFile(const ScratchFile& other, const char* suffix) {
+ filename_ = other.GetFilename();
+ filename_ += suffix;
+ int fd = open(filename_.c_str(), O_RDWR | O_CREAT, 0666);
+ CHECK_NE(-1, fd);
+ file_.reset(new File(fd, GetFilename()));
+ }
+
~ScratchFile() {
int unlink_result = unlink(filename_.c_str());
CHECK_EQ(0, unlink_result);
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 76c4d25..98d4eef 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -223,7 +223,7 @@ ImageSpace* ImageSpace::Init(const char* image_file_name, bool validate_oat_file
space->VerifyImageAllocations();
}
- space->oat_file_.reset(space->OpenOatFile(error_msg));
+ space->oat_file_.reset(space->OpenOatFile(image_file_name, error_msg));
if (space->oat_file_.get() == nullptr) {
DCHECK(!error_msg->empty());
return nullptr;
@@ -241,16 +241,10 @@ ImageSpace* ImageSpace::Init(const char* image_file_name, bool validate_oat_file
return space.release();
}
-OatFile* ImageSpace::OpenOatFile(std::string* error_msg) const {
- const Runtime* runtime = Runtime::Current();
+OatFile* ImageSpace::OpenOatFile(const char* image_path, std::string* error_msg) const {
const ImageHeader& image_header = GetImageHeader();
- // Grab location but don't use Object::AsString as we haven't yet initialized the roots to
- // check the down cast
- mirror::String* oat_location =
- down_cast<mirror::String*>(image_header.GetImageRoot(ImageHeader::kOatLocation));
- std::string oat_filename;
- oat_filename += runtime->GetHostPrefix();
- oat_filename += oat_location->ToModifiedUtf8();
+ std::string oat_filename = ImageHeader::GetOatLocationFromImageLocation(image_path);
+
OatFile* oat_file = OatFile::Open(oat_filename, oat_filename, image_header.GetOatDataBegin(),
!Runtime::Current()->IsCompiler(), error_msg);
if (oat_file == NULL) {
diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h
index 9e19774..116c498 100644
--- a/runtime/gc/space/image_space.h
+++ b/runtime/gc/space/image_space.h
@@ -86,7 +86,7 @@ class ImageSpace : public MemMapSpace {
static ImageSpace* Init(const char* image, bool validate_oat_file, std::string* error_msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- OatFile* OpenOatFile(std::string* error_msg) const
+ OatFile* OpenOatFile(const char* image, std::string* error_msg) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool ValidateOatFile(std::string* error_msg) const
diff --git a/runtime/image.cc b/runtime/image.cc
index 702cc9a..528bfc6 100644
--- a/runtime/image.cc
+++ b/runtime/image.cc
@@ -24,7 +24,7 @@
namespace art {
const byte ImageHeader::kImageMagic[] = { 'a', 'r', 't', '\n' };
-const byte ImageHeader::kImageVersion[] = { '0', '0', '6', '\0' };
+const byte ImageHeader::kImageVersion[] = { '0', '0', '7', '\0' };
ImageHeader::ImageHeader(uint32_t image_begin,
uint32_t image_size,
diff --git a/runtime/image.h b/runtime/image.h
index 246f106..ce2bc58 100644
--- a/runtime/image.h
+++ b/runtime/image.h
@@ -88,6 +88,16 @@ class PACKED(4) ImageHeader {
return RoundUp(image_size_, kPageSize);
}
+ static std::string GetOatLocationFromImageLocation(const std::string& image) {
+ std::string oat_filename = image;
+ if (oat_filename.length() <= 3) {
+ return oat_filename + ".oat";
+ } else {
+ oat_filename.replace(oat_filename.length() - 3, 3, "oat");
+ }
+ return oat_filename;
+ }
+
enum ImageRoot {
kResolutionMethod,
kImtConflictMethod,
@@ -95,7 +105,6 @@ class PACKED(4) ImageHeader {
kCalleeSaveMethod,
kRefsOnlySaveMethod,
kRefsAndArgsSaveMethod,
- kOatLocation,
kDexCaches,
kClassRoots,
kImageRootsMax,
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index 1a3ceb8..8a96d79 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -285,7 +285,7 @@ static jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename
ScopedObjectAccess soa(env);
LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location
<< " has out-of-date oat checksum compared to "
- << image_header.GetImageRoot(ImageHeader::kOatLocation)->AsString()->ToModifiedUtf8();
+ << oat_file->GetLocation();
}
return JNI_TRUE;
}
@@ -295,7 +295,7 @@ static jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename
ScopedObjectAccess soa(env);
LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location
<< " has out-of-date oat begin compared to "
- << image_header.GetImageRoot(ImageHeader::kOatLocation)->AsString()->ToModifiedUtf8();
+ << oat_file->GetLocation();
}
return JNI_TRUE;
}
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index c5b1c4b..765074a 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -427,8 +427,6 @@ bool ParsedOptions::Parse(const Runtime::Options& options, bool ignore_unrecogni
return false;
}
hook_abort_ = reinterpret_cast<void(*)()>(const_cast<void*>(hook));
- } else if (option == "host-prefix") {
- host_prefix_ = reinterpret_cast<const char*>(options[i].second);
} else if (option == "-Xmethod-trace") {
method_trace_ = true;
} else if (StartsWith(option, "-Xmethod-trace-file:")) {
diff --git a/runtime/parsed_options.h b/runtime/parsed_options.h
index b94956e..0af17ee 100644
--- a/runtime/parsed_options.h
+++ b/runtime/parsed_options.h
@@ -32,7 +32,6 @@ class ParsedOptions {
const std::vector<const DexFile*>* boot_class_path_;
std::string boot_class_path_string_;
std::string class_path_string_;
- std::string host_prefix_;
std::string image_;
bool check_jni_;
std::string jni_trace_;
diff --git a/runtime/parsed_options_test.cc b/runtime/parsed_options_test.cc
index 58353b1..7f293cd 100644
--- a/runtime/parsed_options_test.cc
+++ b/runtime/parsed_options_test.cc
@@ -50,7 +50,6 @@ TEST_F(ParsedOptionsTest, ParsedOptions) {
options.push_back(std::make_pair("-Dfoo=bar", null));
options.push_back(std::make_pair("-Dbaz=qux", null));
options.push_back(std::make_pair("-verbose:gc,class,jni", null));
- options.push_back(std::make_pair("host-prefix", "host_prefix"));
options.push_back(std::make_pair("vfprintf", test_vfprintf));
options.push_back(std::make_pair("abort", test_abort));
options.push_back(std::make_pair("exit", test_exit));
@@ -65,7 +64,6 @@ TEST_F(ParsedOptionsTest, ParsedOptions) {
EXPECT_EQ(4 * KB, parsed->heap_maximum_size_);
EXPECT_EQ(1 * MB, parsed->stack_size_);
EXPECT_EQ(0.75, parsed->heap_target_utilization_);
- EXPECT_EQ("host_prefix", parsed->host_prefix_);
EXPECT_TRUE(test_vfprintf == parsed->hook_vfprintf_);
EXPECT_TRUE(test_exit == parsed->hook_exit_);
EXPECT_TRUE(test_abort == parsed->hook_abort_);
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index ae9c983..e80a473 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -335,8 +335,6 @@ jobject CreateSystemClassLoader() {
bool Runtime::Start() {
VLOG(startup) << "Runtime::Start entering";
- CHECK(host_prefix_.empty()) << host_prefix_;
-
// Restore main thread state to kNative as expected by native code.
Thread* self = Thread::Current();
self->TransitionFromRunnableToSuspended(kNative);
@@ -477,7 +475,6 @@ bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) {
Monitor::Init(options->lock_profiling_threshold_, options->hook_is_sensitive_thread_);
- host_prefix_ = options->host_prefix_;
boot_class_path_string_ = options->boot_class_path_string_;
class_path_string_ = options->class_path_string_;
properties_ = options->properties_;
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 5ff334f..2b3f100 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -100,11 +100,6 @@ class Runtime {
return image_compiler_options_;
}
- const std::string& GetHostPrefix() const {
- DCHECK(!IsStarted());
- return host_prefix_;
- }
-
// Starts a runtime, which may cause threads to be started and code to run.
bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_);
@@ -419,18 +414,6 @@ class Runtime {
std::vector<std::string> compiler_options_;
std::vector<std::string> image_compiler_options_;
- // The host prefix is used during cross compilation. It is removed
- // from the start of host paths such as:
- // $ANDROID_PRODUCT_OUT/system/framework/boot.oat
- // to produce target paths such as
- // /system/framework/boot.oat
- // Similarly it is prepended to target paths to arrive back at a
- // host past. In both cases this is necessary because image and oat
- // files embedded expect paths of dependent files (an image points
- // to an oat file and an oat files to one or more dex files). These
- // files contain the expected target path.
- std::string host_prefix_;
-
std::string boot_class_path_string_;
std::string class_path_string_;
std::vector<std::string> properties_;