Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1107)

Side by Side Diff: src/debug/liveedit.cc

Issue 1643533003: Revert of Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/liveedit.h ('k') | src/deoptimizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/scopeinfo.h" 7 #include "src/ast/scopeinfo.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 639
640 640
641 Handle<Code> FunctionInfoWrapper::GetFunctionCode() { 641 Handle<Code> FunctionInfoWrapper::GetFunctionCode() {
642 Handle<Object> element = this->GetField(kCodeOffset_); 642 Handle<Object> element = this->GetField(kCodeOffset_);
643 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); 643 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element);
644 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); 644 Handle<Object> raw_result = UnwrapJSValue(value_wrapper);
645 CHECK(raw_result->IsCode()); 645 CHECK(raw_result->IsCode());
646 return Handle<Code>::cast(raw_result); 646 return Handle<Code>::cast(raw_result);
647 } 647 }
648 648
649 MaybeHandle<TypeFeedbackMetadata> FunctionInfoWrapper::GetFeedbackMetadata() { 649
650 MaybeHandle<TypeFeedbackVector> FunctionInfoWrapper::GetFeedbackVector() {
650 Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_); 651 Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_);
651 if (element->IsJSValue()) { 652 if (element->IsJSValue()) {
652 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); 653 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element);
653 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); 654 Handle<Object> raw_result = UnwrapJSValue(value_wrapper);
654 Handle<SharedFunctionInfo> shared = 655 Handle<SharedFunctionInfo> shared =
655 Handle<SharedFunctionInfo>::cast(raw_result); 656 Handle<SharedFunctionInfo>::cast(raw_result);
656 return Handle<TypeFeedbackMetadata>(shared->feedback_metadata(), isolate()); 657 return Handle<TypeFeedbackVector>(shared->feedback_vector(), isolate());
657 } else { 658 } else {
658 // Scripts may never have a SharedFunctionInfo created. 659 // Scripts may never have a SharedFunctionInfo created.
659 return MaybeHandle<TypeFeedbackMetadata>(); 660 return MaybeHandle<TypeFeedbackVector>();
660 } 661 }
661 } 662 }
662 663
663 664
664 Handle<Object> FunctionInfoWrapper::GetCodeScopeInfo() { 665 Handle<Object> FunctionInfoWrapper::GetCodeScopeInfo() {
665 Handle<Object> element = this->GetField(kCodeScopeInfoOffset_); 666 Handle<Object> element = this->GetField(kCodeScopeInfoOffset_);
666 return UnwrapJSValue(Handle<JSValue>::cast(element)); 667 return UnwrapJSValue(Handle<JSValue>::cast(element));
667 } 668 }
668 669
669 670
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 967
967 // Patch function literals. 968 // Patch function literals.
968 // Name 'literals' is a misnomer. Rather it's a cache for complex object 969 // Name 'literals' is a misnomer. Rather it's a cache for complex object
969 // boilerplates and for a native context. We must clean cached values. 970 // boilerplates and for a native context. We must clean cached values.
970 // Additionally we may need to allocate a new array if number of literals 971 // Additionally we may need to allocate a new array if number of literals
971 // changed. 972 // changed.
972 class LiteralFixer { 973 class LiteralFixer {
973 public: 974 public:
974 static void PatchLiterals(FunctionInfoWrapper* compile_info_wrapper, 975 static void PatchLiterals(FunctionInfoWrapper* compile_info_wrapper,
975 Handle<SharedFunctionInfo> shared_info, 976 Handle<SharedFunctionInfo> shared_info,
976 bool feedback_metadata_changed, Isolate* isolate) { 977 Isolate* isolate) {
977 int new_literal_count = compile_info_wrapper->GetLiteralCount(); 978 int new_literal_count = compile_info_wrapper->GetLiteralCount();
978 int old_literal_count = shared_info->num_literals(); 979 int old_literal_count = shared_info->num_literals();
979 980
980 if (old_literal_count == new_literal_count && !feedback_metadata_changed) { 981 if (old_literal_count == new_literal_count) {
981 // If literal count didn't change, simply go over all functions 982 // If literal count didn't change, simply go over all functions
982 // and clear literal arrays. 983 // and clear literal arrays.
983 ClearValuesVisitor visitor; 984 ClearValuesVisitor visitor;
984 IterateJSFunctions(shared_info, &visitor); 985 IterateJSFunctions(shared_info, &visitor);
985 } else { 986 } else {
986 // When literal count changes, we have to create new array instances. 987 // When literal count changes, we have to create new array instances.
987 // Since we cannot create instances when iterating heap, we should first 988 // Since we cannot create instances when iterating heap, we should first
988 // collect all functions and fix their literal arrays. 989 // collect all functions and fix their literal arrays.
989 Handle<FixedArray> function_instances = 990 Handle<FixedArray> function_instances =
990 CollectJSFunctions(shared_info, isolate); 991 CollectJSFunctions(shared_info, isolate);
991 Handle<TypeFeedbackMetadata> feedback_metadata( 992 Handle<TypeFeedbackVector> vector(shared_info->feedback_vector());
992 shared_info->feedback_metadata());
993 993
994 for (int i = 0; i < function_instances->length(); i++) { 994 for (int i = 0; i < function_instances->length(); i++) {
995 Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i))); 995 Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i)));
996 Handle<TypeFeedbackVector> vector =
997 TypeFeedbackVector::New(isolate, feedback_metadata);
998 Handle<LiteralsArray> new_literals = 996 Handle<LiteralsArray> new_literals =
999 LiteralsArray::New(isolate, vector, new_literal_count, TENURED); 997 LiteralsArray::New(isolate, vector, new_literal_count, TENURED);
1000 fun->set_literals(*new_literals); 998 fun->set_literals(*new_literals);
1001 } 999 }
1002 1000
1003 shared_info->set_num_literals(new_literal_count); 1001 shared_info->set_num_literals(new_literal_count);
1004 } 1002 }
1005 } 1003 }
1006 1004
1007 private: 1005 private:
(...skipping 27 matching lines...) Expand all
1035 if (size > 0) { 1033 if (size > 0) {
1036 CollectVisitor collect_visitor(result); 1034 CollectVisitor collect_visitor(result);
1037 IterateJSFunctions(shared_info, &collect_visitor); 1035 IterateJSFunctions(shared_info, &collect_visitor);
1038 } 1036 }
1039 return result; 1037 return result;
1040 } 1038 }
1041 1039
1042 class ClearValuesVisitor { 1040 class ClearValuesVisitor {
1043 public: 1041 public:
1044 void visit(JSFunction* fun) { 1042 void visit(JSFunction* fun) {
1045 LiteralsArray* literals = fun->literals(); 1043 FixedArray* literals = fun->literals();
1046 int len = literals->literals_count(); 1044 int len = literals->length();
1047 for (int j = 0; j < len; j++) { 1045 for (int j = 0; j < len; j++) {
1048 literals->set_literal_undefined(j); 1046 literals->set_undefined(j);
1049 } 1047 }
1050 } 1048 }
1051 }; 1049 };
1052 1050
1053 class CountVisitor { 1051 class CountVisitor {
1054 public: 1052 public:
1055 void visit(JSFunction* fun) { 1053 void visit(JSFunction* fun) {
1056 count++; 1054 count++;
1057 } 1055 }
1058 int count; 1056 int count;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1111
1114 void LiveEdit::ReplaceFunctionCode( 1112 void LiveEdit::ReplaceFunctionCode(
1115 Handle<JSArray> new_compile_info_array, 1113 Handle<JSArray> new_compile_info_array,
1116 Handle<JSArray> shared_info_array) { 1114 Handle<JSArray> shared_info_array) {
1117 Isolate* isolate = new_compile_info_array->GetIsolate(); 1115 Isolate* isolate = new_compile_info_array->GetIsolate();
1118 1116
1119 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); 1117 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array);
1120 SharedInfoWrapper shared_info_wrapper(shared_info_array); 1118 SharedInfoWrapper shared_info_wrapper(shared_info_array);
1121 1119
1122 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); 1120 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
1123 bool feedback_metadata_changed = false;
1124 1121
1125 if (shared_info->code()->kind() == Code::FUNCTION) { 1122 if (shared_info->code()->kind() == Code::FUNCTION) {
1126 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); 1123 Handle<Code> code = compile_info_wrapper.GetFunctionCode();
1127 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); 1124 ReplaceCodeObject(Handle<Code>(shared_info->code()), code);
1128 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); 1125 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo();
1129 if (code_scope_info->IsFixedArray()) { 1126 if (code_scope_info->IsFixedArray()) {
1130 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); 1127 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info));
1131 } 1128 }
1132 shared_info->DisableOptimization(kLiveEdit); 1129 shared_info->DisableOptimization(kLiveEdit);
1133 // Update the type feedback vector, if needed. 1130 // Update the type feedback vector, if needed.
1134 MaybeHandle<TypeFeedbackMetadata> feedback_metadata = 1131 MaybeHandle<TypeFeedbackVector> feedback_vector =
1135 compile_info_wrapper.GetFeedbackMetadata(); 1132 compile_info_wrapper.GetFeedbackVector();
1136 if (!feedback_metadata.is_null()) { 1133 if (!feedback_vector.is_null()) {
1137 Handle<TypeFeedbackMetadata> checked_feedback_metadata = 1134 shared_info->set_feedback_vector(*feedback_vector.ToHandleChecked());
1138 feedback_metadata.ToHandleChecked();
1139 feedback_metadata_changed = checked_feedback_metadata->DiffersFrom(
1140 shared_info->feedback_metadata());
1141 shared_info->set_feedback_metadata(*checked_feedback_metadata);
1142 } 1135 }
1143 } 1136 }
1144 1137
1145 int start_position = compile_info_wrapper.GetStartPosition(); 1138 int start_position = compile_info_wrapper.GetStartPosition();
1146 int end_position = compile_info_wrapper.GetEndPosition(); 1139 int end_position = compile_info_wrapper.GetEndPosition();
1147 shared_info->set_start_position(start_position); 1140 shared_info->set_start_position(start_position);
1148 shared_info->set_end_position(end_position); 1141 shared_info->set_end_position(end_position);
1149 1142
1150 LiteralFixer::PatchLiterals(&compile_info_wrapper, shared_info, 1143 LiteralFixer::PatchLiterals(&compile_info_wrapper, shared_info, isolate);
1151 feedback_metadata_changed, isolate);
1152 1144
1153 DeoptimizeDependentFunctions(*shared_info); 1145 DeoptimizeDependentFunctions(*shared_info);
1154 isolate->compilation_cache()->Remove(shared_info); 1146 isolate->compilation_cache()->Remove(shared_info);
1155 } 1147 }
1156 1148
1157 1149
1158 void LiveEdit::FunctionSourceUpdated(Handle<JSArray> shared_info_array) { 1150 void LiveEdit::FunctionSourceUpdated(Handle<JSArray> shared_info_array) {
1159 SharedInfoWrapper shared_info_wrapper(shared_info_array); 1151 SharedInfoWrapper shared_info_wrapper(shared_info_array);
1160 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); 1152 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
1161 1153
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 isolate_->active_function_info_listener()->FunctionCode(code); 2037 isolate_->active_function_info_listener()->FunctionCode(code);
2046 } 2038 }
2047 2039
2048 2040
2049 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2041 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2050 return isolate->active_function_info_listener() != NULL; 2042 return isolate->active_function_info_listener() != NULL;
2051 } 2043 }
2052 2044
2053 } // namespace internal 2045 } // namespace internal
2054 } // namespace v8 2046 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/liveedit.h ('k') | src/deoptimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698