Use HashMap<OwnPtr> for ScriptSampleRecordMap
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Dec 2011 05:20:49 +0000 (05:20 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Dec 2011 05:20:49 +0000 (05:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73758

Reviewed by Andreas Kling.

* bytecode/SamplingTool.cpp:
(JSC::SamplingTool::notifyOfScope): Added adoptPtr.
(JSC::SamplingTool::dump): Added get.
* bytecode/SamplingTool.h: Changed the value type of ScriptSampleRecordMap to be OwnPtr.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@101946 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/SamplingTool.cpp
Source/JavaScriptCore/bytecode/SamplingTool.h

index 9aecaf1..bcde684 100644 (file)
@@ -1,5 +1,17 @@
 2011-12-03  Darin Adler  <darin@apple.com>
 
+        Use HashMap<OwnPtr> for ScriptSampleRecordMap
+        https://bugs.webkit.org/show_bug.cgi?id=73758
+
+        Reviewed by Andreas Kling.
+
+        * bytecode/SamplingTool.cpp:
+        (JSC::SamplingTool::notifyOfScope): Added adoptPtr.
+        (JSC::SamplingTool::dump): Added get.
+        * bytecode/SamplingTool.h: Changed the value type of ScriptSampleRecordMap to be OwnPtr.
+
+2011-12-03  Darin Adler  <darin@apple.com>
+
         Use HashMap<OwnPtr> for the opaqueJSClassData map
         https://bugs.webkit.org/show_bug.cgi?id=73759
 
index d369114..0dec25f 100644 (file)
@@ -303,7 +303,7 @@ void SamplingTool::notifyOfScope(JSGlobalData& globalData, ScriptExecutable* scr
 {
 #if ENABLE(CODEBLOCK_SAMPLING)
     MutexLocker locker(m_scriptSampleMapMutex);
-    m_scopeSampleMap->set(script, new ScriptSampleRecord(globalData, script));
+    m_scopeSampleMap->set(script, adoptPtr(new ScriptSampleRecord(globalData, script)));
 #else
     UNUSED_PARAM(globalData);
     UNUSED_PARAM(script);
@@ -412,7 +412,7 @@ void SamplingTool::dump(ExecState* exec)
     Vector<ScriptSampleRecord*> codeBlockSamples(scopeCount);
     ScriptSampleRecordMap::iterator iter = m_scopeSampleMap->begin();
     for (int i = 0; i < scopeCount; ++i, ++iter)
-        codeBlockSamples[i] = iter->second;
+        codeBlockSamples[i] = iter->second.get();
 
     qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScriptSampleRecord*), compareScriptSampleRecords);
 
index 7a76883..b69ef02 100644 (file)
@@ -211,7 +211,7 @@ namespace JSC {
         unsigned m_size;
     };
 
-    typedef WTF::HashMap<ScriptExecutable*, ScriptSampleRecord*> ScriptSampleRecordMap;
+    typedef HashMap<ScriptExecutable*, OwnPtr<ScriptSampleRecord> > ScriptSampleRecordMap;
 
     class SamplingThread {
     public:
@@ -287,20 +287,13 @@ namespace JSC {
             , m_sampleCount(0)
             , m_opcodeSampleCount(0)
 #if ENABLE(CODEBLOCK_SAMPLING)
-            , m_scopeSampleMap(adoptPtr(new ScriptSampleRecordMap()))
+            , m_scopeSampleMap(adoptPtr(new ScriptSampleRecordMap))
 #endif
         {
             memset(m_opcodeSamples, 0, sizeof(m_opcodeSamples));
             memset(m_opcodeSamplesInCTIFunctions, 0, sizeof(m_opcodeSamplesInCTIFunctions));
         }
 
-        ~SamplingTool()
-        {
-#if ENABLE(CODEBLOCK_SAMPLING)
-            deleteAllValues(*m_scopeSampleMap);
-#endif
-        }
-
         void setup();
         void dump(ExecState*);