Index: src/debug/liveedit.cc |
diff --git a/src/debug/liveedit.cc b/src/debug/liveedit.cc |
index 50d60a1d9bbeec81590e5b29d8a91fdb097a5a8b..5b04bbc415f3852a646b54eaa61576362af19f6c 100644 |
--- a/src/debug/liveedit.cc |
+++ b/src/debug/liveedit.cc |
@@ -649,18 +649,17 @@ Handle<Code> FunctionInfoWrapper::GetFunctionCode() { |
return Handle<Code>::cast(raw_result); |
} |
- |
-MaybeHandle<TypeFeedbackVector> FunctionInfoWrapper::GetFeedbackVector() { |
+MaybeHandle<TypeFeedbackMetadata> FunctionInfoWrapper::GetFeedbackMetadata() { |
Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_); |
if (element->IsJSValue()) { |
Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
Handle<SharedFunctionInfo> shared = |
Handle<SharedFunctionInfo>::cast(raw_result); |
- return Handle<TypeFeedbackVector>(shared->feedback_vector(), isolate()); |
+ return Handle<TypeFeedbackMetadata>(shared->feedback_metadata(), isolate()); |
} else { |
// Scripts may never have a SharedFunctionInfo created. |
- return MaybeHandle<TypeFeedbackVector>(); |
+ return MaybeHandle<TypeFeedbackMetadata>(); |
} |
} |
@@ -863,11 +862,11 @@ class LiteralFixer { |
public: |
static void PatchLiterals(FunctionInfoWrapper* compile_info_wrapper, |
Handle<SharedFunctionInfo> shared_info, |
- Isolate* isolate) { |
+ bool feedback_metadata_changed, Isolate* isolate) { |
int new_literal_count = compile_info_wrapper->GetLiteralCount(); |
int old_literal_count = shared_info->num_literals(); |
- if (old_literal_count == new_literal_count) { |
+ if (old_literal_count == new_literal_count && !feedback_metadata_changed) { |
// If literal count didn't change, simply go over all functions |
// and clear literal arrays. |
ClearValuesVisitor visitor; |
@@ -878,10 +877,13 @@ class LiteralFixer { |
// collect all functions and fix their literal arrays. |
Handle<FixedArray> function_instances = |
CollectJSFunctions(shared_info, isolate); |
- Handle<TypeFeedbackVector> vector(shared_info->feedback_vector()); |
+ Handle<TypeFeedbackMetadata> feedback_metadata( |
+ shared_info->feedback_metadata()); |
for (int i = 0; i < function_instances->length(); i++) { |
Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i))); |
+ Handle<TypeFeedbackVector> vector = |
+ TypeFeedbackVector::New(isolate, feedback_metadata); |
Handle<LiteralsArray> new_literals = |
LiteralsArray::New(isolate, vector, new_literal_count, TENURED); |
fun->set_literals(*new_literals); |
@@ -929,10 +931,10 @@ class LiteralFixer { |
class ClearValuesVisitor { |
public: |
void visit(JSFunction* fun) { |
- FixedArray* literals = fun->literals(); |
- int len = literals->length(); |
+ LiteralsArray* literals = fun->literals(); |
+ int len = literals->literals_count(); |
for (int j = 0; j < len; j++) { |
- literals->set_undefined(j); |
+ literals->set_literal_undefined(j); |
} |
} |
}; |
@@ -1007,6 +1009,7 @@ void LiveEdit::ReplaceFunctionCode( |
SharedInfoWrapper shared_info_wrapper(shared_info_array); |
Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
+ bool feedback_metadata_changed = false; |
if (shared_info->is_compiled()) { |
Handle<Code> new_code = compile_info_wrapper.GetFunctionCode(); |
@@ -1031,10 +1034,14 @@ void LiveEdit::ReplaceFunctionCode( |
} |
shared_info->DisableOptimization(kLiveEdit); |
// Update the type feedback vector, if needed. |
- MaybeHandle<TypeFeedbackVector> feedback_vector = |
- compile_info_wrapper.GetFeedbackVector(); |
- if (!feedback_vector.is_null()) { |
- shared_info->set_feedback_vector(*feedback_vector.ToHandleChecked()); |
+ MaybeHandle<TypeFeedbackMetadata> feedback_metadata = |
+ compile_info_wrapper.GetFeedbackMetadata(); |
+ if (!feedback_metadata.is_null()) { |
+ Handle<TypeFeedbackMetadata> checked_feedback_metadata = |
+ feedback_metadata.ToHandleChecked(); |
+ feedback_metadata_changed = checked_feedback_metadata->DiffersFrom( |
+ shared_info->feedback_metadata()); |
+ shared_info->set_feedback_metadata(*checked_feedback_metadata); |
} |
} |
@@ -1043,7 +1050,8 @@ void LiveEdit::ReplaceFunctionCode( |
shared_info->set_start_position(start_position); |
shared_info->set_end_position(end_position); |
- LiteralFixer::PatchLiterals(&compile_info_wrapper, shared_info, isolate); |
+ LiteralFixer::PatchLiterals(&compile_info_wrapper, shared_info, |
+ feedback_metadata_changed, isolate); |
DeoptimizeDependentFunctions(*shared_info); |
isolate->compilation_cache()->Remove(shared_info); |