Issue #2692 - Part 6: Don't #include js/SourceBufferHolder.h in jsapi.h.

Instead, require users to do so. This is a minor translation-unit size
improvement for anyone who never has to use SourceBufferHolder other than
by reference.
This commit is contained in:
Moonchild 2025-03-04 20:16:54 +01:00 • committed by roytam1
commit 2e4620b5af
28 changed files with 43 additions and 8 deletions

View file

@ -27,6 +27,7 @@
#include "nsIScriptSecurityManager.h" #include "nsIScriptSecurityManager.h"
#include "nsIDOMClassInfo.h" #include "nsIDOMClassInfo.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "js/SourceBufferHolder.h"
#include "mozilla/CycleCollectedJSContext.h" #include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/IntentionalCrash.h" #include "mozilla/IntentionalCrash.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"

View file

@ -13,6 +13,7 @@
#include "nsJSUtils.h" #include "nsJSUtils.h"
#include "jsapi.h" #include "jsapi.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/SourceBufferHolder.h"
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIXPConnect.h" #include "nsIXPConnect.h"

View file

@ -11,6 +11,7 @@
#include "prsystem.h" #include "prsystem.h"
#include "jsapi.h" #include "jsapi.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/SourceBufferHolder.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsIContent.h" #include "nsIContent.h"

View file

@ -24,6 +24,7 @@
#include "jsapi.h" #include "jsapi.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/SourceBufferHolder.h"
#include "nsError.h" #include "nsError.h"
#include "nsContentPolicyUtils.h" #include "nsContentPolicyUtils.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"

View file

@ -37,6 +37,7 @@
#include "ImageContainer.h" #include "ImageContainer.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/MemoryMetrics.h" #include "js/MemoryMetrics.h"
#include "js/SourceBufferHolder.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/ContentEvents.h" #include "mozilla/ContentEvents.h"

View file

@ -13,6 +13,7 @@
#include "mozilla/dom/Response.h" #include "mozilla/dom/Response.h"
#include "mozilla/dom/ScriptLoader.h" #include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
#include "js/SourceBufferHolder.h"
#include "nsIInputStreamPump.h" #include "nsIInputStreamPump.h"
#include "nsIThreadRetargetableRequest.h" #include "nsIThreadRetargetableRequest.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"

View file

@ -88,6 +88,7 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "nsTextNode.h" #include "nsTextNode.h"
#include "nsJSUtils.h" #include "nsJSUtils.h"
#include "js/SourceBufferHolder.h"
#include "mozilla/dom/URL.h" #include "mozilla/dom/URL.h"
#include "nsIContentPolicy.h" #include "nsIContentPolicy.h"
#include "mozAutoDocUpdate.h" #include "mozAutoDocUpdate.h"

View file

@ -26,6 +26,7 @@
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h" #include "mozilla/EventStateManager.h"
#include "mozilla/EventStates.h" #include "mozilla/EventStates.h"
#include "js/SourceBufferHolder.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsHTMLStyleSheet.h" #include "nsHTMLStyleSheet.h"
#include "nsNameSpaceManager.h" #include "nsNameSpaceManager.h"

View file

@ -15,6 +15,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "jsapi.h" #include "jsapi.h"
#include "js/SourceBufferHolder.h"
#include "xpcpublic.h" #include "xpcpublic.h"

View file

@ -113,7 +113,6 @@ using JS::IsAcceptableThis;
using JS::NativeImpl; using JS::NativeImpl;
using JS::OwningCompileOptions; using JS::OwningCompileOptions;
using JS::ReadOnlyCompileOptions; using JS::ReadOnlyCompileOptions;
using JS::SourceBufferHolder;
using JS::TransitiveCompileOptions; using JS::TransitiveCompileOptions;
using JS::Rooted; using JS::Rooted;

View file

