Add JIT
Currently disabled by default unless -Xjit is passed in.
The proposed JIT is a method JIT which works by utilizing interpreter
instrumentation to request compilation of hot methods async during
runtime.
JIT options:
-Xjit / -Xnojit
-Xjitcodecachesize:N
-Xjitthreshold:integervalue
The JIT has a shared copy of a compiler driver which is accessed
by worker threads to compile individual methods.
Added JIT code cache and data cache, currently sized at 2 MB
capacity by default. Most apps will only fill a small fraction of
this cache however.
Added support to the compiler for compiling interpreter quickened
byte codes.
Added test target ART_TEST_JIT=TRUE and --jit for run-test.
TODO:
Clean up code cache.
Delete compiled methods after they are added to code cache.
Add more optimizations related to runtime checks e.g. direct pointers
for invokes.
Add method recompilation.
Move instrumentation to DexFile to improve performance and reduce
memory usage.
Bug: 17950037
Change-Id: Ifa5b2684a2d5059ec5a5210733900aafa3c51bca
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 1cd78f8..e8354b2 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -52,19 +52,19 @@
const SwapVector<uint8_t>* code = compiled_method->GetQuickCode();
uint32_t code_size = code->size();
CHECK_NE(0u, code_size);
- const SwapVector<uint8_t>& vmap_table = compiled_method->GetVmapTable();
- uint32_t vmap_table_offset = vmap_table.empty() ? 0u
- : sizeof(OatQuickMethodHeader) + vmap_table.size();
+ const SwapVector<uint8_t>* vmap_table = compiled_method->GetVmapTable();
+ uint32_t vmap_table_offset = vmap_table->empty() ? 0u
+ : sizeof(OatQuickMethodHeader) + vmap_table->size();
const SwapVector<uint8_t>* mapping_table = compiled_method->GetMappingTable();
bool mapping_table_used = mapping_table != nullptr && !mapping_table->empty();
size_t mapping_table_size = mapping_table_used ? mapping_table->size() : 0U;
uint32_t mapping_table_offset = !mapping_table_used ? 0u
- : sizeof(OatQuickMethodHeader) + vmap_table.size() + mapping_table_size;
+ : sizeof(OatQuickMethodHeader) + vmap_table->size() + mapping_table_size;
const SwapVector<uint8_t>* gc_map = compiled_method->GetGcMap();
bool gc_map_used = gc_map != nullptr && !gc_map->empty();
size_t gc_map_size = gc_map_used ? gc_map->size() : 0U;
uint32_t gc_map_offset = !gc_map_used ? 0u
- : sizeof(OatQuickMethodHeader) + vmap_table.size() + mapping_table_size + gc_map_size;
+ : sizeof(OatQuickMethodHeader) + vmap_table->size() + mapping_table_size + gc_map_size;
OatQuickMethodHeader method_header(mapping_table_offset, vmap_table_offset, gc_map_offset,
compiled_method->GetFrameSizeInBytes(),
compiled_method->GetCoreSpillMask(),
@@ -72,14 +72,14 @@
header_code_and_maps_chunks_.push_back(std::vector<uint8_t>());
std::vector<uint8_t>* chunk = &header_code_and_maps_chunks_.back();
- size_t size = sizeof(method_header) + code_size + vmap_table.size() + mapping_table_size +
+ size_t size = sizeof(method_header) + code_size + vmap_table->size() + mapping_table_size +
gc_map_size;
size_t code_offset = compiled_method->AlignCode(size - code_size);
size_t padding = code_offset - (size - code_size);
chunk->reserve(padding + size);
chunk->resize(sizeof(method_header));
memcpy(&(*chunk)[0], &method_header, sizeof(method_header));
- chunk->insert(chunk->begin(), vmap_table.begin(), vmap_table.end());
+ chunk->insert(chunk->begin(), vmap_table->begin(), vmap_table->end());
if (mapping_table_used) {
chunk->insert(chunk->begin(), mapping_table->begin(), mapping_table->end());
}
@@ -212,7 +212,7 @@
CHECK(method != nullptr);
TimingLogger timings("CommonTest::CompileMethod", false, false);
TimingLogger::ScopedTiming t(__FUNCTION__, &timings);
- compiler_driver_->CompileOne(method, &timings);
+ compiler_driver_->CompileOne(Thread::Current(), method, &timings);
TimingLogger::ScopedTiming t2("MakeExecutable", &timings);
MakeExecutable(method);
}