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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2330473002: Class fields, part 3 (backends)
Patch Set: clean up test properly 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/x87/full-codegen-x87.cc ('k') | test/mjsunit/harmony/class-fields-arguments.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 53ef7d95ff187ea6dd69dd4775f526c23d788ba3..168499a171a44972cf95017620682fdd063ec91d 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -1492,6 +1492,18 @@ void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) {
.LoadNamedProperty(literal, prototype_string(), feedback_index(slot))
.StoreAccumulatorInRegister(prototype);
+ // TODO(bakkot) This shouldn't be necessary; I just couldn't figure out how to
+ // invoke the function literal with appropriate home object and receiver
+ // (mainly because of FeedbackVector check failures which are totally opaque
+ // to me)
Dan Ehrenberg 2016/09/10 04:06:54 Seems OK; it'd be good to note that this is motiva
bakkot 2016/09/12 23:05:15 Added a more reasonable comment mentioning that th
+ VariableProxy* static_initializer_proxy = expr->static_initializer_proxy();
+ if (static_initializer_proxy != nullptr) {
+ Variable* variable = static_initializer_proxy->var();
+ builder()->LoadAccumulatorWithRegister(literal);
+ VisitVariableAssignment(variable, Token::INIT, // TODO(bakkot) tokens
Dan Ehrenberg 2016/09/10 04:06:54 What is this TODO?
bakkot 2016/09/12 23:05:15 Oh, I just wasn't sure if Token::INIT or Token::AS
+ FeedbackVectorSlot::Invalid());
+ }
+
VisitClassLiteralProperties(expr, literal, prototype);
builder()->CallRuntime(Runtime::kToFastProperties, literal, 1);
// Assign to class variable.
@@ -1546,6 +1558,18 @@ void BytecodeGenerator::VisitClassLiteralProperties(ClassLiteral* expr,
for (int i = 0; i < expr->properties()->length(); i++) {
ClassLiteral::Property* property = expr->properties()->at(i);
+ if (property->kind() == ClassLiteral::Property::FIELD &&
+ !property->is_static()) {
+ // This just does the ToName call on the field name and stores it in a
Dan Ehrenberg 2016/09/10 04:06:54 Was Melissa O'Neill at Mudd when you went there? O
bakkot 2016/09/12 23:05:15 I've written a more reasonable if slightly wordy c
+ // variable (a proxy for which is the value() of this property)
+ DCHECK(property->value()->IsVariableProxy());
+ Variable* variable = property->value()->AsVariableProxy()->var();
+ VisitForAccumulatorValue(property->key());
+ VisitVariableAssignment(variable, Token::INIT,
+ FeedbackVectorSlot::Invalid());
+ continue;
+ }
+
// Set-up receiver.
Register new_receiver = property->is_static() ? literal : prototype;
if (new_receiver != old_receiver) {
@@ -1594,7 +1618,12 @@ void BytecodeGenerator::VisitClassLiteralProperties(ClassLiteral* expr,
break;
}
case ClassLiteral::Property::FIELD: {
- UNREACHABLE();
+ DCHECK(property->is_static());
+ builder()
+ ->LoadLiteral(Smi::FromInt(property->NeedsSetFunctionName()))
+ .StoreAccumulatorInRegister(set_function_name);
+ builder()->CallRuntime(Runtime::kDefineDataPropertyInLiteral, receiver,
+ 5);
break;
}
}
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | test/mjsunit/harmony/class-fields-arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698