Title: [92058] trunk/Source/_javascript_Core
- Revision
- 92058
- Author
- [email protected]
- Date
- 2011-07-30 16:10:19 -0700 (Sat, 30 Jul 2011)
Log Message
Reduce the size of JSGlobalObject slightly
https://bugs.webkit.org/show_bug.cgi?id=65417
Reviewed by Dan Bernstein.
Push a few members that either aren't commonly used,
or aren't frequently accessed into a separate struct.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::WeakMapsFinalizer::finalize):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::JSGlobalObjectRareData::JSGlobalObjectRareData):
(JSC::JSGlobalObject::createRareDataIfNeeded):
(JSC::JSGlobalObject::setProfileGroup):
(JSC::JSGlobalObject::profileGroup):
(JSC::JSGlobalObject::registerWeakMap):
(JSC::JSGlobalObject::deregisterWeakMap):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (92057 => 92058)
--- trunk/Source/_javascript_Core/ChangeLog 2011-07-30 18:27:23 UTC (rev 92057)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-07-30 23:10:19 UTC (rev 92058)
@@ -1,3 +1,24 @@
+2011-07-30 Oliver Hunt <[email protected]>
+
+ Reduce the size of JSGlobalObject slightly
+ https://bugs.webkit.org/show_bug.cgi?id=65417
+
+ Reviewed by Dan Bernstein.
+
+ Push a few members that either aren't commonly used,
+ or aren't frequently accessed into a separate struct.
+
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init):
+ (JSC::JSGlobalObject::WeakMapsFinalizer::finalize):
+ * runtime/JSGlobalObject.h:
+ (JSC::JSGlobalObject::JSGlobalObjectRareData::JSGlobalObjectRareData):
+ (JSC::JSGlobalObject::createRareDataIfNeeded):
+ (JSC::JSGlobalObject::setProfileGroup):
+ (JSC::JSGlobalObject::profileGroup):
+ (JSC::JSGlobalObject::registerWeakMap):
+ (JSC::JSGlobalObject::deregisterWeakMap):
+
2011-07-30 Balazs Kelemen <[email protected]>
MessageQueue::waitForMessageFilteredWithTimeout can triggers an assertion
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (92057 => 92058)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2011-07-30 18:27:23 UTC (rev 92057)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2011-07-30 23:10:19 UTC (rev 92058)
@@ -130,8 +130,6 @@
m_debugger = 0;
- m_profileGroup = 0;
-
reset(prototype());
}
@@ -427,7 +425,7 @@
void JSGlobalObject::WeakMapsFinalizer::finalize(Handle<Unknown> handle, void*)
{
JSGlobalObject* globalObject = asGlobalObject(handle.get());
- globalObject->m_weakMaps.clear();
+ globalObject->m_rareData.clear();
}
JSGlobalObject::WeakMapsFinalizer* JSGlobalObject::weakMapsFinalizer()
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (92057 => 92058)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2011-07-30 18:27:23 UTC (rev 92057)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2011-07-30 23:10:19 UTC (rev 92058)
@@ -54,9 +54,27 @@
typedef Vector<ExecState*, 16> ExecStateStack;
class JSGlobalObject : public JSVariableObject {
- protected:
+ private:
typedef HashSet<RefPtr<OpaqueJSWeakObjectMap> > WeakMapSet;
+ class WeakMapsFinalizer : public WeakHandleOwner {
+ public:
+ virtual void finalize(Handle<Unknown>, void* context);
+ };
+
+ struct JSGlobalObjectRareData {
+ JSGlobalObjectRareData()
+ : profileGroup(0)
+ {
+ }
+
+ WeakMapSet weakMaps;
+ unsigned profileGroup;
+ Weak<JSGlobalObject> weakMapsFinalizer;
+ };
+
+ protected:
+
RefPtr<JSGlobalData> m_globalData;
size_t m_registerArraySize;
@@ -104,15 +122,9 @@
WriteBarrier<Structure> m_stringObjectStructure;
WriteBarrier<Structure> m_internalFunctionStructure;
- unsigned m_profileGroup;
Debugger* m_debugger;
- WeakMapSet m_weakMaps;
- Weak<JSGlobalObject> m_weakMapsFinalizer;
- class WeakMapsFinalizer : public WeakHandleOwner {
- public:
- virtual void finalize(Handle<Unknown>, void* context);
- };
+ OwnPtr<JSGlobalObjectRareData> m_rareData;
static WeakMapsFinalizer* weakMapsFinalizer();
WeakRandom m_weakRandom;
@@ -121,6 +133,12 @@
bool m_evalEnabled;
+ void createRareDataIfNeeded()
+ {
+ if (!m_rareData)
+ m_rareData = adoptPtr(new JSGlobalObjectRareData);
+ }
+
public:
static JSGlobalObject* create(JSGlobalData& globalData, Structure* structure)
{
@@ -217,8 +235,13 @@
Structure* regExpStructure() const { return m_regExpStructure.get(); }
Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); }
- void setProfileGroup(unsigned value) { m_profileGroup = value; }
- unsigned profileGroup() const { return m_profileGroup; }
+ void setProfileGroup(unsigned value) { createRareDataIfNeeded(); m_rareData->profileGroup = value; }
+ unsigned profileGroup() const
+ {
+ if (!m_rareData)
+ return 0;
+ return m_rareData->profileGroup;
+ }
Debugger* debugger() const { return m_debugger; }
void setDebugger(Debugger* debugger) { m_debugger = debugger; }
@@ -254,14 +277,16 @@
void registerWeakMap(OpaqueJSWeakObjectMap* map)
{
- if (!m_weakMapsFinalizer)
- m_weakMapsFinalizer.set(globalData(), this, weakMapsFinalizer());
- m_weakMaps.add(map);
+ createRareDataIfNeeded();
+ if (!m_rareData->weakMapsFinalizer)
+ m_rareData->weakMapsFinalizer.set(globalData(), this, weakMapsFinalizer());
+ m_rareData->weakMaps.add(map);
}
void deregisterWeakMap(OpaqueJSWeakObjectMap* map)
{
- m_weakMaps.remove(map);
+ if (m_rareData)
+ m_rareData->weakMaps.remove(map);
}
double weakRandomNumber() { return m_weakRandom.get(); }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes