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

Side by Side Diff: runtime/vm/os_thread.h

Issue 2680213002: Updated MallocHooks to collect stack traces when memory is allocated. (Closed)
Patch Set: Added tests and modified stack walker to allow for skipping an arbitrary number of frames before co… 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_OS_THREAD_H_ 5 #ifndef RUNTIME_VM_OS_THREAD_H_
6 #define RUNTIME_VM_OS_THREAD_H_ 6 #define RUNTIME_VM_OS_THREAD_H_
7 7
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/malloc_hooks.h"
11 12
12 // Declare the OS-specific types ahead of defining the generic classes. 13 // Declare the OS-specific types ahead of defining the generic classes.
13 #if defined(TARGET_OS_ANDROID) 14 #if defined(TARGET_OS_ANDROID)
14 #include "vm/os_thread_android.h" 15 #include "vm/os_thread_android.h"
15 #elif defined(TARGET_OS_FUCHSIA) 16 #elif defined(TARGET_OS_FUCHSIA)
16 #include "vm/os_thread_fuchsia.h" 17 #include "vm/os_thread_fuchsia.h"
17 #elif defined(TARGET_OS_LINUX) 18 #elif defined(TARGET_OS_LINUX)
18 #include "vm/os_thread_linux.h" 19 #include "vm/os_thread_linux.h"
19 #elif defined(TARGET_OS_MACOS) 20 #elif defined(TARGET_OS_MACOS)
20 #include "vm/os_thread_macos.h" 21 #include "vm/os_thread_macos.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 *upper = stack_upper; 108 *upper = stack_upper;
108 return true; 109 return true;
109 } 110 }
110 111
111 // Used to temporarily disable or enable thread interrupts. 112 // Used to temporarily disable or enable thread interrupts.
112 void DisableThreadInterrupts(); 113 void DisableThreadInterrupts();
113 void EnableThreadInterrupts(); 114 void EnableThreadInterrupts();
114 bool ThreadInterruptsEnabled(); 115 bool ThreadInterruptsEnabled();
115 116
116 // The currently executing thread, or NULL if not yet initialized. 117 // The currently executing thread, or NULL if not yet initialized.
117 static OSThread* Current() { 118 static OSThread* TryCurrent() {
118 BaseThread* thread = GetCurrentTLS(); 119 BaseThread* thread = GetCurrentTLS();
119 OSThread* os_thread = NULL; 120 OSThread* os_thread = NULL;
120 if (thread != NULL) { 121 if (thread != NULL) {
121 if (thread->is_os_thread()) { 122 if (thread->is_os_thread()) {
122 os_thread = reinterpret_cast<OSThread*>(thread); 123 os_thread = reinterpret_cast<OSThread*>(thread);
123 } else { 124 } else {
124 Thread* vm_thread = reinterpret_cast<Thread*>(thread); 125 Thread* vm_thread = reinterpret_cast<Thread*>(thread);
125 os_thread = GetOSThreadFromThread(vm_thread); 126 os_thread = GetOSThreadFromThread(vm_thread);
126 } 127 }
127 } else { 128 }
129 return os_thread;
130 }
131
132 // The currently executing thread. If there is no currently executing thread,
133 // a new OSThread is created and returned.
134 static OSThread* Current() {
135 OSThread* os_thread = TryCurrent();
136 if (os_thread == NULL) {
128 os_thread = CreateAndSetUnknownThread(); 137 os_thread = CreateAndSetUnknownThread();
129 } 138 }
130 return os_thread; 139 return os_thread;
131 } 140 }
132 static void SetCurrent(OSThread* current); 141 static void SetCurrent(OSThread* current);
133 142
134 // TODO(5411455): Use flag to override default value and Validate the 143 // TODO(5411455): Use flag to override default value and Validate the
135 // stack size by querying OS. 144 // stack size by querying OS.
136 static uword GetSpecifiedStackSize() { 145 static uword GetSpecifiedStackSize() {
137 ASSERT(OSThread::kStackSizeBuffer < OSThread::GetMaxStackSize()); 146 ASSERT(OSThread::kStackSizeBuffer < OSThread::GetMaxStackSize());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 friend class SafepointMonitorLocker; 351 friend class SafepointMonitorLocker;
343 friend void Dart_TestMonitor(); 352 friend void Dart_TestMonitor();
344 DISALLOW_COPY_AND_ASSIGN(Monitor); 353 DISALLOW_COPY_AND_ASSIGN(Monitor);
345 }; 354 };
346 355
347 356
348 } // namespace dart 357 } // namespace dart
349 358
350 359
351 #endif // RUNTIME_VM_OS_THREAD_H_ 360 #endif // RUNTIME_VM_OS_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698