Diff
Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (151855 => 151856)
--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog 2013-06-21 21:27:45 UTC (rev 151856)
@@ -1,5 +1,44 @@
2013-06-21 Filip Pizlo <[email protected]>
+ fourthTier: Merge r146932 and 146933 so that we can profile from DumpRenderTree
+ https://bugs.webkit.org/show_bug.cgi?id=117891
+
+ Reviewed by Mark Hahnenberg.
+
+ Merging the JSC part of these changes required creating a fresh VM to JSONify
+ the profiler database, because that's the only truly safe way to do it. This
+ is because we don't really know when the profiler would be asked to dump JSON,
+ and we might be in the middle of VM shutdown. That's a bug in the ToT version
+ of this, but we didn't catch it because we didn't have enough assertions to
+ that effect.
+
+ * jsc.cpp:
+ (jscmain):
+ * profiler/ProfilerDatabase.cpp:
+ (Profiler):
+ (JSC::Profiler::Database::Database):
+ (JSC::Profiler::Database::~Database):
+ (JSC::Profiler::Database::toJSON):
+ (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:
+ (Database):
+ (JSC::Profiler::Database::databaseID):
+ * runtime/VM.cpp:
+ (JSC::VM::VM):
+ (JSC::VM::createContextGroup):
+ (JSC::VM::create):
+ (JSC::VM::createLeaked):
+ (JSC::VM::sharedInstance):
+ * runtime/VM.h:
+ (VM):
+
+2013-06-21 Filip Pizlo <[email protected]>
+
Merge trunk r146548.
2013-03-21 Filip Pizlo <[email protected]>
Modified: branches/dfgFourthTier/Source/_javascript_Core/jsc.cpp (151855 => 151856)
--- branches/dfgFourthTier/Source/_javascript_Core/jsc.cpp 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/_javascript_Core/jsc.cpp 2013-06-21 21:27:45 UTC (rev 151856)
@@ -760,8 +760,8 @@
JSLockHolder lock(vm.get());
int result;
- if (options.m_profile)
- vm->m_perBytecodeProfiler = adoptPtr(new Profiler::Database(*vm));
+ if (options.m_profile && !vm->m_perBytecodeProfiler)
+ vm->m_perBytecodeProfiler = adoptPtr(new Profiler::Database());
GlobalObject* globalObject = GlobalObject::create(*vm, GlobalObject::createStructure(*vm, jsNull()), options.m_arguments);
bool success = runWithScripts(globalObject, options.m_scripts, options.m_dump);
Modified: branches/dfgFourthTier/Source/_javascript_Core/profiler/ProfilerDatabase.cpp (151855 => 151856)
--- branches/dfgFourthTier/Source/_javascript_Core/profiler/ProfilerDatabase.cpp 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/_javascript_Core/profiler/ProfilerDatabase.cpp 2013-06-21 21:27:45 UTC (rev 151856)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 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
@@ -33,13 +33,24 @@
namespace JSC { namespace Profiler {
-Database::Database(VM& vm)
- : m_vm(vm)
+static volatile int databaseCounter;
+static SpinLock registrationLock = SPINLOCK_INITIALIZER;
+static int didRegisterAtExit;
+static Database* firstDatabase;
+
+Database::Database()
+ : m_databaseID(atomicIncrement(&databaseCounter))
+ , m_shouldSaveAtExit(false)
+ , m_nextRegisteredDatabase(0)
{
}
Database::~Database()
{
+ if (m_shouldSaveAtExit) {
+ removeDatabaseFromAtExit();
+ performAtExitSave();
+ }
}
Bytecodes* Database::ensureBytecodesFor(CodeBlock* codeBlock)
@@ -93,8 +104,10 @@
String Database::toJSON() const
{
+ RefPtr<VM> vm = VM::create(SmallHeap, DisableProfiling);
+ JSLockHolder lock(vm.get());
JSGlobalObject* globalObject = JSGlobalObject::create(
- m_vm, JSGlobalObject::createStructure(m_vm, jsNull()));
+ *vm, JSGlobalObject::createStructure(*vm, jsNull()));
return JSONStringify(globalObject->globalExec(), toJS(globalObject->globalExec()), 0);
}
@@ -109,5 +122,62 @@
return true;
}
+void Database::registerToSaveAtExit(const char* filename)
+{
+ m_atExitSaveFilename = filename;
+
+ if (m_shouldSaveAtExit)
+ return;
+
+ addDatabaseToAtExit();
+ m_shouldSaveAtExit = true;
+}
+
+void Database::addDatabaseToAtExit()
+{
+ if (atomicIncrement(&didRegisterAtExit) == 1)
+ atexit(atExitCallback);
+
+ TCMalloc_SpinLockHolder holder(®istrationLock);
+ m_nextRegisteredDatabase = firstDatabase;
+ firstDatabase = this;
+}
+
+void Database::removeDatabaseFromAtExit()
+{
+ TCMalloc_SpinLockHolder holder(®istrationLock);
+ for (Database** current = &firstDatabase; *current; current = &(*current)->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(®istrationLock);
+ Database* result = firstDatabase;
+ if (result) {
+ firstDatabase = result->m_nextRegisteredDatabase;
+ result->m_nextRegisteredDatabase = 0;
+ result->m_shouldSaveAtExit = false;
+ }
+ return result;
+}
+
+void Database::atExitCallback()
+{
+ while (Database* database = removeFirstAtExitDatabase())
+ database->performAtExitSave();
+}
+
} } // namespace JSC::Profiler
Modified: branches/dfgFourthTier/Source/_javascript_Core/profiler/ProfilerDatabase.h (151855 => 151856)
--- branches/dfgFourthTier/Source/_javascript_Core/profiler/ProfilerDatabase.h 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/_javascript_Core/profiler/ProfilerDatabase.h 2013-06-21 21:27:45 UTC (rev 151856)
@@ -43,9 +43,11 @@
class Database {
WTF_MAKE_FAST_ALLOCATED; WTF_MAKE_NONCOPYABLE(Database);
public:
- JS_EXPORT_PRIVATE Database(VM&);
+ JS_EXPORT_PRIVATE Database();
JS_EXPORT_PRIVATE ~Database();
+ int databaseID() const { return m_databaseID; }
+
Bytecodes* ensureBytecodesFor(CodeBlock*);
void notifyDestruction(CodeBlock*);
@@ -65,7 +67,17 @@
// save failed.
JS_EXPORT_PRIVATE bool save(const char* filename) const;
+ void registerToSaveAtExit(const char* filename);
+
private:
+ void addDatabaseToAtExit();
+ void removeDatabaseFromAtExit();
+ void performAtExitSave() const;
+ static Database* removeFirstAtExitDatabase();
+ static void atExitCallback();
+
+ int m_databaseID;
+
// Use a full-blown adaptive mutex because:
// - There is only one ProfilerDatabase per VM. The size overhead of the system's
// mutex is negligible if you only have one of them.
@@ -80,11 +92,14 @@
typedef Mutex Lock;
typedef MutexLocker Locker;
- VM& m_vm;
SegmentedVector<Bytecodes> m_bytecodes;
HashMap<CodeBlock*, Bytecodes*> m_bytecodesMap;
Vector<RefPtr<Compilation> > m_compilations;
Lock m_lock;
+
+ bool m_shouldSaveAtExit;
+ CString m_atExitSaveFilename;
+ Database* m_nextRegisteredDatabase;
};
} } // namespace JSC::Profiler
Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.cpp (151855 => 151856)
--- branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.cpp 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.cpp 2013-06-21 21:27:45 UTC (rev 151856)
@@ -62,7 +62,9 @@
#include "StrictEvalActivation.h"
#include "StrongInlines.h"
#include "UnlinkedCodeBlock.h"
+#include <wtf/ProcessID.h>
#include <wtf/RetainPtr.h>
+#include <wtf/StringPrintStream.h>
#include <wtf/Threading.h>
#include <wtf/WTFThreadData.h>
@@ -132,7 +134,7 @@
}
#endif // ENABLE(!ASSEMBLER)
-VM::VM(VMType vmType, HeapType heapType)
+VM::VM(VMType vmType, HeapType heapType, ProfilingMode profilingMode)
:
#if ENABLE(ASSEMBLER)
executableAllocator(*this),
@@ -243,9 +245,17 @@
LLInt::Data::performAssertions(*this);
- if (Options::enableProfiler())
- m_perBytecodeProfiler = adoptPtr(new Profiler::Database(*this));
+ if (profilingMode == NormalProfiling && Options::enableProfiler()) {
+ m_perBytecodeProfiler = adoptPtr(new Profiler::Database());
+ StringPrintStream pathOut;
+ const char* profilerPath = getenv("JSC_PROFILER_PATH");
+ if (profilerPath)
+ pathOut.print(profilerPath, "/");
+ pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json");
+ m_perBytecodeProfiler->registerToSaveAtExit(pathOut.toCString().data());
+ }
+
#if ENABLE(DFG_JIT)
if (canUseJIT())
dfgState = adoptPtr(new DFG::LongLivedState());
@@ -328,19 +338,19 @@
#endif
}
-PassRefPtr<VM> VM::createContextGroup(HeapType heapType)
+PassRefPtr<VM> VM::createContextGroup(HeapType heapType, ProfilingMode profilingMode)
{
- return adoptRef(new VM(APIContextGroup, heapType));
+ return adoptRef(new VM(APIContextGroup, heapType, profilingMode));
}
-PassRefPtr<VM> VM::create(HeapType heapType)
+PassRefPtr<VM> VM::create(HeapType heapType, ProfilingMode profilingMode)
{
- return adoptRef(new VM(Default, heapType));
+ return adoptRef(new VM(Default, heapType, profilingMode));
}
-PassRefPtr<VM> VM::createLeaked(HeapType heapType)
+PassRefPtr<VM> VM::createLeaked(HeapType heapType, ProfilingMode profilingMode)
{
- return create(heapType);
+ return create(heapType, profilingMode);
}
bool VM::sharedInstanceExists()
@@ -353,7 +363,7 @@
GlobalJSLock globalLock;
VM*& instance = sharedInstanceInternal();
if (!instance) {
- instance = adoptRef(new VM(APIShared, SmallHeap)).leakRef();
+ instance = adoptRef(new VM(APIShared, SmallHeap, NormalProfiling)).leakRef();
instance->makeUsableFromMultipleThreads();
}
return *instance;
Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.h (151855 => 151856)
--- branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.h 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.h 2013-06-21 21:27:45 UTC (rev 151856)
@@ -166,6 +166,8 @@
#endif
#endif
+ enum ProfilingMode { NormalProfiling, DisableProfiling };
+
class VM : public ThreadSafeRefCounted<VM> {
public:
// WebCore has a one-to-one mapping of threads to VMs;
@@ -187,9 +189,9 @@
static bool sharedInstanceExists();
JS_EXPORT_PRIVATE static VM& sharedInstance();
- JS_EXPORT_PRIVATE static PassRefPtr<VM> create(HeapType = SmallHeap);
- JS_EXPORT_PRIVATE static PassRefPtr<VM> createLeaked(HeapType = SmallHeap);
- static PassRefPtr<VM> createContextGroup(HeapType = SmallHeap);
+ JS_EXPORT_PRIVATE static PassRefPtr<VM> create(HeapType = SmallHeap, ProfilingMode = NormalProfiling);
+ JS_EXPORT_PRIVATE static PassRefPtr<VM> createLeaked(HeapType = SmallHeap, ProfilingMode = NormalProfiling);
+ static PassRefPtr<VM> createContextGroup(HeapType = SmallHeap, ProfilingMode = NormalProfiling);
JS_EXPORT_PRIVATE ~VM();
void makeUsableFromMultipleThreads() { heap.machineThreads().makeUsableFromMultipleThreads(); }
@@ -483,7 +485,7 @@
private:
friend class LLIntOffsetsExtractor;
- VM(VMType, HeapType);
+ VM(VMType, HeapType, ProfilingMode);
static VM*& sharedInstanceInternal();
void createNativeThunk();
#if ENABLE(ASSEMBLER)
Modified: branches/dfgFourthTier/Source/WTF/ChangeLog (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/ChangeLog 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/ChangeLog 2013-06-21 21:27:45 UTC (rev 151856)
@@ -1,3 +1,26 @@
+2013-06-21 Filip Pizlo <[email protected]>
+
+ fourthTier: Merge r146932 and 146933 so that we can profile from DumpRenderTree
+ https://bugs.webkit.org/show_bug.cgi?id=117891
+
+ Reviewed by Mark Hahnenberg.
+
+ The WTF part of this change is a straight-up merge with nothing interesting.
+
+ * 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):
+
2013-06-18 Filip Pizlo <[email protected]>
fourthTier: DFG should have switch_char
Modified: branches/dfgFourthTier/Source/WTF/GNUmakefile.list.am (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/GNUmakefile.list.am 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/GNUmakefile.list.am 2013-06-21 21:27:45 UTC (rev 151856)
@@ -139,6 +139,7 @@
Source/WTF/wtf/PossiblyNull.h \
Source/WTF/wtf/PrintStream.cpp \
Source/WTF/wtf/PrintStream.h \
+ Source/WTF/wtf/ProcessID.h \
Source/WTF/wtf/RandomNumber.cpp \
Source/WTF/wtf/RandomNumber.h \
Source/WTF/wtf/RandomNumberSeed.h \
Modified: branches/dfgFourthTier/Source/WTF/WTF.gypi (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/WTF.gypi 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/WTF.gypi 2013-06-21 21:27:45 UTC (rev 151856)
@@ -84,6 +84,7 @@
'wtf/Platform.h',
'wtf/PossiblyNull.h',
'wtf/PrintStream.h',
+ 'wtf/ProcessID.h',
'wtf/RandomNumber.h',
'wtf/RawPointer.h',
'wtf/RefCounted.h',
Modified: branches/dfgFourthTier/Source/WTF/WTF.pro (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/WTF.pro 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/WTF.pro 2013-06-21 21:27:45 UTC (rev 151856)
@@ -130,6 +130,7 @@
Platform.h \
PossiblyNull.h \
PrintStream.h \
+ ProcessID.h \
RandomNumber.h \
RandomNumberSeed.h \
RawPointer.h \
Modified: branches/dfgFourthTier/Source/WTF/WTF.vcproj/WTF.vcproj (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/WTF.vcproj/WTF.vcproj 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/WTF.vcproj/WTF.vcproj 2013-06-21 21:27:45 UTC (rev 151856)
@@ -1129,6 +1129,10 @@
>
</File>
<File
+ RelativePath="..\wtf\ProcessID.h"
+ >
+ </File>
+ <File
RelativePath="..\wtf\RandomNumber.cpp"
>
</File>
Modified: branches/dfgFourthTier/Source/WTF/WTF.xcodeproj/project.pbxproj (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/WTF.xcodeproj/project.pbxproj 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/WTF.xcodeproj/project.pbxproj 2013-06-21 21:27:45 UTC (rev 151856)
@@ -30,6 +30,7 @@
0F9D3361165DBA73005AD387 /* FilePrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335C165DBA73005AD387 /* FilePrintStream.h */; };
0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9D335D165DBA73005AD387 /* PrintStream.cpp */; };
0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335E165DBA73005AD387 /* PrintStream.h */; };
+ 0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC4488216FE9FE100844BE9 /* ProcessID.h */; };
0FC4EDE61696149600F65041 /* CommaPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC4EDE51696149600F65041 /* CommaPrinter.h */; };
0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AC4154FB22E00983E72 /* FastBitVector.h */; settings = {ATTRIBUTES = (); }; };
0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */; };
@@ -344,6 +345,7 @@
0F9D335C165DBA73005AD387 /* FilePrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePrintStream.h; sourceTree = "<group>"; };
0F9D335D165DBA73005AD387 /* PrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintStream.cpp; sourceTree = "<group>"; };
0F9D335E165DBA73005AD387 /* PrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintStream.h; sourceTree = "<group>"; };
+ 0FC4488216FE9FE100844BE9 /* ProcessID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessID.h; sourceTree = "<group>"; };
0FC4EDE51696149600F65041 /* CommaPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommaPrinter.h; sourceTree = "<group>"; };
0FD81AC4154FB22E00983E72 /* FastBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastBitVector.h; sourceTree = "<group>"; };
0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringPrintStream.cpp; sourceTree = "<group>"; };
@@ -846,6 +848,7 @@
A8A472F3151A825B004123FF /* PossiblyNull.h */,
0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
0F9D335E165DBA73005AD387 /* PrintStream.h */,
+ 0FC4488216FE9FE100844BE9 /* ProcessID.h */,
143F611D1565F0F900DB514A /* RAMSize.cpp */,
143F611E1565F0F900DB514A /* RAMSize.h */,
A8A472FB151A825B004123FF /* RandomNumber.cpp */,
@@ -1302,6 +1305,7 @@
974CFC8E16A4F327006D5404 /* WeakPtr.h in Headers */,
A8A47446151A825B004123FF /* WTFString.h in Headers */,
A8A47487151A825B004123FF /* WTFThreadData.h in Headers */,
+ 0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: branches/dfgFourthTier/Source/WTF/wtf/CMakeLists.txt (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/wtf/CMakeLists.txt 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/wtf/CMakeLists.txt 2013-06-21 21:27:45 UTC (rev 151856)
@@ -89,6 +89,7 @@
Platform.h
PossiblyNull.h
PrintStream.h
+ ProcessID.h
RandomNumber.h
RandomNumberSeed.h
RawPointer.h
Modified: branches/dfgFourthTier/Source/WTF/wtf/MetaAllocator.cpp (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/wtf/MetaAllocator.cpp 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/wtf/MetaAllocator.cpp 2013-06-21 21:27:45 UTC (rev 151856)
@@ -31,6 +31,7 @@
#include <wtf/DataLog.h>
#include <wtf/FastMalloc.h>
+#include <wtf/ProcessID.h>
namespace WTF {
@@ -449,8 +450,9 @@
#if ENABLE(META_ALLOCATOR_PROFILE)
void MetaAllocator::dumpProfile()
{
- dataLogF("%d: MetaAllocator(%p): num allocations = %u, num frees = %u, allocated = %lu, reserved = %lu, committed = %lu\n",
- getpid(), this, m_numAllocations, m_numFrees, m_bytesAllocated, m_bytesReserved, m_bytesCommitted);
+ dataLogF(
+ "%d: MetaAllocator(%p): num allocations = %u, num frees = %u, allocated = %lu, reserved = %lu, committed = %lu\n",
+ getCurrentProcessID(), this, m_numAllocations, m_numFrees, m_bytesAllocated, m_bytesReserved, m_bytesCommitted);
}
#endif
Added: branches/dfgFourthTier/Source/WTF/wtf/ProcessID.h (0 => 151856)
--- branches/dfgFourthTier/Source/WTF/wtf/ProcessID.h (rev 0)
+++ branches/dfgFourthTier/Source/WTF/wtf/ProcessID.h 2013-06-21 21:27:45 UTC (rev 151856)
@@ -0,0 +1,55 @@
+/*
+ * 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 <wtf/Platform.h>
+
+#if OS(UNIX)
+#include <unistd.h>
+#endif
+
+#if PLATFORM(WIN)
+#include <windows.h>
+#endif
+
+namespace WTF {
+
+inline int getCurrentProcessID()
+{
+#if PLATFORM(WIN)
+ return GetCurrentProcessId();
+#else
+ return getpid();
+#endif
+}
+
+} // namespace WTF
+
+using WTF::getCurrentProcessID;
+
+#endif // ProcessID_h
+
Modified: branches/dfgFourthTier/Source/WTF/wtf/text/StringImpl.cpp (151855 => 151856)
--- branches/dfgFourthTier/Source/WTF/wtf/text/StringImpl.cpp 2013-06-21 21:04:21 UTC (rev 151855)
+++ branches/dfgFourthTier/Source/WTF/wtf/text/StringImpl.cpp 2013-06-21 21:27:45 UTC (rev 151856)
@@ -28,6 +28,7 @@
#include "AtomicString.h"
#include "StringBuffer.h"
#include "StringHash.h"
+#include <wtf/ProcessID.h>
#include <wtf/StdLibExtras.h>
#include <wtf/WTFThreadData.h>
#include <wtf/text/CString.h>
@@ -83,7 +84,7 @@
void StringStats::printStats()
{
- dataLogF("String stats for process id %d:\n", getpid());
+ dataLogF("String stats for process id %d:\n", getCurrentProcessID());
unsigned long long totalNumberCharacters = m_total8BitData + m_total16BitData;
double percent8Bit = m_totalNumberStrings ? ((double)m_number8BitStrings * 100) / (double)m_totalNumberStrings : 0.0;