Bug 1608195 - Rename {RegExp,BigInt,ObjLiteral}CreationData to *Stencil. r=djvj

Differential Revision: https://phabricator.services.mozilla.com/D86007
This commit is contained in:
Ted Campbell 2020-08-10 15:15:10 +00:00
Родитель e43558859c
Коммит ffa84134ce
11 изменённых файлов: 51 добавлений и 59 удалений

Просмотреть файл

@ -1636,7 +1636,7 @@ bool BytecodeEmitter::iteratorResultShape(GCThingIndex* shape) {
if (!compilationInfo.objLiteralData.emplaceBack(cx)) {
return false;
}
ObjLiteralCreationData& data = compilationInfo.objLiteralData.back();
ObjLiteralStencil& data = compilationInfo.objLiteralData.back();
data.writer().beginObject(flags);
@ -4598,7 +4598,7 @@ bool BytecodeEmitter::emitCallSiteObjectArray(ListNode* cookedOrRaw,
if (!compilationInfo.objLiteralData.emplaceBack(cx)) {
return false;
}
ObjLiteralCreationData& data = compilationInfo.objLiteralData.back();
ObjLiteralStencil& data = compilationInfo.objLiteralData.back();
ObjLiteralFlags flags(ObjLiteralFlag::Array);
data.writer().beginObject(flags);
@ -8832,7 +8832,7 @@ bool BytecodeEmitter::emitPropertyListObjLiteral(ListNode* obj,
if (!compilationInfo.objLiteralData.emplaceBack(cx)) {
return false;
}
ObjLiteralCreationData& data = compilationInfo.objLiteralData.back();
ObjLiteralStencil& data = compilationInfo.objLiteralData.back();
data.writer().beginObject(flags);
bool noValues = flags.contains(ObjLiteralFlag::NoValues);
@ -8900,7 +8900,7 @@ bool BytecodeEmitter::emitDestructuringRestExclusionSetObjLiteral(
if (!compilationInfo.objLiteralData.emplaceBack(cx)) {
return false;
}
ObjLiteralCreationData& data = compilationInfo.objLiteralData.back();
ObjLiteralStencil& data = compilationInfo.objLiteralData.back();
data.writer().beginObject(flags);
@ -8952,7 +8952,7 @@ bool BytecodeEmitter::emitObjLiteralArray(ParseNode* arrayHead, bool isCow) {
if (!compilationInfo.objLiteralData.emplaceBack(cx)) {
return false;
}
ObjLiteralCreationData& data = compilationInfo.objLiteralData.back();
ObjLiteralStencil& data = compilationInfo.objLiteralData.back();
ObjLiteralFlags flags(ObjLiteralFlag::Array);
if (isCow) {
@ -8991,7 +8991,7 @@ bool BytecodeEmitter::isRHSObjLiteralCompatible(ParseNode* value) {
value->isKind(ParseNodeKind::TemplateStringExpr);
}
bool BytecodeEmitter::emitObjLiteralValue(ObjLiteralCreationData* data,
bool BytecodeEmitter::emitObjLiteralValue(ObjLiteralStencil* data,
ParseNode* value) {
MOZ_ASSERT(isRHSObjLiteralCompatible(value));
if (value->isKind(ParseNodeKind::NumberExpr)) {
@ -9386,12 +9386,12 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::emitObject(ListNode* objNode,
bool isSingletonContext = !objNode->hasNonConstInitializer() &&
objNode->head() && checkSingletonContext();
// Note: this method uses the ObjLiteralWriter and emits
// ObjLiteralCreationData objects into the GCThingList, which will evaluate
// them into real GC objects during JSScript::fullyInitFromEmitter.
// Eventually we want OBJLITERAL to be a real opcode, but for now,
// performance constraints limit us to evaluating object literals at the end
// of parse, when we're allowed to allocate GC things.
// Note: this method uses the ObjLiteralWriter and emits ObjLiteralStencil
// objects into the GCThingList, which will evaluate them into real GC objects
// during JSScript::fullyInitFromEmitter. Eventually we want OBJLITERAL to be
// a real opcode, but for now, performance constraints limit us to evaluating
// object literals at the end of parse, when we're allowed to allocate GC
// things.
//
// There are three cases here, in descending order of preference:
//

Просмотреть файл

@ -501,7 +501,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
// Is a field value OBJLITERAL-compatible?
MOZ_MUST_USE bool isRHSObjLiteralCompatible(ParseNode* value);
MOZ_MUST_USE bool emitObjLiteralValue(ObjLiteralCreationData* data,
MOZ_MUST_USE bool emitObjLiteralValue(ObjLiteralStencil* data,
ParseNode* value);
enum class FieldPlacement { Instance, Static };

Просмотреть файл

@ -69,7 +69,7 @@ bool js::frontend::EmitScriptThingsVector(JSContext* cx,
}
bool operator()(const BigIntIndex& index) {
BigIntCreationData& data = compilationInfo.bigIntData[index];
BigIntStencil& data = compilationInfo.bigIntData[index];
BigInt* bi = data.createBigInt(cx);
if (!bi) {
return false;
@ -79,7 +79,7 @@ bool js::frontend::EmitScriptThingsVector(JSContext* cx,
}
bool operator()(const RegExpIndex& rindex) {
RegExpCreationData& data = compilationInfo.regExpData[rindex];
RegExpStencil& data = compilationInfo.regExpData[rindex];
RegExpObject* regexp = data.createRegExp(cx);
if (!regexp) {
return false;
@ -89,7 +89,7 @@ bool js::frontend::EmitScriptThingsVector(JSContext* cx,
}
bool operator()(const ObjLiteralIndex& index) {
ObjLiteralCreationData& data = compilationInfo.objLiteralData[index];
ObjLiteralStencil& data = compilationInfo.objLiteralData[index];
JSObject* obj = data.create(cx);
if (!obj) {
return false;
@ -163,7 +163,7 @@ void CGScopeNoteList::recordEndImpl(uint32_t index, uint32_t offset) {
list[index].length = offset - list[index].start;
}
JSObject* ObjLiteralCreationData::create(JSContext* cx) const {
JSObject* ObjLiteralStencil::create(JSContext* cx) const {
return InterpretObjLiteral(cx, atoms_, writer_);
}

Просмотреть файл

@ -22,7 +22,7 @@
#include "frontend/CompilationInfo.h" // CompilationInfo
#include "frontend/JumpList.h" // JumpTarget
#include "frontend/NameCollections.h" // AtomIndexMap, PooledMapPtr
#include "frontend/ObjLiteral.h" // ObjLiteralCreationData
#include "frontend/ObjLiteral.h" // ObjLiteralStencil
#include "frontend/ParseNode.h" // BigIntLiteral
#include "frontend/SourceNotes.h" // SrcNote
#include "frontend/Stencil.h" // Stencils

Просмотреть файл

@ -176,11 +176,11 @@ struct MOZ_RAII CompilationInfo : public JS::CustomAutoRooter {
UsedNameTracker usedNames;
LifoAllocScope& allocScope;
// Hold onto the RegExpCreationData and BigIntCreationData that are allocated
// during parse to ensure correct destruction.
Vector<RegExpCreationData> regExpData;
Vector<BigIntCreationData> bigIntData;
Vector<ObjLiteralCreationData> objLiteralData;
// Hold onto the RegExpStencil, BigIntStencil, and ObjLiteralStencil that are
// allocated during parse to ensure correct destruction.
Vector<RegExpStencil> regExpData;
Vector<BigIntStencil> bigIntData;
Vector<ObjLiteralStencil> objLiteralData;
// A Rooted vector to handle tracing of JSFunction*
// and Atoms within.

Просмотреть файл

@ -246,7 +246,7 @@ bool ConvertScopeStencil(JSContext* cx, const SmooshResult& result,
}
// Given the result of SmooshMonkey's parser, convert a list of RegExp data
// into a list of RegExpCreationData.
// into a list of RegExpStencil.
bool ConvertRegExpData(JSContext* cx, const SmooshResult& result,
CompilationInfo& compilationInfo) {
for (size_t i = 0; i < result.regexps.len; i++) {

Просмотреть файл

@ -224,19 +224,19 @@ void ObjLiteralWriter::dumpFields(js::JSONPrinter& json) {
json.endList();
}
void ObjLiteralCreationData::dump() {
void ObjLiteralStencil::dump() {
js::Fprinter out(stderr);
js::JSONPrinter json(out);
dump(json);
}
void ObjLiteralCreationData::dump(js::JSONPrinter& json) {
void ObjLiteralStencil::dump(js::JSONPrinter& json) {
json.beginObject();
dumpFields(json);
json.endObject();
}
void ObjLiteralCreationData::dumpFields(js::JSONPrinter& json) {
void ObjLiteralStencil::dumpFields(js::JSONPrinter& json) {
writer_.dumpFields(json);
json.beginListProperty("atoms");

Просмотреть файл

@ -556,13 +556,13 @@ inline JSObject* InterpretObjLiteral(JSContext* cx,
return InterpretObjLiteral(cx, atoms, writer.getCode(), writer.getFlags());
}
class ObjLiteralCreationData {
class ObjLiteralStencil {
private:
ObjLiteralWriter writer_;
ObjLiteralAtomVector atoms_;
public:
explicit ObjLiteralCreationData(JSContext* cx) : writer_(cx), atoms_(cx) {}
explicit ObjLiteralStencil(JSContext* cx) : writer_(cx), atoms_(cx) {}
ObjLiteralWriter& writer() { return writer_; }

Просмотреть файл

@ -389,7 +389,7 @@ JSAtom* NumericLiteral::toAtom(JSContext* cx) const {
return NumberToAtom(cx, value());
}
RegExpObject* RegExpCreationData::createRegExp(JSContext* cx) const {
RegExpObject* RegExpStencil::createRegExp(JSContext* cx) const {
MOZ_ASSERT(buf_);
return RegExpObject::createSyntaxChecked(cx, buf_.get(), length_, flags_,
TenuredObject);

Просмотреть файл

@ -36,8 +36,8 @@
using namespace js;
using namespace js::frontend;
bool frontend::RegExpCreationData::init(JSContext* cx, JSAtom* pattern,
JS::RegExpFlags flags) {
bool frontend::RegExpStencil::init(JSContext* cx, JSAtom* pattern,
JS::RegExpFlags flags) {
length_ = pattern->length();
buf_ = cx->make_pod_array<char16_t>(length_);
if (!buf_) {
@ -659,13 +659,13 @@ bool CompilationInfo::instantiateStencils() {
#if defined(DEBUG) || defined(JS_JITSPEW)
void RegExpCreationData::dump() {
void RegExpStencil::dump() {
js::Fprinter out(stderr);
js::JSONPrinter json(out);
dump(json);
}
void RegExpCreationData::dump(js::JSONPrinter& json) {
void RegExpStencil::dump(js::JSONPrinter& json) {
GenericPrinter& out = json.beginString();
out.put("/");
@ -707,13 +707,13 @@ void RegExpCreationData::dump(js::JSONPrinter& json) {
json.endString();
}
void BigIntCreationData::dump() {
void BigIntStencil::dump() {
js::Fprinter out(stderr);
js::JSONPrinter json(out);
dump(json);
}
void BigIntCreationData::dump(js::JSONPrinter& json) {
void BigIntStencil::dump(js::JSONPrinter& json) {
GenericPrinter& out = json.beginString();
for (size_t i = 0; i < length_; i++) {

Просмотреть файл

@ -16,14 +16,14 @@
#include "frontend/AbstractScopePtr.h" // AbstractScopePtr, ScopeIndex
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ObjLiteral.h" // ObjLiteralCreationData
#include "frontend/ObjLiteral.h" // ObjLiteralStencil
#include "frontend/TypedIndex.h" // TypedIndex
#include "js/GCVariant.h" // GC Support for mozilla::Variant
#include "js/RegExpFlags.h" // JS::RegExpFlags
#include "js/RootingAPI.h" // Handle
#include "js/TypeDecls.h" // JSContext,JSAtom,JSFunction
#include "js/UniquePtr.h" // js::UniquePtr
#include "js/Utility.h" // JS::FreePolicy, UniqueTwoByteChars
#include "js/Utility.h" // UniqueTwoByteChars
#include "js/Vector.h" // js::Vector
#include "util/Text.h" // DuplicateString
#include "vm/BigIntType.h" // ParseBigIntLiteral
@ -44,6 +44,9 @@ class JSONPrinter;
namespace frontend {
struct CompilationInfo;
class ScriptStencil;
class RegExpStencil;
class BigIntStencil;
// [SMDOC] Script Stencil (Frontend Representation)
//
@ -54,18 +57,11 @@ struct CompilationInfo;
//
// Renaming to use the term stencil more broadly is still in progress.
// Arbitrary typename to disambiguate TypedIndexes;
class FunctionIndexType;
// We need to be able to forward declare this type, so make a subclass
// rather than just using.
class FunctionIndex : public TypedIndex<FunctionIndexType> {
// Delegate constructors;
using Base = TypedIndex<FunctionIndexType>;
using Base::Base;
};
using ObjLiteralIndex = TypedIndex<ObjLiteralCreationData>;
// Typed indices for the different stencil elements in the compilation result.
using RegExpIndex = TypedIndex<RegExpStencil>;
using BigIntIndex = TypedIndex<BigIntStencil>;
using ObjLiteralIndex = TypedIndex<ObjLiteralStencil>;
using FunctionIndex = TypedIndex<ScriptStencil>;
FunctionFlags InitialFunctionFlags(FunctionSyntaxKind kind,
GeneratorKind generatorKind,
@ -75,13 +71,13 @@ FunctionFlags InitialFunctionFlags(FunctionSyntaxKind kind,
// This owns a set of characters, previously syntax checked as a RegExp. Used
// to avoid allocating the RegExp on the GC heap during parsing.
class RegExpCreationData {
UniquePtr<char16_t[], JS::FreePolicy> buf_;
class RegExpStencil {
UniqueTwoByteChars buf_;
size_t length_ = 0;
JS::RegExpFlags flags_;
public:
RegExpCreationData() = default;
RegExpStencil() = default;
MOZ_MUST_USE bool init(JSContext* cx, mozilla::Range<const char16_t> range,
JS::RegExpFlags flags) {
@ -104,17 +100,15 @@ class RegExpCreationData {
#endif
};
using RegExpIndex = TypedIndex<RegExpCreationData>;
// This owns a set of characters guaranteed to parse into a BigInt via
// ParseBigIntLiteral. Used to avoid allocating the BigInt on the
// GC heap during parsing.
class BigIntCreationData {
class BigIntStencil {
UniqueTwoByteChars buf_;
size_t length_ = 0;
public:
BigIntCreationData() = default;
BigIntStencil() = default;
MOZ_MUST_USE bool init(JSContext* cx, const Vector<char16_t, 32>& buf) {
#ifdef DEBUG
@ -146,8 +140,6 @@ class BigIntCreationData {
#endif
};
using BigIntIndex = TypedIndex<BigIntCreationData>;
class ScopeStencil {
friend class js::AbstractScopePtr;
friend class js::GCMarker;