/usr/include/mozjs-38/js/ProfilingFrameIterator.h is in libmozjs-38-dev 38.8.0~repack1-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef js_ProfilingFrameIterator_h
#define js_ProfilingFrameIterator_h
#include "mozilla/Alignment.h"
#include <stdint.h>
#include "js/Utility.h"
class JSAtom;
struct JSRuntime;
namespace js {
class Activation;
class AsmJSProfilingFrameIterator;
namespace jit {
class JitActivation;
class JitProfilingFrameIterator;
}
}
namespace JS {
// This iterator can be used to walk the stack of a thread suspended at an
// arbitrary pc. To provide acurate results, profiling must have been enabled
// (via EnableRuntimeProfilingStack) before executing the callstack being
// unwound.
class JS_PUBLIC_API(ProfilingFrameIterator)
{
JSRuntime* rt_;
js::Activation* activation_;
// When moving past a JitActivation, we need to save the prevJitTop
// from it to use as the exit-frame pointer when the next caller jit
// activation (if any) comes around.
void* savedPrevJitTop_;
static const unsigned StorageSpace = 6 * sizeof(void*);
mozilla::AlignedStorage<StorageSpace> storage_;
js::AsmJSProfilingFrameIterator& asmJSIter() {
MOZ_ASSERT(!done());
MOZ_ASSERT(isAsmJS());
return *reinterpret_cast<js::AsmJSProfilingFrameIterator*>(storage_.addr());
}
const js::AsmJSProfilingFrameIterator& asmJSIter() const {
MOZ_ASSERT(!done());
MOZ_ASSERT(isAsmJS());
return *reinterpret_cast<const js::AsmJSProfilingFrameIterator*>(storage_.addr());
}
js::jit::JitProfilingFrameIterator& jitIter() {
MOZ_ASSERT(!done());
MOZ_ASSERT(isJit());
return *reinterpret_cast<js::jit::JitProfilingFrameIterator*>(storage_.addr());
}
const js::jit::JitProfilingFrameIterator& jitIter() const {
MOZ_ASSERT(!done());
MOZ_ASSERT(isJit());
return *reinterpret_cast<const js::jit::JitProfilingFrameIterator*>(storage_.addr());
}
void settle();
public:
struct RegisterState
{
RegisterState() : pc(nullptr), sp(nullptr), lr(nullptr) {}
void* pc;
void* sp;
void* lr;
};
ProfilingFrameIterator(JSRuntime* rt, const RegisterState& state);
~ProfilingFrameIterator();
void operator++();
bool done() const { return !activation_; }
// Assuming the stack grows down (we do), the return value:
// - always points into the stack
// - is weakly monotonically increasing (may be equal for successive frames)
// - will compare greater than newer native and psuedo-stack frame addresses
// and less than older native and psuedo-stack frame addresses
void* stackAddress() const;
enum FrameKind
{
Frame_Baseline,
Frame_Ion,
Frame_AsmJS
};
struct Frame
{
FrameKind kind;
void* stackAddress;
void* returnAddress;
void* activation;
const char* label;
bool hasTrackedOptimizations;
};
uint32_t extractStack(Frame* frames, uint32_t offset, uint32_t end) const;
private:
void iteratorConstruct(const RegisterState& state);
void iteratorConstruct();
void iteratorDestroy();
bool iteratorDone();
bool isAsmJS() const;
bool isJit() const;
};
JS_FRIEND_API(bool)
IsProfilingEnabledForRuntime(JSRuntime* runtime);
} // namespace JS
#endif /* js_ProfilingFrameIterator_h */
|