Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: runtime/vm/os_thread.h

Issue 2680213002: Updated MallocHooks to collect stack traces when memory is allocated. (Closed)
Patch Set: Updated tests, addressed prior comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/os_thread.h
diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h
index 41e77180ed74cf2dd256c4eede7dd3882b2faaab..8225de728015f594cc991dbe0f2b2ec4f416c204 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"
zra 2017/02/16 23:15:49 Why is this included here?
bkonyi 2017/02/16 23:25:31 This is probably something I forgot to remove from
// Declare the OS-specific types ahead of defining the generic classes.
#if defined(TARGET_OS_ANDROID)
@@ -116,7 +117,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) {
@@ -126,7 +127,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;
« no previous file with comments | « runtime/vm/os_macos.cc ('k') | runtime/vm/os_win.cc » ('j') | runtime/vm/profiler_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698