@ -12,6 +12,7 @@
#include "jshashutil.h" #include "jshashutil.h"
#include "frontend/BytecodeCompiler.h" #include "frontend/BytecodeCompiler.h"
#include "js/SourceBufferHolder.h"
#include "vm/Debugger.h" #include "vm/Debugger.h"
#include "vm/GlobalObject.h" #include "vm/GlobalObject.h"
#include "vm/JSONParser.h" #include "vm/JSONParser.h"
@ -25,6 +26,7 @@ using mozilla::HashString;
using mozilla::RangedPtr; using mozilla::RangedPtr;
using JS::AutoCheckCannotGC; using JS::AutoCheckCannotGC;
using JS::SourceBufferHolder;
// We should be able to assert this for *any* fp->environmentChain(). // We should be able to assert this for *any* fp->environmentChain().
static void static void

View file

@ -16,6 +16,7 @@
#include "frontend/FoldConstants.h" #include "frontend/FoldConstants.h"
#include "frontend/NameFunctions.h" #include "frontend/NameFunctions.h"
#include "frontend/Parser.h" #include "frontend/Parser.h"
#include "js/SourceBufferHolder.h"
#include "vm/GlobalObject.h" #include "vm/GlobalObject.h"
#include "vm/TraceLogging.h" #include "vm/TraceLogging.h"
#include "wasm/AsmJS.h" #include "wasm/AsmJS.h"
@ -27,9 +28,12 @@
using namespace js; using namespace js;
using namespace js::frontend; using namespace js::frontend;
using mozilla::Maybe; using mozilla::Maybe;
using mozilla::Nothing; using mozilla::Nothing;
using JS::SourceBufferHolder;
class MOZ_STACK_CLASS AutoCompilationTraceLogger class MOZ_STACK_CLASS AutoCompilationTraceLogger
{ {
public: public:

View file

@ -28,7 +28,7 @@ namespace frontend {
JSScript* JSScript*
CompileGlobalScript(ExclusiveContext* cx, LifoAlloc& alloc, ScopeKind scopeKind, CompileGlobalScript(ExclusiveContext* cx, LifoAlloc& alloc, ScopeKind scopeKind,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, JS::SourceBufferHolder& srcBuf,
SourceCompressionTask* extraSct = nullptr, SourceCompressionTask* extraSct = nullptr,
ScriptSourceObject** sourceObjectOut = nullptr); ScriptSourceObject** sourceObjectOut = nullptr);
@ -36,17 +36,17 @@ JSScript*
CompileEvalScript(ExclusiveContext* cx, LifoAlloc& alloc, CompileEvalScript(ExclusiveContext* cx, LifoAlloc& alloc,
HandleObject scopeChain, HandleScope enclosingScope, HandleObject scopeChain, HandleScope enclosingScope,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, JS::SourceBufferHolder& srcBuf,
SourceCompressionTask* extraSct = nullptr, SourceCompressionTask* extraSct = nullptr,
ScriptSourceObject** sourceObjectOut = nullptr); ScriptSourceObject** sourceObjectOut = nullptr);
ModuleObject* ModuleObject*
CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options, CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf); JS::SourceBufferHolder& srcBuf);
ModuleObject* ModuleObject*
CompileModule(ExclusiveContext* cx, const ReadOnlyCompileOptions& options, CompileModule(ExclusiveContext* cx, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, LifoAlloc& alloc, JS::SourceBufferHolder& srcBuf, LifoAlloc& alloc,
ScriptSourceObject** sourceObjectOut = nullptr); ScriptSourceObject** sourceObjectOut = nullptr);
MOZ_MUST_USE bool MOZ_MUST_USE bool

View file

@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/ */
#include "js/SourceBufferHolder.h"
#include "jsapi-tests/tests.h" #include "jsapi-tests/tests.h"
using mozilla::ArrayLength; using mozilla::ArrayLength;

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/SourceBufferHolder.h"
#include "jsapi-tests/tests.h" #include "jsapi-tests/tests.h"
BEGIN_TEST(testMutedErrors) BEGIN_TEST(testMutedErrors)

View file

@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "js/SourceBufferHolder.h"
#include "jsapi-tests/tests.h" #include "jsapi-tests/tests.h"
struct ScriptObjectFixture : public JSAPITest { struct ScriptObjectFixture : public JSAPITest {

View file

@ -63,6 +63,7 @@
#include "js/Initialization.h" #include "js/Initialization.h"
#include "js/Proxy.h" #include "js/Proxy.h"
#include "js/SliceBudget.h" #include "js/SliceBudget.h"
#include "js/SourceBufferHolder.h"
#include "js/StructuredClone.h" #include "js/StructuredClone.h"
#include "js/Utility.h" #include "js/Utility.h"
#include "vm/AsyncFunction.h" #include "vm/AsyncFunction.h"
@ -106,6 +107,7 @@ using mozilla::PodZero;
using mozilla::Some; using mozilla::Some;
using JS::AutoGCRooter; using JS::AutoGCRooter;
using JS::SourceBufferHolder;
using JS::ToInt32; using JS::ToInt32;
using JS::ToInteger; using JS::ToInteger;
using JS::ToUint32; using JS::ToUint32;

View file

@ -38,7 +38,6 @@
#include "js/Principals.h" #include "js/Principals.h"
#include "js/Realm.h" #include "js/Realm.h"
#include "js/RootingAPI.h" #include "js/RootingAPI.h"
#include "js/SourceBufferHolder.h"
#include "js/Stream.h" #include "js/Stream.h"
#include "js/TracingAPI.h" #include "js/TracingAPI.h"
#include "js/Transcoding.h" #include "js/Transcoding.h"

View file

@ -39,6 +39,7 @@
#include "jit/JitFrameIterator.h" #include "jit/JitFrameIterator.h"
#include "js/CallNonGenericMethod.h" #include "js/CallNonGenericMethod.h"
#include "js/Proxy.h" #include "js/Proxy.h"
#include "js/SourceBufferHolder.h"
#include "vm/AsyncFunction.h" #include "vm/AsyncFunction.h"
#include "vm/AsyncIteration.h" #include "vm/AsyncIteration.h"
#include "vm/Debugger.h" #include "vm/Debugger.h"
@ -67,6 +68,7 @@ using mozilla::PodCopy;
using mozilla::RangedPtr; using mozilla::RangedPtr;
using mozilla::Some; using mozilla::Some;
using JS::SourceBufferHolder;
static bool static bool
fun_enumerate(JSContext* cx, HandleObject obj) fun_enumerate(JSContext* cx, HandleObject obj)
{ {

View file

@ -41,6 +41,7 @@
#include "jit/Ion.h" #include "jit/Ion.h"
#include "jit/IonCode.h" #include "jit/IonCode.h"
#include "js/MemoryMetrics.h" #include "js/MemoryMetrics.h"
#include "js/SourceBufferHolder.h"
#include "js/Utility.h" #include "js/Utility.h"
#include "vm/ArgumentsObject.h" #include "vm/ArgumentsObject.h"
#include "vm/Compression.h" #include "vm/Compression.h"
@ -68,6 +69,8 @@ using mozilla::PodCopy;
using mozilla::PodZero; using mozilla::PodZero;
using mozilla::RotateLeft; using mozilla::RotateLeft;
using JS::SourceBufferHolder;
template<XDRMode mode> template<XDRMode mode>
bool bool
js::XDRScriptConst(XDRState<mode>* xdr, MutableHandleValue vp) js::XDRScriptConst(XDRState<mode>* xdr, MutableHandleValue vp)

View file

@ -74,6 +74,7 @@
#include "js/Equality.h" // JS::SameValue #include "js/Equality.h" // JS::SameValue
#include "js/GCAPI.h" #include "js/GCAPI.h"
#include "js/Initialization.h" #include "js/Initialization.h"
#include "js/SourceBufferHolder.h"
#include "js/StructuredClone.h" #include "js/StructuredClone.h"
#include "js/TrackedOptimizationInfo.h" #include "js/TrackedOptimizationInfo.h"
#include "perf/jsperf.h" #include "perf/jsperf.h"
@ -4062,8 +4063,8 @@ ParseModule(JSContext* cx, unsigned argc, Value* vp)
return false; return false;
const char16_t* chars = stableChars.twoByteRange().begin().get(); const char16_t* chars = stableChars.twoByteRange().begin().get();
SourceBufferHolder srcBuf(chars, scriptContents->length(), JS::SourceBufferHolder srcBuf(chars, scriptContents->length(),
SourceBufferHolder::NoOwnership); SourceBufferHolder::NoOwnership);
RootedObject module(cx, frontend::CompileModule(cx, options, srcBuf)); RootedObject module(cx, frontend::CompileModule(cx, options, srcBuf));
if (!module) if (!module)

View file

@ -27,6 +27,7 @@
#include "jit/BaselineJIT.h" #include "jit/BaselineJIT.h"
#include "js/Date.h" #include "js/Date.h"
#include "js/GCAPI.h" #include "js/GCAPI.h"
#include "js/SourceBufferHolder.h"
#include "js/UbiNodeBreadthFirst.h" #include "js/UbiNodeBreadthFirst.h"
#include "js/Vector.h" #include "js/Vector.h"
#include "proxy/ScriptedProxyHandler.h" #include "proxy/ScriptedProxyHandler.h"
@ -51,6 +52,7 @@ using namespace js;
using JS::dbg::AutoEntryMonitor; using JS::dbg::AutoEntryMonitor;
using JS::dbg::Builder; using JS::dbg::Builder;
using js::frontend::IsIdentifier; using js::frontend::IsIdentifier;
using JS::SourceBufferHolder;
using mozilla::ArrayLength; using mozilla::ArrayLength;
using mozilla::DebugOnly; using mozilla::DebugOnly;
using mozilla::MakeScopeExit; using mozilla::MakeScopeExit;

View file

@ -10,6 +10,7 @@
#include "jsnativestack.h" #include "jsnativestack.h"
#include "jsnum.h" // For FIX_FPU() #include "jsnum.h" // For FIX_FPU()
#include "js/SourceBufferHolder.h"
#include "builtin/Promise.h" #include "builtin/Promise.h"
#include "frontend/BytecodeCompiler.h" #include "frontend/BytecodeCompiler.h"
@ -33,6 +34,8 @@ using mozilla::DebugOnly;
using mozilla::Unused; using mozilla::Unused;
using mozilla::TimeDuration; using mozilla::TimeDuration;
using JS::SourceBufferHolder;
namespace js { namespace js {
GlobalHelperThreadState* gHelperThreadState = nullptr; GlobalHelperThreadState* gHelperThreadState = nullptr;

View file

@ -21,6 +21,7 @@
#include "frontend/TokenStream.h" #include "frontend/TokenStream.h"
#include "jit/Ion.h" #include "jit/Ion.h"
#include "js/SourceBufferHolder.h"
#include "threading/ConditionVariable.h" #include "threading/ConditionVariable.h"
#include "vm/MutexIDs.h" #include "vm/MutexIDs.h"

View file

@ -33,6 +33,7 @@
#include "frontend/Parser.h" #include "frontend/Parser.h"
#include "gc/Policy.h" #include "gc/Policy.h"
#include "js/MemoryMetrics.h" #include "js/MemoryMetrics.h"
#include "js/SourceBufferHolder.h"
#include "vm/SelfHosting.h" #include "vm/SelfHosting.h"
#include "vm/StringBuffer.h" #include "vm/StringBuffer.h"
#include "vm/Time.h" #include "vm/Time.h"
@ -67,6 +68,7 @@ using mozilla::PodZero;
using mozilla::PositiveInfinity; using mozilla::PositiveInfinity;
using JS::AsmJSOption; using JS::AsmJSOption;
using JS::GenericNaN; using JS::GenericNaN;
using JS::SourceBufferHolder;
/*****************************************************************************/ /*****************************************************************************/

View file

@ -17,6 +17,7 @@
#endif #endif
#include "jsapi.h" #include "jsapi.h"
#include "js/SourceBufferHolder.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"

View file

@ -19,6 +19,7 @@
#include "jsapi.h" #include "jsapi.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/SourceBufferHolder.h"
#include "nsJSPrincipals.h" #include "nsJSPrincipals.h"
#include "xpcprivate.h" // For xpc::OptionsBase #include "xpcprivate.h" // For xpc::OptionsBase
#include "jswrapper.h" #include "jswrapper.h"

View file

@ -10,6 +10,7 @@
#include "AccessCheck.h" #include "AccessCheck.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "js/Proxy.h" #include "js/Proxy.h"
#include "js/SourceBufferHolder.h"
#include "js/StructuredClone.h" #include "js/StructuredClone.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsGlobalWindow.h" #include "nsGlobalWindow.h"