mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-28 18:17:29 +09:00
Issue #2155 - Simplify BytecodeEmitter::isRestParameter
This commit is contained in:
parent
e8fee20566
commit
da05c050e3
2 changed files with 11 additions and 21 deletions
|
|
@ -9407,28 +9407,23 @@ BytecodeEmitter::emitSelfHostedAllowContentIter(ParseNode* pn)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BytecodeEmitter::isRestParameter(ParseNode* pn, bool* result)
|
BytecodeEmitter::isRestParameter(ParseNode* pn)
|
||||||
{
|
{
|
||||||
if (!sc->isFunctionBox()) {
|
if (!sc->isFunctionBox())
|
||||||
*result = false;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionBox* funbox = sc->asFunctionBox();
|
FunctionBox* funbox = sc->asFunctionBox();
|
||||||
RootedFunction fun(cx, funbox->function());
|
RootedFunction fun(cx, funbox->function());
|
||||||
if (!funbox->hasRest()) {
|
if (!funbox->hasRest())
|
||||||
*result = false;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pn->isKind(PNK_NAME)) {
|
if (!pn->isKind(PNK_NAME)) {
|
||||||
if (emitterMode == BytecodeEmitter::SelfHosting && pn->isKind(PNK_CALL)) {
|
if (emitterMode == BytecodeEmitter::SelfHosting && pn->isKind(PNK_CALL)) {
|
||||||
ParseNode* pn2 = pn->pn_head;
|
ParseNode* pn2 = pn->pn_head;
|
||||||
if (pn2->getKind() == PNK_NAME && pn2->name() == cx->names().allowContentIter)
|
if (pn2->getKind() == PNK_NAME && pn2->name() == cx->names().allowContentIter)
|
||||||
return isRestParameter(pn2->pn_next, result);
|
return isRestParameter(pn2->pn_next);
|
||||||
}
|
}
|
||||||
*result = false;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSAtom* name = pn->name();
|
JSAtom* name = pn->name();
|
||||||
|
|
@ -9440,12 +9435,11 @@ BytecodeEmitter::isRestParameter(ParseNode* pn, bool* result)
|
||||||
// used: `function f(...[]) {}`.
|
// used: `function f(...[]) {}`.
|
||||||
JSAtom* paramName =
|
JSAtom* paramName =
|
||||||
bindings->trailingNames[bindings->nonPositionalFormalStart - 1].name();
|
bindings->trailingNames[bindings->nonPositionalFormalStart - 1].name();
|
||||||
*result = paramName && name == paramName;
|
return paramName && name == paramName;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -9462,11 +9456,7 @@ BytecodeEmitter::emitOptimizeSpread(ParseNode* arg0, JumpList* jmp, bool* emitte
|
||||||
// skip spread operation and pass it directly to spread call operation.
|
// skip spread operation and pass it directly to spread call operation.
|
||||||
// See the comment in OptimizeSpreadCall in Interpreter.cpp for the
|
// See the comment in OptimizeSpreadCall in Interpreter.cpp for the
|
||||||
// optimizable conditons.
|
// optimizable conditons.
|
||||||
bool result = false;
|
if (!isRestParameter(arg0)) {
|
||||||
if (!isRestParameter(arg0, &result))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
*emitted = false;
|
*emitted = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -775,7 +775,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
|
||||||
MOZ_MUST_USE bool emitConditionalExpression(ConditionalExpression& conditional,
|
MOZ_MUST_USE bool emitConditionalExpression(ConditionalExpression& conditional,
|
||||||
ValueUsage valueUsage = ValueUsage::WantValue);
|
ValueUsage valueUsage = ValueUsage::WantValue);
|
||||||
|
|
||||||
MOZ_MUST_USE bool isRestParameter(ParseNode* pn, bool* result);
|
MOZ_MUST_USE bool isRestParameter(ParseNode* pn);
|
||||||
MOZ_MUST_USE bool emitOptimizeSpread(ParseNode* arg0, JumpList* jmp, bool* emitted);
|
MOZ_MUST_USE bool emitOptimizeSpread(ParseNode* arg0, JumpList* jmp, bool* emitted);
|
||||||
|
|
||||||
MOZ_MUST_USE bool emitCallOrNew(ParseNode* pn,
|
MOZ_MUST_USE bool emitCallOrNew(ParseNode* pn,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue