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

Unified Diff: src/compiler.cc

Issue 1632993003: 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, 11 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 9e45531a4b22124d09e2485a80a08d9296e96b8d..7fbbfb17ff5daf7b809e94144a3b35a3f45ba633 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();
@@ -790,7 +787,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());
@@ -808,7 +804,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());
@@ -1022,7 +1018,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;
@@ -1037,16 +1032,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;
}
@@ -1077,7 +1070,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();
@@ -1153,15 +1146,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);
+ }
}
@@ -1273,7 +1263,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());
@@ -1600,10 +1590,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
@@ -1623,7 +1617,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());
@@ -1652,7 +1646,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;
}
@@ -1678,7 +1672,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.
@@ -1725,10 +1719,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