summaryrefslogtreecommitdiff
path: root/src/compiler.cc
diff options
context:
space:
mode:
author buzbee <buzbee@google.com> 2012-10-12 07:35:41 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-10-12 07:35:42 -0700
commit4fe0ef28ed58502a3652e827f5931df0b45cf39c (patch)
tree5fa390e59abda86faac886284611d3f94ca614b5 /src/compiler.cc
parent9958daab2a4b0c26482698ac74d3035600115faf (diff)
parent4df2bbdfe6602ce5f141b7b44028b95faa0bd8ef (diff)
Merge "Enable multi-threaded Quick compilation" into dalvik-dev
Diffstat (limited to 'src/compiler.cc')
-rw-r--r--src/compiler.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index 7bec994604..b0d373bd32 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -322,6 +322,8 @@ Compiler::Compiler(InstructionSet instruction_set, bool image, size_t thread_cou
}
VLOG(compiler) << "dlopen(\"" << compiler_so_name << "\", RTLD_LAZY) returned " << compiler_library_;
+ CHECK_PTHREAD_CALL(pthread_key_create, (&tls_key_, NULL), "compiler tls key");
+
#if defined(ART_USE_LLVM_COMPILER) || defined(ART_USE_GREENLAND_COMPILER)
// Initialize compiler_context_
typedef void (*InitCompilerContextFn)(Compiler&);
@@ -431,6 +433,16 @@ Compiler::~Compiler() {
}
}
+CompilerTls* Compiler::GetTls() {
+ // Lazily create thread-local storage
+ CompilerTls* res = static_cast<CompilerTls*>(pthread_getspecific(tls_key_));
+ if (res == NULL) {
+ res = new CompilerTls();
+ CHECK_PTHREAD_CALL(pthread_setspecific, (tls_key_, res), "compiler tls");
+ }
+ return res;
+}
+
ByteArray* Compiler::CreateResolutionStub(InstructionSet instruction_set,
Runtime::TrampolineType type) {
switch (instruction_set) {