summaryrefslogtreecommitdiff
path: root/src/compiler_llvm/compilation_unit.cc
diff options
context:
space:
mode:
author Logan Chien <loganchien@google.com> 2012-04-23 09:10:46 +0800
committer Shih-wei Liao <sliao@google.com> 2012-04-23 03:24:28 -0700
commit8ba2fc5b1ca044241e03c355424b782a9a8ca08d (patch)
tree768bd5c27210785bea49e0930aa76eb138988a03 /src/compiler_llvm/compilation_unit.cc
parent90dc30f4b9967e850d0594e57dfa8e7cb0369575 (diff)
Add mutex lock to CompilationUnit.
Change-Id: I2555dcc72ca8a765627b9267bfc32ad97315472f
Diffstat (limited to 'src/compiler_llvm/compilation_unit.cc')
-rw-r--r--src/compiler_llvm/compilation_unit.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index 8be388d56c..909248594a 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -111,8 +111,8 @@ llvm::Module* makeLLVMModuleContents(llvm::Module* module);
CompilationUnit::CompilationUnit(InstructionSet insn_set, size_t elf_idx)
-: insn_set_(insn_set), elf_idx_(elf_idx), context_(new llvm::LLVMContext()),
- mem_usage_(0), num_elf_funcs_(0) {
+: cunit_lock_("compilation_unit_lock"), insn_set_(insn_set), elf_idx_(elf_idx),
+ context_(new llvm::LLVMContext()), mem_usage_(0), num_elf_funcs_(0) {
// Create the module and include the runtime function declaration
module_ = new llvm::Module("art", *context_);
@@ -146,6 +146,7 @@ CompilationUnit::~CompilationUnit() {
bool CompilationUnit::WriteBitcodeToFile(const std::string& bitcode_filename) {
+ MutexLock GUARD(cunit_lock_);
std::string errmsg;
llvm::OwningPtr<llvm::tool_output_file> out_file(
@@ -166,6 +167,8 @@ bool CompilationUnit::WriteBitcodeToFile(const std::string& bitcode_filename) {
bool CompilationUnit::Materialize() {
+ MutexLock GUARD(cunit_lock_);
+
// Prepare the pipe between parent process and child process
int pipe_fd[2];
if (pipe(pipe_fd) == -1) {
@@ -246,12 +249,14 @@ bool CompilationUnit::Materialize() {
void CompilationUnit::RegisterCompiledMethod(const llvm::Function* func,
CompiledMethod* compiled_method) {
+ MutexLock GUARD(cunit_lock_);
compiled_methods_map_.Put(func, compiled_method);
}
void CompilationUnit::UpdateFrameSizeInBytes(const llvm::Function* func,
size_t frame_size_in_bytes) {
+ MutexLock GUARD(cunit_lock_);
SafeMap<const llvm::Function*, CompiledMethod*>::iterator iter =
compiled_methods_map_.find(func);