| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
| 10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 VisitDeclarations(expr->scope()->declarations()); | 1234 VisitDeclarations(expr->scope()->declarations()); |
| 1235 VisitClassLiteralContents(expr); | 1235 VisitClassLiteralContents(expr); |
| 1236 } else { | 1236 } else { |
| 1237 VisitDeclarations(expr->scope()->declarations()); | 1237 VisitDeclarations(expr->scope()->declarations()); |
| 1238 VisitClassLiteralContents(expr); | 1238 VisitClassLiteralContents(expr); |
| 1239 } | 1239 } |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 void BytecodeGenerator::VisitClassLiteralContents(ClassLiteral* expr) { | 1242 void BytecodeGenerator::VisitClassLiteralContents(ClassLiteral* expr) { |
| 1243 VisitClassLiteralForRuntimeDefinition(expr); | 1243 VisitClassLiteralForRuntimeDefinition(expr); |
| 1244 // The prototype is ensured to exist by Runtime_DefineClass in | 1244 |
| 1245 // VisitClassForRuntimeDefinition. No access check is needed here | 1245 // Load the "prototype" from the constructor. |
| 1246 // since the constructor is created by the class literal. | |
| 1247 register_allocator()->PrepareForConsecutiveAllocations(2); | 1246 register_allocator()->PrepareForConsecutiveAllocations(2); |
| 1248 Register literal = register_allocator()->NextConsecutiveRegister(); | 1247 Register literal = register_allocator()->NextConsecutiveRegister(); |
| 1249 Register prototype = register_allocator()->NextConsecutiveRegister(); | 1248 Register prototype = register_allocator()->NextConsecutiveRegister(); |
| 1249 Handle<String> name = isolate()->factory()->prototype_string(); |
| 1250 FeedbackVectorSlot slot = expr->PrototypeSlot(); |
| 1250 builder() | 1251 builder() |
| 1251 ->StoreAccumulatorInRegister(literal) | 1252 ->StoreAccumulatorInRegister(literal) |
| 1252 .LoadPrototypeOrInitialMap() | 1253 .LoadNamedProperty(literal, name, feedback_index(slot), language_mode()) |
| 1253 .StoreAccumulatorInRegister(prototype); | 1254 .StoreAccumulatorInRegister(prototype); |
| 1254 | 1255 |
| 1255 VisitClassLiteralProperties(expr, literal, prototype); | 1256 VisitClassLiteralProperties(expr, literal, prototype); |
| 1256 builder()->CallRuntime(Runtime::kFinalizeClassDefinition, literal, 2); | 1257 builder()->CallRuntime(Runtime::kFinalizeClassDefinition, literal, 2); |
| 1257 // Assign to class variable. | 1258 // Assign to class variable. |
| 1258 if (expr->class_variable_proxy() != nullptr) { | 1259 if (expr->class_variable_proxy() != nullptr) { |
| 1259 Variable* var = expr->class_variable_proxy()->var(); | 1260 Variable* var = expr->class_variable_proxy()->var(); |
| 1260 FeedbackVectorSlot slot = expr->NeedsProxySlot() | 1261 FeedbackVectorSlot slot = expr->NeedsProxySlot() |
| 1261 ? expr->ProxySlot() | 1262 ? expr->ProxySlot() |
| 1262 : FeedbackVectorSlot::Invalid(); | 1263 : FeedbackVectorSlot::Invalid(); |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2709 } | 2710 } |
| 2710 | 2711 |
| 2711 | 2712 |
| 2712 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2713 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 2713 return info()->feedback_vector()->GetIndex(slot); | 2714 return info()->feedback_vector()->GetIndex(slot); |
| 2714 } | 2715 } |
| 2715 | 2716 |
| 2716 } // namespace interpreter | 2717 } // namespace interpreter |
| 2717 } // namespace internal | 2718 } // namespace internal |
| 2718 } // namespace v8 | 2719 } // namespace v8 |
| OLD | NEW |