Bug 1865597 - Add error checking when initializing parallel marking and disable on...
[gecko.git] / js / src / frontend / Frontend2.h
blob6d14de999c60a82dc40d16ccfaff3498ff337f4d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef frontend_Frontend2_h
8 #define frontend_Frontend2_h
10 #include "mozilla/Utf8.h" // mozilla::Utf8Unit
12 #include <stddef.h> // size_t
13 #include <stdint.h> // uint8_t
15 #include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions
16 #include "js/RootingAPI.h" // JS::Handle
17 #include "js/SourceText.h" // JS::SourceText
18 #include "js/UniquePtr.h" // js::UniquePtr
19 #include "vm/JSScript.h" // JSScript
21 struct JSContext;
23 struct SmooshResult;
25 namespace js {
27 class ScriptSourceObject;
28 class FrontendContext;
30 namespace frontend {
32 struct CompilationInput;
33 struct ExtensibleCompilationStencil;
34 struct CompilationGCOutput;
35 struct CompilationState;
37 // This is declarated as a class mostly to solve dependency around `friend`
38 // declarations in the simple way.
39 class Smoosh {
40 public:
41 [[nodiscard]] static bool tryCompileGlobalScriptToExtensibleStencil(
42 JSContext* cx, FrontendContext* fc, CompilationInput& input,
43 JS::SourceText<mozilla::Utf8Unit>& srcBuf,
44 UniquePtr<ExtensibleCompilationStencil>& stencilOut);
47 // Initialize SmooshMonkey globals, such as the logging system.
48 void InitSmoosh();
50 // Use the SmooshMonkey frontend to parse and free the generated AST. Returns
51 // true if no error were detected while parsing.
52 [[nodiscard]] bool SmooshParseScript(JSContext* cx, const uint8_t* bytes,
53 size_t length);
54 [[nodiscard]] bool SmooshParseModule(JSContext* cx, const uint8_t* bytes,
55 size_t length);
57 } // namespace frontend
59 } // namespace js
61 #endif /* frontend_Frontend2_h */