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
142 lines
4.4 KiB
C++
142 lines
4.4 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 "vm/globals.h"
|
|
#include "vm/simulator.h"
|
|
#include "vm/signal_handler.h"
|
|
#if defined(TARGET_OS_LINUX)
|
|
|
|
namespace dart {
|
|
|
|
uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) {
|
|
uintptr_t pc = 0;
|
|
|
|
#if defined(TARGET_ARCH_IA32)
|
|
pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
|
|
#elif defined(TARGET_ARCH_X64)
|
|
pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]);
|
|
#elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
|
|
pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
|
|
#elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
|
|
pc = static_cast<uintptr_t>(mcontext.gregs[REG_EIP]);
|
|
#elif defined(TARGET_ARCH_ARM64) && defined(USING_SIMULATOR)
|
|
pc = static_cast<uintptr_t>(mcontext.gregs[REG_RIP]);
|
|
#elif defined(TARGET_ARCH_ARM)
|
|
pc = static_cast<uintptr_t>(mcontext.arm_pc);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
pc = static_cast<uintptr_t>(mcontext.pc);
|
|
#elif defined(TARGET_ARCH_MIPS)
|
|
pc = static_cast<uintptr_t>(mcontext.pc);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return pc;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
|
|
uintptr_t fp = 0;
|
|
|
|
#if defined(TARGET_ARCH_IA32)
|
|
fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
|
|
#elif defined(TARGET_ARCH_X64)
|
|
fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]);
|
|
#elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
|
|
fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
|
|
#elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
|
|
fp = static_cast<uintptr_t>(mcontext.gregs[REG_EBP]);
|
|
#elif defined(TARGET_ARCH_ARM64) && defined(USING_SIMULATOR)
|
|
fp = static_cast<uintptr_t>(mcontext.gregs[REG_RBP]);
|
|
#elif defined(TARGET_ARCH_ARM)
|
|
fp = static_cast<uintptr_t>(mcontext.arm_fp);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
fp = static_cast<uintptr_t>(mcontext.regs[29]);
|
|
#elif defined(TARGET_ARCH_MIPS)
|
|
fp = static_cast<uintptr_t>(mcontext.gregs[30]);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
|
|
return fp;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) {
|
|
uintptr_t sp = 0;
|
|
|
|
#if defined(TARGET_ARCH_IA32)
|
|
sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
|
|
#elif defined(TARGET_ARCH_X64)
|
|
sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]);
|
|
#elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
|
|
sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
|
|
#elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
|
|
sp = static_cast<uintptr_t>(mcontext.gregs[REG_ESP]);
|
|
#elif defined(TARGET_ARCH_ARM64) && defined(USING_SIMULATOR)
|
|
sp = static_cast<uintptr_t>(mcontext.gregs[REG_RSP]);
|
|
#elif defined(TARGET_ARCH_ARM)
|
|
sp = static_cast<uintptr_t>(mcontext.arm_sp);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
sp = static_cast<uintptr_t>(mcontext.sp);
|
|
#elif defined(TARGET_ARCH_MIPS)
|
|
sp = static_cast<uintptr_t>(mcontext.gregs[29]);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return sp;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) {
|
|
#if defined(TARGET_ARCH_ARM64) && !defined(USING_SIMULATOR)
|
|
return static_cast<uintptr_t>(mcontext.regs[18]);
|
|
#else
|
|
return GetCStackPointer(mcontext);
|
|
#endif
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
|
|
uintptr_t lr = 0;
|
|
|
|
#if defined(TARGET_ARCH_IA32)
|
|
lr = 0;
|
|
#elif defined(TARGET_ARCH_X64)
|
|
lr = 0;
|
|
#elif defined(TARGET_ARCH_MIPS) && defined(USING_SIMULATOR)
|
|
lr = 0;
|
|
#elif defined(TARGET_ARCH_ARM) && defined(USING_SIMULATOR)
|
|
lr = 0;
|
|
#elif defined(TARGET_ARCH_ARM64) && defined(USING_SIMULATOR)
|
|
lr = 0;
|
|
#elif defined(TARGET_ARCH_ARM)
|
|
lr = static_cast<uintptr_t>(mcontext.arm_lr);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
lr = static_cast<uintptr_t>(mcontext.lr);
|
|
#elif defined(TARGET_ARCH_MIPS)
|
|
lr = static_cast<uintptr_t>(mcontext.gregs[31]);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return lr;
|
|
}
|
|
|
|
|
|
void SignalHandler::Install(SignalAction action) {
|
|
struct sigaction act;
|
|
act.sa_handler = NULL;
|
|
act.sa_sigaction = action;
|
|
sigemptyset(&act.sa_mask);
|
|
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
|
// TODO(johnmccutchan): Do we care about restoring the signal handler?
|
|
struct sigaction old_act;
|
|
int r = sigaction(SIGPROF, &act, &old_act);
|
|
ASSERT(r == 0);
|
|
}
|
|
|
|
|
|
} // namespace dart
|
|
|
|
#endif // defined(TARGET_OS_LINUX)
|