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
diff --git a/Android.mk b/Android.mk
index 3502740..92f5c70 100644
--- a/Android.mk
+++ b/Android.mk
@@ -96,6 +96,7 @@
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 @@
$$(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-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 @@
.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 @@
.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 10dc2d3..c25925d 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -54,7 +54,7 @@
$(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 619b056..05d6693 100644
--- a/compiler/image_test.cc
+++ b/compiler/image_test.cc
@@ -42,7 +42,9 @@
};
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 @@
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 964cfe9..69e0950 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -426,8 +426,6 @@
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 041a66b..9f6b454 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -133,12 +133,7 @@
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 @@
}
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 @@
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 @@
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 @@
}
} 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 @@
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 @@
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 @@
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 @@
}
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 330a307..bbeb802 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -59,7 +59,7 @@
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 @@
" 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 @@
"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 @@
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 @@
}
}
- 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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 6550532..8366e71 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -824,13 +824,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 e68ad7f..f4a0426 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -115,7 +115,7 @@
$(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 997e84b..de6ba3f 100755
--- a/test/etc/host-run-test-jar
+++ b/test/etc/host-run-test-jar
@@ -93,7 +93,6 @@
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 0000000..6c385dc
--- /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 0a6c941..6db8cd0 100755
--- a/tools/art
+++ b/tools/art
@@ -33,9 +33,21 @@
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 \