| 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/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 // Load the "prototype" from the constructor. | 1408 // Load the "prototype" from the constructor. |
| 1409 Register literal = register_allocator()->NewRegister(); | 1409 Register literal = register_allocator()->NewRegister(); |
| 1410 Register prototype = register_allocator()->NewRegister(); | 1410 Register prototype = register_allocator()->NewRegister(); |
| 1411 FeedbackVectorSlot slot = expr->PrototypeSlot(); | 1411 FeedbackVectorSlot slot = expr->PrototypeSlot(); |
| 1412 builder() | 1412 builder() |
| 1413 ->StoreAccumulatorInRegister(literal) | 1413 ->StoreAccumulatorInRegister(literal) |
| 1414 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) | 1414 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) |
| 1415 .StoreAccumulatorInRegister(prototype); | 1415 .StoreAccumulatorInRegister(prototype); |
| 1416 | 1416 |
| 1417 VisitClassLiteralProperties(expr, literal, prototype); | 1417 VisitClassLiteralProperties(expr, literal, prototype); |
| 1418 BuildClassLiteralNameProperty(expr, literal); |
| 1418 builder()->CallRuntime(Runtime::kToFastProperties, literal); | 1419 builder()->CallRuntime(Runtime::kToFastProperties, literal); |
| 1419 // Assign to class variable. | 1420 // Assign to class variable. |
| 1420 if (expr->class_variable_proxy() != nullptr) { | 1421 if (expr->class_variable_proxy() != nullptr) { |
| 1421 VariableProxy* proxy = expr->class_variable_proxy(); | 1422 VariableProxy* proxy = expr->class_variable_proxy(); |
| 1422 FeedbackVectorSlot slot = expr->NeedsProxySlot() | 1423 FeedbackVectorSlot slot = expr->NeedsProxySlot() |
| 1423 ? expr->ProxySlot() | 1424 ? expr->ProxySlot() |
| 1424 : FeedbackVectorSlot::Invalid(); | 1425 : FeedbackVectorSlot::Invalid(); |
| 1425 BuildVariableAssignment(proxy->var(), Token::INIT, slot, | 1426 BuildVariableAssignment(proxy->var(), Token::INIT, slot, |
| 1426 HoleCheckMode::kElided); | 1427 HoleCheckMode::kElided); |
| 1427 } | 1428 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 break; | 1507 break; |
| 1507 } | 1508 } |
| 1508 case ClassLiteral::Property::FIELD: { | 1509 case ClassLiteral::Property::FIELD: { |
| 1509 UNREACHABLE(); | 1510 UNREACHABLE(); |
| 1510 break; | 1511 break; |
| 1511 } | 1512 } |
| 1512 } | 1513 } |
| 1513 } | 1514 } |
| 1514 } | 1515 } |
| 1515 | 1516 |
| 1517 void BytecodeGenerator::BuildClassLiteralNameProperty(ClassLiteral* expr, |
| 1518 Register literal) { |
| 1519 if (!expr->has_name_static_property() && |
| 1520 !expr->constructor()->raw_name()->IsEmpty()) { |
| 1521 Runtime::FunctionId runtime_id = |
| 1522 expr->has_static_computed_names() |
| 1523 ? Runtime::kInstallClassNameAccessorWithCheck |
| 1524 : Runtime::kInstallClassNameAccessor; |
| 1525 builder()->CallRuntime(runtime_id, literal); |
| 1526 } |
| 1527 } |
| 1528 |
| 1516 void BytecodeGenerator::VisitNativeFunctionLiteral( | 1529 void BytecodeGenerator::VisitNativeFunctionLiteral( |
| 1517 NativeFunctionLiteral* expr) { | 1530 NativeFunctionLiteral* expr) { |
| 1518 size_t entry = builder()->AllocateConstantPoolEntry(); | 1531 size_t entry = builder()->AllocateConstantPoolEntry(); |
| 1519 builder()->CreateClosure(entry, NOT_TENURED); | 1532 builder()->CreateClosure(entry, NOT_TENURED); |
| 1520 native_function_literals_.push_back(std::make_pair(expr, entry)); | 1533 native_function_literals_.push_back(std::make_pair(expr, entry)); |
| 1521 } | 1534 } |
| 1522 | 1535 |
| 1523 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { | 1536 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { |
| 1524 VisitBlock(expr->block()); | 1537 VisitBlock(expr->block()); |
| 1525 VisitVariableProxy(expr->result()); | 1538 VisitVariableProxy(expr->result()); |
| (...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3218 } | 3231 } |
| 3219 | 3232 |
| 3220 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3233 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3221 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3234 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3222 : Runtime::kStoreKeyedToSuper_Sloppy; | 3235 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3223 } | 3236 } |
| 3224 | 3237 |
| 3225 } // namespace interpreter | 3238 } // namespace interpreter |
| 3226 } // namespace internal | 3239 } // namespace internal |
| 3227 } // namespace v8 | 3240 } // namespace v8 |
| OLD | NEW |