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::MakeBytecode(Isolate* isolate) { | 689 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(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 | 693 AllocateDeferredConstants(); |
694 GenerateBytecode(); | |
695 FinalizeBytecode(isolate); | |
696 | |
697 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 694 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
698 | |
699 return scope.CloseAndEscape(builder()->ToBytecodeArray(isolate)); | 695 return scope.CloseAndEscape(builder()->ToBytecodeArray(isolate)); |
700 } | 696 } |
701 | 697 |
702 void BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { | 698 void BytecodeGenerator::AllocateDeferredConstants() { |
703 // Build global declaration pair arrays. | 699 // Build global declaration pair arrays. |
704 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 700 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
705 Handle<FixedArray> declarations = | 701 Handle<FixedArray> declarations = |
706 globals_builder->AllocateDeclarationPairs(info()); | 702 globals_builder->AllocateDeclarationPairs(info()); |
707 if (declarations.is_null()) return SetStackOverflow(); | 703 if (declarations.is_null()) return SetStackOverflow(); |
708 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), | 704 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), |
709 declarations); | 705 declarations); |
710 } | 706 } |
711 | 707 |
712 // Find or build shared function infos. | 708 // Find or build shared function infos. |
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 return execution_context()->scope()->language_mode(); | 3414 return execution_context()->scope()->language_mode(); |
3419 } | 3415 } |
3420 | 3416 |
3421 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3417 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3422 return TypeFeedbackVector::GetIndex(slot); | 3418 return TypeFeedbackVector::GetIndex(slot); |
3423 } | 3419 } |
3424 | 3420 |
3425 } // namespace interpreter | 3421 } // namespace interpreter |
3426 } // namespace internal | 3422 } // namespace internal |
3427 } // namespace v8 | 3423 } // namespace v8 |
OLD | NEW |