summaryrefslogtreecommitdiffstats
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
parent093aad184b4451639951a7e012d9b55cbf8c8a07 (diff)
downloadart-9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40.tar.gz
art-9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40.tar.bz2
art-9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40.zip
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
-rw-r--r--Android.mk15
-rw-r--r--build/Android.oat.mk2
-rw-r--r--compiler/image_test.cc6
-rw-r--r--compiler/image_writer.cc2
-rw-r--r--dex2oat/dex2oat.cc32
-rw-r--r--oatdump/oatdump.cc52
-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
-rw-r--r--test/Android.mk2
-rwxr-xr-xtest/etc/host-run-test-jar1
-rw-r--r--tools/Android.mk32
-rwxr-xr-xtools/art16
22 files changed, 104 insertions, 129 deletions
diff --git a/Android.mk b/Android.mk
index 35027400a8..92f5c7083e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -96,6 +96,7 @@ include $(art_path)/dex2oat/Android.mk
include $(art_path)/disassembler/Android.mk
include $(art_path)/oatdump/Android.mk
include $(art_path)/dalvikvm/Android.mk
+include $(art_path)/tools/Android.mk
include $(art_build_path)/Android.oat.mk
# ART_HOST_DEPENDENCIES depends on Android.executable.mk above for ART_HOST_EXECUTABLES
@@ -272,7 +273,7 @@ oat-target-$(1): $$(OUT_OAT_FILE)
$$(OUT_OAT_FILE): $(PRODUCT_OUT)/$(1) $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(DEX2OAT_DEPENDENCY)
@mkdir -p $$(dir $$@)
- $(DEX2OAT) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) --instruction-set-features=$(TARGET_INSTRUCTION_SET_FEATURES) --android-root=$(PRODUCT_OUT)/system
+ $(DEX2OAT) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --instruction-set=$(TARGET_ARCH) --instruction-set-features=$(TARGET_INSTRUCTION_SET_FEATURES) --android-root=$(PRODUCT_OUT)/system
endif
@@ -305,6 +306,14 @@ build-art-host: $(ART_HOST_EXECUTABLES) $(ART_HOST_GTEST_EXECUTABLES) $(HO
build-art-target: $(ART_TARGET_EXECUTABLES) $(ART_TARGET_GTEST_EXECUTABLES) $(TARGET_CORE_IMG_OUT) $(TARGET_OUT)/lib/libjavacore.so
########################################################################
+# "m art-host" for just building the files needed to run the art script
+.PHONY: art-host
+art-host: $(HOST_OUT_EXECUTABLES)/art $(HOST_OUT)/bin/dalvikvm $(HOST_OUT)/lib/libart.so $(HOST_OUT)/bin/dex2oat $(HOST_OUT_JAVA_LIBRARIES)/core.art $(HOST_OUT)/lib/libjavacore.so
+
+.PHONY: art-host-debug
+art-host-debug: art-host $(HOST_OUT)/lib/libartd.so $(HOST_OUT)/bin/dex2oatd
+
+########################################################################
# oatdump targets
ART_DUMP_OAT_PATH ?= $(OUT_DIR)
@@ -323,7 +332,7 @@ dump-oat-core: dump-oat-core-host dump-oat-core-target
.PHONY: dump-oat-core-host
ifeq ($(ART_BUILD_HOST),true)
dump-oat-core-host: $(HOST_CORE_IMG_OUT) $(OATDUMP)
- $(OATDUMP) --image=$(HOST_CORE_IMG_OUT) --output=$(ART_DUMP_OAT_PATH)/core.host.oatdump.txt --host-prefix=""
+ $(OATDUMP) --image=$(HOST_CORE_IMG_OUT) --output=$(ART_DUMP_OAT_PATH)/core.host.oatdump.txt
@echo Output in $(ART_DUMP_OAT_PATH)/core.host.oatdump.txt
endif
@@ -337,7 +346,7 @@ endif
.PHONY: dump-oat-boot
ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
dump-oat-boot: $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(OATDUMP)
- $(OATDUMP) --image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --output=$(ART_DUMP_OAT_PATH)/boot.oatdump.txt --host-prefix=$(DEXPREOPT_PRODUCT_DIR_FULL_PATH)
+ $(OATDUMP) --image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --output=$(ART_DUMP_OAT_PATH)/boot.oatdump.txt
@echo Output in $(ART_DUMP_OAT_PATH)/boot.oatdump.txt
endif
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index 10dc2d3fd2..c25925d5a7 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -54,7 +54,7 @@ $(TARGET_CORE_IMG_OUT): $(TARGET_CORE_DEX_FILES) $(DEX2OAT_DEPENDENCY)
$(hide) $(DEX2OAT) --runtime-arg -Xms16m --runtime-arg -Xmx16m --image-classes=$(PRELOADED_CLASSES) $(addprefix \
--dex-file=,$(TARGET_CORE_DEX_FILES)) $(addprefix --dex-location=,$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$(TARGET_CORE_OAT_OUT) \
--oat-location=$(TARGET_CORE_OAT) --image=$(TARGET_CORE_IMG_OUT) --base=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
- --instruction-set=$(TARGET_ARCH) --instruction-set-features=$(TARGET_INSTRUCTION_SET_FEATURES) --host-prefix=$(PRODUCT_OUT) --android-root=$(PRODUCT_OUT)/system
+ --instruction-set=$(TARGET_ARCH) --instruction-set-features=$(TARGET_INSTRUCTION_SET_FEATURES) --android-root=$(PRODUCT_OUT)/system
$(HOST_CORE_OAT_OUT): $(HOST_CORE_IMG_OUT)
diff --git a/compiler/image_test.cc b/compiler/image_test.cc
index 619b056f57..05d6693f70 100644
--- a/compiler/image_test.cc
+++ b/compiler/image_test.cc
@@ -42,7 +42,9 @@ class ImageTest : public CommonCompilerTest {
};
TEST_F(ImageTest, WriteRead) {
- ScratchFile tmp_elf;
+ // Create a root tmp file, to be the base of the .art and .oat temporary files.
+ ScratchFile tmp;
+ ScratchFile tmp_elf(tmp, "oat");
{
{
jobject class_loader = NULL;
@@ -75,7 +77,7 @@ TEST_F(ImageTest, WriteRead) {
UniquePtr<File> tmp_oat(OS::OpenFileReadWrite(tmp_elf.GetFilename().c_str()));
ASSERT_TRUE(tmp_oat.get() != NULL);
- ScratchFile tmp_image;
+ ScratchFile tmp_image(tmp, "art");
const uintptr_t requested_image_base = ART_BASE_ADDRESS;
{
ImageWriter writer(*compiler_driver_.get());
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index 964cfe99b2..69e09509f3 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -426,8 +426,6 @@ ObjectArray<Object>* ImageWriter::CreateImageRoots() const {
runtime->GetCalleeSaveMethod(Runtime::kRefsOnly));
image_roots->Set<false>(ImageHeader::kRefsAndArgsSaveMethod,
runtime->GetCalleeSaveMethod(Runtime::kRefsAndArgs));
- image_roots->Set<false>(ImageHeader::kOatLocation,
- String::AllocFromModifiedUtf8(self, oat_file_->GetLocation().c_str()));
image_roots->Set<false>(ImageHeader::kDexCaches, dex_caches);
image_roots->Set<false>(ImageHeader::kClassRoots, class_linker->GetClassRoots());
for (int i = 0; i < ImageHeader::kImageRootsMax; i++) {
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 041a66b34e..9f6b454cc9 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -133,12 +133,7 @@ static void Usage(const char* fmt, ...) {
UsageError("");
UsageError(" --boot-image=<file.art>: provide the image file for the boot class path.");
UsageError(" Example: --boot-image=/system/framework/boot.art");
- UsageError(" Default: <host-prefix>/system/framework/boot.art");
- UsageError("");
- UsageError(" --host-prefix=<path>: used to translate host paths to target paths during");
- UsageError(" cross compilation.");
- UsageError(" Example: --host-prefix=out/target/product/crespo");
- UsageError(" Default: $ANDROID_PRODUCT_OUT");
+ UsageError(" Default: $ANDROID_ROOT/system/framework/boot.art");
UsageError("");
UsageError(" --android-root=<path>: used to locate libraries for portable linking.");
UsageError(" Example: --android-root=out/host/linux-x86");
@@ -306,7 +301,6 @@ class Dex2Oat {
}
const CompilerDriver* CreateOatFile(const std::string& boot_image_option,
- const std::string* host_prefix,
const std::string& android_root,
bool is_host,
const std::vector<const DexFile*>& dex_files,
@@ -364,9 +358,6 @@ class Dex2Oat {
image_file_location_oat_data_begin =
reinterpret_cast<uintptr_t>(image_space->GetImageHeader().GetOatDataBegin());
image_file_location = image_space->GetImageFilename();
- if (host_prefix != NULL && StartsWith(image_file_location, host_prefix->c_str())) {
- image_file_location = image_file_location.substr(host_prefix->size());
- }
}
OatWriter oat_writer(dex_files,
@@ -725,7 +716,6 @@ static int dex2oat(int argc, char** argv) {
std::string image_filename;
std::string boot_image_filename;
uintptr_t image_base = 0;
- UniquePtr<std::string> host_prefix;
std::string android_root;
std::vector<const char*> runtime_args;
int thread_count = sysconf(_SC_NPROCESSORS_CONF);
@@ -826,8 +816,6 @@ static int dex2oat(int argc, char** argv) {
}
} else if (option.starts_with("--boot-image=")) {
boot_image_filename = option.substr(strlen("--boot-image=")).data();
- } else if (option.starts_with("--host-prefix=")) {
- host_prefix.reset(new std::string(option.substr(strlen("--host-prefix=")).data()));
} else if (option.starts_with("--android-root=")) {
android_root = option.substr(strlen("--android-root=")).data();
} else if (option.starts_with("--instruction-set=")) {
@@ -934,13 +922,6 @@ static int dex2oat(int argc, char** argv) {
Usage("--oat-fd should not be used with --image");
}
- if (host_prefix.get() == NULL) {
- const char* android_product_out = getenv("ANDROID_PRODUCT_OUT");
- if (android_product_out != NULL) {
- host_prefix.reset(new std::string(android_product_out));
- }
- }
-
if (android_root.empty()) {
const char* android_root_env_var = getenv("ANDROID_ROOT");
if (android_root_env_var == NULL) {
@@ -951,12 +932,7 @@ static int dex2oat(int argc, char** argv) {
bool image = (!image_filename.empty());
if (!image && boot_image_filename.empty()) {
- if (host_prefix.get() == NULL) {
- boot_image_filename += GetAndroidRoot();
- } else {
- boot_image_filename += *host_prefix.get();
- boot_image_filename += "/system";
- }
+ boot_image_filename += GetAndroidRoot();
boot_image_filename += "/framework/boot.art";
}
std::string boot_image_option;
@@ -1094,9 +1070,6 @@ static int dex2oat(int argc, char** argv) {
runtime_options.push_back(std::make_pair(boot_image_option.c_str(),
reinterpret_cast<void*>(NULL)));
}
- if (host_prefix.get() != NULL) {
- runtime_options.push_back(std::make_pair("host-prefix", host_prefix->c_str()));
- }
for (size_t i = 0; i < runtime_args.size(); i++) {
runtime_options.push_back(std::make_pair(runtime_args[i], reinterpret_cast<void*>(NULL)));
}
@@ -1220,7 +1193,6 @@ static int dex2oat(int argc, char** argv) {
}
UniquePtr<const CompilerDriver> compiler(dex2oat->CreateOatFile(boot_image_option,
- host_prefix.get(),
android_root,
is_host,
dex_files,
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 330a307df7..bbeb802617 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -59,7 +59,7 @@ namespace art {
static void usage() {
fprintf(stderr,
"Usage: oatdump [options] ...\n"
- " Example: oatdump --image=$ANDROID_PRODUCT_OUT/system/framework/boot.art --host-prefix=$ANDROID_PRODUCT_OUT\n"
+ " Example: oatdump --image=$ANDROID_PRODUCT_OUT/system/framework/boot.art\n"
" Example: adb shell oatdump --image=/system/framework/boot.art\n"
"\n");
fprintf(stderr,
@@ -75,12 +75,6 @@ static void usage() {
" Example: --boot-image=/system/framework/boot.art\n"
"\n");
fprintf(stderr,
- " --host-prefix may be used to translate host paths to target paths during\n"
- " cross compilation.\n"
- " Example: --host-prefix=out/target/product/crespo\n"
- " Default: $ANDROID_PRODUCT_OUT\n"
- "\n");
- fprintf(stderr,
" --output=<file> may be used to send the output to a file.\n"
" Example: --output=/tmp/oatdump.txt\n"
"\n");
@@ -99,16 +93,14 @@ const char* image_roots_descriptions_[] = {
"kCalleeSaveMethod",
"kRefsOnlySaveMethod",
"kRefsAndArgsSaveMethod",
- "kOatLocation",
"kDexCaches",
"kClassRoots",
};
class OatDumper {
public:
- explicit OatDumper(const std::string& host_prefix, const OatFile& oat_file, bool dump_raw_mapping_table, bool dump_raw_gc_map)
- : host_prefix_(host_prefix),
- oat_file_(oat_file),
+ explicit OatDumper(const OatFile& oat_file, bool dump_raw_mapping_table, bool dump_raw_gc_map)
+ : oat_file_(oat_file),
oat_dex_files_(oat_file.GetOatDexFiles()),
dump_raw_mapping_table_(dump_raw_mapping_table),
dump_raw_gc_map_(dump_raw_gc_map),
@@ -146,9 +138,6 @@ class OatDumper {
os << "IMAGE FILE LOCATION:\n";
const std::string image_file_location(oat_header.GetImageFileLocation());
os << image_file_location;
- if (!image_file_location.empty() && !host_prefix_.empty()) {
- os << " (" << host_prefix_ << image_file_location << ")";
- }
os << "\n\n";
os << "BEGIN:\n";
@@ -702,7 +691,6 @@ class OatDumper {
}
}
- const std::string host_prefix_;
const OatFile& oat_file_;
std::vector<const OatFile::OatDexFile*> oat_dex_files_;
bool dump_raw_mapping_table_;
@@ -714,10 +702,10 @@ class OatDumper {
class ImageDumper {
public:
explicit ImageDumper(std::ostream* os, const std::string& image_filename,
- const std::string& host_prefix, gc::space::ImageSpace& image_space,
+ gc::space::ImageSpace& image_space,
const ImageHeader& image_header, bool dump_raw_mapping_table,
bool dump_raw_gc_map)
- : os_(os), image_filename_(image_filename), host_prefix_(host_prefix),
+ : os_(os), image_filename_(image_filename),
image_space_(image_space), image_header_(image_header),
dump_raw_mapping_table_(dump_raw_mapping_table),
dump_raw_gc_map_(dump_raw_gc_map) {}
@@ -784,13 +772,8 @@ class ImageDumper {
os << "\n";
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
- mirror::Object* oat_location_object = image_header_.GetImageRoot(ImageHeader::kOatLocation);
- std::string oat_location(oat_location_object->AsString()->ToModifiedUtf8());
+ std::string oat_location = ImageHeader::GetOatLocationFromImageLocation(image_filename_);
os << "OAT LOCATION: " << oat_location;
- if (!host_prefix_.empty()) {
- oat_location = host_prefix_ + oat_location;
- os << " (" << oat_location << ")";
- }
os << "\n";
std::string error_msg;
const OatFile* oat_file = class_linker->FindOatFileFromOatLocation(oat_location, &error_msg);
@@ -802,7 +785,7 @@ class ImageDumper {
stats_.oat_file_bytes = oat_file->Size();
- oat_dumper_.reset(new OatDumper(host_prefix_, *oat_file, dump_raw_mapping_table_,
+ oat_dumper_.reset(new OatDumper(*oat_file, dump_raw_mapping_table_,
dump_raw_gc_map_));
for (const OatFile::OatDexFile* oat_dex_file : oat_file->GetOatDexFiles()) {
@@ -1424,7 +1407,6 @@ class ImageDumper {
UniquePtr<OatDumper> oat_dumper_;
std::ostream* os_;
const std::string image_filename_;
- const std::string host_prefix_;
gc::space::ImageSpace& image_space_;
const ImageHeader& image_header_;
bool dump_raw_mapping_table_;
@@ -1449,7 +1431,6 @@ static int oatdump(int argc, char** argv) {
const char* image_filename = NULL;
const char* boot_image_filename = NULL;
std::string elf_filename_prefix;
- UniquePtr<std::string> host_prefix;
std::ostream* os = &std::cout;
UniquePtr<std::ofstream> out;
bool dump_raw_mapping_table = false;
@@ -1463,8 +1444,6 @@ static int oatdump(int argc, char** argv) {
image_filename = option.substr(strlen("--image=")).data();
} else if (option.starts_with("--boot-image=")) {
boot_image_filename = option.substr(strlen("--boot-image=")).data();
- } else if (option.starts_with("--host-prefix=")) {
- host_prefix.reset(new std::string(option.substr(strlen("--host-prefix=")).data()));
} else if (option.starts_with("--dump:")) {
if (option == "--dump:raw_mapping_table") {
dump_raw_mapping_table = true;
@@ -1498,15 +1477,6 @@ static int oatdump(int argc, char** argv) {
return EXIT_FAILURE;
}
- if (host_prefix.get() == NULL) {
- const char* android_product_out = getenv("ANDROID_PRODUCT_OUT");
- if (android_product_out != NULL) {
- host_prefix.reset(new std::string(android_product_out));
- } else {
- host_prefix.reset(new std::string(""));
- }
- }
-
if (oat_filename != NULL) {
std::string error_msg;
OatFile* oat_file =
@@ -1515,7 +1485,7 @@ static int oatdump(int argc, char** argv) {
fprintf(stderr, "Failed to open oat file from '%s': %s\n", oat_filename, error_msg.c_str());
return EXIT_FAILURE;
}
- OatDumper oat_dumper(*host_prefix.get(), *oat_file, dump_raw_mapping_table, dump_raw_gc_map);
+ OatDumper oat_dumper(*oat_file, dump_raw_mapping_table, dump_raw_gc_map);
oat_dumper.Dump(*os);
return EXIT_SUCCESS;
}
@@ -1545,10 +1515,6 @@ static int oatdump(int argc, char** argv) {
options.push_back(std::make_pair(image_option.c_str(), reinterpret_cast<void*>(NULL)));
}
- if (!host_prefix->empty()) {
- options.push_back(std::make_pair("host-prefix", host_prefix->c_str()));
- }
-
if (!Runtime::Create(options, false)) {
fprintf(stderr, "Failed to create runtime\n");
return EXIT_FAILURE;
@@ -1566,7 +1532,7 @@ static int oatdump(int argc, char** argv) {
fprintf(stderr, "Invalid image header %s\n", image_filename);
return EXIT_FAILURE;
}
- ImageDumper image_dumper(os, image_filename, *host_prefix.get(), *image_space, image_header,
+ ImageDumper image_dumper(os, image_filename, *image_space, image_header,
dump_raw_mapping_table, dump_raw_gc_map);
image_dumper.Dump();
return EXIT_SUCCESS;
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 6550532f3b..8366e7142e 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 e2ecf4b0b9..cef0703691 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 76c4d25480..98d4eefe50 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 9e19774b23..116c49863c 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 702cc9a677..528bfc631c 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 246f106382..ce2bc587e3 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 1a3ceb80d8..8a96d7928c 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 c5b1c4b558..765074ad95 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 b94956e84a..0af17eef8a 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 58353b13a2..7f293cdb5a 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 ae9c9836c2..e80a473156 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 5ff334f6be..2b3f100411 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_;
diff --git a/test/Android.mk b/test/Android.mk
index e68ad7fa71..f4a0426bf1 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -115,7 +115,7 @@ test-art-target-oat-$(1): $(ART_TEST_OUT)/oat-test-dex-$(1).jar test-art-target-
$(hide) rm /tmp/test-art-target-oat-$(1)
$(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex: $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).jar $(HOST_CORE_IMG_OUT) | $(DEX2OAT)
- $(DEX2OAT) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$(PWD)/$$< --oat-file=$(PWD)/$$@ --instruction-set=$(HOST_ARCH) --host --host-prefix="" --android-root=$(HOST_OUT)
+ $(DEX2OAT) --runtime-arg -Xms16m --runtime-arg -Xmx16m --boot-image=$(HOST_CORE_IMG_OUT) --dex-file=$(PWD)/$$< --oat-file=$(PWD)/$$@ --instruction-set=$(HOST_ARCH) --host --android-root=$(HOST_OUT)
.PHONY: test-art-host-oat-default-$(1)
test-art-host-oat-default-$(1): $(HOST_OUT_JAVA_LIBRARIES)/oat-test-dex-$(1).odex test-art-host-dependencies
diff --git a/test/etc/host-run-test-jar b/test/etc/host-run-test-jar
index 997e84b7f0..de6ba3fcc4 100755
--- a/test/etc/host-run-test-jar
+++ b/test/etc/host-run-test-jar
@@ -93,7 +93,6 @@ export ANDROID_DATA="$DEX_LOCATION"
export ANDROID_ROOT="${ANDROID_HOST_OUT}"
export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
-unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
exe="${ANDROID_ROOT}/bin/dalvikvm"
diff --git a/tools/Android.mk b/tools/Android.mk
new file mode 100644
index 0000000000..6c385dcb45
--- /dev/null
+++ b/tools/Android.mk
@@ -0,0 +1,32 @@
+#
+# Copyright (C) 2014 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(WITH_HOST_DALVIK),true)
+# Copy the art shell script to the host's bin directory
+include $(CLEAR_VARS)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE := art
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/art $(ACP)
+ @echo "Copy: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-new-target)
+ $(hide) chmod 755 $@
+
+endif
diff --git a/tools/art b/tools/art
index 0a6c941347..6db8cd05a1 100755
--- a/tools/art
+++ b/tools/art
@@ -33,9 +33,21 @@ while true; do
fi
done
-unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
+function follow_links() {
+ file="$1"
+ while [ -h "$file" ]; do
+ # On Mac OS, readlink -f doesn't work.
+ file="$(readlink "$file")"
+ done
+ echo "$file"
+}
+
+PROG_NAME="$(follow_links "$BASH_SOURCE")"
+PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
+ANDROID_BUILD_TOP="$(cd "${PROG_DIR}/../../../../" ; pwd -P)/"
+ANDROID_HOST_OUT=$PROG_DIR/..
+
mkdir -p /tmp/android-data/dalvik-cache
-cd $ANDROID_BUILD_TOP
ANDROID_DATA=/tmp/android-data \
ANDROID_ROOT=$ANDROID_HOST_OUT \
LD_LIBRARY_PATH=$ANDROID_HOST_OUT/lib \