Explicitly pass Thread::Current to MutexLock and Alloc.

Change-Id: I8b75bc0617915465f102815b32306aa7760dcae4
diff --git a/src/oat/runtime/arm/stub_arm.cc b/src/oat/runtime/arm/stub_arm.cc
index 7add255..4099ddb 100644
--- a/src/oat/runtime/arm/stub_arm.cc
+++ b/src/oat/runtime/arm/stub_arm.cc
@@ -82,7 +82,8 @@
 
   assembler->EmitSlowPaths();
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> resolution_trampoline(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> resolution_trampoline(self, ByteArray::Alloc(self, cs));
   CHECK(resolution_trampoline.get() != NULL);
   MemoryRegion code(resolution_trampoline->GetData(), resolution_trampoline->GetLength());
   assembler->FinalizeInstructions(code);
@@ -128,7 +129,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> abstract_stub(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> abstract_stub(self, ByteArray::Alloc(self, cs));
   CHECK(abstract_stub.get() != NULL);
   MemoryRegion code(abstract_stub->GetData(), abstract_stub->GetLength());
   assembler->FinalizeInstructions(code);
@@ -156,7 +158,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> jni_stub(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> jni_stub(self, ByteArray::Alloc(self, cs));
   CHECK(jni_stub.get() != NULL);
   MemoryRegion code(jni_stub->GetData(), jni_stub->GetLength());
   assembler->FinalizeInstructions(code);
diff --git a/src/oat/runtime/mips/stub_mips.cc b/src/oat/runtime/mips/stub_mips.cc
index d545e4a..9691308 100644
--- a/src/oat/runtime/mips/stub_mips.cc
+++ b/src/oat/runtime/mips/stub_mips.cc
@@ -112,7 +112,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> resolution_trampoline(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> resolution_trampoline(self, ByteArray::Alloc(self, cs));
   CHECK(resolution_trampoline.get() != NULL);
   MemoryRegion code(resolution_trampoline->GetData(), resolution_trampoline->GetLength());
   assembler->FinalizeInstructions(code);
@@ -157,7 +158,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> abstract_stub(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> abstract_stub(self, ByteArray::Alloc(self, cs));
   CHECK(abstract_stub.get() != NULL);
   MemoryRegion code(abstract_stub->GetData(), abstract_stub->GetLength());
   assembler->FinalizeInstructions(code);
@@ -197,7 +199,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> jni_stub(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> jni_stub(self, ByteArray::Alloc(self, cs));
   CHECK(jni_stub.get() != NULL);
   MemoryRegion code(jni_stub->GetData(), jni_stub->GetLength());
   assembler->FinalizeInstructions(code);
diff --git a/src/oat/runtime/support_alloc.cc b/src/oat/runtime/support_alloc.cc
index fd7fb65..fb70285 100644
--- a/src/oat/runtime/support_alloc.cc
+++ b/src/oat/runtime/support_alloc.cc
@@ -37,7 +37,7 @@
                                         Thread* self, AbstractMethod** sp)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
-  return AllocArrayFromCode(type_idx, method, component_count, false);
+  return AllocArrayFromCode(type_idx, method, component_count, self, false);
 }
 
 extern "C" Array* artAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, AbstractMethod* method,
@@ -45,7 +45,7 @@
                                                        Thread* self, AbstractMethod** sp)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
-  return AllocArrayFromCode(type_idx, method, component_count, true);
+  return AllocArrayFromCode(type_idx, method, component_count, self, true);
 }
 
 extern "C" Array* artCheckAndAllocArrayFromCode(uint32_t type_idx, AbstractMethod* method,
diff --git a/src/oat/runtime/support_proxy.cc b/src/oat/runtime/support_proxy.cc
index 4ff2e5f..3d0c1c8 100644
--- a/src/oat/runtime/support_proxy.cc
+++ b/src/oat/runtime/support_proxy.cc
@@ -104,7 +104,7 @@
   args_jobj[2].l = NULL;
   ObjectArray<Object>* args = NULL;
   if ((num_params - 1) > 0) {
-    args = Runtime::Current()->GetClassLinker()->AllocObjectArray<Object>(num_params - 1);
+    args = Runtime::Current()->GetClassLinker()->AllocObjectArray<Object>(self, num_params - 1);
     if (args == NULL) {
       CHECK(self->IsExceptionPending());
       return;
@@ -120,7 +120,7 @@
   cur_arg = 0;  // reset stack location to read to start
   // reset index, will index into param type array which doesn't include the receiver
   param_index = 0;
-  ObjectArray<Class>* param_types = proxy_mh.GetParameterTypes();
+  ObjectArray<Class>* param_types = proxy_mh.GetParameterTypes(self);
   if (param_types == NULL) {
     CHECK(self->IsExceptionPending());
     return;
diff --git a/src/oat/runtime/x86/stub_x86.cc b/src/oat/runtime/x86/stub_x86.cc
index 7941d15..cade99d 100644
--- a/src/oat/runtime/x86/stub_x86.cc
+++ b/src/oat/runtime/x86/stub_x86.cc
@@ -92,7 +92,8 @@
 
   assembler->EmitSlowPaths();
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> resolution_trampoline(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> resolution_trampoline(self, ByteArray::Alloc(self, cs));
   CHECK(resolution_trampoline.get() != NULL);
   MemoryRegion code(resolution_trampoline->GetData(), resolution_trampoline->GetLength());
   assembler->FinalizeInstructions(code);
@@ -146,7 +147,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> abstract_stub(Thread::Current(),ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> abstract_stub(self, ByteArray::Alloc(self, cs));
   CHECK(abstract_stub.get() != NULL);
   MemoryRegion code(abstract_stub->GetData(), abstract_stub->GetLength());
   assembler->FinalizeInstructions(code);
@@ -179,7 +181,8 @@
   assembler->EmitSlowPaths();
 
   size_t cs = assembler->CodeSize();
-  SirtRef<ByteArray> jni_stub(Thread::Current(), ByteArray::Alloc(cs));
+  Thread* self = Thread::Current();
+  SirtRef<ByteArray> jni_stub(self, ByteArray::Alloc(self, cs));
   CHECK(jni_stub.get() != NULL);
   MemoryRegion code(jni_stub->GetData(), jni_stub->GetLength());
   assembler->FinalizeInstructions(code);