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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 execution_result_(nullptr), | 679 execution_result_(nullptr), |
680 register_allocator_(nullptr), | 680 register_allocator_(nullptr), |
681 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 681 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
682 generator_state_(), | 682 generator_state_(), |
683 loop_depth_(0), | 683 loop_depth_(0), |
684 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), | 684 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), |
685 prototype_string_(info->isolate()->factory()->prototype_string()) { | 685 prototype_string_(info->isolate()->factory()->prototype_string()) { |
686 InitializeAstVisitor(info->isolate()->stack_guard()->real_climit()); | 686 InitializeAstVisitor(info->isolate()->stack_guard()->real_climit()); |
687 } | 687 } |
688 | 688 |
689 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { | 689 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(Isolate* isolate) { |
690 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles | 690 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles |
691 // created as part of bytecode finalization. | 691 // created as part of bytecode finalization. |
692 HandleScope scope(isolate); | 692 HandleScope scope(isolate); |
693 AllocateDeferredConstants(); | 693 |
| 694 GenerateBytecode(); |
| 695 FinalizeBytecode(isolate); |
| 696 |
694 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 697 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
| 698 |
695 return scope.CloseAndEscape(builder()->ToBytecodeArray(isolate)); | 699 return scope.CloseAndEscape(builder()->ToBytecodeArray(isolate)); |
696 } | 700 } |
697 | 701 |
698 void BytecodeGenerator::AllocateDeferredConstants() { | 702 void BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { |
699 // Build global declaration pair arrays. | 703 // Build global declaration pair arrays. |
700 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 704 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
701 Handle<FixedArray> declarations = | 705 Handle<FixedArray> declarations = |
702 globals_builder->AllocateDeclarationPairs(info()); | 706 globals_builder->AllocateDeclarationPairs(info()); |
703 if (declarations.is_null()) return SetStackOverflow(); | 707 if (declarations.is_null()) return SetStackOverflow(); |
704 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), | 708 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), |
705 declarations); | 709 declarations); |
706 } | 710 } |
707 | 711 |
708 // Find or build shared function infos. | 712 // Find or build shared function infos. |
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3414 return execution_context()->scope()->language_mode(); | 3418 return execution_context()->scope()->language_mode(); |
3415 } | 3419 } |
3416 | 3420 |
3417 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3421 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3418 return TypeFeedbackVector::GetIndex(slot); | 3422 return TypeFeedbackVector::GetIndex(slot); |
3419 } | 3423 } |
3420 | 3424 |
3421 } // namespace interpreter | 3425 } // namespace interpreter |
3422 } // namespace internal | 3426 } // namespace internal |
3423 } // namespace v8 | 3427 } // namespace v8 |
OLD | NEW |