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
62 lines
1.9 KiB
C++
62 lines
1.9 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.
|
|
|
|
#include "platform/globals.h"
|
|
#if defined(TARGET_OS_LINUX)
|
|
|
|
#include "vm/flags.h"
|
|
#include "vm/os.h"
|
|
#include "vm/signal_handler.h"
|
|
#include "vm/thread_interrupter.h"
|
|
|
|
namespace dart {
|
|
|
|
DECLARE_FLAG(bool, thread_interrupter);
|
|
DECLARE_FLAG(bool, trace_thread_interrupter);
|
|
|
|
class ThreadInterrupterLinux : public AllStatic {
|
|
public:
|
|
static void ThreadInterruptSignalHandler(int signal, siginfo_t* info,
|
|
void* context_) {
|
|
if (signal != SIGPROF) {
|
|
return;
|
|
}
|
|
InterruptableThreadState* state = ThreadInterrupter::CurrentThreadState();
|
|
if ((state == NULL) || (state->callback == NULL)) {
|
|
// No interrupter state or callback.
|
|
return;
|
|
}
|
|
ASSERT(OSThread::Compare(state->id, OSThread::GetCurrentThreadId()));
|
|
// Extract thread state.
|
|
ucontext_t* context = reinterpret_cast<ucontext_t*>(context_);
|
|
mcontext_t mcontext = context->uc_mcontext;
|
|
InterruptedThreadState its;
|
|
its.tid = state->id;
|
|
its.pc = SignalHandler::GetProgramCounter(mcontext);
|
|
its.fp = SignalHandler::GetFramePointer(mcontext);
|
|
its.csp = SignalHandler::GetCStackPointer(mcontext);
|
|
its.dsp = SignalHandler::GetDartStackPointer(mcontext);
|
|
its.lr = SignalHandler::GetLinkRegister(mcontext);
|
|
state->callback(its, state->data);
|
|
}
|
|
};
|
|
|
|
|
|
void ThreadInterrupter::InterruptThread(InterruptableThreadState* state) {
|
|
if (FLAG_trace_thread_interrupter) {
|
|
OS::Print("ThreadInterrupter interrupting %p\n",
|
|
reinterpret_cast<void*>(state->id));
|
|
}
|
|
pthread_kill(state->id, SIGPROF);
|
|
}
|
|
|
|
|
|
void ThreadInterrupter::InstallSignalHandler() {
|
|
SignalHandler::Install(ThreadInterrupterLinux::ThreadInterruptSignalHandler);
|
|
}
|
|
|
|
} // namespace dart
|
|
|
|
#endif // defined(TARGET_OS_LINUX)
|