Bug 1692648 - Part 4: Add ExtensibleCompilationStencil and move stencil-related fields from CompilationState, and make CompilationState subclass of it. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D105720
This commit is contained in:
Tooru Fujisawa 2021-02-24 04:22:29 +00:00
parent 23690adb54
commit 0bbe9def38
3 changed files with 37 additions and 30 deletions

View File

@ -597,9 +597,32 @@ inline const CompilationStencil& BaseCompilationStencil::asCompilationStencil()
return *static_cast<const CompilationStencil*>(this);
}
struct MOZ_RAII CompilationState {
// Until we have dealt with Atoms in the front end, we need to hold
// onto them.
// Temporary space to accumulate stencil data.
// Copied to BaseCompilationStencil by `CompilationState::finish` method.
//
// See BaseCompilationStencil for each field's description.
struct ExtensibleCompilationStencil {
Vector<ScriptStencil, 0, js::SystemAllocPolicy> scriptData;
Vector<ScriptStencilExtra, 0, js::SystemAllocPolicy> scriptExtra;
Vector<TaggedScriptThingIndex, 0, js::SystemAllocPolicy> gcThingData;
Vector<ScopeStencil, 0, js::SystemAllocPolicy> scopeData;
Vector<BaseParserScopeData*, 0, js::SystemAllocPolicy> scopeNames;
Vector<RegExpStencil, 0, js::SystemAllocPolicy> regExpData;
Vector<BigIntStencil, 0, js::SystemAllocPolicy> bigIntData;
Vector<ObjLiteralStencil, 0, js::SystemAllocPolicy> objLiteralData;
StencilAsmJSContainer asmJS;
// Table of parser atoms for this compilation.
ParserAtomsTable parserAtoms;
ExtensibleCompilationStencil(JSContext* cx, LifoAlloc& stencilAlloc);
};
struct MOZ_RAII CompilationState : public ExtensibleCompilationStencil {
Directives directives;
ScopeContext scopeContext;
@ -609,26 +632,6 @@ struct MOZ_RAII CompilationState {
CompilationInput& input;
// Temporary space to accumulate stencil data.
// Copied to BaseCompilationStencil by `finish` method.
//
// See corresponding BaseCompilationStencil fields for desription.
Vector<RegExpStencil, 0, js::SystemAllocPolicy> regExpData;
Vector<BigIntStencil, 0, js::SystemAllocPolicy> bigIntData;
Vector<ObjLiteralStencil, 0, js::SystemAllocPolicy> objLiteralData;
Vector<ScriptStencil, 0, js::SystemAllocPolicy> scriptData;
Vector<ScriptStencilExtra, 0, js::SystemAllocPolicy> scriptExtra;
Vector<ScopeStencil, 0, js::SystemAllocPolicy> scopeData;
Vector<BaseParserScopeData*, 0, js::SystemAllocPolicy> scopeNames;
Vector<TaggedScriptThingIndex, 0, js::SystemAllocPolicy> gcThingData;
// Accumulate asmJS modules here and then transfer to the stencil during the
// `finish` method.
StencilAsmJSContainer asmJS;
// Table of parser atoms for this compilation.
ParserAtomsTable parserAtoms;
// The number of functions that *will* have bytecode.
// This doesn't count top-level non-function script.
//

View File

@ -15,7 +15,7 @@
#include "frontend/AbstractScopePtr.h" // ScopeIndex
#include "frontend/BytecodeCompilation.h" // CanLazilyParse
#include "frontend/BytecodeSection.h" // EmitScriptThingsVector
#include "frontend/CompilationStencil.h" // CompilationStencil, CompilationGCOutput
#include "frontend/CompilationStencil.h" // CompilationStencil, ExtensibleCompilationStencil, CompilationGCOutput
#include "frontend/SharedContext.h"
#include "gc/AllocKind.h" // gc::AllocKind
#include "gc/Rooting.h" // RootedAtom
@ -1545,15 +1545,19 @@ bool CompilationStencil::deserializeStencils(JSContext* cx,
return true;
}
ExtensibleCompilationStencil::ExtensibleCompilationStencil(
JSContext* cx, LifoAlloc& stencilAlloc)
: parserAtoms(cx->runtime(), stencilAlloc) {}
CompilationState::CompilationState(JSContext* cx,
LifoAllocScope& frontendAllocScope,
CompilationInput& input,
LifoAlloc& stencilAlloc)
: directives(input.options.forceStrictMode()),
: ExtensibleCompilationStencil(cx, stencilAlloc),
directives(input.options.forceStrictMode()),
usedNames(cx),
allocScope(frontendAllocScope),
input(input),
parserAtoms(cx->runtime(), stencilAlloc) {}
input(input) {}
SharedDataContainer::~SharedDataContainer() {
if (isEmpty()) {

View File

@ -164,7 +164,7 @@ using RegExpIndex = TypedIndex<RegExpStencil>;
using BigIntIndex = TypedIndex<BigIntStencil>;
using ObjLiteralIndex = TypedIndex<ObjLiteralStencil>;
// Index into {CompilationState,BaseCompilationStencil}.gcThingData.
// Index into {ExtensibleCompilationStencil,BaseCompilationStencil}.gcThingData.
class CompilationGCThingType {};
using CompilationGCThingIndex = TypedIndex<CompilationGCThingType>;
@ -757,8 +757,8 @@ class ScriptStencil {
// * lazy Function (cannot be asm.js module)
// GCThings are stored into
// {CompilationState,BaseCompilationStencil}.gcThingData, in [gcThingsOffset,
// gcThingsOffset + gcThingsLength) range.
// {ExtensibleCompilationStencil,BaseCompilationStencil}.gcThingData,
// in [gcThingsOffset, gcThingsOffset + gcThingsLength) range.
CompilationGCThingIndex gcThingsOffset;
uint32_t gcThingsLength = 0;