OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/debug/liveedit.h" | 5 #include "src/debug/liveedit.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/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 static void PatchFeedbackVector(FunctionInfoWrapper* compile_info_wrapper, | 751 static void PatchFeedbackVector(FunctionInfoWrapper* compile_info_wrapper, |
752 Handle<SharedFunctionInfo> shared_info, | 752 Handle<SharedFunctionInfo> shared_info, |
753 Isolate* isolate) { | 753 Isolate* isolate) { |
754 int new_literal_count = compile_info_wrapper->GetLiteralCount(); | 754 int new_literal_count = compile_info_wrapper->GetLiteralCount(); |
755 | 755 |
756 // When feedback metadata changes, we have to create new array instances. | 756 // When feedback metadata changes, we have to create new array instances. |
757 // Since we cannot create instances when iterating heap, we should first | 757 // Since we cannot create instances when iterating heap, we should first |
758 // collect all functions and fix their literal arrays. | 758 // collect all functions and fix their literal arrays. |
759 Handle<FixedArray> function_instances = | 759 Handle<FixedArray> function_instances = |
760 CollectJSFunctions(shared_info, isolate); | 760 CollectJSFunctions(shared_info, isolate); |
761 Handle<FeedbackMetadata> feedback_metadata( | |
762 shared_info->feedback_metadata()); | |
763 | 761 |
764 for (int i = 0; i < function_instances->length(); i++) { | 762 for (int i = 0; i < function_instances->length(); i++) { |
765 Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i))); | 763 Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i))); |
766 Handle<FeedbackVector> vector = | 764 fun->set_feedback_vector_cell(isolate->heap()->undefined_cell()); |
767 FeedbackVector::New(isolate, feedback_metadata); | 765 // Only create feedback vectors if we already have the metadata. |
768 fun->feedback_vector_cell()->set_value(*vector); | 766 if (shared_info->is_compiled()) JSFunction::EnsureLiterals(fun); |
769 } | 767 } |
770 | 768 |
771 shared_info->set_num_literals(new_literal_count); | 769 shared_info->set_num_literals(new_literal_count); |
772 } | 770 } |
773 | 771 |
774 private: | 772 private: |
775 // Iterates all function instances in the HEAP that refers to the | 773 // Iterates all function instances in the HEAP that refers to the |
776 // provided shared_info. | 774 // provided shared_info. |
777 template<typename Visitor> | 775 template<typename Visitor> |
778 static void IterateJSFunctions(Handle<SharedFunctionInfo> shared_info, | 776 static void IterateJSFunctions(Handle<SharedFunctionInfo> shared_info, |
779 Visitor* visitor) { | 777 Visitor* visitor) { |
780 HeapIterator iterator(shared_info->GetHeap()); | 778 HeapIterator iterator(shared_info->GetHeap()); |
781 for (HeapObject* obj = iterator.next(); obj != NULL; | 779 for (HeapObject* obj = iterator.next(); obj != NULL; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 isolate->debug()->RemoveDebugInfoAndClearFromShared( | 916 isolate->debug()->RemoveDebugInfoAndClearFromShared( |
919 handle(shared_info->GetDebugInfo())); | 917 handle(shared_info->GetDebugInfo())); |
920 } | 918 } |
921 shared_info->set_scope_info(new_shared_info->scope_info()); | 919 shared_info->set_scope_info(new_shared_info->scope_info()); |
922 shared_info->set_outer_scope_info(new_shared_info->outer_scope_info()); | 920 shared_info->set_outer_scope_info(new_shared_info->outer_scope_info()); |
923 shared_info->DisableOptimization(kLiveEdit); | 921 shared_info->DisableOptimization(kLiveEdit); |
924 // Update the type feedback vector, if needed. | 922 // Update the type feedback vector, if needed. |
925 Handle<FeedbackMetadata> new_feedback_metadata( | 923 Handle<FeedbackMetadata> new_feedback_metadata( |
926 new_shared_info->feedback_metadata()); | 924 new_shared_info->feedback_metadata()); |
927 shared_info->set_feedback_metadata(*new_feedback_metadata); | 925 shared_info->set_feedback_metadata(*new_feedback_metadata); |
| 926 } else { |
| 927 shared_info->set_feedback_metadata( |
| 928 FeedbackMetadata::cast(isolate->heap()->empty_fixed_array())); |
928 } | 929 } |
929 | 930 |
930 int start_position = compile_info_wrapper.GetStartPosition(); | 931 int start_position = compile_info_wrapper.GetStartPosition(); |
931 int end_position = compile_info_wrapper.GetEndPosition(); | 932 int end_position = compile_info_wrapper.GetEndPosition(); |
932 shared_info->set_start_position(start_position); | 933 shared_info->set_start_position(start_position); |
933 shared_info->set_end_position(end_position); | 934 shared_info->set_end_position(end_position); |
934 | 935 |
935 FeedbackVectorFixer::PatchFeedbackVector(&compile_info_wrapper, shared_info, | 936 FeedbackVectorFixer::PatchFeedbackVector(&compile_info_wrapper, shared_info, |
936 isolate); | 937 isolate); |
937 | 938 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 scope_info_length++; | 1646 scope_info_length++; |
1646 | 1647 |
1647 current_scope = current_scope->outer_scope(); | 1648 current_scope = current_scope->outer_scope(); |
1648 } | 1649 } |
1649 | 1650 |
1650 return scope_info_list; | 1651 return scope_info_list; |
1651 } | 1652 } |
1652 | 1653 |
1653 } // namespace internal | 1654 } // namespace internal |
1654 } // namespace v8 | 1655 } // namespace v8 |
OLD | NEW |