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...) 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::MakeBytecode() { | 691 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode() { |
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 | 695 AllocateDeferredConstants(); |
696 GenerateBytecode(); | |
697 FinalizeBytecode(); | |
698 | |
699 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 696 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
700 | |
701 return scope.CloseAndEscape(builder()->ToBytecodeArray()); | 697 return scope.CloseAndEscape(builder()->ToBytecodeArray()); |
702 } | 698 } |
703 | 699 |
704 void BytecodeGenerator::FinalizeBytecode() { | 700 void BytecodeGenerator::AllocateDeferredConstants() { |
705 // Build global declaration pair arrays. | 701 // Build global declaration pair arrays. |
706 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 702 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
707 Handle<FixedArray> declarations = | 703 Handle<FixedArray> declarations = |
708 globals_builder->AllocateDeclarationPairs(info()); | 704 globals_builder->AllocateDeclarationPairs(info()); |
709 if (declarations.is_null()) return SetStackOverflow(); | 705 if (declarations.is_null()) return SetStackOverflow(); |
710 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), | 706 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), |
711 declarations); | 707 declarations); |
712 } | 708 } |
713 | 709 |
714 // Find or build shared function infos. | 710 // Find or build shared function infos. |
(...skipping 2716 matching lines...) Loading... |
3431 return execution_context()->scope()->language_mode(); | 3427 return execution_context()->scope()->language_mode(); |
3432 } | 3428 } |
3433 | 3429 |
3434 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3430 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3435 return TypeFeedbackVector::GetIndex(slot); | 3431 return TypeFeedbackVector::GetIndex(slot); |
3436 } | 3432 } |
3437 | 3433 |
3438 } // namespace interpreter | 3434 } // namespace interpreter |
3439 } // namespace internal | 3435 } // namespace internal |
3440 } // namespace v8 | 3436 } // namespace v8 |
OLD | NEW |