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

Unified Diff: src/full-codegen/full-codegen.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/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen/full-codegen.cc
diff --git a/src/full-codegen/full-codegen.cc b/src/full-codegen/full-codegen.cc
index 6182094e821933230802568745df22e03b9b5872..a5134d9ae06d31d0e94389bc285585250d0cd0af 100644
--- a/src/full-codegen/full-codegen.cc
+++ b/src/full-codegen/full-codegen.cc
@@ -1528,6 +1528,20 @@ void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) {
PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER);
PushOperand(result_register());
+ // The below proxy exists to allow static field initializers to have the
+ // correct home object and receiver. It's only necessary if the initializers
+ // are called as a part of class definition instead of immediately after it,
+ // in which case they could simply refer to the class just constructed. The
+ // latter is actually what's currently specified, and this will need to be
+ // changed if that behavior is settled upon. See also
+ // https://github.com/tc39/proposal-class-public-fields/issues/50
+ VariableProxy* static_initializer_proxy = lit->static_initializer_proxy();
+ if (static_initializer_proxy != nullptr) {
+ Variable* variable = static_initializer_proxy->var();
+ EmitVariableAssignment(variable, Token::INIT,
+ FeedbackVectorSlot::Invalid());
+ }
+
// Load the "prototype" from the constructor.
__ Move(LoadDescriptor::ReceiverRegister(), result_register());
__ LoadRoot(LoadDescriptor::NameRegister(), Heap::kprototype_stringRootIndex);
« no previous file with comments | « src/full-codegen/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698