f2333f63a5
Profiler improvements: - Track Functions in profile and build Function based trie - Associate code objects with functions - Created cpu_profile.dart library - Major speed improvements for disassembly view - Fix truncation of disassembly comments - Ability to get code object ticks from disassembly view - Inlining mini-map in disassembly view. - Remove a bunch of unused data from profile service response - In some cases a caller PC that is better than the PC marker is inserted into the stack trace - Inlined functions are expanded - Ability to clear profile - New flag '--keep_code' which keeps deoptimized code around for use by the profiler. General fixes: - Fix caching in service library - Remove pubspec.yaml before running pub get R=asiva@google.com, rmacnak@google.com Review URL: https://codereview.chromium.org//928833003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44067 260f80e4-7a28-3924-810f-c04153c831b5
103 lines
3.0 KiB
C++
103 lines
3.0 KiB
C++
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef VM_THREAD_INTERRUPTER_H_
|
|
#define VM_THREAD_INTERRUPTER_H_
|
|
|
|
#include "vm/allocation.h"
|
|
#include "vm/signal_handler.h"
|
|
#include "vm/os_thread.h"
|
|
|
|
|
|
namespace dart {
|
|
|
|
struct InterruptedThreadState {
|
|
ThreadId tid;
|
|
uintptr_t pc;
|
|
uintptr_t csp;
|
|
uintptr_t dsp;
|
|
uintptr_t fp;
|
|
uintptr_t lr;
|
|
};
|
|
|
|
// When a thread is interrupted the thread specific interrupt callback will be
|
|
// invoked. Each callback is given an InterruptedThreadState and the user data
|
|
// pointer. When inside a thread interrupt callback doing any of the following
|
|
// is forbidden:
|
|
// * Accessing TLS.
|
|
// * Allocating memory.
|
|
// * Taking a lock.
|
|
typedef void (*ThreadInterruptCallback)(const InterruptedThreadState& state,
|
|
void* data);
|
|
|
|
// State stored per registered thread.
|
|
class InterruptableThreadState {
|
|
public:
|
|
ThreadId id;
|
|
ThreadInterruptCallback callback;
|
|
void* data;
|
|
};
|
|
|
|
class ThreadInterrupter : public AllStatic {
|
|
public:
|
|
static void InitOnce();
|
|
|
|
static void Startup();
|
|
static void Shutdown();
|
|
|
|
// Delay between interrupts.
|
|
static void SetInterruptPeriod(intptr_t period);
|
|
|
|
// Wake up the thread interrupter thread.
|
|
static void WakeUp();
|
|
|
|
// Register the currently running thread for interrupts. If the current thread
|
|
// is already registered, callback and data will be updated.
|
|
static InterruptableThreadState* Register(ThreadInterruptCallback callback,
|
|
void* data);
|
|
// Unregister the currently running thread for interrupts.
|
|
static void Unregister();
|
|
|
|
// Get the current thread state. Will create a thread state if one hasn't
|
|
// been allocated.
|
|
static InterruptableThreadState* GetCurrentThreadState();
|
|
// Get the current thread state. Will not create one if one doesn't exist.
|
|
static InterruptableThreadState* CurrentThreadState();
|
|
|
|
// Interrupt a thread.
|
|
static void InterruptThread(InterruptableThreadState* thread_state);
|
|
|
|
private:
|
|
static const intptr_t kMaxThreads = 4096;
|
|
static bool initialized_;
|
|
static bool shutdown_;
|
|
static bool thread_running_;
|
|
static ThreadId interrupter_thread_id_;
|
|
static Monitor* monitor_;
|
|
static intptr_t interrupt_period_;
|
|
static intptr_t current_wait_time_;
|
|
static ThreadLocalKey thread_state_key_;
|
|
|
|
static bool InDeepSleep() {
|
|
return current_wait_time_ == Monitor::kNoTimeout;
|
|
}
|
|
|
|
static InterruptableThreadState* _EnsureThreadStateCreated();
|
|
static void UpdateStateObject(ThreadInterruptCallback callback, void* data);
|
|
|
|
static void SetCurrentThreadState(InterruptableThreadState* state);
|
|
|
|
static void ThreadMain(uword parameters);
|
|
|
|
static void InstallSignalHandler();
|
|
|
|
friend class ThreadInterrupterVisitIsolates;
|
|
};
|
|
|
|
void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data);
|
|
|
|
} // namespace dart
|
|
|
|
#endif // VM_THREAD_INTERRUPTER_H_
|