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

Unified Diff: src/interpreter/bytecode-generator.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/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index c67e5d43f706b797a63f5fe9b77257d0fefefe69..4d359acab5cf411608455a9201c454f6659394a6 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -571,8 +571,7 @@ BytecodeGenerator::BytecodeGenerator(CompilationInfo* info)
generator_state_(),
loop_depth_(0),
home_object_symbol_(info->isolate()->factory()->home_object_symbol()),
- prototype_string_(info->isolate()->factory()->prototype_string()) {
-}
+ prototype_string_(info->isolate()->factory()->prototype_string()) {}
rmcilroy 2016/11/14 13:22:18 nit - did "git cl" do this? If not, please revert.
Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) {
AllocateDeferredConstants();
@@ -1392,6 +1391,7 @@ void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) {
.StoreAccumulatorInRegister(prototype);
VisitClassLiteralProperties(expr, literal, prototype);
+ BuildClassLiteralNameProperty(expr, literal);
builder()->CallRuntime(Runtime::kToFastProperties, literal);
// Assign to class variable.
if (expr->class_variable_proxy() != nullptr) {
@@ -1493,6 +1493,21 @@ void BytecodeGenerator::VisitClassLiteralProperties(ClassLiteral* expr,
}
}
+void BytecodeGenerator::BuildClassLiteralNameProperty(ClassLiteral* expr,
+ Register literal) {
+ DCHECK(expr->constructor()->raw_name() != nullptr);
rmcilroy 2016/11/14 13:22:18 no point having this DCHECK since the next line wi
+
+ if (!expr->constructor()->raw_name()->IsEmpty()) {
+ RegisterAllocationScope register_scope(this);
+ RegisterList args = register_allocator()->NewRegisterList(2);
+ builder()
+ ->MoveRegister(literal, args[0])
+ .LoadLiteral(expr->constructor()->name())
+ .StoreAccumulatorInRegister(args[1])
+ .CallRuntime(Runtime::kDefineClassNameProperty, args);
+ }
+}
+
void BytecodeGenerator::VisitNativeFunctionLiteral(
NativeFunctionLiteral* expr) {
size_t entry = builder()->AllocateConstantPoolEntry();

Powered by Google App Engine
This is Rietveld 408576698