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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,6 +4,7 @@
* 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 "js/SourceBufferHolder.h"
#include "jsapi-tests/tests.h"
struct ScriptObjectFixture : public JSAPITest {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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