Enable multi-threaded Quick compilation
Reuse thread-local copies of llvm context data for Quick compiler
(while continuing to regenerate fresh ones per method for Portable).
This is a transitional CL - the upcoming compiler driver change
is expected to pass pass a thread context structure to each compiler
worker thread rather than use the pthread_key mechanism.
Change-Id: I277920a5c2705748c3a9f37ceace53c903747ec2
diff --git a/src/compiler.h b/src/compiler.h
index c5f19f7..5e9dbd7 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -40,6 +40,22 @@
class OatCompilationUnit;
class TimingLogger;
+// Thread-local storage compiler worker threads
+class CompilerTls {
+#if defined(ART_USE_QUICK_COMPILER)
+ public:
+ CompilerTls() : llvm_info_(NULL) {}
+ ~CompilerTls() {}
+
+ void* GetLLVMInfo() { return llvm_info_; }
+
+ void SetLLVMInfo(void* llvm_info) { llvm_info_ = llvm_info; }
+
+ private:
+ void* llvm_info_;
+#endif
+};
+
class Compiler {
public:
// Create a compiler targeting the requested "instruction_set".
@@ -72,6 +88,8 @@
return image_;
}
+ CompilerTls* GetTls();
+
// Stub to throw AbstractMethodError
static ByteArray* CreateAbstractMethodErrorStub(InstructionSet instruction_set)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -347,6 +365,8 @@
const char* shorty, uint32_t shorty_len);
CreateInvokeStubFn create_invoke_stub_;
+ pthread_key_t tls_key_;
+
#if defined(ART_USE_LLVM_COMPILER)
typedef CompiledInvokeStub* (*CreateProxyStubFn)
(Compiler& compiler, const char* shorty, uint32_t shorty_len);