Ignore:
Timestamp:
Mar 26, 2013, 2:43:27 PM (12 years ago)
Author:
[email protected]
Message:

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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.h

    r140718 r146932  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4646    JS_EXPORT_PRIVATE ~Database();
    4747   
     48    int databaseID() const { return m_databaseID; }
     49   
    4850    Bytecodes* ensureBytecodesFor(CodeBlock*);
    4951    void notifyDestruction(CodeBlock*);
     
    6668    JS_EXPORT_PRIVATE bool save(const char* filename) const;
    6769
     70    void registerToSaveAtExit(const char* filename);
     71   
    6872private:
    6973
     74    void addDatabaseToAtExit();
     75    void removeDatabaseFromAtExit();
     76    void performAtExitSave() const;
     77    static Database* removeFirstAtExitDatabase();
     78    static void atExitCallback();
     79   
     80    int m_databaseID;
    7081    JSGlobalData& m_globalData;
    7182    SegmentedVector<Bytecodes> m_bytecodes;
    7283    HashMap<CodeBlock*, Bytecodes*> m_bytecodesMap;
    7384    Vector<RefPtr<Compilation> > m_compilations;
     85    bool m_shouldSaveAtExit;
     86    CString m_atExitSaveFilename;
     87    Database* m_nextRegisteredDatabase;
    7488};
    7589
Note: See TracChangeset for help on using the changeset viewer.