зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8719c4f31ad8 (bug 1580338) for spidermonkey in TraceKind.h on a CLOSED TREE
This commit is contained in:
Родитель
6c038766da
Коммит
8223953e66
|
@ -3167,7 +3167,7 @@ bool ASTSerializer::literal(ParseNode* pn, MutableHandleValue dst) {
|
|||
break;
|
||||
|
||||
case ParseNodeKind::RegExpExpr: {
|
||||
RootedObject re1(cx, pn->as<RegExpLiteral>().getOrCreate(cx));
|
||||
RootedObject re1(cx, pn->as<RegExpLiteral>().objbox()->object());
|
||||
LOCAL_ASSERT(re1 && re1->is<RegExpObject>());
|
||||
|
||||
RootedObject re2(cx, CloneRegExpObject(cx, re1.as<RegExpObject>()));
|
||||
|
|
|
@ -9851,8 +9851,9 @@ bool BytecodeEmitter::emitTree(
|
|||
break;
|
||||
|
||||
case ParseNodeKind::RegExpExpr: {
|
||||
ObjectBox* obj = pn->as<RegExpLiteral>().objbox();
|
||||
uint32_t index;
|
||||
if (!perScriptData().gcThingList().append(&pn->as<RegExpLiteral>(), &index)) {
|
||||
if (!perScriptData().gcThingList().append(obj, &index)) {
|
||||
return false;
|
||||
}
|
||||
if (!emitRegExp(index)) {
|
||||
|
|
|
@ -72,15 +72,6 @@ bool GCThingList::finish(JSContext* cx, mozilla::Span<JS::GCCellPtr> array) {
|
|||
array[i] = JS::GCCellPtr(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator()(RegExpCreationData& data) {
|
||||
RegExpObject* regexp = data.createRegExp(cx);
|
||||
if (!regexp) {
|
||||
return false;
|
||||
}
|
||||
array[i] = JS::GCCellPtr(regexp);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
for (uint32_t i = 0; i < length(); i++) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class ObjectBox;
|
|||
|
||||
struct MOZ_STACK_CLASS GCThingList {
|
||||
using ListType = mozilla::Variant<StackGCCellPtr, BigIntCreationData,
|
||||
ObjLiteralCreationData, RegExpCreationData>;
|
||||
ObjLiteralCreationData>;
|
||||
JS::RootedVector<ListType> vector;
|
||||
|
||||
// Last emitted object.
|
||||
|
@ -79,15 +79,6 @@ struct MOZ_STACK_CLASS GCThingList {
|
|||
*index = vector.length();
|
||||
return vector.append(mozilla::AsVariant(std::move(objlit)));
|
||||
}
|
||||
MOZ_MUST_USE bool append(RegExpLiteral* literal, uint32_t* index) {
|
||||
*index = vector.length();
|
||||
if (literal->isDeferred()) {
|
||||
return vector.append(
|
||||
mozilla::AsVariant(std::move(literal->creationData())));
|
||||
}
|
||||
return vector.append(mozilla::AsVariant(
|
||||
StackGCCellPtr(JS::GCCellPtr(literal->objbox()->object()))));
|
||||
}
|
||||
MOZ_MUST_USE bool append(ObjectBox* obj, uint32_t* index);
|
||||
|
||||
uint32_t length() const { return vector.length(); }
|
||||
|
@ -395,10 +386,6 @@ namespace JS {
|
|||
template <>
|
||||
struct GCPolicy<js::frontend::BigIntCreationData>
|
||||
: JS::IgnoreGCPolicy<js::frontend::BigIntCreationData> {};
|
||||
|
||||
template <>
|
||||
struct GCPolicy<js::frontend::RegExpCreationData>
|
||||
: JS::IgnoreGCPolicy<js::frontend::RegExpCreationData> {};
|
||||
} // namespace JS
|
||||
|
||||
#endif /* frontend_BytecodeSection_h */
|
||||
|
|
|
@ -221,10 +221,6 @@ class FullParseHandler {
|
|||
return new_<RegExpLiteral>(objbox, pos);
|
||||
}
|
||||
|
||||
RegExpLiteralType newRegExp(const TokenPos& pos) {
|
||||
return new_<RegExpLiteral>(pos);
|
||||
}
|
||||
|
||||
ConditionalExpressionType newConditional(Node cond, Node thenExpr,
|
||||
Node elseExpr) {
|
||||
return new_<ConditionalExpression>(cond, thenExpr, elseExpr);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "jsnum.h"
|
||||
|
||||
#include "frontend/Parser.h"
|
||||
#include "vm/RegExpObject.h"
|
||||
|
||||
#include "vm/JSContext-inl.h"
|
||||
|
||||
|
@ -408,19 +407,6 @@ bool BigIntLiteral::isZero() {
|
|||
|
||||
BigInt* BigIntLiteral::value() { return box()->value(); }
|
||||
|
||||
RegExpObject* RegExpCreationData::createRegExp(JSContext* cx) const {
|
||||
MOZ_ASSERT(buf_);
|
||||
return RegExpObject::createSyntaxChecked(cx, buf_.get(), length_, flags_,
|
||||
TenuredObject);
|
||||
}
|
||||
|
||||
RegExpObject* RegExpLiteral::getOrCreate(JSContext* cx) const {
|
||||
if (data_.is<ObjectBox*>()) {
|
||||
return &objbox()->object()->as<RegExpObject>();
|
||||
}
|
||||
return data_.as<RegExpCreationData>().createRegExp(cx);
|
||||
}
|
||||
|
||||
FunctionBox* ObjectBox::asFunctionBox() {
|
||||
MOZ_ASSERT(isFunctionBox());
|
||||
|
||||
|
|
|
@ -1893,49 +1893,14 @@ class BooleanLiteral : public NullaryNode {
|
|||
}
|
||||
};
|
||||
|
||||
// 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_;
|
||||
size_t length_ = 0;
|
||||
JS::RegExpFlags flags_;
|
||||
|
||||
public:
|
||||
RegExpCreationData() = default;
|
||||
|
||||
MOZ_MUST_USE bool init(JSContext* cx, mozilla::Range<const char16_t> range,
|
||||
JS::RegExpFlags flags) {
|
||||
length_ = range.length();
|
||||
buf_ = js::DuplicateString(cx, range.begin().get(), range.length());
|
||||
if (!buf_) {
|
||||
return false;
|
||||
}
|
||||
flags_ = flags;
|
||||
return true;
|
||||
}
|
||||
|
||||
RegExpObject* createRegExp(JSContext* cx) const;
|
||||
};
|
||||
|
||||
class RegExpLiteral : public ParseNode {
|
||||
mozilla::Variant<mozilla::Nothing, ObjectBox*, RegExpCreationData> data_;
|
||||
ObjectBox* objbox_;
|
||||
|
||||
public:
|
||||
RegExpLiteral(ObjectBox* reobj, const TokenPos& pos)
|
||||
: ParseNode(ParseNodeKind::RegExpExpr, pos), data_(reobj) {}
|
||||
: ParseNode(ParseNodeKind::RegExpExpr, pos), objbox_(reobj) {}
|
||||
|
||||
explicit RegExpLiteral(const TokenPos& pos)
|
||||
: ParseNode(ParseNodeKind::RegExpExpr, pos), data_(mozilla::Nothing()) {}
|
||||
|
||||
void init(RegExpCreationData data) {
|
||||
data_ = mozilla::AsVariant(std::move(data));
|
||||
}
|
||||
|
||||
bool isDeferred() const { return data_.is<RegExpCreationData>(); }
|
||||
|
||||
ObjectBox* objbox() const { return data_.as<ObjectBox*>(); }
|
||||
|
||||
RegExpObject* getOrCreate(JSContext* cx) const;
|
||||
ObjectBox* objbox() const { return objbox_; }
|
||||
|
||||
#ifdef DEBUG
|
||||
void dumpImpl(GenericPrinter& out, int indent);
|
||||
|
@ -1951,8 +1916,6 @@ class RegExpLiteral : public ParseNode {
|
|||
bool accept(Visitor& visitor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RegExpCreationData& creationData() { return data_.as<RegExpCreationData>(); }
|
||||
};
|
||||
|
||||
class PropertyAccess : public BinaryNode {
|
||||
|
|
|
@ -9629,38 +9629,8 @@ RegExpLiteral* Parser<FullParseHandler, Unit>::newRegExp() {
|
|||
|
||||
// Create the regexp and check its syntax.
|
||||
const auto& chars = tokenStream.getCharBuffer();
|
||||
mozilla::Range<const char16_t> range(chars.begin(), chars.length());
|
||||
RegExpFlags flags = anyChars.currentToken().regExpFlags();
|
||||
|
||||
if (this->getTreeHolder().isDeferred()) {
|
||||
{
|
||||
LifoAllocScope allocScope(&cx_->tempLifoAlloc());
|
||||
// Verify that the Regexp will syntax parse when the time comes to
|
||||
// instantiate it.
|
||||
if (!irregexp::ParsePatternSyntax(anyChars, allocScope.alloc(), range,
|
||||
flags.unicode())) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// With RegExpCreationData stack allocated, it is responsible for cleanup
|
||||
// until the data is moved into, after the potentially OOMing operations
|
||||
// are done, at which point the responsibility for cleanup becomes the
|
||||
// deferred allocation list, stored in the ParseInfo.
|
||||
RegExpCreationData data;
|
||||
if (!data.init(cx_, range, flags)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RegExpLiteral* node = handler_.newRegExp(pos());
|
||||
if (!node) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
node->init(std::move(data));
|
||||
return node;
|
||||
}
|
||||
|
||||
Rooted<RegExpObject*> reobj(cx_);
|
||||
reobj = RegExpObject::create(cx_, chars.begin(), chars.length(), flags,
|
||||
anyChars, TenuredObject);
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
// |jit-test| --no-ion; skip-if: !('oomTest' in this)
|
||||
|
||||
// Ion is too slow executing this test, hence the --no-ion above
|
||||
|
||||
var test = () => {
|
||||
var ng = newGlobal({deferredParserAlloc: true});
|
||||
|
||||
function foo() {
|
||||
var x = /hi/;
|
||||
var y = 128n;
|
||||
function inner(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
var a = inner(y, y);
|
||||
return x.exec(a.toString());
|
||||
}
|
||||
|
||||
ng.evaluate(foo.toString());
|
||||
ng.evaluate('foo()');
|
||||
};
|
||||
test();
|
||||
oomTest(test);
|
|
@ -249,26 +249,6 @@ RegExpObject* RegExpObject::create(JSContext* cx, HandleAtom source,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return createSyntaxChecked(cx, source, flags, newKind);
|
||||
}
|
||||
|
||||
RegExpObject* RegExpObject::createSyntaxChecked(JSContext* cx,
|
||||
const char16_t* chars,
|
||||
size_t length,
|
||||
RegExpFlags flags,
|
||||
NewObjectKind newKind) {
|
||||
RootedAtom source(cx, AtomizeChars(cx, chars, length));
|
||||
if (!source) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return createSyntaxChecked(cx, source, flags, newKind);
|
||||
}
|
||||
|
||||
RegExpObject* RegExpObject::createSyntaxChecked(JSContext* cx,
|
||||
HandleAtom source,
|
||||
RegExpFlags flags,
|
||||
NewObjectKind newKind) {
|
||||
Rooted<RegExpObject*> regexp(cx, RegExpAlloc(cx, newKind));
|
||||
if (!regexp) {
|
||||
return nullptr;
|
||||
|
|
|
@ -65,9 +65,6 @@ class RegExpObject : public NativeObject {
|
|||
static_assert(RegExpObject::FLAGS_SLOT == REGEXP_FLAGS_SLOT,
|
||||
"FLAGS_SLOT values should be in sync with self-hosted JS");
|
||||
|
||||
static RegExpObject* create(JSContext* cx, HandleAtom source,
|
||||
NewObjectKind newKind);
|
||||
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = 3;
|
||||
static const unsigned PRIVATE_SLOT = 3;
|
||||
|
@ -83,16 +80,6 @@ class RegExpObject : public NativeObject {
|
|||
static RegExpObject* create(JSContext* cx, const CharT* chars, size_t length,
|
||||
JS::RegExpFlags flags, NewObjectKind newKind);
|
||||
|
||||
// This variant assumes that the characters have already previously been
|
||||
// syntax checked.
|
||||
static RegExpObject* createSyntaxChecked(JSContext* cx, const char16_t* chars,
|
||||
size_t length, JS::RegExpFlags flags,
|
||||
NewObjectKind newKind);
|
||||
|
||||
static RegExpObject* createSyntaxChecked(JSContext* cx, HandleAtom source,
|
||||
JS::RegExpFlags flags,
|
||||
NewObjectKind newKind);
|
||||
|
||||
template <typename CharT>
|
||||
static RegExpObject* create(JSContext* cx, const CharT* chars, size_t length,
|
||||
JS::RegExpFlags flags,
|
||||
|
|
Загрузка…
Ссылка в новой задаче