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) {
LanguageModeScope language_mode_scope(this, STRICT);
if (node->extends()) Visit(node->extends());
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++) {
VisitLiteralProperty(node->properties()->at(i));
}
......
......@@ -365,10 +365,6 @@ void ClassLiteral::AssignFeedbackSlots(FeedbackVectorSpec* spec,
home_object_slot_ = spec->AddStoreICSlot(language_mode);
}
if (NeedsProxySlot()) {
proxy_slot_ = spec->AddStoreICSlot(language_mode);
}
for (int i = 0; i < properties()->length(); i++) {
ClassLiteral::Property* property = properties()->at(i);
Expression* value = property->value();
......
......@@ -2512,7 +2512,7 @@ class ClassLiteral final : public Expression {
typedef ClassLiteralProperty Property;
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_; }
void set_extends(Expression* e) { extends_ = e; }
FunctionLiteral* constructor() const { return constructor_; }
......@@ -2539,26 +2539,20 @@ class ClassLiteral final : public Expression {
void AssignFeedbackSlots(FeedbackVectorSpec* spec, LanguageMode language_mode,
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 ProxySlot() const { return proxy_slot_; }
private:
friend class AstNodeFactory;
ClassLiteral(Scope* scope, VariableProxy* class_variable_proxy,
Expression* extends, FunctionLiteral* constructor,
ZoneList<Property*>* properties, int start_position,
int end_position, bool has_name_static_property,
bool has_static_computed_names, bool is_anonymous)
ClassLiteral(Scope* scope, Variable* class_variable, Expression* extends,
FunctionLiteral* constructor, ZoneList<Property*>* properties,
int start_position, int end_position,
bool has_name_static_property, bool has_static_computed_names,
bool is_anonymous)
: Expression(start_position, kClassLiteral),
end_position_(end_position),
scope_(scope),
class_variable_proxy_(class_variable_proxy),
class_variable_(class_variable),
extends_(extends),
constructor_(constructor),
properties_(properties) {
......@@ -2569,9 +2563,8 @@ class ClassLiteral final : public Expression {
int end_position_;
FeedbackSlot home_object_slot_;
FeedbackSlot proxy_slot_;
Scope* scope_;
VariableProxy* class_variable_proxy_;
Variable* class_variable_;
Expression* extends_;
FunctionLiteral* constructor_;
ZoneList<Property*>* properties_;
......@@ -3324,7 +3317,7 @@ class AstNodeFactory final BASE_EMBEDDED {
ClassLiteral::Property(key, value, kind, is_static, is_computed_name);
}
ClassLiteral* NewClassLiteral(Scope* scope, VariableProxy* proxy,
ClassLiteral* NewClassLiteral(Scope* scope, Variable* variable,
Expression* extends,
FunctionLiteral* constructor,
ZoneList<ClassLiteral::Property*>* properties,
......@@ -3333,7 +3326,7 @@ class AstNodeFactory final BASE_EMBEDDED {
bool has_static_computed_names,
bool is_anonymous) {
return new (zone_)
ClassLiteral(scope, proxy, extends, constructor, properties,
ClassLiteral(scope, variable, extends, constructor, properties,
start_position, end_position, has_name_static_property,
has_static_computed_names, is_anonymous);
}
......
......@@ -1735,12 +1735,11 @@ void BytecodeGenerator::BuildClassLiteral(ClassLiteral* expr) {
BuildClassLiteralNameProperty(expr, constructor);
builder()->CallRuntime(Runtime::kToFastProperties, constructor);
// Assign to class variable.
if (expr->class_variable_proxy() != nullptr) {
VariableProxy* proxy = expr->class_variable_proxy();
FeedbackSlot slot =
expr->NeedsProxySlot() ? expr->ProxySlot() : FeedbackSlot::Invalid();
BuildVariableAssignment(proxy->var(), Token::INIT, slot,
HoleCheckMode::kElided);
if (expr->class_variable() != nullptr) {
DCHECK(expr->class_variable()->IsStackLocal() ||
expr->class_variable()->IsContextSlot());
BuildVariableAssignment(expr->class_variable(), Token::INIT,
FeedbackSlot::Invalid(), HoleCheckMode::kElided);
}
}
......
......@@ -551,7 +551,7 @@ class ParserBase {
struct ClassInfo {
public:
explicit ClassInfo(ParserBase* parser)
: proxy(nullptr),
: variable(nullptr),
extends(parser->impl()->NullExpression()),
properties(parser->impl()->NewClassPropertyList(4)),
constructor(parser->impl()->NullExpression()),
......@@ -559,7 +559,7 @@ class ParserBase {
has_name_static_property(false),
has_static_computed_names(false),
is_anonymous(false) {}
VariableProxy* proxy;
Variable* variable;
ExpressionT extends;
typename Types::ClassPropertyList properties;
FunctionLiteralT constructor;
......
......@@ -3127,11 +3127,12 @@ void Parser::DeclareClassVariable(const AstRawString* name,
#endif
if (name != nullptr) {
class_info->proxy = factory()->NewVariableProxy(name, NORMAL_VARIABLE);
VariableProxy* proxy = factory()->NewVariableProxy(name, NORMAL_VARIABLE);
Declaration* declaration =
factory()->NewVariableDeclaration(class_info->proxy, class_token_pos);
Declare(declaration, DeclarationDescriptor::NORMAL, CONST,
Variable::DefaultInitializationFlag(CONST), ok);
factory()->NewVariableDeclaration(proxy, class_token_pos);
class_info->variable =
Declare(declaration, DeclarationDescriptor::NORMAL, CONST,
Variable::DefaultInitializationFlag(CONST), ok);
}
}
......@@ -3185,12 +3186,12 @@ Expression* Parser::RewriteClassLiteral(Scope* block_scope,
}
if (name != nullptr) {
DCHECK_NOT_NULL(class_info->proxy);
class_info->proxy->var()->set_initializer_position(end_pos);
DCHECK_NOT_NULL(class_info->variable);
class_info->variable->set_initializer_position(end_pos);
}
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->has_name_static_property,
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