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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Move computed property names check to parser and runtime function Created 4 years, 1 month 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
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 161a33a10d4ac8663c2e57e81b99a737b8468cfc..f2b64d0b146b4c5825b2f71f95306783a2bc58ac 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1625,8 +1625,8 @@ void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) {
// The static prototype property is read only. We handle the non computed
// property name case in the parser. Since this is the only case where we
- // need to check for an own read only property we special case this so we do
- // not need to do this for every property.
+ // need to check for an own read only property we special case this so we
+ // do not need to do this for every property.
if (property->is_static() && property->is_computed_name()) {
Node* check = BuildThrowIfStaticPrototype(environment()->Pop(),
expr->GetIdForProperty(i));
@@ -1672,8 +1672,22 @@ void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) {
}
}
- // Set the constructor to have fast properties.
prototype = environment()->Pop();
+
+ // Install a "name" property if missing.
+ if (!expr->has_name_static_property() &&
+ !expr->constructor()->raw_name()->IsEmpty()) {
+ literal = environment()->Pop();
+ const Operator* op =
+ javascript()->CallRuntime(Runtime::kInstallClassNameAccessor);
+ literal =
+ NewNode(op, literal,
+ jsgraph()->BooleanConstant(expr->has_static_computed_names()));
Toon Verwaest 2016/11/29 12:27:47 The standard way is to call a different runtime fu
+ PrepareFrameState(literal, BailoutId::None());
+ environment()->Push(literal);
+ }
+
+ // Set the constructor to have fast properties.
literal = environment()->Pop();
const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties);
literal = NewNode(op, literal);

Powered by Google App Engine
This is Rietveld 408576698