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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::FinalizeBytecode(Isolate* isolate) { |
690 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles | |
691 // created as part of bytecode finalization. | |
692 HandleScope scope(isolate); | |
693 AllocateDeferredConstants(); | 690 AllocateDeferredConstants(); |
694 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 691 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
695 return scope.CloseAndEscape(builder()->ToBytecodeArray(isolate)); | 692 return builder()->ToBytecodeArray(isolate); |
696 } | 693 } |
697 | 694 |
698 void BytecodeGenerator::AllocateDeferredConstants() { | 695 void BytecodeGenerator::AllocateDeferredConstants() { |
699 // Build global declaration pair arrays. | 696 // Build global declaration pair arrays. |
700 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 697 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
701 Handle<FixedArray> declarations = | 698 Handle<FixedArray> declarations = |
702 globals_builder->AllocateDeclarationPairs(info()); | 699 globals_builder->AllocateDeclarationPairs(info()); |
703 if (declarations.is_null()) return SetStackOverflow(); | 700 if (declarations.is_null()) return SetStackOverflow(); |
704 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), | 701 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), |
705 declarations); | 702 declarations); |
(...skipping 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 return execution_context()->scope()->language_mode(); | 3399 return execution_context()->scope()->language_mode(); |
3403 } | 3400 } |
3404 | 3401 |
3405 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3402 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3406 return TypeFeedbackVector::GetIndex(slot); | 3403 return TypeFeedbackVector::GetIndex(slot); |
3407 } | 3404 } |
3408 | 3405 |
3409 } // namespace interpreter | 3406 } // namespace interpreter |
3410 } // namespace internal | 3407 } // namespace internal |
3411 } // namespace v8 | 3408 } // namespace v8 |
OLD | NEW |