From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../profiler/core/ProfileAdditionalInformation.cpp | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tools/profiler/core/ProfileAdditionalInformation.cpp (limited to 'tools/profiler/core/ProfileAdditionalInformation.cpp') diff --git a/tools/profiler/core/ProfileAdditionalInformation.cpp b/tools/profiler/core/ProfileAdditionalInformation.cpp new file mode 100644 index 0000000000..ba3cd80e7c --- /dev/null +++ b/tools/profiler/core/ProfileAdditionalInformation.cpp @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 8; 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/. */ + +#include "ProfileAdditionalInformation.h" + +#include "jsapi.h" +#include "js/JSON.h" +#include "js/PropertyAndElement.h" +#include "js/Value.h" +#include "mozilla/JSONStringWriteFuncs.h" +#include "mozilla/ipc/IPDLParamTraits.h" + +#ifdef MOZ_GECKO_PROFILER +# include "platform.h" + +void mozilla::ProfileGenerationAdditionalInformation::ToJSValue( + JSContext* aCx, JS::MutableHandle aRetVal) const { + // Get the shared libraries array. + JS::Rooted sharedLibrariesVal(aCx); + { + JSONStringWriteFunc buffer; + JSONWriter w(buffer, JSONWriter::SingleLineStyle); + w.StartArrayElement(); + AppendSharedLibraries(w, mSharedLibraries); + w.EndArray(); + NS_ConvertUTF8toUTF16 buffer16(buffer.StringCRef()); + MOZ_ALWAYS_TRUE(JS_ParseJSON(aCx, + static_cast(buffer16.get()), + buffer16.Length(), &sharedLibrariesVal)); + } + + JS::Rooted additionalInfoObj(aCx, JS_NewPlainObject(aCx)); + JS_SetProperty(aCx, additionalInfoObj, "sharedLibraries", sharedLibrariesVal); + aRetVal.setObject(*additionalInfoObj); +} +#endif // MOZ_GECKO_PROFILER + +namespace IPC { + +#ifdef MOZ_GECKO_PROFILER +void IPC::ParamTraits::Write(MessageWriter* aWriter, + const paramType& aParam) { + WriteParam(aWriter, aParam.mStart); + WriteParam(aWriter, aParam.mEnd); + WriteParam(aWriter, aParam.mOffset); + WriteParam(aWriter, aParam.mBreakpadId); + WriteParam(aWriter, aParam.mCodeId); + WriteParam(aWriter, aParam.mModuleName); + WriteParam(aWriter, aParam.mModulePath); + WriteParam(aWriter, aParam.mDebugName); + WriteParam(aWriter, aParam.mDebugPath); + WriteParam(aWriter, aParam.mVersion); + WriteParam(aWriter, aParam.mArch); +} + +bool IPC::ParamTraits::Read(MessageReader* aReader, + paramType* aResult) { + return ReadParam(aReader, &aResult->mStart) && + ReadParam(aReader, &aResult->mEnd) && + ReadParam(aReader, &aResult->mOffset) && + ReadParam(aReader, &aResult->mBreakpadId) && + ReadParam(aReader, &aResult->mCodeId) && + ReadParam(aReader, &aResult->mModuleName) && + ReadParam(aReader, &aResult->mModulePath) && + ReadParam(aReader, &aResult->mDebugName) && + ReadParam(aReader, &aResult->mDebugPath) && + ReadParam(aReader, &aResult->mVersion) && + ReadParam(aReader, &aResult->mArch); +} + +void IPC::ParamTraits::Write(MessageWriter* aWriter, + const paramType& aParam) { + paramType& p = const_cast(aParam); + WriteParam(aWriter, p.mEntries); +} + +bool IPC::ParamTraits::Read(MessageReader* aReader, + paramType* aResult) { + return ReadParam(aReader, &aResult->mEntries); +} +#endif // MOZ_GECKO_PROFILER + +void IPC::ParamTraits::Write( + MessageWriter* aWriter, const paramType& aParam) { +#ifdef MOZ_GECKO_PROFILER + WriteParam(aWriter, aParam.mSharedLibraries); +#endif // MOZ_GECKO_PROFILER +} + +bool IPC::ParamTraits::Read( + MessageReader* aReader, paramType* aResult) { +#ifdef MOZ_GECKO_PROFILER + return ReadParam(aReader, &aResult->mSharedLibraries); +#else + return true; +#endif // MOZ_GECKO_PROFILER +} + +} // namespace IPC -- cgit v1.2.3