| Index: runtime/vm/os_thread.h
|
| diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h
|
| index da298316dd60bd29c673b2754365830eaa462ad1..25007496c7aeb6a8a16a09c4741b30798b942792 100644
|
| --- a/runtime/vm/os_thread.h
|
| +++ b/runtime/vm/os_thread.h
|
| @@ -8,6 +8,7 @@
|
| #include "platform/globals.h"
|
| #include "vm/allocation.h"
|
| #include "vm/globals.h"
|
| +#include "vm/malloc_hooks.h"
|
|
|
| // Declare the OS-specific types ahead of defining the generic classes.
|
| #if defined(TARGET_OS_ANDROID)
|
| @@ -114,7 +115,7 @@ class OSThread : public BaseThread {
|
| bool ThreadInterruptsEnabled();
|
|
|
| // The currently executing thread, or NULL if not yet initialized.
|
| - static OSThread* Current() {
|
| + static OSThread* TryCurrent() {
|
| BaseThread* thread = GetCurrentTLS();
|
| OSThread* os_thread = NULL;
|
| if (thread != NULL) {
|
| @@ -124,7 +125,15 @@ class OSThread : public BaseThread {
|
| Thread* vm_thread = reinterpret_cast<Thread*>(thread);
|
| os_thread = GetOSThreadFromThread(vm_thread);
|
| }
|
| - } else {
|
| + }
|
| + return os_thread;
|
| + }
|
| +
|
| + // The currently executing thread. If there is no currently executing thread,
|
| + // a new OSThread is created and returned.
|
| + static OSThread* Current() {
|
| + OSThread* os_thread = TryCurrent();
|
| + if (os_thread == NULL) {
|
| os_thread = CreateAndSetUnknownThread();
|
| }
|
| return os_thread;
|
|
|