1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef js_ProfilingFrameIterator_h
8 #define js_ProfilingFrameIterator_h
10 #include "mozilla/Alignment.h"
14 #include "js/Utility.h"
21 class AsmJSProfilingFrameIterator
;
26 // This iterator can be used to walk the stack of a thread suspended at an
27 // arbitrary pc. To provide acurate results, profiling must have been enabled
28 // (via EnableRuntimeProfilingStack) before executing the callstack being
30 class JS_PUBLIC_API(ProfilingFrameIterator
)
32 js::Activation
*activation_
;
34 static const unsigned StorageSpace
= 6 * sizeof(void*);
35 mozilla::AlignedStorage
<StorageSpace
> storage_
;
36 js::AsmJSProfilingFrameIterator
&asmJSIter() {
38 return *reinterpret_cast<js::AsmJSProfilingFrameIterator
*>(storage_
.addr());
40 const js::AsmJSProfilingFrameIterator
&asmJSIter() const {
42 return *reinterpret_cast<const js::AsmJSProfilingFrameIterator
*>(storage_
.addr());
50 RegisterState() : pc(nullptr), sp(nullptr), lr(nullptr) {}
56 ProfilingFrameIterator(JSRuntime
*rt
, const RegisterState
&state
);
57 ~ProfilingFrameIterator();
59 bool done() const { return !activation_
; }
61 // Assuming the stack grows down (we do), the return value:
62 // - always points into the stack
63 // - is weakly monotonically increasing (may be equal for successive frames)
64 // - will compare greater than newer native and psuedo-stack frame addresses
65 // and less than older native and psuedo-stack frame addresses
66 void *stackAddress() const;
68 // Return a label suitable for regexp-matching as performed by
69 // browser/devtools/profiler/cleopatra/js/parserWorker.js
70 const char *label() const;
73 void iteratorConstruct(const RegisterState
&state
);
74 void iteratorConstruct();
75 void iteratorDestroy();
81 #endif /* js_ProfilingFrameIterator_h */