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

Unified Diff: src/debug/liveedit.cc

Issue 1668103002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug/liveedit.h ('k') | src/deoptimizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/liveedit.cc
diff --git a/src/debug/liveedit.cc b/src/debug/liveedit.cc
index 91c990d19b7d078600d7b59bc7429e3c353c1b7c..b266b049a544e5ffed25c7846f7a999b617bc30e 100644
--- a/src/debug/liveedit.cc
+++ b/src/debug/liveedit.cc
@@ -646,18 +646,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>();
}
}
@@ -974,11 +973,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;
@@ -989,10 +988,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);
@@ -1040,10 +1042,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);
}
}
};
@@ -1118,6 +1120,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->code()->kind() == Code::FUNCTION) {
Handle<Code> code = compile_info_wrapper.GetFunctionCode();
@@ -1128,10 +1131,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);
}
}
@@ -1140,7 +1147,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);
« 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