Commit 7621d487 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[class] Remove needs_home_object from InitializeClassFieldsStatement

Initialize the home object when we create the initializer function
keeping this in line with other functions that initialize home object.

Bug: v8:5367
Change-Id: I1c5e32ae0cb496740341e6c99c9359f6c5e00875
Reviewed-on: https://chromium-review.googlesource.com/754163Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49153}
parent ea04c667
......@@ -2433,19 +2433,14 @@ class InitializeClassFieldsStatement final : public Statement {
public:
typedef ClassLiteralProperty Property;
ZoneList<Property*>* fields() const { return fields_; }
bool needs_home_object() const { return needs_home_object_; }
private:
friend class AstNodeFactory;
InitializeClassFieldsStatement(ZoneList<Property*>* fields,
bool needs_home_object, int pos)
: Statement(pos, kInitializeClassFieldsStatement),
fields_(fields),
needs_home_object_(needs_home_object) {}
InitializeClassFieldsStatement(ZoneList<Property*>* fields, int pos)
: Statement(pos, kInitializeClassFieldsStatement), fields_(fields) {}
ZoneList<Property*>* fields_;
bool needs_home_object_;
};
class ClassLiteral final : public Expression {
......@@ -3334,9 +3329,8 @@ class AstNodeFactory final BASE_EMBEDDED {
}
InitializeClassFieldsStatement* NewInitializeClassFieldsStatement(
ZoneList<ClassLiteralProperty*>* args, bool needs_home_object, int pos) {
return new (zone_)
InitializeClassFieldsStatement(args, needs_home_object, pos);
ZoneList<ClassLiteralProperty*>* args, int pos) {
return new (zone_) InitializeClassFieldsStatement(args, pos);
}
Zone* zone() const { return zone_; }
......
......@@ -1798,6 +1798,15 @@ void BytecodeGenerator::BuildClassLiteral(ClassLiteral* expr) {
RegisterList args = register_allocator()->NewRegisterList(1);
Register initializer = register_allocator()->NewRegister();
VisitForRegisterValue(expr->static_fields_initializer(), initializer);
if (FunctionLiteral::NeedsHomeObject(expr->static_fields_initializer())) {
FeedbackSlot slot = feedback_spec()->AddStoreICSlot(language_mode());
builder()
->LoadAccumulatorWithRegister(constructor)
.StoreHomeObjectProperty(initializer, feedback_index(slot),
language_mode());
}
builder()
->MoveRegister(constructor, args[0])
.CallProperty(initializer, args,
......@@ -1908,15 +1917,6 @@ void BytecodeGenerator::VisitClassLiteralProperties(ClassLiteral* expr,
void BytecodeGenerator::VisitInitializeClassFieldsStatement(
InitializeClassFieldsStatement* expr) {
Register constructor(builder()->Receiver());
if (expr->needs_home_object()) {
FeedbackSlot slot = feedback_spec()->AddStoreICSlot(language_mode());
builder()
->LoadAccumulatorWithRegister(constructor)
.StoreHomeObjectProperty(Register::function_closure(),
feedback_index(slot), language_mode());
}
Register key = register_allocator()->NewRegister();
Register value = register_allocator()->NewRegister();
......
......@@ -3291,9 +3291,8 @@ Expression* Parser::RewriteClassLiteral(Scope* block_scope,
// function() { .. static class fields initializer .. }
ZoneList<Statement*>* statements = NewStatementList(1);
InitializeClassFieldsStatement* class_fields =
factory()->NewInitializeClassFieldsStatement(
class_info->static_fields,
class_info->field_scope->NeedsHomeObject(), kNoSourcePosition);
factory()->NewInitializeClassFieldsStatement(class_info->static_fields,
kNoSourcePosition);
statements->Add(class_fields, zone());
static_fields_initializer = factory()->NewFunctionLiteral(
ast_value_factory()->empty_string(), class_info->field_scope,
......
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