From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/frontend/BytecodeCompilation.h | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 js/src/frontend/BytecodeCompilation.h (limited to 'js/src/frontend/BytecodeCompilation.h') diff --git a/js/src/frontend/BytecodeCompilation.h b/js/src/frontend/BytecodeCompilation.h new file mode 100644 index 0000000000..f6bd649725 --- /dev/null +++ b/js/src/frontend/BytecodeCompilation.h @@ -0,0 +1,108 @@ +/* -*- 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/. */ + +#ifndef frontend_BytecodeCompilation_h +#define frontend_BytecodeCompilation_h + +#include "mozilla/AlreadyAddRefed.h" +#include "mozilla/Utf8.h" // mozilla::Utf8Unit + +#include "frontend/ScriptIndex.h" // ScriptIndex +#include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions, JS::InstantiateOptions +#include "js/SourceText.h" // JS::SourceText +#include "js/TypeDecls.h" // JS::Handle (fwd) +#include "js/UniquePtr.h" // js::UniquePtr +#include "vm/ScopeKind.h" // js::ScopeKind + +namespace js { + +class Scope; +class LifoAlloc; +class FrontendContext; + +namespace frontend { + +struct CompilationInput; +struct CompilationGCOutput; +struct CompilationStencil; +struct ExtensibleCompilationStencil; +class ScopeBindingCache; + +extern already_AddRefed CompileGlobalScriptToStencil( + JSContext* maybeCx, FrontendContext* fc, js::LifoAlloc& tempLifoAlloc, + CompilationInput& input, ScopeBindingCache* scopeCache, + JS::SourceText& srcBuf, ScopeKind scopeKind); + +extern already_AddRefed CompileGlobalScriptToStencil( + JSContext* maybeCx, FrontendContext* fc, js::LifoAlloc& tempLifoAlloc, + CompilationInput& input, ScopeBindingCache* scopeCache, + JS::SourceText& srcBuf, ScopeKind scopeKind); + +extern UniquePtr +CompileGlobalScriptToExtensibleStencil(JSContext* maybeCx, FrontendContext* fc, + CompilationInput& input, + ScopeBindingCache* scopeCache, + JS::SourceText& srcBuf, + ScopeKind scopeKind); + +extern UniquePtr +CompileGlobalScriptToExtensibleStencil( + JSContext* maybeCx, FrontendContext* fc, CompilationInput& input, + ScopeBindingCache* scopeCache, JS::SourceText& srcBuf, + ScopeKind scopeKind); + +// Perform some operation to reduce the time taken by instantiation. +// +// Part of InstantiateStencils can be done by calling PrepareForInstantiate. +// PrepareForInstantiate is GC-free operation that can be performed +// off-main-thread without parse global. +[[nodiscard]] extern bool PrepareForInstantiate( + JSContext* maybeCx, FrontendContext* fc, CompilationInput& input, + const CompilationStencil& stencil, CompilationGCOutput& gcOutput); + +[[nodiscard]] extern bool InstantiateStencils(JSContext* cx, + CompilationInput& input, + const CompilationStencil& stencil, + CompilationGCOutput& gcOutput); + +extern JSScript* CompileGlobalScript(JSContext* cx, FrontendContext* fc, + const JS::ReadOnlyCompileOptions& options, + JS::SourceText& srcBuf, + ScopeKind scopeKind); + +extern JSScript* CompileGlobalScript(JSContext* cx, FrontendContext* fc, + const JS::ReadOnlyCompileOptions& options, + JS::SourceText& srcBuf, + ScopeKind scopeKind); + +extern JSScript* CompileEvalScript(JSContext* cx, + const JS::ReadOnlyCompileOptions& options, + JS::SourceText& srcBuf, + JS::Handle enclosingScope, + JS::Handle enclosingEnv); + +extern bool DelazifyCanonicalScriptedFunction(JSContext* cx, + FrontendContext* fc, + JS::Handle fun); + +extern already_AddRefed DelazifyCanonicalScriptedFunction( + JSContext* cx, FrontendContext* fc, ScopeBindingCache* scopeCache, + CompilationStencil& context, ScriptIndex scriptIndex); + +// Certain compile options will disable the syntax parser entirely. +inline bool CanLazilyParse(const JS::ReadOnlyCompileOptions& options) { + return !options.discardSource && !options.sourceIsLazy && + !options.forceFullParse(); +} + +void FireOnNewScript(JSContext* cx, const JS::InstantiateOptions& options, + JS::Handle script); + +} // namespace frontend + +} // namespace js + +#endif // frontend_BytecodeCompilation_h -- cgit v1.2.3