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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 global_declarations_(0, info->zone()), | 564 global_declarations_(0, info->zone()), |
565 function_literals_(0, info->zone()), | 565 function_literals_(0, info->zone()), |
566 native_function_literals_(0, info->zone()), | 566 native_function_literals_(0, info->zone()), |
567 execution_control_(nullptr), | 567 execution_control_(nullptr), |
568 execution_context_(nullptr), | 568 execution_context_(nullptr), |
569 execution_result_(nullptr), | 569 execution_result_(nullptr), |
570 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 570 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
571 generator_state_(), | 571 generator_state_(), |
572 loop_depth_(0), | 572 loop_depth_(0), |
573 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), | 573 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), |
574 prototype_string_(info->isolate()->factory()->prototype_string()) { | 574 prototype_string_(info->isolate()->factory()->prototype_string()) {} |
rmcilroy
2016/11/14 13:22:18
nit - did "git cl" do this? If not, please revert.
| |
575 } | |
576 | 575 |
577 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { | 576 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { |
578 AllocateDeferredConstants(); | 577 AllocateDeferredConstants(); |
579 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 578 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
580 return builder()->ToBytecodeArray(isolate); | 579 return builder()->ToBytecodeArray(isolate); |
581 } | 580 } |
582 | 581 |
583 void BytecodeGenerator::AllocateDeferredConstants() { | 582 void BytecodeGenerator::AllocateDeferredConstants() { |
584 // Build global declaration pair arrays. | 583 // Build global declaration pair arrays. |
585 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 584 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 RegisterList args = register_allocator()->NewRegisterList(2); | 1384 RegisterList args = register_allocator()->NewRegisterList(2); |
1386 Register literal = args[0]; | 1385 Register literal = args[0]; |
1387 Register prototype = args[1]; | 1386 Register prototype = args[1]; |
1388 FeedbackVectorSlot slot = expr->PrototypeSlot(); | 1387 FeedbackVectorSlot slot = expr->PrototypeSlot(); |
1389 builder() | 1388 builder() |
1390 ->StoreAccumulatorInRegister(literal) | 1389 ->StoreAccumulatorInRegister(literal) |
1391 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) | 1390 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) |
1392 .StoreAccumulatorInRegister(prototype); | 1391 .StoreAccumulatorInRegister(prototype); |
1393 | 1392 |
1394 VisitClassLiteralProperties(expr, literal, prototype); | 1393 VisitClassLiteralProperties(expr, literal, prototype); |
1394 BuildClassLiteralNameProperty(expr, literal); | |
1395 builder()->CallRuntime(Runtime::kToFastProperties, literal); | 1395 builder()->CallRuntime(Runtime::kToFastProperties, literal); |
1396 // Assign to class variable. | 1396 // Assign to class variable. |
1397 if (expr->class_variable_proxy() != nullptr) { | 1397 if (expr->class_variable_proxy() != nullptr) { |
1398 Variable* var = expr->class_variable_proxy()->var(); | 1398 Variable* var = expr->class_variable_proxy()->var(); |
1399 FeedbackVectorSlot slot = expr->NeedsProxySlot() | 1399 FeedbackVectorSlot slot = expr->NeedsProxySlot() |
1400 ? expr->ProxySlot() | 1400 ? expr->ProxySlot() |
1401 : FeedbackVectorSlot::Invalid(); | 1401 : FeedbackVectorSlot::Invalid(); |
1402 VisitVariableAssignment(var, Token::INIT, slot); | 1402 VisitVariableAssignment(var, Token::INIT, slot); |
1403 } | 1403 } |
1404 } | 1404 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 break; | 1486 break; |
1487 } | 1487 } |
1488 case ClassLiteral::Property::FIELD: { | 1488 case ClassLiteral::Property::FIELD: { |
1489 UNREACHABLE(); | 1489 UNREACHABLE(); |
1490 break; | 1490 break; |
1491 } | 1491 } |
1492 } | 1492 } |
1493 } | 1493 } |
1494 } | 1494 } |
1495 | 1495 |
1496 void BytecodeGenerator::BuildClassLiteralNameProperty(ClassLiteral* expr, | |
1497 Register literal) { | |
1498 DCHECK(expr->constructor()->raw_name() != nullptr); | |
rmcilroy
2016/11/14 13:22:18
no point having this DCHECK since the next line wi
| |
1499 | |
1500 if (!expr->constructor()->raw_name()->IsEmpty()) { | |
1501 RegisterAllocationScope register_scope(this); | |
1502 RegisterList args = register_allocator()->NewRegisterList(2); | |
1503 builder() | |
1504 ->MoveRegister(literal, args[0]) | |
1505 .LoadLiteral(expr->constructor()->name()) | |
1506 .StoreAccumulatorInRegister(args[1]) | |
1507 .CallRuntime(Runtime::kDefineClassNameProperty, args); | |
1508 } | |
1509 } | |
1510 | |
1496 void BytecodeGenerator::VisitNativeFunctionLiteral( | 1511 void BytecodeGenerator::VisitNativeFunctionLiteral( |
1497 NativeFunctionLiteral* expr) { | 1512 NativeFunctionLiteral* expr) { |
1498 size_t entry = builder()->AllocateConstantPoolEntry(); | 1513 size_t entry = builder()->AllocateConstantPoolEntry(); |
1499 builder()->CreateClosure(entry, NOT_TENURED); | 1514 builder()->CreateClosure(entry, NOT_TENURED); |
1500 native_function_literals_.push_back(std::make_pair(expr, entry)); | 1515 native_function_literals_.push_back(std::make_pair(expr, entry)); |
1501 } | 1516 } |
1502 | 1517 |
1503 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { | 1518 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { |
1504 VisitBlock(expr->block()); | 1519 VisitBlock(expr->block()); |
1505 VisitVariableProxy(expr->result()); | 1520 VisitVariableProxy(expr->result()); |
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3187 } | 3202 } |
3188 | 3203 |
3189 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3204 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3190 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3205 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3191 : Runtime::kStoreKeyedToSuper_Sloppy; | 3206 : Runtime::kStoreKeyedToSuper_Sloppy; |
3192 } | 3207 } |
3193 | 3208 |
3194 } // namespace interpreter | 3209 } // namespace interpreter |
3195 } // namespace internal | 3210 } // namespace internal |
3196 } // namespace v8 | 3211 } // namespace v8 |
OLD | NEW |