Revert "cleanup: Replace pointers with out-parameters and fix-up formatting"
This reverts commit a315f5c546b796f55f4872bb6efc15eb858d9639.
--
Revert "runtime: cleanup class_linker out-parameters and formatting"
This reverts commit bc1d78daa463572c5a770cdca858a3b51d8e1b7b.
--
Revert "base: replace raw pointers for out-parameters with safer out<T>"
This reverts commit fb326cffc679cab8eb873b9e44795706f023cb3c.
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 80fc7fa..a23d94d 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -32,7 +32,6 @@
#endif
#include "art_method-inl.h"
-#include "base/out.h"
#include "base/bit_vector.h"
#include "base/stl_util.h"
#include "base/unix_file/fd_file.h"
@@ -89,16 +88,16 @@
OatFile* OatFile::OpenWithElfFile(ElfFile* elf_file,
const std::string& location,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
std::unique_ptr<OatFile> oat_file(new OatFile(location, false));
oat_file->elf_file_.reset(elf_file);
uint64_t offset, size;
- bool has_section = elf_file->GetSectionOffsetAndSize(".rodata", outof(offset), outof(size));
+ bool has_section = elf_file->GetSectionOffsetAndSize(".rodata", &offset, &size);
CHECK(has_section);
oat_file->begin_ = elf_file->Begin() + offset;
oat_file->end_ = elf_file->Begin() + size + offset;
// Ignore the optional .bss section when opening non-executable.
- return oat_file->Setup(abs_dex_location, outof_forward(error_msg)) ? oat_file.release() : nullptr;
+ return oat_file->Setup(abs_dex_location, error_msg) ? oat_file.release() : nullptr;
}
OatFile* OatFile::Open(const std::string& filename,
@@ -107,7 +106,7 @@
uint8_t* oat_file_begin,
bool executable,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
CHECK(!filename.empty()) << location;
CheckLocation(location);
std::unique_ptr<OatFile> ret;
@@ -155,34 +154,27 @@
return ret.release();
}
-OatFile* OatFile::OpenWritable(File* file,
- const std::string& location,
+OatFile* OatFile::OpenWritable(File* file, const std::string& location,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
CheckLocation(location);
- return OpenElfFile(file, location, nullptr, nullptr, true, false, abs_dex_location,
- outof_forward(error_msg));
+ return OpenElfFile(file, location, nullptr, nullptr, true, false, abs_dex_location, error_msg);
}
-OatFile* OatFile::OpenReadable(File* file,
- const std::string& location,
+OatFile* OatFile::OpenReadable(File* file, const std::string& location,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
CheckLocation(location);
- return OpenElfFile(file, location, nullptr, nullptr, false, false, abs_dex_location,
- outof_forward(error_msg));
+ return OpenElfFile(file, location, nullptr, nullptr, false, false, abs_dex_location, error_msg);
}
OatFile* OatFile::OpenDlopen(const std::string& elf_filename,
const std::string& location,
uint8_t* requested_base,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
std::unique_ptr<OatFile> oat_file(new OatFile(location, true));
- bool success = oat_file->Dlopen(elf_filename,
- requested_base,
- abs_dex_location,
- outof_forward(error_msg));
+ bool success = oat_file->Dlopen(elf_filename, requested_base, abs_dex_location, error_msg);
if (!success) {
return nullptr;
}
@@ -196,10 +188,10 @@
bool writable,
bool executable,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
std::unique_ptr<OatFile> oat_file(new OatFile(location, executable));
bool success = oat_file->ElfFileOpen(file, requested_base, oat_file_begin, writable, executable,
- abs_dex_location, outof_forward(error_msg));
+ abs_dex_location, error_msg);
if (!success) {
CHECK(!error_msg->empty());
return nullptr;
@@ -208,13 +200,8 @@
}
OatFile::OatFile(const std::string& location, bool is_executable)
- : location_(location),
- begin_(nullptr),
- end_(nullptr),
- bss_begin_(nullptr),
- bss_end_(nullptr),
- is_executable_(is_executable),
- dlopen_handle_(nullptr),
+ : location_(location), begin_(nullptr), end_(nullptr), bss_begin_(nullptr), bss_end_(nullptr),
+ is_executable_(is_executable), dlopen_handle_(nullptr),
secondary_lookup_lock_("OatFile secondary lookup lock", kOatFileSecondaryLookupLock) {
CHECK(!location_.empty());
}
@@ -226,10 +213,8 @@
}
}
-bool OatFile::Dlopen(const std::string& elf_filename,
- uint8_t* requested_base,
- const char* abs_dex_location,
- out<std::string> error_msg) {
+bool OatFile::Dlopen(const std::string& elf_filename, uint8_t* requested_base,
+ const char* abs_dex_location, std::string* error_msg) {
#ifdef __APPLE__
// The dl_iterate_phdr syscall is missing. There is similar API on OSX,
// but let's fallback to the custom loading code for the time being.
@@ -334,28 +319,22 @@
LOG(ERROR) << "File " << elf_filename << " loaded with dlopen but can not find its mmaps.";
}
- return Setup(abs_dex_location, outof_forward(error_msg));
+ return Setup(abs_dex_location, error_msg);
#endif // __APPLE__
}
-bool OatFile::ElfFileOpen(File* file,
- uint8_t* requested_base,
- uint8_t* oat_file_begin,
- bool writable,
- bool executable,
+bool OatFile::ElfFileOpen(File* file, uint8_t* requested_base, uint8_t* oat_file_begin,
+ bool writable, bool executable,
const char* abs_dex_location,
- out<std::string> error_msg) {
+ std::string* error_msg) {
// TODO: rename requested_base to oat_data_begin
- elf_file_.reset(ElfFile::Open(file,
- writable,
- /*program_header_only*/true,
- outof_forward(error_msg),
+ elf_file_.reset(ElfFile::Open(file, writable, /*program_header_only*/true, error_msg,
oat_file_begin));
if (elf_file_ == nullptr) {
DCHECK(!error_msg->empty());
return false;
}
- bool loaded = elf_file_->Load(executable, outof_forward(error_msg));
+ bool loaded = elf_file_->Load(executable, error_msg);
if (!loaded) {
DCHECK(!error_msg->empty());
return false;
@@ -396,10 +375,10 @@
bss_end_ += sizeof(uint32_t);
}
- return Setup(abs_dex_location, outof_forward(error_msg));
+ return Setup(abs_dex_location, error_msg);
}
-bool OatFile::Setup(const char* abs_dex_location, out<std::string> error_msg) {
+bool OatFile::Setup(const char* abs_dex_location, std::string* error_msg) {
if (!GetOatHeader().IsValid()) {
std::string cause = GetOatHeader().GetValidationErrorMessage();
*error_msg = StringPrintf("Invalid oat header for '%s': %s", GetLocation().c_str(),
@@ -638,9 +617,9 @@
return reinterpret_cast<const DexFile::Header*>(dex_file_pointer_)->file_size_;
}
-std::unique_ptr<const DexFile> OatFile::OatDexFile::OpenDexFile(out<std::string> error_msg) const {
+std::unique_ptr<const DexFile> OatFile::OatDexFile::OpenDexFile(std::string* error_msg) const {
return DexFile::Open(dex_file_pointer_, FileSize(), dex_file_location_,
- dex_file_location_checksum_, this, outof_forward(error_msg));
+ dex_file_location_checksum_, this, error_msg);
}
uint32_t OatFile::OatDexFile::GetOatClassOffset(uint16_t class_def_index) const {
@@ -798,7 +777,7 @@
return out.str();
}
-bool OatFile::CheckStaticDexFileDependencies(const char* dex_dependencies, out<std::string> msg) {
+bool OatFile::CheckStaticDexFileDependencies(const char* dex_dependencies, std::string* msg) {
if (dex_dependencies == nullptr || dex_dependencies[0] == 0) {
// No dependencies.
return true;
@@ -807,7 +786,7 @@
// Assumption: this is not performance-critical. So it's OK to do this with a std::string and
// Split() instead of manual parsing of the combined char*.
std::vector<std::string> split;
- Split(dex_dependencies, kDexClassPathEncodingSeparator, outof(split));
+ Split(dex_dependencies, kDexClassPathEncodingSeparator, &split);
if (split.size() % 2 != 0) {
// Expected pairs of location and checksum.
*msg = StringPrintf("Odd number of elements in dependency list %s", dex_dependencies);
@@ -827,8 +806,8 @@
uint32_t dex_checksum;
std::string error_msg;
if (DexFile::GetChecksum(DexFile::GetDexCanonicalLocation(location.c_str()).c_str(),
- outof(dex_checksum),
- outof(error_msg))) {
+ &dex_checksum,
+ &error_msg)) {
if (converted != dex_checksum) {
*msg = StringPrintf("Checksums don't match for %s: %" PRId64 " vs %u",
location.c_str(), converted, dex_checksum);
@@ -847,7 +826,8 @@
}
bool OatFile::GetDexLocationsFromDependencies(const char* dex_dependencies,
- out<std::vector<std::string>> locations) {
+ std::vector<std::string>* locations) {
+ DCHECK(locations != nullptr);
if (dex_dependencies == nullptr || dex_dependencies[0] == 0) {
return true;
}
@@ -855,7 +835,7 @@
// Assumption: this is not performance-critical. So it's OK to do this with a std::string and
// Split() instead of manual parsing of the combined char*.
std::vector<std::string> split;
- Split(dex_dependencies, kDexClassPathEncodingSeparator, outof(split));
+ Split(dex_dependencies, kDexClassPathEncodingSeparator, &split);
if (split.size() % 2 != 0) {
// Expected pairs of location and checksum.
return false;