Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: src/full-codegen/mips64/full-codegen-mips64.cc

Issue 2330473002: Class fields, part 3 (backends)
Patch Set: bytecode test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen/mips64/full-codegen-mips64.cc
diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc
index b14c63452d3257b6c6255963dcf3b803885b096e..68d6364fa9ca980a73afc113020260123e4ad631 100644
--- a/src/full-codegen/mips64/full-codegen-mips64.cc
+++ b/src/full-codegen/mips64/full-codegen-mips64.cc
@@ -1989,6 +1989,30 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
ClassLiteral::Property* property = lit->properties()->at(i);
Expression* value = property->value();
+ if (property->kind() == ClassLiteral::Property::FIELD &&
+ !property->is_static()) {
+ // Non-static properties produced by the parser have as their 'key' an
+ // expression producing their name and as their 'value' a variable which
+ // is refered to by the synthetic initializer function in order to
+ // determine the name during class instantiation. This is necessary
+ // because computed names must only be evaluated once, at class definition
+ // time.
+ // That is, code which looks like `class C { [f()] = 1; }` is desugared
+ // into something like
+ // class C { constructor(){ this.[.class-field-0-name] = 1; } };
+ // let .class-field-0-name = f();
+ // except that the assignment to .class-field-name-0 occurs interleaved
+ // with the rest of the class body; it is performed by the block in which
+ // this comment appears.
+ DCHECK(property->value()->IsVariableProxy());
+ Variable* variable = property->value()->AsVariableProxy()->var();
+ VisitForStackValue(property->key());
+ EmitVariableAssignment(variable, Token::INIT,
+ FeedbackVectorSlot::Invalid());
+ DropOperands(1);
+ continue;
+ }
+
Register scratch = a1;
if (property->is_static()) {
__ ld(scratch, MemOperand(sp, kPointerSize)); // constructor
@@ -2030,8 +2054,11 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
break;
case ClassLiteral::Property::FIELD:
- default:
- UNREACHABLE();
+ DCHECK(property->is_static());
+ PushOperand(Smi::FromInt(DONT_ENUM));
+ PushOperand(Smi::FromInt(property->NeedsSetFunctionName()));
+ CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral);
+ break;
}
}
}
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698