summaryrefslogtreecommitdiffstats
path: root/runtime/common_test.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/common_test.h')
-rw-r--r--runtime/common_test.h116
1 files changed, 62 insertions, 54 deletions
diff --git a/runtime/common_test.h b/runtime/common_test.h
index a75a513..daa2ff1 100644
--- a/runtime/common_test.h
+++ b/runtime/common_test.h
@@ -26,7 +26,7 @@
#include "../../external/icu4c/common/unicode/uvernum.h"
#include "../compiler/dex/quick/dex_file_to_method_inliner_map.h"
-#include "../compiler/dex/verified_methods_data.h"
+#include "../compiler/dex/verification_results.h"
#include "../compiler/driver/compiler_driver.h"
#include "base/macros.h"
#include "base/stl_util.h"
@@ -48,6 +48,7 @@
#include "scoped_thread_state_change.h"
#include "ScopedLocalRef.h"
#include "thread.h"
+#include "utils.h"
#include "UniquePtr.h"
#include "verifier/method_verifier.h"
#include "verifier/method_verifier-inl.h"
@@ -160,11 +161,7 @@ class ScratchFile {
#if defined(__arm__)
-
-#include <signal.h>
-#include <asm/sigcontext.h>
-#include <asm-generic/ucontext.h>
-
+#include <sys/ucontext.h>
// A signal handler called when have an illegal instruction. We record the fact in
// a global boolean and then increment the PC in the signal context to return to
@@ -266,11 +263,6 @@ static InstructionSetFeatures ParseFeatureList(std::string str) {
class CommonTest : public testing::Test {
public:
- static void MakeExecutable(const mirror::ByteArray* code_array) {
- CHECK(code_array != NULL);
- MakeExecutable(code_array->GetData(), code_array->GetLength());
- }
-
static void MakeExecutable(const std::vector<uint8_t>& code) {
CHECK_NE(code.size(), 0U);
MakeExecutable(&code[0], code.size());
@@ -284,31 +276,39 @@ class CommonTest : public testing::Test {
const uint8_t* mapping_table,
const uint8_t* vmap_table,
const uint8_t* gc_map) {
- return OatFile::OatMethod(NULL,
- reinterpret_cast<uint32_t>(code),
- frame_size_in_bytes,
- core_spill_mask,
- fp_spill_mask,
- reinterpret_cast<uint32_t>(mapping_table),
- reinterpret_cast<uint32_t>(vmap_table),
- reinterpret_cast<uint32_t>(gc_map));
+ const byte* base = nullptr; // Base of data in oat file, ie 0.
+ uint32_t code_offset = PointerToLowMemUInt32(code);
+ uint32_t mapping_table_offset = PointerToLowMemUInt32(mapping_table);
+ uint32_t vmap_table_offset = PointerToLowMemUInt32(vmap_table);
+ uint32_t gc_map_offset = PointerToLowMemUInt32(gc_map);
+ return OatFile::OatMethod(base,
+ code_offset,
+ frame_size_in_bytes,
+ core_spill_mask,
+ fp_spill_mask,
+ mapping_table_offset,
+ vmap_table_offset,
+ gc_map_offset);
}
void MakeExecutable(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- CHECK(method != NULL);
+ CHECK(method != nullptr);
- const CompiledMethod* compiled_method = NULL;
+ const CompiledMethod* compiled_method = nullptr;
if (!method->IsAbstract()) {
- const mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache();
+ mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache();
const DexFile& dex_file = *dex_cache->GetDexFile();
compiled_method =
compiler_driver_->GetCompiledMethod(MethodReference(&dex_file,
method->GetDexMethodIndex()));
}
- if (compiled_method != NULL) {
- const std::vector<uint8_t>& code = compiled_method->GetCode();
- MakeExecutable(code);
- const void* method_code = CompiledMethod::CodePointer(&code[0],
+ if (compiled_method != nullptr) {
+ const std::vector<uint8_t>* code = compiled_method->GetQuickCode();
+ if (code == nullptr) {
+ code = compiled_method->GetPortableCode();
+ }
+ MakeExecutable(*code);
+ const void* method_code = CompiledMethod::CodePointer(&(*code)[0],
compiled_method->GetInstructionSet());
LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code;
OatFile::OatMethod oat_method = CreateOatMethod(method_code,
@@ -321,9 +321,9 @@ class CommonTest : public testing::Test {
oat_method.LinkMethod(method);
method->SetEntryPointFromInterpreter(artInterpreterToCompiledCodeBridge);
} else {
- const void* method_code;
// No code? You must mean to go into the interpreter.
- method_code = GetCompiledCodeToInterpreterBridge();
+ const void* method_code = kUsePortableCompiler ? GetPortableToInterpreterBridge()
+ : GetQuickToInterpreterBridge();
OatFile::OatMethod oat_method = CreateOatMethod(method_code,
kStackAlignment,
0,
@@ -334,6 +334,14 @@ class CommonTest : public testing::Test {
oat_method.LinkMethod(method);
method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterBridge);
}
+ // Create bridges to transition between different kinds of compiled bridge.
+ if (method->GetEntryPointFromPortableCompiledCode() == nullptr) {
+ method->SetEntryPointFromPortableCompiledCode(GetPortableToQuickBridge());
+ } else {
+ CHECK(method->GetEntryPointFromQuickCompiledCode() == nullptr);
+ method->SetEntryPointFromQuickCompiledCode(GetQuickToPortableBridge());
+ method->SetIsPortableCompiled();
+ }
}
static void MakeExecutable(const void* code_start, size_t code_length) {
@@ -419,15 +427,11 @@ class CommonTest : public testing::Test {
std::string max_heap_string(StringPrintf("-Xmx%zdm", gc::Heap::kDefaultMaximumSize / MB));
// TODO: make selectable
-#if defined(ART_USE_PORTABLE_COMPILER)
- CompilerBackend compiler_backend = kPortable;
-#else
- CompilerBackend compiler_backend = kQuick;
-#endif
+ CompilerBackend compiler_backend = kUsePortableCompiler ? kPortable : kQuick;
- verified_methods_data_.reset(new VerifiedMethodsData);
+ verification_results_.reset(new VerificationResults);
method_inliner_map_.reset(compiler_backend == kQuick ? new DexFileToMethodInlinerMap : nullptr);
- callbacks_.Reset(verified_methods_data_.get(), method_inliner_map_.get());
+ callbacks_.Reset(verification_results_.get(), method_inliner_map_.get());
Runtime::Options options;
options.push_back(std::make_pair("compilercallbacks", static_cast<CompilerCallbacks*>(&callbacks_)));
options.push_back(std::make_pair("bootclasspath", &boot_class_path_));
@@ -464,6 +468,8 @@ class CommonTest : public testing::Test {
instruction_set = kMips;
#elif defined(__i386__)
instruction_set = kX86;
+#elif defined(__x86_64__)
+ instruction_set = kX86_64;
#endif
for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) {
@@ -474,13 +480,12 @@ class CommonTest : public testing::Test {
}
}
class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
- CumulativeLogger timer("Compilation times");
- compiler_driver_.reset(new CompilerDriver(verified_methods_data_.get(),
+ compiler_driver_.reset(new CompilerDriver(verification_results_.get(),
method_inliner_map_.get(),
compiler_backend, instruction_set,
instruction_set_features,
true, new CompilerDriver::DescriptorSet,
- 2, true, true, &timer));
+ 2, true));
}
// We typically don't generate an image in unit tests, disable this optimization by default.
compiler_driver_->SetSupportBootImageFixup(false);
@@ -527,7 +532,7 @@ class CommonTest : public testing::Test {
compiler_driver_.reset();
callbacks_.Reset(nullptr, nullptr);
method_inliner_map_.reset();
- verified_methods_data_.reset();
+ verification_results_.reset();
STLDeleteElements(&opened_dex_files_);
Runtime::Current()->GetHeap()->VerifyHeap(); // Check for heap corruption after the test
@@ -645,7 +650,9 @@ class CommonTest : public testing::Test {
image_reservation_.reset(MemMap::MapAnonymous("image reservation",
reinterpret_cast<byte*>(ART_BASE_ADDRESS),
(size_t)100 * 1024 * 1024, // 100MB
- PROT_NONE, &error_msg));
+ PROT_NONE,
+ false /* no need for 4gb flag with fixed mmap*/,
+ &error_msg));
CHECK(image_reservation_.get() != nullptr) << error_msg;
}
@@ -655,31 +662,31 @@ class CommonTest : public testing::Test {
class TestCompilerCallbacks : public CompilerCallbacks {
public:
- TestCompilerCallbacks() : verified_methods_data_(nullptr), method_inliner_map_(nullptr) { }
+ TestCompilerCallbacks() : verification_results_(nullptr), method_inliner_map_(nullptr) { }
- void Reset(VerifiedMethodsData* verified_methods_data,
+ void Reset(VerificationResults* verification_results,
DexFileToMethodInlinerMap* method_inliner_map) {
- verified_methods_data_ = verified_methods_data;
+ verification_results_ = verification_results;
method_inliner_map_ = method_inliner_map;
}
virtual bool MethodVerified(verifier::MethodVerifier* verifier)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- CHECK(verified_methods_data_);
- bool result = verified_methods_data_->ProcessVerifiedMethod(verifier);
+ CHECK(verification_results_);
+ bool result = verification_results_->ProcessVerifiedMethod(verifier);
if (result && method_inliner_map_ != nullptr) {
MethodReference ref = verifier->GetMethodReference();
method_inliner_map_->GetMethodInliner(ref.dex_file)
- ->AnalyseMethodCode(ref.dex_method_index, verifier->CodeItem());
+ ->AnalyseMethodCode(verifier);
}
return result;
}
virtual void ClassRejected(ClassReference ref) {
- verified_methods_data_->AddRejectedClass(ref);
+ verification_results_->AddRejectedClass(ref);
}
private:
- VerifiedMethodsData* verified_methods_data_;
+ VerificationResults* verification_results_;
DexFileToMethodInlinerMap* method_inliner_map_;
};
@@ -690,7 +697,7 @@ class CommonTest : public testing::Test {
UniquePtr<Runtime> runtime_;
// Owned by the runtime
ClassLinker* class_linker_;
- UniquePtr<VerifiedMethodsData> verified_methods_data_;
+ UniquePtr<VerificationResults> verification_results_;
UniquePtr<DexFileToMethodInlinerMap> method_inliner_map_;
TestCompilerCallbacks callbacks_;
UniquePtr<CompilerDriver> compiler_driver_;
@@ -738,11 +745,12 @@ class CheckJniAbortCatcher {
// MCLinker link LLVM ELF output because we no longer just have code
// blobs in memory. We'll need to dlopen to load and relocate
// temporary output to resurrect these tests.
-#if defined(ART_USE_PORTABLE_COMPILER)
-#define TEST_DISABLED_FOR_PORTABLE() printf("WARNING: TEST DISABLED FOR PORTABLE\n"); return
-#else
-#define TEST_DISABLED_FOR_PORTABLE()
-#endif
+#define TEST_DISABLED_FOR_PORTABLE() \
+ if (kUsePortableCompiler) { \
+ printf("WARNING: TEST DISABLED FOR PORTABLE\n"); \
+ return; \
+ }
+
} // namespace art
namespace std {