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

Unified Diff: src/compiler.cc

Issue 1670813005: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.h ('k') | src/compiler/access-builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index ae9d3f262556a431ebda83a927e5ace4b8480eb6..354542d56e3f44ff14420659726a56a493499aee 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -130,8 +130,8 @@
if (shared_info()->is_compiled()) {
// We should initialize the CompilationInfo feedback vector from the
// passed in shared info, rather than creating a new one.
- feedback_metadata_ = Handle<TypeFeedbackMetadata>(
- shared_info()->feedback_metadata(), parse_info->isolate());
+ feedback_vector_ = Handle<TypeFeedbackVector>(
+ shared_info()->feedback_vector(), parse_info->isolate());
}
if (shared_info()->never_compiled()) MarkAsFirstCompile();
}
@@ -205,16 +205,18 @@
(!has_shared_info() || !shared_info()->optimization_disabled());
}
-void CompilationInfo::EnsureFeedbackMetadata() {
- if (feedback_metadata_.is_null()) {
- feedback_metadata_ =
+
+void CompilationInfo::EnsureFeedbackVector() {
+ if (feedback_vector_.is_null()) {
+ Handle<TypeFeedbackMetadata> feedback_metadata =
TypeFeedbackMetadata::New(isolate(), literal()->feedback_vector_spec());
+ feedback_vector_ = TypeFeedbackVector::New(isolate(), feedback_metadata);
}
// It's very important that recompiles do not alter the structure of the
// type feedback vector.
- CHECK(
- !feedback_metadata_->SpecDiffersFrom(literal()->feedback_vector_spec()));
+ CHECK(!feedback_vector_->metadata()->SpecDiffersFrom(
+ literal()->feedback_vector_spec()));
}
@@ -380,11 +382,6 @@
DCHECK(info()->shared_info()->has_deoptimization_support());
DCHECK(!info()->is_first_compile());
-
- // If we have a closure make sure it has the literals array at this point.
- if (!info()->closure().is_null()) {
- JSFunction::EnsureLiterals(info()->closure());
- }
bool optimization_disabled = info()->shared_info()->optimization_disabled();
bool dont_crankshaft = info()->shared_info()->dont_crankshaft();
@@ -815,7 +812,6 @@
Handle<SharedFunctionInfo> shared = info->shared_info();
FunctionLiteral* lit = info->literal();
DCHECK_EQ(shared->language_mode(), lit->language_mode());
- shared->set_num_literals(lit->materialized_literal_count());
SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
MaybeDisableOptimization(shared, lit->dont_optimize_reason());
@@ -833,7 +829,7 @@
// Update the code and feedback vector for the shared function info.
shared->ReplaceCode(*info->code());
- shared->set_feedback_metadata(*info->feedback_metadata());
+ shared->set_feedback_vector(*info->feedback_vector());
if (info->has_bytecode_array()) {
DCHECK(shared->function_data()->IsUndefined());
shared->set_function_data(*info->bytecode_array());
@@ -1047,7 +1043,6 @@
if (FLAG_always_opt) {
Handle<Code> opt_code;
- JSFunction::EnsureLiterals(function);
if (Compiler::GetOptimizedCode(function, Compiler::NOT_CONCURRENT)
.ToHandle(&opt_code)) {
result = opt_code;
@@ -1062,16 +1057,14 @@
if (function->is_compiled()) return true;
MaybeHandle<Code> maybe_code = Compiler::GetLazyCode(function);
Handle<Code> code;
- Isolate* isolate = function->GetIsolate();
if (!maybe_code.ToHandle(&code)) {
if (flag == CLEAR_EXCEPTION) {
- isolate->clear_pending_exception();
+ function->GetIsolate()->clear_pending_exception();
}
return false;
}
function->ReplaceCode(*code);
DCHECK(function->is_compiled());
- JSFunction::EnsureLiterals(function);
return true;
}
@@ -1102,7 +1095,7 @@
if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
shared->EnableDeoptimizationSupport(*unoptimized.code());
- shared->set_feedback_metadata(*unoptimized.feedback_metadata());
+ shared->set_feedback_vector(*unoptimized.feedback_vector());
info->MarkAsCompiled();
@@ -1178,15 +1171,12 @@
bool Compiler::CompileDebugCode(Handle<JSFunction> function) {
Handle<SharedFunctionInfo> shared(function->shared());
- bool result;
if (IsEvalToplevel(shared)) {
- result = CompileEvalForDebugging(function, shared);
+ return CompileEvalForDebugging(function, shared);
} else {
CompilationInfoWithZone info(function);
- result = CompileForDebugging(&info);
- }
- JSFunction::EnsureLiterals(function);
- return result;
+ return CompileForDebugging(&info);
+ }
}
@@ -1298,7 +1288,7 @@
lit->name(), lit->materialized_literal_count(), lit->kind(),
info->code(),
ScopeInfo::Create(info->isolate(), info->zone(), info->scope()),
- info->feedback_metadata());
+ info->feedback_vector());
if (info->has_bytecode_array()) {
DCHECK(result->function_data()->IsUndefined());
result->set_function_data(*info->bytecode_array());
@@ -1625,10 +1615,14 @@
if (lazy) {
Handle<Code> code = isolate->builtins()->CompileLazy();
info.SetCode(code);
- // There's no need in theory for a lazy-compiled function to have type
- // feedback metadata, but some parts of the system expect all
- // SharedFunctionInfo instances to have one.
- info.EnsureFeedbackMetadata();
+ // There's no need in theory for a lazy-compiled function to have a type
+ // feedback vector, but some parts of the system expect all
+ // SharedFunctionInfo instances to have one. The size of the vector depends
+ // on how many feedback-needing nodes are in the tree, and when lazily
+ // parsing we might not know that, if this function was never parsed before.
+ // In that case the vector will be replaced the next time MakeCode is
+ // called.
+ info.EnsureFeedbackVector();
scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate));
} else if (Renumber(info.parse_info()) && GenerateBaselineCode(&info)) {
// Code generation will ensure that the feedback vector is present and
@@ -1648,7 +1642,7 @@
Handle<SharedFunctionInfo> result =
isolate->factory()->NewSharedFunctionInfo(
literal->name(), literal->materialized_literal_count(),
- literal->kind(), info.code(), scope_info, info.feedback_metadata());
+ literal->kind(), info.code(), scope_info, info.feedback_vector());
if (info.has_bytecode_array()) {
DCHECK(result->function_data()->IsUndefined());
result->set_function_data(*info.bytecode_array());
@@ -1677,7 +1671,7 @@
DCHECK(!existing->HasDebugCode());
existing->ReplaceCode(*info.code());
existing->set_scope_info(*scope_info);
- existing->set_feedback_metadata(*info.feedback_metadata());
+ existing->set_feedback_vector(*info.feedback_vector());
}
return existing;
}
@@ -1703,7 +1697,7 @@
Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo(
name, literals, FunctionKind::kNormalFunction, code,
Handle<ScopeInfo>(fun->shared()->scope_info()),
- Handle<TypeFeedbackMetadata>(fun->shared()->feedback_metadata()));
+ Handle<TypeFeedbackVector>(fun->shared()->feedback_vector()));
shared->set_construct_stub(*construct_stub);
// Copy the function data to the shared function info.
@@ -1750,10 +1744,6 @@
}
shared->ReplaceCode(*current_code);
}
-
- // At this point we know we've compiled the function, so make sure the closure
- // points to valid literals and type-feedback-vector.
- JSFunction::EnsureLiterals(function);
current_code->set_profiler_ticks(0);
« no previous file with comments | « src/compiler.h ('k') | src/compiler/access-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698