Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 630e247caf8863b2ffafd47cf91db22d370b91b3..0d8bbaf9b59da8c08d351518e382e9e7a2a684b5 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -1411,20 +1411,34 @@ void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
| } |
| void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { |
| - VisitClassLiteralForRuntimeDefinition(expr); |
| - |
| - // Load the "prototype" from the constructor. |
| - Register literal = register_allocator()->NewRegister(); |
| + Register constructor = register_allocator()->NewRegister(); |
| + VisitForRegisterValue(expr->constructor(), constructor); |
|
rmcilroy
2017/01/04 09:55:59
nit - you can just do:
Register constructor = Visi
adamk
2017/01/04 17:57:03
Ah, nice.
|
| Register prototype = register_allocator()->NewRegister(); |
|
rmcilroy
2017/01/04 09:55:59
nit - you could save a register if you allocate th
adamk
2017/01/04 17:57:03
Done.
|
| - FeedbackVectorSlot slot = expr->PrototypeSlot(); |
| - builder() |
| - ->StoreAccumulatorInRegister(literal) |
| - .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) |
| - .StoreAccumulatorInRegister(prototype); |
| + { |
| + RegisterAllocationScope register_scope(this); |
| + RegisterList args = register_allocator()->NewRegisterList(4); |
| + VisitForAccumulatorValueOrTheHole(expr->extends()); |
| + builder() |
| + ->StoreAccumulatorInRegister(args[0]) |
| + .MoveRegister(constructor, args[1]) |
| + .LoadLiteral(Smi::FromInt(expr->start_position())) |
| + .StoreAccumulatorInRegister(args[2]) |
| + .LoadLiteral(Smi::FromInt(expr->end_position())) |
| + .StoreAccumulatorInRegister(args[3]) |
| + .CallRuntime(Runtime::kDefineClass, args) |
| + .StoreAccumulatorInRegister(prototype); |
| + } |
| - VisitClassLiteralProperties(expr, literal, prototype); |
| - BuildClassLiteralNameProperty(expr, literal); |
| - builder()->CallRuntime(Runtime::kToFastProperties, literal); |
| + if (FunctionLiteral::NeedsHomeObject(expr->constructor())) { |
| + // prototype is already in the accumulator |
|
rmcilroy
2017/01/04 09:55:59
nit - fullstop and capital letter for comments.
adamk
2017/01/04 17:57:03
Done.
|
| + builder()->StoreNamedProperty(constructor, home_object_symbol(), |
| + feedback_index(expr->HomeObjectSlot()), |
| + language_mode()); |
| + } |
| + |
| + VisitClassLiteralProperties(expr, constructor, prototype); |
| + BuildClassLiteralNameProperty(expr, constructor); |
| + builder()->CallRuntime(Runtime::kToFastProperties, constructor); |
| // Assign to class variable. |
| if (expr->class_variable_proxy() != nullptr) { |
| VariableProxy* proxy = expr->class_variable_proxy(); |
| @@ -1436,23 +1450,8 @@ void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { |
| } |
| } |
| -void BytecodeGenerator::VisitClassLiteralForRuntimeDefinition( |
| - ClassLiteral* expr) { |
| - RegisterAllocationScope register_scope(this); |
| - RegisterList args = register_allocator()->NewRegisterList(4); |
| - VisitForAccumulatorValueOrTheHole(expr->extends()); |
| - builder()->StoreAccumulatorInRegister(args[0]); |
| - VisitForRegisterValue(expr->constructor(), args[1]); |
| - builder() |
| - ->LoadLiteral(Smi::FromInt(expr->start_position())) |
| - .StoreAccumulatorInRegister(args[2]) |
| - .LoadLiteral(Smi::FromInt(expr->end_position())) |
| - .StoreAccumulatorInRegister(args[3]) |
| - .CallRuntime(Runtime::kDefineClass, args); |
| -} |
| - |
| void BytecodeGenerator::VisitClassLiteralProperties(ClassLiteral* expr, |
| - Register literal, |
| + Register constructor, |
| Register prototype) { |
| RegisterAllocationScope register_scope(this); |
| RegisterList args = register_allocator()->NewRegisterList(4); |
| @@ -1466,7 +1465,7 @@ void BytecodeGenerator::VisitClassLiteralProperties(ClassLiteral* expr, |
| ClassLiteral::Property* property = expr->properties()->at(i); |
| // Set-up receiver. |
| - Register new_receiver = property->is_static() ? literal : prototype; |
| + Register new_receiver = property->is_static() ? constructor : prototype; |
| if (new_receiver != old_receiver) { |
| builder()->MoveRegister(new_receiver, receiver); |
| old_receiver = new_receiver; |