Commit 1aa78974 authored by ssid@chromium.org's avatar ssid@chromium.org

Fix perf regression in blink_perf.shadow_dom.

The static strings were destructed at the exit instead of leaked,
causing performance regression. Since the GCInfo objects are leaked,
holding a reference in the struct will leak the strings.

BUG=520948

Review URL: https://codereview.chromium.org/1300263003

git-svn-id: svn://svn.chromium.org/blink/trunk@200944 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent aca93387
...@@ -111,16 +111,15 @@ extern PLATFORM_EXPORT GCInfo const** s_gcInfoTable; ...@@ -111,16 +111,15 @@ extern PLATFORM_EXPORT GCInfo const** s_gcInfoTable;
// reachable. There is a GCInfo struct for each class that directly // reachable. There is a GCInfo struct for each class that directly
// inherits from GarbageCollected or GarbageCollectedFinalized. // inherits from GarbageCollected or GarbageCollectedFinalized.
struct GCInfo { struct GCInfo {
using GetClassNameCallback = const String& (*)();
bool hasFinalizer() const { return m_nonTrivialFinalizer; } bool hasFinalizer() const { return m_nonTrivialFinalizer; }
bool hasVTable() const { return m_hasVTable; } bool hasVTable() const { return m_hasVTable; }
const String& className() const { return m_classNameGetter(); } const String& className() const { return m_className; }
TraceCallback m_trace; TraceCallback m_trace;
FinalizationCallback m_finalize; FinalizationCallback m_finalize;
bool m_nonTrivialFinalizer; bool m_nonTrivialFinalizer;
bool m_hasVTable; bool m_hasVTable;
GetClassNameCallback m_classNameGetter; // |m_className| is held as a reference to prevent dtor being called at exit.
const String& m_className;
}; };
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
...@@ -172,7 +171,7 @@ struct GCInfoAtBase { ...@@ -172,7 +171,7 @@ struct GCInfoAtBase {
FinalizerTrait<T>::finalize, FinalizerTrait<T>::finalize,
FinalizerTrait<T>::nonTrivialFinalizer, FinalizerTrait<T>::nonTrivialFinalizer,
WTF::IsPolymorphic<T>::value, WTF::IsPolymorphic<T>::value,
TypenameStringTrait<T>::get TypenameStringTrait<T>::get()
}; };
RETURN_GCINFO_INDEX(); RETURN_GCINFO_INDEX();
} }
......
...@@ -41,11 +41,10 @@ ...@@ -41,11 +41,10 @@
#include "wtf/Forward.h" #include "wtf/Forward.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
#include "wtf/HashTraits.h" #include "wtf/HashTraits.h"
#include "wtf/TypeTraits.h"
#if ENABLE(GC_PROFILING)
#include "wtf/InstanceCounter.h" #include "wtf/InstanceCounter.h"
#include "wtf/Threading.h"
#include "wtf/TypeTraits.h"
#include "wtf/text/WTFString.h" #include "wtf/text/WTFString.h"
#endif
namespace blink { namespace blink {
...@@ -391,7 +390,7 @@ struct TypenameStringTrait { ...@@ -391,7 +390,7 @@ struct TypenameStringTrait {
// This method is not thread safe. // This method is not thread safe.
static const String& get() static const String& get()
{ {
DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFunctionName(WTF::extractNameFunction<T>()))); AtomicallyInitializedStaticReference(AtomicString, typenameString, new AtomicString(WTF::extractTypeNameFromFunctionName(WTF::extractNameFunction<T>())));
return typenameString; return typenameString;
} }
}; };
......
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