Commit a4af0ce6 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[ic] Track the IC state change in FeedbackNexus::ConfigureMegamorphic

- This precents us from logging two ICEvents for a megamorphic miss that adds
  a new property
- We don't have to reset the profiler ticks anymore for this miss

The particular case for missing to add a new property happens ~1700 times in
the Speedometer Angular benchmark where we get an already internalized key
as property name.

Change-Id: I2362c3b7a66d9def1bc4295f6f1e64c96b25fe8a
Reviewed-on: https://chromium-review.googlesource.com/777259
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49464}
parent 00772e4d
......@@ -524,12 +524,22 @@ void FeedbackNexus::ConfigurePremonomorphic() {
SKIP_WRITE_BARRIER);
}
void FeedbackNexus::ConfigureMegamorphic(IcCheckType property_type) {
bool FeedbackNexus::ConfigureMegamorphic(IcCheckType property_type) {
DisallowHeapAllocation no_gc;
Isolate* isolate = GetIsolate();
SetFeedback(*FeedbackVector::MegamorphicSentinel(isolate),
SKIP_WRITE_BARRIER);
SetFeedbackExtra(Smi::FromInt(static_cast<int>(property_type)),
SKIP_WRITE_BARRIER);
bool changed = false;
Symbol* sentinel = *FeedbackVector::MegamorphicSentinel(isolate);
if (GetFeedback() != sentinel) {
SetFeedback(sentinel, SKIP_WRITE_BARRIER);
changed = true;
}
Smi* extra = Smi::FromInt(static_cast<int>(property_type));
if (changed || GetFeedbackExtra() != extra) {
SetFeedbackExtra(extra, SKIP_WRITE_BARRIER);
changed = true;
}
return changed;
}
InlineCacheState LoadICNexus::StateFromFeedback() const {
......
......@@ -586,7 +586,7 @@ class FeedbackNexus {
virtual void Clear() { ConfigureUninitialized(); }
virtual void ConfigureUninitialized();
void ConfigurePremonomorphic();
void ConfigureMegamorphic(IcCheckType property_type);
bool ConfigureMegamorphic(IcCheckType property_type);
inline Object* GetFeedback() const;
inline Object* GetFeedbackExtra() const;
......
......@@ -369,12 +369,16 @@ static bool MigrateDeprecated(Handle<Object> object) {
return true;
}
void IC::ConfigureVectorState(IC::State new_state, Handle<Object> key) {
bool IC::ConfigureVectorState(IC::State new_state, Handle<Object> key) {
if (new_state == PREMONOMORPHIC) {
nexus()->ConfigurePremonomorphic();
} else if (new_state == MEGAMORPHIC) {
DCHECK_IMPLIES(!is_keyed(), key->IsName());
nexus()->ConfigureMegamorphic(key->IsName() ? PROPERTY : ELEMENT);
IcCheckType property_type = key->IsName() ? PROPERTY : ELEMENT;
if (!nexus()->ConfigureMegamorphic(property_type)) {
vector_set_ = true;
return false;
}
} else {
UNREACHABLE();
}
......@@ -383,6 +387,7 @@ void IC::ConfigureVectorState(IC::State new_state, Handle<Object> key) {
OnFeedbackChanged(
isolate(), *vector(), slot(), GetHostFunction(),
new_state == PREMONOMORPHIC ? "Premonomorphic" : "Megamorphic");
return true;
}
void IC::ConfigureVectorState(Handle<Name> name, Handle<Map> map,
......@@ -1392,6 +1397,7 @@ void StoreIC::UpdateCaches(LookupIterator* lookup, Handle<Object> value,
if (created_new_transition_) {
// The first time a transition is performed, there's a good chance that
// it won't be taken again, so don't bother creating a handler.
TRACE_GENERIC_IC("new transition");
TRACE_IC("StoreIC", lookup->name());
return;
}
......@@ -1943,9 +1949,10 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
JSReceiver::MAY_BE_STORE_FROM_KEYED),
Object);
if (vector_needs_update()) {
ConfigureVectorState(MEGAMORPHIC, key);
TRACE_GENERIC_IC("unhandled internalized string key");
TRACE_IC("StoreIC", key);
if (ConfigureVectorState(MEGAMORPHIC, key)) {
TRACE_GENERIC_IC("unhandled internalized string key");
TRACE_IC("StoreIC", key);
}
}
return store_handle;
}
......
......@@ -90,7 +90,7 @@ class IC {
}
// Configure for most states.
void ConfigureVectorState(IC::State new_state, Handle<Object> key);
bool ConfigureVectorState(IC::State new_state, Handle<Object> key);
// Configure the vector for MONOMORPHIC.
void ConfigureVectorState(Handle<Name> name, Handle<Map> map,
Handle<Object> handler);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment