Files
palemoon27/js/public/ProfilingFrameIterator.h
T
roytam1 7d2b02d5fd import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1233109 - Refactor module parsing to instantiate ModuleBuilder earlier r=shu (ae6693165a)
- Bug 1233109 - Call into the ModuleBuilder as we parse rather than traversing the AST again afterwards r=shu (c28f785d33)
- Bug 1233109 - Check for duplicate exported names using the data in the ModuleBuilder and remove ModuleBox::exportNames r=shu (03999c3ebf)
- Bug 1233109 - Make the getters in Import/ExportEntryObject const r=shu (ed6c2e5dca)
- Bug 1228211 (part 1) - Rearrange nsDisplayCanvasBackgroundImage::Paint(). r=dholbert. (00f3aacb07)
- Bug 1228211 (part 2) - Remove unused functions in nsRenderingContext. r=dholbert. (86d9983e82)
- Bug 1231550 - Use DrawTarget instead of gfxContext and/or nsRenderingContext in many places in font/text code. r=jfkthame. (b0962c9b17)
- Bug 1234418 - Not trust glyph run starts from a cluster start character. r=jfkthame (b0920d8072)
- more of  Bug 1222166 - use gcc/clang warning f (690640c6c7)
- Bug 1064843 part 1 - Make nsImageFrame inherit nsContainerFrame. r=dholbert (bd5efe0a93)
- Bug 1238660 part 1 - Make mWinsInCascade initially false; r=hiro (8420017e68)
- Bug 1238660 part 2 - Preserve "wins in cascade" state when updating animations; r=hiro (348a8ef769)
- Bug 1230408 - Move suppress line break check out from control of SkipParentDisplayBasedStyleFixup. r=dbaron (ca853b3162)
- Bug 1238660 part 3 - Add crashtest; r=hiro (ab4daba520)
- Bug 1230005: Factor out relocation style decision; r=jolesen (03ea0e9ba0)
- Bug 1230005: Hide specifics of the LDR instruction; r=jolesen (92b0396f81)
- Bug 1230005: Flush the assembler buffer at the end of asm.js compilation; r=luke (06e0911bfb)
- Bug 1230005: Delay buffer flushing in asm.js until the last minute; r=luke (d3be91cca5)
- Bug 1233111 - Share method lists for SIMD types. r=bbouvier (70ec039259)
- Bug 1229642 - Fix unified build duplicate static name error (rs=jandem) (eb05c13fec)
- Bug 1231338 - SAB gating test cases. r=luke (a8c6740745)
- Bug 1233111 - Remove geometry altering SIMD conversions. r=bbouvier (a9c93d7694)
- Bug 1233111 - Add unsigned SIMD types to interpreter. r=bbouvier (6187dc7a1e)
- Bug 1233111 - Add ecma_7 shift tests. r=bbouvier (17c612dac5)
- Bug 1233111 - Implement SIMD shiftRightByScalar(). r=bbouvie (b9b0c848b7)
- Bug 1233111 - Add a new ToUint8() function. r=efaust (f1bc50a229)
- ug 1233111 - Implement saturating arithmetic for SIMD. r=bbouvier (42a98a07d6)
- Bug 1229642 - Factor out StringToNewUTF8CharsZ (r=jandem) (3c4f71214b)
- revert PM modification to setProfilingEnabled (4a05202975)
- Bug 1229642 - Split wasm::Module out of AsmJSModule (r=bbouvier) (75a1832b1a)
- Bug 1229642 - change to AsmJSActivation to WasmActivation (r=bbouvier) (a2e8513369)
- Bug 1229642 - Factor AsmJSLink.cpp into wasm/asm.js and consolidate AsmJS* into AsmJS.cpp (r=bbouvier) (3a489c6410)
2023-08-01 11:58:43 +08:00

196 lines
6.1 KiB
C++

