mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1688055 - Part 4: Use existing NamedLambdaObject subclass rather than LexicalEnvironmentObject where appropriate. r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D106521
This commit is contained in:
parent
f7f31319ba
commit
9958ae418b
@ -10936,9 +10936,9 @@ class MPostWriteElementBarrier
|
||||
};
|
||||
|
||||
class MNewNamedLambdaObject : public MNullaryInstruction {
|
||||
CompilerGCPointer<LexicalEnvironmentObject*> templateObj_;
|
||||
CompilerGCPointer<NamedLambdaObject*> templateObj_;
|
||||
|
||||
explicit MNewNamedLambdaObject(LexicalEnvironmentObject* templateObj)
|
||||
explicit MNewNamedLambdaObject(NamedLambdaObject* templateObj)
|
||||
: MNullaryInstruction(classOpcode), templateObj_(templateObj) {
|
||||
setResultType(MIRType::Object);
|
||||
}
|
||||
@ -10947,7 +10947,7 @@ class MNewNamedLambdaObject : public MNullaryInstruction {
|
||||
INSTRUCTION_HEADER(NewNamedLambdaObject)
|
||||
TRIVIAL_NEW_WRAPPERS
|
||||
|
||||
LexicalEnvironmentObject* templateObj() { return templateObj_; }
|
||||
NamedLambdaObject* templateObj() { return templateObj_; }
|
||||
AliasSet getAliasSet() const override { return AliasSet::None(); }
|
||||
};
|
||||
|
||||
|
@ -325,9 +325,9 @@ bool WarpBuilder::buildInline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
MInstruction* WarpBuilder::buildNamedLambdaEnv(
|
||||
MDefinition* callee, MDefinition* env,
|
||||
LexicalEnvironmentObject* templateObj) {
|
||||
MInstruction* WarpBuilder::buildNamedLambdaEnv(MDefinition* callee,
|
||||
MDefinition* env,
|
||||
NamedLambdaObject* templateObj) {
|
||||
MOZ_ASSERT(!templateObj->hasDynamicSlots());
|
||||
|
||||
MInstruction* namedLambda = MNewNamedLambdaObject::New(alloc(), templateObj);
|
||||
@ -420,7 +420,7 @@ bool WarpBuilder::buildEnvironmentChain() {
|
||||
MDefinition* callee = getCallee();
|
||||
MInstruction* envDef = MFunctionEnvironment::New(alloc(), callee);
|
||||
current->add(envDef);
|
||||
if (LexicalEnvironmentObject* obj = env.namedLambdaTemplate) {
|
||||
if (NamedLambdaObject* obj = env.namedLambdaTemplate) {
|
||||
envDef = buildNamedLambdaEnv(callee, envDef, obj);
|
||||
}
|
||||
if (CallObject* obj = env.callObjectTemplate) {
|
||||
|
@ -276,7 +276,7 @@ class MOZ_STACK_CLASS WarpBuilder : public WarpBuilderShared {
|
||||
|
||||
[[nodiscard]] bool buildEnvironmentChain();
|
||||
MInstruction* buildNamedLambdaEnv(MDefinition* callee, MDefinition* env,
|
||||
LexicalEnvironmentObject* templateObj);
|
||||
NamedLambdaObject* templateObj);
|
||||
MInstruction* buildCallObject(MDefinition* callee, MDefinition* env,
|
||||
CallObject* templateObj);
|
||||
MInstruction* buildLoadSlot(MDefinition* obj, uint32_t numFixedSlots,
|
||||
|
@ -280,12 +280,12 @@ AbortReasonOr<WarpEnvironment> WarpScriptOracle::createEnvironment() {
|
||||
callObjectTemplate = &templateEnv->as<CallObject>();
|
||||
}
|
||||
|
||||
LexicalEnvironmentObject* namedLambdaTemplate = nullptr;
|
||||
NamedLambdaObject* namedLambdaTemplate = nullptr;
|
||||
if (fun->needsNamedLambdaEnvironment()) {
|
||||
if (callObjectTemplate) {
|
||||
templateEnv = templateEnv->enclosingEnvironment();
|
||||
}
|
||||
namedLambdaTemplate = &templateEnv->as<LexicalEnvironmentObject>();
|
||||
namedLambdaTemplate = &templateEnv->as<NamedLambdaObject>();
|
||||
}
|
||||
|
||||
return WarpEnvironment(
|
||||
|
@ -21,8 +21,8 @@ namespace js {
|
||||
|
||||
class ArgumentsObject;
|
||||
class CallObject;
|
||||
class LexicalEnvironmentObject;
|
||||
class ModuleEnvironmentObject;
|
||||
class NamedLambdaObject;
|
||||
|
||||
namespace jit {
|
||||
|
||||
@ -464,11 +464,11 @@ struct NoEnvironment {};
|
||||
using ConstantObjectEnvironment = WarpGCPtr<JSObject*>;
|
||||
struct FunctionEnvironment {
|
||||
WarpGCPtr<CallObject*> callObjectTemplate;
|
||||
WarpGCPtr<LexicalEnvironmentObject*> namedLambdaTemplate;
|
||||
WarpGCPtr<NamedLambdaObject*> namedLambdaTemplate;
|
||||
|
||||
public:
|
||||
FunctionEnvironment(CallObject* callObjectTemplate,
|
||||
LexicalEnvironmentObject* namedLambdaTemplate)
|
||||
NamedLambdaObject* namedLambdaTemplate)
|
||||
: callObjectTemplate(callObjectTemplate),
|
||||
namedLambdaTemplate(namedLambdaTemplate) {}
|
||||
};
|
||||
|
@ -1133,6 +1133,13 @@ inline bool JSObject::is<js::NonSyntacticLexicalEnvironmentObject>() const {
|
||||
!as<js::LexicalEnvironmentObject>().isSyntactic();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool JSObject::is<js::NamedLambdaObject>() const {
|
||||
return is<js::LexicalEnvironmentObject>() &&
|
||||
!is<js::ExtensibleLexicalEnvironmentObject>() &&
|
||||
as<js::LexicalEnvironmentObject>().scope().isNamedLambda();
|
||||
}
|
||||
|
||||
template <>
|
||||
bool JSObject::is<js::DebugEnvironmentProxy>() const;
|
||||
|
||||
@ -1208,15 +1215,14 @@ inline bool IsFrameInitialEnvironment(AbstractFramePtr frame,
|
||||
}
|
||||
|
||||
// For named lambda frames without CallObjects (i.e., no binding in the
|
||||
// body of the function was closed over), the LexicalEnvironmentObject
|
||||
// body of the function was closed over), the NamedLambdaObject
|
||||
// corresponding to the named lambda scope is the initial environment.
|
||||
if constexpr (std::is_same_v<SpecificEnvironment, NamedLambdaObject>) {
|
||||
if (frame.isFunctionFrame() &&
|
||||
frame.callee()->needsNamedLambdaEnvironment() &&
|
||||
!frame.callee()->needsCallObject()) {
|
||||
LexicalScope* namedLambdaScope = frame.script()->maybeNamedLambdaScope();
|
||||
return &env.template as<LexicalEnvironmentObject>().scope() ==
|
||||
namedLambdaScope;
|
||||
return &env.scope() == namedLambdaScope;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,6 +393,11 @@ class Scope : public gc::TenuredCellWithNonGCPointer<BaseScopeData> {
|
||||
|
||||
ScopeKind kind() const { return kind_; }
|
||||
|
||||
bool isNamedLambda() const {
|
||||
return kind() == ScopeKind::NamedLambda ||
|
||||
kind() == ScopeKind::StrictNamedLambda;
|
||||
}
|
||||
|
||||
Shape* environmentShape() const { return environmentShape_; }
|
||||
|
||||
Scope* enclosing() const { return enclosingScope_; }
|
||||
|
Loading…
Reference in New Issue
Block a user