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/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 execution_control_(nullptr), | 681 execution_control_(nullptr), |
682 execution_context_(nullptr), | 682 execution_context_(nullptr), |
683 execution_result_(nullptr), | 683 execution_result_(nullptr), |
684 register_allocator_(nullptr), | 684 register_allocator_(nullptr), |
685 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 685 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
686 generator_state_(), | 686 generator_state_(), |
687 loop_depth_(0) { | 687 loop_depth_(0) { |
688 InitializeAstVisitor(isolate()->stack_guard()->real_climit()); | 688 InitializeAstVisitor(isolate()->stack_guard()->real_climit()); |
689 } | 689 } |
690 | 690 |
691 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode() { | 691 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() { |
692 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles | 692 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles |
693 // created as part of bytecode finalization. | 693 // created as part of bytecode finalization. |
694 HandleScope scope(isolate()); | 694 HandleScope scope(isolate()); |
695 AllocateDeferredConstants(); | 695 |
| 696 GenerateBytecode(); |
| 697 FinalizeBytecode(); |
| 698 |
696 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 699 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
| 700 |
697 return scope.CloseAndEscape(builder()->ToBytecodeArray()); | 701 return scope.CloseAndEscape(builder()->ToBytecodeArray()); |
698 } | 702 } |
699 | 703 |
700 void BytecodeGenerator::AllocateDeferredConstants() { | 704 void BytecodeGenerator::FinalizeBytecode() { |
701 // Build global declaration pair arrays. | 705 // Build global declaration pair arrays. |
702 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 706 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
703 Handle<FixedArray> declarations = | 707 Handle<FixedArray> declarations = |
704 globals_builder->AllocateDeclarationPairs(info()); | 708 globals_builder->AllocateDeclarationPairs(info()); |
705 if (declarations.is_null()) return SetStackOverflow(); | 709 if (declarations.is_null()) return SetStackOverflow(); |
706 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), | 710 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), |
707 declarations); | 711 declarations); |
708 } | 712 } |
709 | 713 |
710 // Find or build shared function infos. | 714 // Find or build shared function infos. |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3427 return execution_context()->scope()->language_mode(); | 3431 return execution_context()->scope()->language_mode(); |
3428 } | 3432 } |
3429 | 3433 |
3430 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3434 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3431 return TypeFeedbackVector::GetIndex(slot); | 3435 return TypeFeedbackVector::GetIndex(slot); |
3432 } | 3436 } |
3433 | 3437 |
3434 } // namespace interpreter | 3438 } // namespace interpreter |
3435 } // namespace internal | 3439 } // namespace internal |
3436 } // namespace v8 | 3440 } // namespace v8 |
OLD | NEW |