/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
class ProfilerCodeAddressService; struct JSContext;
class ProfileBufferEntry { public: using KindUnderlyingType =
std::underlying_type_t<::mozilla::ProfileBufferEntryKind>; using Kind = mozilla::ProfileBufferEntryKind;
// Packed layout: 1 byte for the tag + 8 bytes for the value.
static_assert(sizeof(ProfileBufferEntry) == 9, "bad ProfileBufferEntry size");
// Contains all the information about JIT frames that is needed to stream stack // frames for JitReturnAddr entries in the profiler buffer. // Every return address (void*) is mapped to one or more JITFrameKeys, and // every JITFrameKey is mapped to a JSON string for that frame. // mRangeStart and mRangeEnd describe the range in the buffer for which this // mapping is valid. Only JitReturnAddr entries within that buffer range can be // processed using this JITFrameInfoForBufferRange object. struct JITFrameInfoForBufferRange final {
JITFrameInfoForBufferRange Clone() const;
uint64_t mRangeStart;
uint64_t mRangeEnd; // mRangeEnd marks the first invalid index.
// Creates a new JITFrameInfoForBufferRange object in mRanges by looking up // information about the provided JIT return addresses using aCx. // Addresses are provided like this: // The caller of AddInfoForRange supplies a function in aJITAddressProvider. // This function will be called once, synchronously, with an // aJITAddressConsumer argument, which is a function that needs to be called // for every address. That function can be called multiple times for the same // address. void AddInfoForRange(
uint64_t aRangeStart, uint64_t aRangeEnd, JSContext* aCx, const std::function<void(const std::function<void(void*)>&)>&
aJITAddressProvider);
// Returns whether the information stored in this object is still relevant // for any entries in the buffer. bool HasExpired(uint64_t aCurrentBufferRangeStart) const { if (mRanges.empty()) { // No information means no relevant information. Allow this object to be // discarded. returntrue;
} return mRanges.back().mRangeEnd <= aCurrentBufferRangeStart;
}
// The encapsulated data points at the local FailureLatch, so on the way out // they must be given a new external FailureLatch to start using instead.
mozilla::Vector<JITFrameInfoForBufferRange>&& MoveRangesWithNewFailureLatch(
mozilla::FailureLatch& aFailureLatch) &&;
mozilla::UniquePtr<UniqueJSONStrings>&& MoveUniqueStringsWithNewFailureLatch(
mozilla::FailureLatch& aFailureLatch) &&;
private: // JITFrameInfo's may exist during profiling, so it carries its own fallible // FailureLatch. If&when the data below is finally extracted, any error is // forwarded to the caller.
mozilla::FailureLatchSource mLocalFailureLatchSource;
// The array of ranges of JIT frame information, sorted by buffer position. // Ranges are non-overlapping. // The JSON of the cached frames can contain string indexes, which refer // to strings in mUniqueStrings.
mozilla::Vector<JITFrameInfoForBufferRange> mRanges;
// The string table which contains strings used in the frame JSON that's // cached in mRanges.
mozilla::UniquePtr<UniqueJSONStrings> mUniqueStrings;
};
class UniqueStacks final : public mozilla::FailureLatch { public: struct FrameKey { explicit FrameKey(constchar* aLocation)
: mData(NormalFrameData{nsCString(aLocation), false, false, 0,
mozilla::Nothing(), mozilla::Nothing()}) {}
// Return a StackKey for aFrame as the stack's root frame (no prefix).
[[nodiscard]] mozilla::Maybe<StackKey> BeginStack(const FrameKey& aFrame);
// Return a new StackKey that is obtained by appending aFrame to aStack.
[[nodiscard]] mozilla::Maybe<StackKey> AppendFrame(const StackKey& aStack, const FrameKey& aFrame);
// Look up frame keys for the given JIT address, and ensure that our frame // table has entries for the returned frame keys. The JSON for these frames // is taken from mJITInfoRanges. // aBufferPosition is needed in order to look up the correct JIT frame info // object in mJITInfoRanges.
[[nodiscard]] mozilla::Maybe<mozilla::Vector<UniqueStacks::FrameKey>>
LookupFramesForJITAddressFromBufferPos(void* aJITAddress,
uint64_t aBufferPosition);
// Find the function name at the given PC (if a ProfilerCodeAddressService was // provided), otherwise just stringify that PC.
[[nodiscard]] nsAutoCString FunctionNameOrAddress(void* aPC);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.