summaryrefslogtreecommitdiff
path: root/runtime/jit
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/jit')
-rw-r--r--runtime/jit/jit.cc6
-rw-r--r--runtime/jit/jit.h9
-rw-r--r--runtime/jit/jit_code_cache.cc8
-rw-r--r--runtime/jit/jit_code_cache.h14
-rw-r--r--runtime/jit/jit_code_cache_test.cc21
-rw-r--r--runtime/jit/jit_instrumentation.cc16
-rw-r--r--runtime/jit/jit_instrumentation.h20
7 files changed, 45 insertions, 49 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 5dc739edb2..bc9545b5a8 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -18,11 +18,11 @@
#include <dlfcn.h>
+#include "art_method-inl.h"
#include "entrypoints/runtime_asm_entrypoints.h"
#include "interpreter/interpreter.h"
#include "jit_code_cache.h"
#include "jit_instrumentation.h"
-#include "mirror/art_method-inl.h"
#include "runtime.h"
#include "runtime_options.h"
#include "thread_list.h"
@@ -100,7 +100,7 @@ bool Jit::LoadCompiler(std::string* error_msg) {
*error_msg = "JIT couldn't find jit_unload entry point";
return false;
}
- jit_compile_method_ = reinterpret_cast<bool (*)(void*, mirror::ArtMethod*, Thread*)>(
+ jit_compile_method_ = reinterpret_cast<bool (*)(void*, ArtMethod*, Thread*)>(
dlsym(jit_library_handle_, "jit_compile_method"));
if (jit_compile_method_ == nullptr) {
dlclose(jit_library_handle_);
@@ -126,7 +126,7 @@ bool Jit::LoadCompiler(std::string* error_msg) {
return true;
}
-bool Jit::CompileMethod(mirror::ArtMethod* method, Thread* self) {
+bool Jit::CompileMethod(ArtMethod* method, Thread* self) {
DCHECK(!method->IsRuntimeMethod());
if (Dbg::IsDebuggerActive() && Dbg::MethodHasAnyBreakpoints(method)) {
VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to breakpoint";
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 8f92453866..dbd8977d91 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -30,13 +30,10 @@
namespace art {
+class ArtMethod;
class CompilerCallbacks;
struct RuntimeArgumentMap;
-namespace mirror {
-class ArtMethod;
-} // namespace mirror
-
namespace jit {
class JitCodeCache;
@@ -50,7 +47,7 @@ class Jit {
virtual ~Jit();
static Jit* Create(JitOptions* options, std::string* error_msg);
- bool CompileMethod(mirror::ArtMethod* method, Thread* self)
+ bool CompileMethod(ArtMethod* method, Thread* self)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void CreateInstrumentationCache(size_t compile_threshold);
void CreateThreadPool();
@@ -79,7 +76,7 @@ class Jit {
void* jit_compiler_handle_;
void* (*jit_load_)(CompilerCallbacks**);
void (*jit_unload_)(void*);
- bool (*jit_compile_method_)(void*, mirror::ArtMethod*, Thread*);
+ bool (*jit_compile_method_)(void*, ArtMethod*, Thread*);
// Performance monitoring.
bool dump_info_on_shutdown_;
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 4d367e01eb..cd5f4cb529 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -18,8 +18,8 @@
#include <sstream>
+#include "art_method-inl.h"
#include "mem_map.h"
-#include "mirror/art_method-inl.h"
#include "oat_file-inl.h"
namespace art {
@@ -58,7 +58,7 @@ JitCodeCache::JitCodeCache(MemMap* mem_map)
code_cache_end_ = mem_map->End();
}
-bool JitCodeCache::ContainsMethod(mirror::ArtMethod* method) const {
+bool JitCodeCache::ContainsMethod(ArtMethod* method) const {
return ContainsCodePtr(method->GetEntryPointFromQuickCompiledCode());
}
@@ -93,7 +93,7 @@ uint8_t* JitCodeCache::AddDataArray(Thread* self, const uint8_t* begin, const ui
return data_cache_ptr_ - size;
}
-const void* JitCodeCache::GetCodeFor(mirror::ArtMethod* method) {
+const void* JitCodeCache::GetCodeFor(ArtMethod* method) {
const void* code = method->GetEntryPointFromQuickCompiledCode();
if (ContainsCodePtr(code)) {
return code;
@@ -106,7 +106,7 @@ const void* JitCodeCache::GetCodeFor(mirror::ArtMethod* method) {
return nullptr;
}
-void JitCodeCache::SaveCompiledCode(mirror::ArtMethod* method, const void* old_code_ptr) {
+void JitCodeCache::SaveCompiledCode(ArtMethod* method, const void* old_code_ptr) {
DCHECK_EQ(method->GetEntryPointFromQuickCompiledCode(), old_code_ptr);
DCHECK(ContainsCodePtr(old_code_ptr)) << PrettyMethod(method) << " old_code_ptr="
<< old_code_ptr;
diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h
index 8b76647161..c1ea921834 100644
--- a/runtime/jit/jit_code_cache.h
+++ b/runtime/jit/jit_code_cache.h
@@ -31,13 +31,10 @@
namespace art {
+class ArtMethod;
class CompiledMethod;
class CompilerCallbacks;
-namespace mirror {
-class ArtMethod;
-} // namespcae mirror
-
namespace jit {
class JitInstrumentationCache;
@@ -80,7 +77,7 @@ class JitCodeCache {
}
// Return true if the code cache contains the code pointer which si the entrypoint of the method.
- bool ContainsMethod(mirror::ArtMethod* method) const
+ bool ContainsMethod(ArtMethod* method) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Return true if the code cache contains a code ptr.
@@ -95,12 +92,12 @@ class JitCodeCache {
LOCKS_EXCLUDED(lock_);
// Get code for a method, returns null if it is not in the jit cache.
- const void* GetCodeFor(mirror::ArtMethod* method)
+ const void* GetCodeFor(ArtMethod* method)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCKS_EXCLUDED(lock_);
// Save the compiled code for a method so that GetCodeFor(method) will return old_code_ptr if the
// entrypoint isn't within the cache.
- void SaveCompiledCode(mirror::ArtMethod* method, const void* old_code_ptr)
+ void SaveCompiledCode(ArtMethod* method, const void* old_code_ptr)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCKS_EXCLUDED(lock_);
private:
@@ -125,10 +122,9 @@ class JitCodeCache {
const uint8_t* data_cache_begin_;
const uint8_t* data_cache_end_;
size_t num_methods_;
- // TODO: This relies on methods not moving.
// This map holds code for methods if they were deoptimized by the instrumentation stubs. This is
// required since we have to implement ClassLinker::GetQuickOatCodeFor for walking stacks.
- SafeMap<mirror::ArtMethod*, const void*> method_code_map_ GUARDED_BY(lock_);
+ SafeMap<ArtMethod*, const void*> method_code_map_ GUARDED_BY(lock_);
DISALLOW_IMPLICIT_CONSTRUCTORS(JitCodeCache);
};
diff --git a/runtime/jit/jit_code_cache_test.cc b/runtime/jit/jit_code_cache_test.cc
index afa5a3e7ee..cd123b97d9 100644
--- a/runtime/jit/jit_code_cache_test.cc
+++ b/runtime/jit/jit_code_cache_test.cc
@@ -16,9 +16,9 @@
#include "common_runtime_test.h"
+#include "art_method-inl.h"
#include "class_linker.h"
#include "jit_code_cache.h"
-#include "mirror/art_method-inl.h"
#include "scoped_thread_state_change.h"
#include "thread-inl.h"
@@ -50,15 +50,15 @@ TEST_F(JitCodeCacheTest, TestCoverage) {
ASSERT_TRUE(code_cache->ContainsCodePtr(reserved_code));
ASSERT_EQ(code_cache->NumMethods(), 1u);
ClassLinker* const cl = Runtime::Current()->GetClassLinker();
- auto h_method = hs.NewHandle(cl->AllocArtMethod(soa.Self()));
- ASSERT_FALSE(code_cache->ContainsMethod(h_method.Get()));
- h_method->SetEntryPointFromQuickCompiledCode(reserved_code);
- ASSERT_TRUE(code_cache->ContainsMethod(h_method.Get()));
- ASSERT_EQ(code_cache->GetCodeFor(h_method.Get()), reserved_code);
+ auto* method = cl->AllocArtMethodArray(soa.Self(), 1);
+ ASSERT_FALSE(code_cache->ContainsMethod(method));
+ method->SetEntryPointFromQuickCompiledCode(reserved_code);
+ ASSERT_TRUE(code_cache->ContainsMethod(method));
+ ASSERT_EQ(code_cache->GetCodeFor(method), reserved_code);
// Save the code and then change it.
- code_cache->SaveCompiledCode(h_method.Get(), reserved_code);
- h_method->SetEntryPointFromQuickCompiledCode(nullptr);
- ASSERT_EQ(code_cache->GetCodeFor(h_method.Get()), reserved_code);
+ code_cache->SaveCompiledCode(method, reserved_code);
+ method->SetEntryPointFromQuickCompiledCode(nullptr);
+ ASSERT_EQ(code_cache->GetCodeFor(method), reserved_code);
const uint8_t data_arr[] = {1, 2, 3, 4, 5};
uint8_t* data_ptr = code_cache->AddDataArray(soa.Self(), data_arr, data_arr + sizeof(data_arr));
ASSERT_TRUE(data_ptr != nullptr);
@@ -76,7 +76,8 @@ TEST_F(JitCodeCacheTest, TestOverflow) {
size_t data_bytes = 0;
constexpr size_t kCodeArrSize = 4 * KB;
constexpr size_t kDataArrSize = 4 * KB;
- uint8_t data_arr[kDataArrSize] = {53};
+ uint8_t data_arr[kDataArrSize];
+ std::fill_n(data_arr, arraysize(data_arr), 53);
// Add code and data until we are full.
uint8_t* code_ptr = nullptr;
uint8_t* data_ptr = nullptr;
diff --git a/runtime/jit/jit_instrumentation.cc b/runtime/jit/jit_instrumentation.cc
index 32326740c6..1e56cdca30 100644
--- a/runtime/jit/jit_instrumentation.cc
+++ b/runtime/jit/jit_instrumentation.cc
@@ -16,9 +16,9 @@
#include "jit_instrumentation.h"
+#include "art_method-inl.h"
#include "jit.h"
#include "jit_code_cache.h"
-#include "mirror/art_method-inl.h"
#include "scoped_thread_state_change.h"
namespace art {
@@ -26,7 +26,7 @@ namespace jit {
class JitCompileTask : public Task {
public:
- explicit JitCompileTask(mirror::ArtMethod* method, JitInstrumentationCache* cache)
+ explicit JitCompileTask(ArtMethod* method, JitInstrumentationCache* cache)
: method_(method), cache_(cache) {
}
@@ -45,7 +45,7 @@ class JitCompileTask : public Task {
}
private:
- mirror::ArtMethod* const method_;
+ ArtMethod* const method_;
JitInstrumentationCache* const cache_;
DISALLOW_IMPLICIT_CONSTRUCTORS(JitCompileTask);
@@ -63,7 +63,7 @@ void JitInstrumentationCache::DeleteThreadPool() {
thread_pool_.reset();
}
-void JitInstrumentationCache::SignalCompiled(Thread* self, mirror::ArtMethod* method) {
+void JitInstrumentationCache::SignalCompiled(Thread* self, ArtMethod* method) {
ScopedObjectAccessUnchecked soa(self);
jmethodID method_id = soa.EncodeMethod(method);
MutexLock mu(self, lock_);
@@ -73,7 +73,7 @@ void JitInstrumentationCache::SignalCompiled(Thread* self, mirror::ArtMethod* me
}
}
-void JitInstrumentationCache::AddSamples(Thread* self, mirror::ArtMethod* method, size_t count) {
+void JitInstrumentationCache::AddSamples(Thread* self, ArtMethod* method, size_t count) {
ScopedObjectAccessUnchecked soa(self);
// Since we don't have on-stack replacement, some methods can remain in the interpreter longer
// than we want resulting in samples even after the method is compiled.
@@ -101,11 +101,13 @@ void JitInstrumentationCache::AddSamples(Thread* self, mirror::ArtMethod* method
}
if (is_hot) {
if (thread_pool_.get() != nullptr) {
- thread_pool_->AddTask(self, new JitCompileTask(method->GetInterfaceMethodIfProxy(), this));
+ thread_pool_->AddTask(self, new JitCompileTask(
+ method->GetInterfaceMethodIfProxy(sizeof(void*)), this));
thread_pool_->StartWorkers(self);
} else {
VLOG(jit) << "Compiling hot method " << PrettyMethod(method);
- Runtime::Current()->GetJit()->CompileMethod(method->GetInterfaceMethodIfProxy(), self);
+ Runtime::Current()->GetJit()->CompileMethod(
+ method->GetInterfaceMethodIfProxy(sizeof(void*)), self);
}
}
}
diff --git a/runtime/jit/jit_instrumentation.h b/runtime/jit/jit_instrumentation.h
index 72acaef2a3..27894eb6c2 100644
--- a/runtime/jit/jit_instrumentation.h
+++ b/runtime/jit/jit_instrumentation.h
@@ -31,12 +31,12 @@
namespace art {
namespace mirror {
- class ArtMethod;
class Class;
class Object;
class Throwable;
} // namespace mirror
class ArtField;
+class ArtMethod;
union JValue;
class Thread;
@@ -46,9 +46,9 @@ namespace jit {
class JitInstrumentationCache {
public:
explicit JitInstrumentationCache(size_t hot_method_threshold);
- void AddSamples(Thread* self, mirror::ArtMethod* method, size_t samples)
+ void AddSamples(Thread* self, ArtMethod* method, size_t samples)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void SignalCompiled(Thread* self, mirror::ArtMethod* method)
+ void SignalCompiled(Thread* self, ArtMethod* method)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void CreateThreadPool();
void DeleteThreadPool();
@@ -67,31 +67,31 @@ class JitInstrumentationListener : public instrumentation::InstrumentationListen
explicit JitInstrumentationListener(JitInstrumentationCache* cache);
virtual void MethodEntered(Thread* thread, mirror::Object* /*this_object*/,
- mirror::ArtMethod* method, uint32_t /*dex_pc*/)
+ ArtMethod* method, uint32_t /*dex_pc*/)
OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
instrumentation_cache_->AddSamples(thread, method, 1);
}
virtual void MethodExited(Thread* /*thread*/, mirror::Object* /*this_object*/,
- mirror::ArtMethod* /*method*/, uint32_t /*dex_pc*/,
+ ArtMethod* /*method*/, uint32_t /*dex_pc*/,
const JValue& /*return_value*/)
OVERRIDE { }
virtual void MethodUnwind(Thread* /*thread*/, mirror::Object* /*this_object*/,
- mirror::ArtMethod* /*method*/, uint32_t /*dex_pc*/) OVERRIDE { }
+ ArtMethod* /*method*/, uint32_t /*dex_pc*/) OVERRIDE { }
virtual void FieldRead(Thread* /*thread*/, mirror::Object* /*this_object*/,
- mirror::ArtMethod* /*method*/, uint32_t /*dex_pc*/,
+ ArtMethod* /*method*/, uint32_t /*dex_pc*/,
ArtField* /*field*/) OVERRIDE { }
virtual void FieldWritten(Thread* /*thread*/, mirror::Object* /*this_object*/,
- mirror::ArtMethod* /*method*/, uint32_t /*dex_pc*/,
+ ArtMethod* /*method*/, uint32_t /*dex_pc*/,
ArtField* /*field*/, const JValue& /*field_value*/)
OVERRIDE { }
virtual void ExceptionCaught(Thread* /*thread*/,
mirror::Throwable* /*exception_object*/) OVERRIDE { }
virtual void DexPcMoved(Thread* /*self*/, mirror::Object* /*this_object*/,
- mirror::ArtMethod* /*method*/, uint32_t /*new_dex_pc*/) OVERRIDE { }
+ ArtMethod* /*method*/, uint32_t /*new_dex_pc*/) OVERRIDE { }
// We only care about how many dex instructions were executed in the Jit.
- virtual void BackwardBranch(Thread* thread, mirror::ArtMethod* method, int32_t dex_pc_offset)
+ virtual void BackwardBranch(Thread* thread, ArtMethod* method, int32_t dex_pc_offset)
OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
CHECK_LE(dex_pc_offset, 0);
instrumentation_cache_->AddSamples(thread, method, 1);