Files
sousa-gecko/dom/webgpu/CompilationMessage.h
Emilio Cobos Álvarez fe182cca64 Bug 2025271 - Simplify DOMString. r=smaug,nika,extension-reviewers,core-sessionstore-reviewers,dom-worker-reviewers,robwu,asuth
Make DOMString a regular nsAutoTString with some special methods for
performance in some hot getters. For that, we need to change a bit
nsTString:

 * Support for unowned buffers: Owned buffers now are represented by
   STRINGBUFFER|OWNED flags, rather than REFCOUNTED.

 * Inlining of the destructor: It showed up in profiles, it's also just
   a few instructions, so probably worth it. We could OOL the owned path
   I guess, if we wanted to.

 * Inlinling and reordering of NonVoidStringToJsval. Old code had
   special DOMString path inline with [buffer, literal, copy] paths,
   then out of line code with [literal, buffer, copy]. Instead,
   consolidate everything in a [buffer, literal, copy] inline path.
   Do the same for UTF8/Latin1 strings too for consistency.

Differential Revision: https://phabricator.services.mozilla.com/D288148
2026-04-13 09:33:54 +00:00

54 lines
1.6 KiB
C++

/* 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 GPU_CompilationMessage_H_
#define GPU_CompilationMessage_H_
#include "ObjectModel.h"
#include "mozilla/dom/WebGPUBinding.h"
#include "nsWrapperCache.h"
namespace mozilla {
namespace dom {
class DOMString;
} // namespace dom
namespace webgpu {
class CompilationInfo;
class CompilationMessage final : public nsWrapperCache, public ChildOf<Device> {
dom::GPUCompilationMessageType mType;
uint64_t mLineNum = 0;
uint64_t mLinePos = 0;
uint64_t mOffset = 0;
uint64_t mLength = 0;
const nsString mMessage;
public:
GPU_DECL_CYCLE_COLLECTION(CompilationMessage)
GPU_DECL_JS_WRAP(CompilationMessage)
explicit CompilationMessage(Device* const aParent,
dom::GPUCompilationMessageType aType,
uint64_t aLineNum, uint64_t aLinePos,
uint64_t aOffset, uint64_t aLength,
nsString&& aMessage);
void GetMessage(dom::DOMString& aMessage) {
aMessage.SetKnownLiveString(mMessage);
}
dom::GPUCompilationMessageType Type() const { return mType; }
uint64_t LineNum() const { return mLineNum; }
uint64_t LinePos() const { return mLinePos; }
uint64_t Offset() const { return mOffset; }
uint64_t Length() const { return mLength; }
private:
virtual ~CompilationMessage();
};
} // namespace webgpu
} // namespace mozilla
#endif // GPU_CompilationMessage_H_