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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Avoid a runtime call for anonymous classes 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..8b8ac76ee51ea07710474ba3bdfa5ee827b57d29 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1672,9 +1672,20 @@ void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) {
}
}
- // Set the constructor to have fast properties.
prototype = environment()->Pop();
literal = environment()->Pop();
+
+ // ES6 section 14.5.16 class expression evaluation, step 5
+ DCHECK(expr->constructor()->raw_name() != nullptr);
+ if (!expr->constructor()->raw_name()->IsEmpty()) {
+ Node* value = jsgraph()->Constant(expr->constructor()->name());
+ const Operator* op =
+ javascript()->CallRuntime(Runtime::kDefineClassNameProperty);
+ literal = NewNode(op, literal, value);
+ PrepareFrameState(literal, BailoutId::None());
+ }
+
+ // Set the constructor to have fast properties.
const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties);
literal = NewNode(op, literal);
« no previous file with comments | « src/code-stubs.cc ('k') | src/contexts.h » ('j') | src/full-codegen/x64/full-codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698