From 4df2bbdfe6602ce5f141b7b44028b95faa0bd8ef Mon Sep 17 00:00:00 2001 From: buzbee Date: Thu, 11 Oct 2012 14:46:06 -0700 Subject: 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 --- src/compiler.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/compiler.h') diff --git a/src/compiler.h b/src/compiler.h index c5f19f7be9..5e9dbd77b5 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -40,6 +40,22 @@ class CompilationContext; 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 @@ class Compiler { return image_; } + CompilerTls* GetTls(); + // Stub to throw AbstractMethodError static ByteArray* CreateAbstractMethodErrorStub(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -347,6 +365,8 @@ class Compiler { 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); -- cgit v1.2.3-59-g8ed1b