зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1562102 - Use more Handle in BytecodeEmitter methods and helper classes. r=jorendorff,jonco
Depends on D36695 Differential Revision: https://phabricator.services.mozilla.com/D36696 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ea680be1a5
Коммит
2f5c338236
|
@ -1765,7 +1765,7 @@ bool BytecodeEmitter::emitFinishIteratorResult(bool done) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BytecodeEmitter::emitGetNameAtLocation(JSAtom* name,
|
||||
bool BytecodeEmitter::emitGetNameAtLocation(Handle<JSAtom*> name,
|
||||
const NameLocation& loc) {
|
||||
NameOpEmitter noe(this, name, loc, NameOpEmitter::Kind::Get);
|
||||
if (!noe.emitGet()) {
|
||||
|
@ -1776,7 +1776,8 @@ bool BytecodeEmitter::emitGetNameAtLocation(JSAtom* name,
|
|||
}
|
||||
|
||||
bool BytecodeEmitter::emitGetName(NameNode* name) {
|
||||
return emitGetName(name->name());
|
||||
RootedAtom nameAtom(cx, name->name());
|
||||
return emitGetName(nameAtom);
|
||||
}
|
||||
|
||||
bool BytecodeEmitter::emitTDZCheckIfNeeded(HandleAtom name,
|
||||
|
@ -1904,7 +1905,8 @@ bool BytecodeEmitter::emitNameIncDec(UnaryNode* incDec) {
|
|||
|
||||
ParseNodeKind kind = incDec->getKind();
|
||||
NameNode* name = &incDec->kid()->as<NameNode>();
|
||||
NameOpEmitter noe(this, name->atom(),
|
||||
RootedAtom nameAtom(cx, name->atom());
|
||||
NameOpEmitter noe(this, nameAtom,
|
||||
kind == ParseNodeKind::PostIncrementExpr
|
||||
? NameOpEmitter::Kind::PostIncrement
|
||||
: kind == ParseNodeKind::PreIncrementExpr
|
||||
|
@ -4037,7 +4039,8 @@ bool BytecodeEmitter::emitSingleDeclaration(ListNode* declList, NameNode* decl,
|
|||
return true;
|
||||
}
|
||||
|
||||
NameOpEmitter noe(this, decl->name(), NameOpEmitter::Kind::Initialize);
|
||||
RootedAtom nameAtom(cx, decl->name());
|
||||
NameOpEmitter noe(this, nameAtom, NameOpEmitter::Kind::Initialize);
|
||||
if (!noe.prepareForRhs()) {
|
||||
// [stack] ENV?
|
||||
return false;
|
||||
|
@ -5335,7 +5338,8 @@ bool BytecodeEmitter::emitInitializeForInOrOfTarget(TernaryNode* forHead) {
|
|||
}
|
||||
|
||||
if (nameNode) {
|
||||
NameOpEmitter noe(this, nameNode->name(), NameOpEmitter::Kind::Initialize);
|
||||
RootedAtom nameAtom(cx, nameNode->name());
|
||||
NameOpEmitter noe(this, nameAtom, NameOpEmitter::Kind::Initialize);
|
||||
if (!noe.prepareForRhs()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -5480,8 +5484,8 @@ bool BytecodeEmitter::emitForIn(ForNode* forInLoop,
|
|||
return false;
|
||||
}
|
||||
|
||||
NameOpEmitter noe(this, nameNode->name(),
|
||||
NameOpEmitter::Kind::Initialize);
|
||||
RootedAtom nameAtom(cx, nameNode->name());
|
||||
NameOpEmitter noe(this, nameAtom, NameOpEmitter::Kind::Initialize);
|
||||
if (!noe.prepareForRhs()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -7225,12 +7229,14 @@ bool BytecodeEmitter::isRestParameter(ParseNode* expr) {
|
|||
bool BytecodeEmitter::emitCalleeAndThis(ParseNode* callee, ParseNode* call,
|
||||
CallOrNewEmitter& cone) {
|
||||
switch (callee->getKind()) {
|
||||
case ParseNodeKind::Name:
|
||||
if (!cone.emitNameCallee(callee->as<NameNode>().name())) {
|
||||
case ParseNodeKind::Name: {
|
||||
RootedAtom nameAtom(cx, callee->as<NameNode>().name());
|
||||
if (!cone.emitNameCallee(nameAtom)) {
|
||||
// [stack] CALLEE THIS
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParseNodeKind::DotExpr: {
|
||||
MOZ_ASSERT(emitterMode != BytecodeEmitter::SelfHosting);
|
||||
PropertyAccess* prop = &callee->as<PropertyAccess>();
|
||||
|
@ -8050,7 +8056,7 @@ bool BytecodeEmitter::emitCreateFieldKeys(ListNode* obj) {
|
|||
return true;
|
||||
}
|
||||
|
||||
NameOpEmitter noe(this, cx->names().dotFieldKeys,
|
||||
NameOpEmitter noe(this, cx->names().dotFieldKeys.toHandle(),
|
||||
NameOpEmitter::Kind::Initialize);
|
||||
if (!noe.prepareForRhs()) {
|
||||
return false;
|
||||
|
@ -8663,10 +8669,11 @@ bool BytecodeEmitter::emitInitializeFunctionSpecialNames() {
|
|||
}
|
||||
|
||||
bool BytecodeEmitter::emitLexicalInitialization(NameNode* name) {
|
||||
return emitLexicalInitialization(name->name());
|
||||
RootedAtom nameAtom(cx, name->name());
|
||||
return emitLexicalInitialization(nameAtom);
|
||||
}
|
||||
|
||||
bool BytecodeEmitter::emitLexicalInitialization(JSAtom* name) {
|
||||
bool BytecodeEmitter::emitLexicalInitialization(Handle<JSAtom*> name) {
|
||||
NameOpEmitter noe(this, name, NameOpEmitter::Kind::Initialize);
|
||||
if (!noe.prepareForRhs()) {
|
||||
return false;
|
||||
|
|
|
@ -528,9 +528,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
|||
MOZ_MUST_USE bool emitArgOp(JSOp op, uint16_t slot);
|
||||
MOZ_MUST_USE bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec);
|
||||
|
||||
MOZ_MUST_USE bool emitGetNameAtLocation(JSAtom* name,
|
||||
MOZ_MUST_USE bool emitGetNameAtLocation(Handle<JSAtom*> name,
|
||||
const NameLocation& loc);
|
||||
MOZ_MUST_USE bool emitGetName(JSAtom* name) {
|
||||
MOZ_MUST_USE bool emitGetNameAtLocation(ImmutablePropertyNamePtr name,
|
||||
const NameLocation& loc) {
|
||||
return emitGetNameAtLocation(name.toHandle(), loc);
|
||||
}
|
||||
MOZ_MUST_USE bool emitGetName(Handle<JSAtom*> name) {
|
||||
return emitGetNameAtLocation(name, lookupName(name));
|
||||
}
|
||||
MOZ_MUST_USE bool emitGetName(ImmutablePropertyNamePtr name) {
|
||||
return emitGetNameAtLocation(name, lookupName(name));
|
||||
}
|
||||
MOZ_MUST_USE bool emitGetName(NameNode* name);
|
||||
|
@ -755,7 +762,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
|||
MOZ_MUST_USE bool emitFunctionFormalParameters(ListNode* paramsBody);
|
||||
MOZ_MUST_USE bool emitInitializeFunctionSpecialNames();
|
||||
MOZ_MUST_USE bool emitLexicalInitialization(NameNode* name);
|
||||
MOZ_MUST_USE bool emitLexicalInitialization(JSAtom* name);
|
||||
MOZ_MUST_USE bool emitLexicalInitialization(Handle<JSAtom*> name);
|
||||
|
||||
// Emit bytecode for the spread operator.
|
||||
//
|
||||
|
|
|
@ -38,7 +38,7 @@ CallOrNewEmitter::CallOrNewEmitter(BytecodeEmitter* bce, JSOp op,
|
|||
MOZ_ASSERT(isCall() || isNew() || isSuperCall());
|
||||
}
|
||||
|
||||
bool CallOrNewEmitter::emitNameCallee(JSAtom* name) {
|
||||
bool CallOrNewEmitter::emitNameCallee(Handle<JSAtom*> name) {
|
||||
MOZ_ASSERT(state_ == State::Start);
|
||||
|
||||
NameOpEmitter noe(
|
||||
|
|
|
@ -290,7 +290,7 @@ class MOZ_STACK_CLASS CallOrNewEmitter {
|
|||
}
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool emitNameCallee(JSAtom* name);
|
||||
MOZ_MUST_USE bool emitNameCallee(Handle<JSAtom*> name);
|
||||
MOZ_MUST_USE PropOpEmitter& prepareForPropCallee(bool isSuperProp);
|
||||
MOZ_MUST_USE ElemOpEmitter& prepareForElemCallee(bool isSuperElem);
|
||||
MOZ_MUST_USE bool prepareForFunctionCallee();
|
||||
|
|
|
@ -16,15 +16,13 @@
|
|||
using namespace js;
|
||||
using namespace js::frontend;
|
||||
|
||||
NameOpEmitter::NameOpEmitter(BytecodeEmitter* bce, JSAtom* name, Kind kind)
|
||||
: bce_(bce),
|
||||
kind_(kind),
|
||||
name_(bce_->cx, name),
|
||||
loc_(bce_->lookupName(name_)) {}
|
||||
NameOpEmitter::NameOpEmitter(BytecodeEmitter* bce, Handle<JSAtom*> name,
|
||||
Kind kind)
|
||||
: bce_(bce), kind_(kind), name_(name), loc_(bce_->lookupName(name_)) {}
|
||||
|
||||
NameOpEmitter::NameOpEmitter(BytecodeEmitter* bce, JSAtom* name,
|
||||
NameOpEmitter::NameOpEmitter(BytecodeEmitter* bce, Handle<JSAtom*> name,
|
||||
const NameLocation& loc, Kind kind)
|
||||
: bce_(bce), kind_(kind), name_(bce_->cx, name), loc_(loc) {}
|
||||
: bce_(bce), kind_(kind), name_(name), loc_(loc) {}
|
||||
|
||||
bool NameOpEmitter::emitGet() {
|
||||
MOZ_ASSERT(state_ == State::Start);
|
||||
|
|
|
@ -79,7 +79,7 @@ class MOZ_STACK_CLASS NameOpEmitter {
|
|||
|
||||
bool emittedBindOp_ = false;
|
||||
|
||||
RootedAtom name_;
|
||||
Handle<JSAtom*> name_;
|
||||
|
||||
uint32_t atomIndex_;
|
||||
|
||||
|
@ -132,9 +132,9 @@ class MOZ_STACK_CLASS NameOpEmitter {
|
|||
#endif
|
||||
|
||||
public:
|
||||
NameOpEmitter(BytecodeEmitter* bce, JSAtom* name, Kind kind);
|
||||
NameOpEmitter(BytecodeEmitter* bce, JSAtom* name, const NameLocation& loc,
|
||||
Kind kind);
|
||||
NameOpEmitter(BytecodeEmitter* bce, Handle<JSAtom*> name, Kind kind);
|
||||
NameOpEmitter(BytecodeEmitter* bce, Handle<JSAtom*> name,
|
||||
const NameLocation& loc, Kind kind);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool isCall() const { return kind_ == Kind::Call; }
|
||||
|
|
|
@ -761,7 +761,8 @@ bool ClassEmitter::prepareForFieldInitializers(size_t numFields) {
|
|||
// .initializers is a variable that stores an array of lambdas containing
|
||||
// code (the initializer) for each field. Upon an object's construction,
|
||||
// these lambdas will be called, defining the values.
|
||||
initializersAssignment_.emplace(bce_, bce_->cx->names().dotInitializers,
|
||||
initializersAssignment_.emplace(bce_,
|
||||
bce_->cx->names().dotInitializers.toHandle(),
|
||||
NameOpEmitter::Kind::Initialize);
|
||||
if (!initializersAssignment_->prepareForRhs()) {
|
||||
return false;
|
||||
|
|
|
@ -851,7 +851,13 @@ class ImmutableTenuredPtr {
|
|||
operator T() const { return value; }
|
||||
T operator->() const { return value; }
|
||||
|
||||
operator Handle<T>() const { return Handle<T>::fromMarkedLocation(&value); }
|
||||
// `ImmutableTenuredPtr<T>` is implicitly convertible to `Handle<T>`.
|
||||
//
|
||||
// In case you need to convert to `Handle<U>` where `U` is base class of `T`,
|
||||
// convert this to `Handle<T>` by `toHandle()` and then use implicit
|
||||
// conversion from `Handle<T>` to `Handle<U>`.
|
||||
operator Handle<T>() const { return toHandle(); }
|
||||
Handle<T> toHandle() const { return Handle<T>::fromMarkedLocation(&value); }
|
||||
|
||||
void init(T ptr) {
|
||||
MOZ_ASSERT(ptr->isTenured());
|
||||
|
|
Загрузка…
Ссылка в новой задаче