<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[146932] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/146932">146932</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2013-03-26 14:43:27 -0700 (Tue, 26 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>JSC_enableProfiler=true should also cause JSGlobalData to save the profiler output somewhere
https://bugs.webkit.org/show_bug.cgi?id=113144

Source/JavaScriptCore: 

Reviewed by Geoffrey Garen.
        
Added the ability to save profiler output with JSC_enableProfiler=true. It will save it
to the current directory, or JSC_PROFILER_PATH if the latter was specified.
        
This works by saving the Profiler::Database either when it is destroyed or atexit(),
whichever happens first.
        
This allows use of the profiler from any WebKit client.

* jsc.cpp:
(jscmain):
* profiler/ProfilerDatabase.cpp:
(Profiler):
(JSC::Profiler::Database::Database):
(JSC::Profiler::Database::~Database):
(JSC::Profiler::Database::registerToSaveAtExit):
(JSC::Profiler::Database::addDatabaseToAtExit):
(JSC::Profiler::Database::removeDatabaseFromAtExit):
(JSC::Profiler::Database::performAtExitSave):
(JSC::Profiler::Database::removeFirstAtExitDatabase):
(JSC::Profiler::Database::atExitCallback):
* profiler/ProfilerDatabase.h:
(JSC::Profiler::Database::databaseID):
(Database):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):

Source/WTF: 

Reviewed by Geoffrey Garen.
        
I got tired of the fact that getpid(2) is not a syscall on Windows (unless you do
_getpid() I believe), so I wrote a header that abstracts it. I also changed existing
code that uses getpid() to use WTF::getCurrentProcessID().

* GNUmakefile.list.am:
* WTF.gypi:
* WTF.pro:
* WTF.vcproj/WTF.vcproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocator::dumpProfile):
* wtf/ProcessID.h: Added.
(WTF):
(WTF::getCurrentProcessID):
* wtf/text/StringImpl.cpp:
(WTF::StringStats::printStats):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerProfilerDatabasecpp">trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerProfilerDatabaseh">trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalDatacpp">trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFGNUmakefilelistam">trunk/Source/WTF/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWTFWTFgypi">trunk/Source/WTF/WTF.gypi</a></li>
<li><a href="#trunkSourceWTFWTFpro">trunk/Source/WTF/WTF.pro</a></li>
<li><a href="#trunkSourceWTFWTFvcprojWTFvcproj">trunk/Source/WTF/WTF.vcproj/WTF.vcproj</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWTFwtfMetaAllocatorcpp">trunk/Source/WTF/wtf/MetaAllocator.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextStringImplcpp">trunk/Source/WTF/wtf/text/StringImpl.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfProcessIDh">trunk/Source/WTF/wtf/ProcessID.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/JavaScriptCore/ChangeLog        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -1,5 +1,38 @@
</span><span class="cx"> 2013-03-25  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        JSC_enableProfiler=true should also cause JSGlobalData to save the profiler output somewhere
+        https://bugs.webkit.org/show_bug.cgi?id=113144
+
+        Reviewed by Geoffrey Garen.
+        
+        Added the ability to save profiler output with JSC_enableProfiler=true. It will save it
+        to the current directory, or JSC_PROFILER_PATH if the latter was specified.
+        
+        This works by saving the Profiler::Database either when it is destroyed or atexit(),
+        whichever happens first.
+        
+        This allows use of the profiler from any WebKit client.
+
+        * jsc.cpp:
+        (jscmain):
+        * profiler/ProfilerDatabase.cpp:
+        (Profiler):
+        (JSC::Profiler::Database::Database):
+        (JSC::Profiler::Database::~Database):
+        (JSC::Profiler::Database::registerToSaveAtExit):
+        (JSC::Profiler::Database::addDatabaseToAtExit):
+        (JSC::Profiler::Database::removeDatabaseFromAtExit):
+        (JSC::Profiler::Database::performAtExitSave):
+        (JSC::Profiler::Database::removeFirstAtExitDatabase):
+        (JSC::Profiler::Database::atExitCallback):
+        * profiler/ProfilerDatabase.h:
+        (JSC::Profiler::Database::databaseID):
+        (Database):
+        * runtime/JSGlobalData.cpp:
+        (JSC::JSGlobalData::JSGlobalData):
+
+2013-03-25  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
</ins><span class="cx">         ArrayMode should not consider SpecOther when refining the base
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=113271
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -764,7 +764,7 @@
</span><span class="cx">     JSLockHolder lock(globalData.get());
</span><span class="cx">     int result;
</span><span class="cx"> 
</span><del>-    if (options.m_profile)
</del><ins>+    if (options.m_profile &amp;&amp; !globalData-&gt;m_perBytecodeProfiler)
</ins><span class="cx">         globalData-&gt;m_perBytecodeProfiler = adoptPtr(new Profiler::Database(*globalData));
</span><span class="cx">     
</span><span class="cx">     GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.m_arguments);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerProfilerDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -33,13 +33,25 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace Profiler {
</span><span class="cx"> 
</span><ins>+static volatile int databaseCounter;
+static SpinLock registrationLock;
+static int didRegisterAtExit;
+static Database* firstDatabase;
+
</ins><span class="cx"> Database::Database(JSGlobalData&amp; globalData)
</span><del>-    : m_globalData(globalData)
</del><ins>+    : m_databaseID(atomicIncrement(&amp;databaseCounter))
+    , m_globalData(globalData)
+    , m_shouldSaveAtExit(false)
+    , m_nextRegisteredDatabase(0)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Database::~Database()
</span><span class="cx"> {
</span><ins>+    if (m_shouldSaveAtExit) {
+        removeDatabaseFromAtExit();
+        performAtExitSave();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Bytecodes* Database::ensureBytecodesFor(CodeBlock* codeBlock)
</span><span class="lines">@@ -110,5 +122,62 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Database::registerToSaveAtExit(const char* filename)
+{
+    m_atExitSaveFilename = filename;
+    
+    if (m_shouldSaveAtExit)
+        return;
+    
+    addDatabaseToAtExit();
+    m_shouldSaveAtExit = true;
+}
+
+void Database::addDatabaseToAtExit()
+{
+    if (atomicIncrement(&amp;didRegisterAtExit) == 1)
+        atexit(atExitCallback);
+    
+    TCMalloc_SpinLockHolder holder(&amp;registrationLock);
+    m_nextRegisteredDatabase = firstDatabase;
+    firstDatabase = this;
+}
+
+void Database::removeDatabaseFromAtExit()
+{
+    TCMalloc_SpinLockHolder holder(&amp;registrationLock);
+    for (Database** current = &amp;firstDatabase; *current; current = &amp;(*current)-&gt;m_nextRegisteredDatabase) {
+        if (*current != this)
+            continue;
+        *current = m_nextRegisteredDatabase;
+        m_nextRegisteredDatabase = 0;
+        m_shouldSaveAtExit = false;
+        break;
+    }
+}
+
+void Database::performAtExitSave() const
+{
+    save(m_atExitSaveFilename.data());
+}
+
+Database* Database::removeFirstAtExitDatabase()
+{
+    TCMalloc_SpinLockHolder holder(&amp;registrationLock);
+    Database* result = firstDatabase;
+    if (result) {
+        firstDatabase = result-&gt;m_nextRegisteredDatabase;
+        result-&gt;m_nextRegisteredDatabase = 0;
+        result-&gt;m_shouldSaveAtExit = false;
+    }
+    return result;
+}
+
+void Database::atExitCallback()
+{
+    while (Database* database = removeFirstAtExitDatabase())
+        database-&gt;performAtExitSave();
+}
+
</ins><span class="cx"> } } // namespace JSC::Profiler
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerProfilerDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.h (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.h        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.h        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -45,6 +45,8 @@
</span><span class="cx">     JS_EXPORT_PRIVATE Database(JSGlobalData&amp;);
</span><span class="cx">     JS_EXPORT_PRIVATE ~Database();
</span><span class="cx">     
</span><ins>+    int databaseID() const { return m_databaseID; }
+    
</ins><span class="cx">     Bytecodes* ensureBytecodesFor(CodeBlock*);
</span><span class="cx">     void notifyDestruction(CodeBlock*);
</span><span class="cx">     
</span><span class="lines">@@ -65,12 +67,24 @@
</span><span class="cx">     // save failed.
</span><span class="cx">     JS_EXPORT_PRIVATE bool save(const char* filename) const;
</span><span class="cx"> 
</span><ins>+    void registerToSaveAtExit(const char* filename);
+    
</ins><span class="cx"> private:
</span><span class="cx"> 
</span><ins>+    void addDatabaseToAtExit();
+    void removeDatabaseFromAtExit();
+    void performAtExitSave() const;
+    static Database* removeFirstAtExitDatabase();
+    static void atExitCallback();
+    
+    int m_databaseID;
</ins><span class="cx">     JSGlobalData&amp; m_globalData;
</span><span class="cx">     SegmentedVector&lt;Bytecodes&gt; m_bytecodes;
</span><span class="cx">     HashMap&lt;CodeBlock*, Bytecodes*&gt; m_bytecodesMap;
</span><span class="cx">     Vector&lt;RefPtr&lt;Compilation&gt; &gt; m_compilations;
</span><ins>+    bool m_shouldSaveAtExit;
+    CString m_atExitSaveFilename;
+    Database* m_nextRegisteredDatabase;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } } // namespace JSC::Profiler
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2011 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2008, 2011, 2013 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -60,7 +60,9 @@
</span><span class="cx"> #include &quot;StrictEvalActivation.h&quot;
</span><span class="cx"> #include &quot;StrongInlines.h&quot;
</span><span class="cx"> #include &quot;UnlinkedCodeBlock.h&quot;
</span><ins>+#include &lt;wtf/ProcessID.h&gt;
</ins><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><ins>+#include &lt;wtf/StringPrintStream.h&gt;
</ins><span class="cx"> #include &lt;wtf/Threading.h&gt;
</span><span class="cx"> #include &lt;wtf/WTFThreadData.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -247,9 +249,17 @@
</span><span class="cx"> 
</span><span class="cx">     LLInt::Data::performAssertions(*this);
</span><span class="cx">     
</span><del>-    if (Options::enableProfiler())
</del><ins>+    if (Options::enableProfiler()) {
</ins><span class="cx">         m_perBytecodeProfiler = adoptPtr(new Profiler::Database(*this));
</span><span class="cx"> 
</span><ins>+        StringPrintStream pathOut;
+        const char* profilerPath = getenv(&quot;JSC_PROFILER_PATH&quot;);
+        if (profilerPath)
+            pathOut.print(profilerPath, &quot;/&quot;);
+        pathOut.print(&quot;JSCProfile-&quot;, getCurrentProcessID(), &quot;-&quot;, m_perBytecodeProfiler-&gt;databaseID(), &quot;.json&quot;);
+        m_perBytecodeProfiler-&gt;registerToSaveAtExit(pathOut.toCString().data());
+    }
+
</ins><span class="cx"> #if ENABLE(DFG_JIT)
</span><span class="cx">     if (canUseJIT())
</span><span class="cx">         m_dfgState = adoptPtr(new DFG::LongLivedState());
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/ChangeLog        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2013-03-23  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        JSC_enableProfiler=true should also cause JSGlobalData to save the profiler output somewhere
+        https://bugs.webkit.org/show_bug.cgi?id=113144
+
+        Reviewed by Geoffrey Garen.
+        
+        I got tired of the fact that getpid(2) is not a syscall on Windows (unless you do
+        _getpid() I believe), so I wrote a header that abstracts it. I also changed existing
+        code that uses getpid() to use WTF::getCurrentProcessID().
+
+        * GNUmakefile.list.am:
+        * WTF.gypi:
+        * WTF.pro:
+        * WTF.vcproj/WTF.vcproj:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/MetaAllocator.cpp:
+        (WTF::MetaAllocator::dumpProfile):
+        * wtf/ProcessID.h: Added.
+        (WTF):
+        (WTF::getCurrentProcessID):
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringStats::printStats):
+
</ins><span class="cx"> 2013-03-25  Kent Tamura  &lt;tkent@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Rename ENABLE_INPUT_TYPE_DATETIME
</span></span></pre></div>
<a id="trunkSourceWTFGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/GNUmakefile.list.am (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/GNUmakefile.list.am        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/GNUmakefile.list.am        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -139,6 +139,7 @@
</span><span class="cx">     Source/WTF/wtf/PossiblyNull.h \
</span><span class="cx">     Source/WTF/wtf/PrintStream.cpp \
</span><span class="cx">     Source/WTF/wtf/PrintStream.h \
</span><ins>+    Source/WTF/wtf/ProcessID.h \
</ins><span class="cx">     Source/WTF/wtf/RandomNumber.cpp \
</span><span class="cx">     Source/WTF/wtf/RandomNumber.h \
</span><span class="cx">     Source/WTF/wtf/RandomNumberSeed.h \
</span></span></pre></div>
<a id="trunkSourceWTFWTFgypi"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.gypi (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.gypi        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/WTF.gypi        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx">             'wtf/Platform.h',
</span><span class="cx">             'wtf/PossiblyNull.h',
</span><span class="cx">             'wtf/PrintStream.h',
</span><ins>+            'wtf/ProcessID.h',
</ins><span class="cx">             'wtf/RandomNumber.h',
</span><span class="cx">             'wtf/RawPointer.h',
</span><span class="cx">             'wtf/RefCounted.h',
</span></span></pre></div>
<a id="trunkSourceWTFWTFpro"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.pro (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.pro        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/WTF.pro        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -130,6 +130,7 @@
</span><span class="cx">     Platform.h \
</span><span class="cx">     PossiblyNull.h \
</span><span class="cx">     PrintStream.h \
</span><ins>+    ProcessID.h \
</ins><span class="cx">     RandomNumber.h \
</span><span class="cx">     RandomNumberSeed.h \
</span><span class="cx">     RawPointer.h \
</span></span></pre></div>
<a id="trunkSourceWTFWTFvcprojWTFvcproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.vcproj/WTF.vcproj (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.vcproj/WTF.vcproj        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/WTF.vcproj/WTF.vcproj        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -1129,6 +1129,10 @@
</span><span class="cx">                         &gt;
</span><span class="cx">                 &lt;/File&gt;
</span><span class="cx">                 &lt;File
</span><ins>+                        RelativePath=&quot;..\wtf\ProcessID.h&quot;
+                        &gt;
+                &lt;/File&gt;
+                &lt;File
</ins><span class="cx">                         RelativePath=&quot;..\wtf\RandomNumber.cpp&quot;
</span><span class="cx">                         &gt;
</span><span class="cx">                 &lt;/File&gt;
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx">                 0F9D3361165DBA73005AD387 /* FilePrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335C165DBA73005AD387 /* FilePrintStream.h */; };
</span><span class="cx">                 0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9D335D165DBA73005AD387 /* PrintStream.cpp */; };
</span><span class="cx">                 0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335E165DBA73005AD387 /* PrintStream.h */; };
</span><ins>+                0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC4488216FE9FE100844BE9 /* ProcessID.h */; };
</ins><span class="cx">                 0FC4EDE61696149600F65041 /* CommaPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC4EDE51696149600F65041 /* CommaPrinter.h */; };
</span><span class="cx">                 0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AC4154FB22E00983E72 /* FastBitVector.h */; settings = {ATTRIBUTES = (); }; };
</span><span class="cx">                 0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */; };
</span><span class="lines">@@ -336,6 +337,7 @@
</span><span class="cx">                 0F9D335C165DBA73005AD387 /* FilePrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePrintStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F9D335D165DBA73005AD387 /* PrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F9D335E165DBA73005AD387 /* PrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                0FC4488216FE9FE100844BE9 /* ProcessID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessID.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 0FC4EDE51696149600F65041 /* CommaPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommaPrinter.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FD81AC4154FB22E00983E72 /* FastBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastBitVector.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringPrintStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -833,6 +835,7 @@
</span><span class="cx">                                 A8A472F3151A825B004123FF /* PossiblyNull.h */,
</span><span class="cx">                                 0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
</span><span class="cx">                                 0F9D335E165DBA73005AD387 /* PrintStream.h */,
</span><ins>+                                0FC4488216FE9FE100844BE9 /* ProcessID.h */,
</ins><span class="cx">                                 143F611D1565F0F900DB514A /* RAMSize.cpp */,
</span><span class="cx">                                 143F611E1565F0F900DB514A /* RAMSize.h */,
</span><span class="cx">                                 A8A472FB151A825B004123FF /* RandomNumber.cpp */,
</span><span class="lines">@@ -1285,6 +1288,7 @@
</span><span class="cx">                                 974CFC8E16A4F327006D5404 /* WeakPtr.h in Headers */,
</span><span class="cx">                                 A8A47446151A825B004123FF /* WTFString.h in Headers */,
</span><span class="cx">                                 A8A47487151A825B004123FF /* WTFThreadData.h in Headers */,
</span><ins>+                                0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/wtf/CMakeLists.txt        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx">     Platform.h
</span><span class="cx">     PossiblyNull.h
</span><span class="cx">     PrintStream.h
</span><ins>+    ProcessID.h
</ins><span class="cx">     RandomNumber.h
</span><span class="cx">     RandomNumberSeed.h
</span><span class="cx">     RawPointer.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfMetaAllocatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MetaAllocator.cpp (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MetaAllocator.cpp        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/wtf/MetaAllocator.cpp        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/DataLog.h&gt;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><ins>+#include &lt;wtf/ProcessID.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><span class="lines">@@ -449,8 +450,9 @@
</span><span class="cx"> #if ENABLE(META_ALLOCATOR_PROFILE)
</span><span class="cx"> void MetaAllocator::dumpProfile()
</span><span class="cx"> {
</span><del>-    dataLogF(&quot;%d: MetaAllocator(%p): num allocations = %u, num frees = %u, allocated = %lu, reserved = %lu, committed = %lu\n&quot;,
-            getpid(), this, m_numAllocations, m_numFrees, m_bytesAllocated, m_bytesReserved, m_bytesCommitted);
</del><ins>+    dataLogF(
+        &quot;%d: MetaAllocator(%p): num allocations = %u, num frees = %u, allocated = %lu, reserved = %lu, committed = %lu\n&quot;,
+        getCurrentProcessID(), this, m_numAllocations, m_numFrees, m_bytesAllocated, m_bytesReserved, m_bytesCommitted);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfProcessIDh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/ProcessID.h (0 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/ProcessID.h                                (rev 0)
+++ trunk/Source/WTF/wtf/ProcessID.h        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef ProcessID_h
+#define ProcessID_h
+
+#include &lt;wtf/Platform.h&gt;
+
+#if OS(UNIX)
+#include &lt;unistd.h&gt;
+#endif
+
+#if PLATFORM(WIN)
+#include &lt;windows.h&gt;
+#endif
+
+namespace WTF {
+
+inline int getCurrentProcessID()
+{
+#if PLATFORM(WIN)
+    return GetCurrentProcessId();
+#else
+    return getpid();
+#endif
+}
+
+} // namespace WTF
+
+using WTF::getCurrentProcessID;
+
+#endif // ProcessID_h
+
</ins></span></pre></div>
<a id="trunkSourceWTFwtftextStringImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (146931 => 146932)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringImpl.cpp        2013-03-26 21:42:26 UTC (rev 146931)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp        2013-03-26 21:43:27 UTC (rev 146932)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;AtomicString.h&quot;
</span><span class="cx"> #include &quot;StringBuffer.h&quot;
</span><span class="cx"> #include &quot;StringHash.h&quot;
</span><ins>+#include &lt;wtf/ProcessID.h&gt;
</ins><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/WTFThreadData.h&gt;
</span><span class="cx"> #include &lt;wtf/unicode/CharacterNames.h&gt;
</span><span class="lines">@@ -81,7 +82,7 @@
</span><span class="cx"> 
</span><span class="cx"> void StringStats::printStats()
</span><span class="cx"> {
</span><del>-    dataLogF(&quot;String stats for process id %d:\n&quot;, getpid());
</del><ins>+    dataLogF(&quot;String stats for process id %d:\n&quot;, getCurrentProcessID());
</ins><span class="cx"> 
</span><span class="cx">     unsigned long long totalNumberCharacters = m_total8BitData + m_total16BitData;
</span><span class="cx">     double percent8Bit = m_totalNumberStrings ? ((double)m_number8BitStrings * 100) / (double)m_totalNumberStrings : 0.0;
</span></span></pre>
</div>
</div>

</body>
</html>