/* -*- 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 "mozilla/Maybe.h"
#include "jsbytecode.h"
#include "js/TypeDecls.h"
#include "js/Utility.h"
struct JSRuntime;
class JSScript;
namespace js {
class Activation;
namespace jit {
class JitActivation;
class JitProfilingFrameIterator;
class JitcodeGlobalEntry;
} // namespace jit
namespace wasm {
class ProfilingFrameIterator;
} // namespace wasm
} // namespace js
namespace JS {
struct ForEachTrackedOptimizationAttemptOp;
struct ForEachTrackedOptimizationTypeInfoOp;
// 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_;
uint32_t sampleBufferGen_;
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 = 8 * sizeof(void*);
mozilla::AlignedStorage<StorageSpace> storage_;
js::wasm::ProfilingFrameIterator& asmJSIter() {
MOZ_ASSERT(!done());
MOZ_ASSERT(isAsmJS());
return *reinterpret_cast<js::wasm::ProfilingFrameIterator*>(storage_.addr());
}
const js::wasm::ProfilingFrameIterator& asmJSIter() const {
MOZ_ASSERT(!done());
MOZ_ASSERT(isAsmJS());
return *reinterpret_cast<const js::wasm::ProfilingFrameIterator*>(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();
bool hasSampleBufferGen() const {
return sampleBufferGen_ != UINT32_MAX;
}
public:
struct RegisterState
{
RegisterState() : pc(nullptr), sp(nullptr), lr(nullptr) {}
void* pc;
void* sp;
void* lr;
};
ProfilingFrameIterator(JSRuntime* rt, const RegisterState& state,
uint32_t sampleBufferGen = UINT32_MAX);
~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 isAsmJS() const;
bool isJit() const;
uint32_t extractStack(Frame* frames, uint32_t offset, uint32_t end) const;
mozilla::Maybe<Frame> getPhysicalFrameWithoutLabel() const;
private:
mozilla::Maybe<Frame> getPhysicalFrameAndEntry(js::jit::JitcodeGlobalEntry* entry) const;
void iteratorConstruct(const RegisterState& state);
void iteratorConstruct();
void iteratorDestroy();
bool iteratorDone();
};
JS_FRIEND_API(bool)
IsProfilingEnabledForRuntime(JSRuntime* runtime);
/**
* After each sample run, this method should be called with the latest sample
* buffer generation, and the lapCount. It will update corresponding fields on
* JSRuntime.
*
* See fields |profilerSampleBufferGen|, |profilerSampleBufferLapCount| on
* JSRuntime for documentation about what these values are used for.
*/
JS_FRIEND_API(void)
UpdateJSRuntimeProfilerSampleBufferGen(JSRuntime* runtime, uint32_t generation,
uint32_t lapCount);
struct ForEachProfiledFrameOp
{
// A handle to the underlying JitcodeGlobalEntry, so as to avoid repeated
// lookups on JitcodeGlobalTable.
class MOZ_STACK_CLASS FrameHandle
{
friend JS_PUBLIC_API(void) ForEachProfiledFrame(JSRuntime* rt, void* addr,
ForEachProfiledFrameOp& op);
JSRuntime* rt_;
js::jit::JitcodeGlobalEntry& entry_;
void* addr_;
void* canonicalAddr_;
const char* label_;
uint32_t depth_;
mozilla::Maybe<uint8_t> optsIndex_;
FrameHandle(JSRuntime* rt, js::jit::JitcodeGlobalEntry& entry, void* addr,
const char* label, uint32_t depth);
void updateHasTrackedOptimizations();
public:
const char* label() const { return label_; }
uint32_t depth() const { return depth_; }
bool hasTrackedOptimizations() const { return optsIndex_.isSome(); }
void* canonicalAddress() const { return canonicalAddr_; }
ProfilingFrameIterator::FrameKind frameKind() const;
void forEachOptimizationAttempt(ForEachTrackedOptimizationAttemptOp& op,
JSScript** scriptOut, jsbytecode** pcOut) const;
void forEachOptimizationTypeInfo(ForEachTrackedOptimizationTypeInfoOp& op) const;
};
// Called once per frame.
virtual void operator()(const FrameHandle& frame) = 0;
};
JS_PUBLIC_API(void)
ForEachProfiledFrame(JSRuntime* rt, void* addr, ForEachProfiledFrameOp& op);
} // namespace JS
#endif /* js_ProfilingFrameIterator_h */