Commit 3ac1947e authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[ast] Remove unused feedback slot for the class name variable

Also store the variable directly on ClassLiteral, as the proxy serves
as a useless form of indirection.

Bug: v8:6092
Change-Id: If0182a808cde4e349c1bf5a003a1ecee5bd14b13
Reviewed-on: https://chromium-review.googlesource.com/667800Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48072}
parent a900e53f
...@@ -411,9 +411,6 @@ void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { ...@@ -411,9 +411,6 @@ void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) {
LanguageModeScope language_mode_scope(this, STRICT); LanguageModeScope language_mode_scope(this, STRICT);
if (node->extends()) Visit(node->extends()); if (node->extends()) Visit(node->extends());
if (node->constructor()) Visit(node->constructor()); if (node->constructor()) Visit(node->constructor());
if (node->class_variable_proxy()) {
VisitVariableProxy(node->class_variable_proxy());
}
for (int i = 0; i < node->properties()->length(); i++) { for (int i = 0; i < node->properties()->length(); i++) {
VisitLiteralProperty(node->properties()->at(i)); VisitLiteralProperty(node->properties()->at(i));
} }
......
...@@ -365,10 +365,6 @@ void ClassLiteral::AssignFeedbackSlots(FeedbackVectorSpec* spec, ...@@ -365,10 +365,6 @@ void ClassLiteral::AssignFeedbackSlots(FeedbackVectorSpec* spec,
home_object_slot_ = spec->AddStoreICSlot(language_mode); home_object_slot_ = spec->AddStoreICSlot(language_mode);
} }
if (NeedsProxySlot()) {
proxy_slot_ = spec->AddStoreICSlot(language_mode);
}
for (int i = 0; i < properties()->length(); i++) { for (int i = 0; i < properties()->length(); i++) {
ClassLiteral::Property* property = properties()->at(i); ClassLiteral::Property* property = properties()->at(i);
Expression* value = property->value(); Expression* value = property->value();
......
...@@ -2512,7 +2512,7 @@ class ClassLiteral final : public Expression { ...@@ -2512,7 +2512,7 @@ class ClassLiteral final : public Expression {
typedef ClassLiteralProperty Property; typedef ClassLiteralProperty Property;
Scope* scope() const { return scope_; } Scope* scope() const { return scope_; }
VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } Variable* class_variable() const { return class_variable_; }
Expression* extends() const { return extends_; } Expression* extends() const { return extends_; }
void set_extends(Expression* e) { extends_ = e; } void set_extends(Expression* e) { extends_ = e; }
FunctionLiteral* constructor() const { return constructor_; } FunctionLiteral* constructor() const { return constructor_; }
...@@ -2539,26 +2539,20 @@ class ClassLiteral final : public Expression { ...@@ -2539,26 +2539,20 @@ class ClassLiteral final : public Expression {
void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode, void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode,
FunctionKind kind, FeedbackSlotCache* cache); FunctionKind kind, FeedbackSlotCache* cache);
bool NeedsProxySlot() const {
return class_variable_proxy() != nullptr &&
class_variable_proxy()->var()->IsUnallocated();
}
FeedbackSlot HomeObjectSlot() const { return home_object_slot_; } FeedbackSlot HomeObjectSlot() const { return home_object_slot_; }
FeedbackSlot ProxySlot() const { return proxy_slot_; }
private: private:
friend class AstNodeFactory; friend class AstNodeFactory;
ClassLiteral(Scope* scope, VariableProxy* class_variable_proxy, ClassLiteral(Scope* scope, Variable* class_variable, Expression* extends,
Expression* extends, FunctionLiteral* constructor, FunctionLiteral* constructor, ZoneList<Property*>* properties,
ZoneList<Property*>* properties, int start_position, int start_position, int end_position,
int end_position, bool has_name_static_property, bool has_name_static_property, bool has_static_computed_names,
bool has_static_computed_names, bool is_anonymous) bool is_anonymous)
: Expression(start_position, kClassLiteral), : Expression(start_position, kClassLiteral),
end_position_(end_position), end_position_(end_position),
scope_(scope), scope_(scope),
class_variable_proxy_(class_variable_proxy), class_variable_(class_variable),
extends_(extends), extends_(extends),
constructor_(constructor), constructor_(constructor),
properties_(properties) { properties_(properties) {
...@@ -2569,9 +2563,8 @@ class ClassLiteral final : public Expression { ...@@ -2569,9 +2563,8 @@ class ClassLiteral final : public Expression {
int end_position_; int end_position_;
FeedbackSlot home_object_slot_; FeedbackSlot home_object_slot_;
FeedbackSlot proxy_slot_;
Scope* scope_; Scope* scope_;
VariableProxy* class_variable_proxy_; Variable* class_variable_;
Expression* extends_; Expression* extends_;
FunctionLiteral* constructor_; FunctionLiteral* constructor_;
ZoneList<Property*>* properties_; ZoneList<Property*>* properties_;
...@@ -3324,7 +3317,7 @@ class AstNodeFactory final BASE_EMBEDDED { ...@@ -3324,7 +3317,7 @@ class AstNodeFactory final BASE_EMBEDDED {
ClassLiteral::Property(key, value, kind, is_static, is_computed_name); ClassLiteral::Property(key, value, kind, is_static, is_computed_name);
} }
ClassLiteral* NewClassLiteral(Scope* scope, VariableProxy* proxy, ClassLiteral* NewClassLiteral(Scope* scope, Variable* variable,
Expression* extends, Expression* extends,
FunctionLiteral* constructor, FunctionLiteral* constructor,
ZoneList<ClassLiteral::Property*>* properties, ZoneList<ClassLiteral::Property*>* properties,
...@@ -3333,7 +3326,7 @@ class AstNodeFactory final BASE_EMBEDDED { ...@@ -3333,7 +3326,7 @@ class AstNodeFactory final BASE_EMBEDDED {
bool has_static_computed_names, bool has_static_computed_names,
bool is_anonymous) { bool is_anonymous) {
return new (zone_) return new (zone_)
ClassLiteral(scope, proxy, extends, constructor, properties, ClassLiteral(scope, variable, extends, constructor, properties,
start_position, end_position, has_name_static_property, start_position, end_position, has_name_static_property,
has_static_computed_names, is_anonymous); has_static_computed_names, is_anonymous);
} }
......
...@@ -1735,12 +1735,11 @@ void BytecodeGenerator::BuildClassLiteral(ClassLiteral* expr) { ...@@ -1735,12 +1735,11 @@ void BytecodeGenerator::BuildClassLiteral(ClassLiteral* expr) {
BuildClassLiteralNameProperty(expr, constructor); BuildClassLiteralNameProperty(expr, constructor);
builder()->CallRuntime(Runtime::kToFastProperties, constructor); builder()->CallRuntime(Runtime::kToFastProperties, constructor);
// Assign to class variable. // Assign to class variable.
if (expr->class_variable_proxy() != nullptr) { if (expr->class_variable() != nullptr) {
VariableProxy* proxy = expr->class_variable_proxy(); DCHECK(expr->class_variable()->IsStackLocal() ||
FeedbackSlot slot = expr->class_variable()->IsContextSlot());
expr->NeedsProxySlot() ? expr->ProxySlot() : FeedbackSlot::Invalid(); BuildVariableAssignment(expr->class_variable(), Token::INIT,
BuildVariableAssignment(proxy->var(), Token::INIT, slot, FeedbackSlot::Invalid(), HoleCheckMode::kElided);
HoleCheckMode::kElided);
} }
} }
......
...@@ -551,7 +551,7 @@ class ParserBase { ...@@ -551,7 +551,7 @@ class ParserBase {
struct ClassInfo { struct ClassInfo {
public: public:
explicit ClassInfo(ParserBase* parser) explicit ClassInfo(ParserBase* parser)
: proxy(nullptr), : variable(nullptr),
extends(parser->impl()->NullExpression()), extends(parser->impl()->NullExpression()),
properties(parser->impl()->NewClassPropertyList(4)), properties(parser->impl()->NewClassPropertyList(4)),
constructor(parser->impl()->NullExpression()), constructor(parser->impl()->NullExpression()),
...@@ -559,7 +559,7 @@ class ParserBase { ...@@ -559,7 +559,7 @@ class ParserBase {
has_name_static_property(false), has_name_static_property(false),
has_static_computed_names(false), has_static_computed_names(false),
is_anonymous(false) {} is_anonymous(false) {}
VariableProxy* proxy; Variable* variable;
ExpressionT extends; ExpressionT extends;
typename Types::ClassPropertyList properties; typename Types::ClassPropertyList properties;
FunctionLiteralT constructor; FunctionLiteralT constructor;
......
...@@ -3127,11 +3127,12 @@ void Parser::DeclareClassVariable(const AstRawString* name, ...@@ -3127,11 +3127,12 @@ void Parser::DeclareClassVariable(const AstRawString* name,
#endif #endif
if (name != nullptr) { if (name != nullptr) {
class_info->proxy = factory()->NewVariableProxy(name, NORMAL_VARIABLE); VariableProxy* proxy = factory()->NewVariableProxy(name, NORMAL_VARIABLE);
Declaration* declaration = Declaration* declaration =
factory()->NewVariableDeclaration(class_info->proxy, class_token_pos); factory()->NewVariableDeclaration(proxy, class_token_pos);
Declare(declaration, DeclarationDescriptor::NORMAL, CONST, class_info->variable =
Variable::DefaultInitializationFlag(CONST), ok); Declare(declaration, DeclarationDescriptor::NORMAL, CONST,
Variable::DefaultInitializationFlag(CONST), ok);
} }
} }
...@@ -3185,12 +3186,12 @@ Expression* Parser::RewriteClassLiteral(Scope* block_scope, ...@@ -3185,12 +3186,12 @@ Expression* Parser::RewriteClassLiteral(Scope* block_scope,
} }
if (name != nullptr) { if (name != nullptr) {
DCHECK_NOT_NULL(class_info->proxy); DCHECK_NOT_NULL(class_info->variable);
class_info->proxy->var()->set_initializer_position(end_pos); class_info->variable->set_initializer_position(end_pos);
} }
ClassLiteral* class_literal = factory()->NewClassLiteral( ClassLiteral* class_literal = factory()->NewClassLiteral(
block_scope, class_info->proxy, class_info->extends, block_scope, class_info->variable, class_info->extends,
class_info->constructor, class_info->properties, pos, end_pos, class_info->constructor, class_info->properties, pos, end_pos,
class_info->has_name_static_property, class_info->has_name_static_property,
class_info->has_static_computed_names, class_info->is_anonymous); class_info->has_static_computed_names, class_info->is_anonymous);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment