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 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 RegisterList args = register_allocator()->NewRegisterList(2); | 1385 RegisterList args = register_allocator()->NewRegisterList(2); |
1386 Register literal = args[0]; | 1386 Register literal = args[0]; |
1387 Register prototype = args[1]; | 1387 Register prototype = args[1]; |
1388 FeedbackVectorSlot slot = expr->PrototypeSlot(); | 1388 FeedbackVectorSlot slot = expr->PrototypeSlot(); |
1389 builder() | 1389 builder() |
1390 ->StoreAccumulatorInRegister(literal) | 1390 ->StoreAccumulatorInRegister(literal) |
1391 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) | 1391 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) |
1392 .StoreAccumulatorInRegister(prototype); | 1392 .StoreAccumulatorInRegister(prototype); |
1393 | 1393 |
1394 VisitClassLiteralProperties(expr, literal, prototype); | 1394 VisitClassLiteralProperties(expr, literal, prototype); |
1395 BuildClassLiteralNameProperty(expr, literal); | |
1395 builder()->CallRuntime(Runtime::kToFastProperties, literal); | 1396 builder()->CallRuntime(Runtime::kToFastProperties, literal); |
1396 // Assign to class variable. | 1397 // Assign to class variable. |
1397 if (expr->class_variable_proxy() != nullptr) { | 1398 if (expr->class_variable_proxy() != nullptr) { |
1398 Variable* var = expr->class_variable_proxy()->var(); | 1399 Variable* var = expr->class_variable_proxy()->var(); |
1399 FeedbackVectorSlot slot = expr->NeedsProxySlot() | 1400 FeedbackVectorSlot slot = expr->NeedsProxySlot() |
1400 ? expr->ProxySlot() | 1401 ? expr->ProxySlot() |
1401 : FeedbackVectorSlot::Invalid(); | 1402 : FeedbackVectorSlot::Invalid(); |
1402 VisitVariableAssignment(var, Token::INIT, slot); | 1403 VisitVariableAssignment(var, Token::INIT, slot); |
1403 } | 1404 } |
1404 } | 1405 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 break; | 1487 break; |
1487 } | 1488 } |
1488 case ClassLiteral::Property::FIELD: { | 1489 case ClassLiteral::Property::FIELD: { |
1489 UNREACHABLE(); | 1490 UNREACHABLE(); |
1490 break; | 1491 break; |
1491 } | 1492 } |
1492 } | 1493 } |
1493 } | 1494 } |
1494 } | 1495 } |
1495 | 1496 |
1497 void BytecodeGenerator::BuildClassLiteralNameProperty(ClassLiteral* expr, | |
1498 Register literal) { | |
1499 if (!expr->has_name_static_property() && | |
1500 !expr->constructor()->raw_name()->IsEmpty()) { | |
1501 RegisterList args = register_allocator()->NewRegisterList(2); | |
1502 builder() | |
1503 ->MoveRegister(literal, args[0]) | |
1504 .LoadBoolean(expr->has_static_computed_names()) | |
1505 .StoreAccumulatorInRegister(args[1]) | |
rmcilroy
2016/11/29 13:05:23
Rather than storing a compile time known boolean a
| |
1506 .CallRuntime(Runtime::kInstallClassNameAccessor, args); | |
1507 } | |
1508 } | |
1509 | |
1496 void BytecodeGenerator::VisitNativeFunctionLiteral( | 1510 void BytecodeGenerator::VisitNativeFunctionLiteral( |
1497 NativeFunctionLiteral* expr) { | 1511 NativeFunctionLiteral* expr) { |
1498 size_t entry = builder()->AllocateConstantPoolEntry(); | 1512 size_t entry = builder()->AllocateConstantPoolEntry(); |
1499 builder()->CreateClosure(entry, NOT_TENURED); | 1513 builder()->CreateClosure(entry, NOT_TENURED); |
1500 native_function_literals_.push_back(std::make_pair(expr, entry)); | 1514 native_function_literals_.push_back(std::make_pair(expr, entry)); |
1501 } | 1515 } |
1502 | 1516 |
1503 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { | 1517 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { |
1504 VisitBlock(expr->block()); | 1518 VisitBlock(expr->block()); |
1505 VisitVariableProxy(expr->result()); | 1519 VisitVariableProxy(expr->result()); |
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3187 } | 3201 } |
3188 | 3202 |
3189 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3203 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3190 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3204 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3191 : Runtime::kStoreKeyedToSuper_Sloppy; | 3205 : Runtime::kStoreKeyedToSuper_Sloppy; |
3192 } | 3206 } |
3193 | 3207 |
3194 } // namespace interpreter | 3208 } // namespace interpreter |
3195 } // namespace internal | 3209 } // namespace internal |
3196 } // namespace v8 | 3210 } // namespace v8 |
OLD | NEW |