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