Changeset 106197 in webkit


Ignore:
Timestamp:
Jan 28, 2012 7:47:13 PM (12 years ago)
Author:
barraclough@apple.com
Message:

Implement a JIT-code aware sampling profiler for JSC
https://bugs.webkit.org/show_bug.cgi?id=76855

Reviewed by Oliver Hunt.

To enable the profiler, set the JSC_CODE_PROFILING environment variable to
1 (no tracing the C stack), 2 (trace one level of C code) or 3 (recursively
trace all samples).

The profiler requires -fomit-frame-pointer to be removed from the build flags.

  • JavaScriptCore.exp:
    • Removed an export.
  • JavaScriptCore.xcodeproj/project.pbxproj:
    • Added new files
  • bytecode/CodeBlock.cpp:
    • For baseline codeblocks, cache the result of canCompileWithDFG.
  • bytecode/CodeBlock.h:
    • For baseline codeblocks, cache the result of canCompileWithDFG.
  • jit/ExecutableAllocator.cpp:

(JSC::ExecutableAllocator::initializeAllocator):

  • Notify the profiler when the allocator is created.

(JSC::ExecutableAllocator::allocate):

  • Inform the allocated of the ownerUID.
  • jit/ExecutableAllocatorFixedVMPool.cpp:

(JSC::ExecutableAllocator::initializeAllocator):

  • Notify the profiler when the allocator is created.

(JSC::ExecutableAllocator::allocate):

  • Inform the allocated of the ownerUID.
  • jit/JITStubs.cpp:
    • If profiling, don't mask the return address in JIT code. (We do so to provide nicer backtraces in debug builds).
  • runtime/Completion.cpp:

(JSC::evaluate):

  • Notify the profiler of script evaluations.
  • tools: Added.
  • tools/CodeProfile.cpp: Added.

(JSC::symbolName):

  • Helper function to get the name of a symbol in the framework.

(JSC::truncateTrace):

  • Helper to truncate traces into methods know to have uninformatively deep stacks.

(JSC::CodeProfile::sample):

  • Record a stack trace classifying samples.

(JSC::CodeProfile::report):

  • {Print profiler output.
  • tools/CodeProfile.h: Added.
    • new class, captures a set of samples associated with an evaluated script, and nested to record samples from subscripts.
  • tools/CodeProfiling.cpp: Added.

(JSC::CodeProfiling::profilingTimer):

  • callback fired then a timer event occurs.

(JSC::CodeProfiling::notifyAllocator):

  • called when the executable allocator is constructed.

(JSC::CodeProfiling::getOwnerUIDForPC):

  • helper to lookup the codeblock from an address in JIT code

(JSC::CodeProfiling::begin):

  • enter a profiling scope.

(JSC::CodeProfiling::end):

  • exit a profiling scope.
  • tools/CodeProfiling.h: Added.
    • new class, instantialed from Completion to define a profiling scope.
  • tools/ProfileTreeNode.h: Added.
    • new class, used to construct a tree of samples.
  • tools/TieredMMapArray.h: Added.
    • new class, a malloc-free vector (can be used while the main thread is suspended, possibly holding the malloc heap lock).
  • wtf/MetaAllocator.cpp:

(WTF::MetaAllocatorHandle::MetaAllocatorHandle):
(WTF::MetaAllocator::allocate):

  • Allow allocation handles to track information about their owner.
  • wtf/MetaAllocator.h:

(MetaAllocator):

  • Allow allocation handles to track information about their owner.
  • wtf/MetaAllocatorHandle.h:

(MetaAllocatorHandle):
(WTF::MetaAllocatorHandle::ownerUID):

  • Allow allocation handles to track information about their owner.
  • wtf/OSAllocator.h:

(WTF::OSAllocator::reallocateCommitted):

  • reallocate an existing, committed memory allocation.
Location:
trunk/Source/JavaScriptCore
Files:
7 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r106078 r106197  
    1515    "${JAVASCRIPTCORE_DIR}/profiler"
    1616    "${JAVASCRIPTCORE_DIR}/runtime"
     17    "${JAVASCRIPTCORE_DIR}/tools"
    1718    "${JAVASCRIPTCORE_DIR}/yarr"
    1819    "${JAVASCRIPTCORE_DIR}/wtf"
     
    201202    runtime/UString.cpp
    202203
     204    tools/CodeProfile.cpp
     205    tools/CodeProfiling.cpp
     206
    203207    yarr/YarrPattern.cpp
    204208    yarr/YarrInterpreter.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r106189 r106197  
     12012-01-27  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Implement a JIT-code aware sampling profiler for JSC
     4        https://bugs.webkit.org/show_bug.cgi?id=76855
     5
     6        Reviewed by Oliver Hunt.
     7
     8        To enable the profiler, set the JSC_CODE_PROFILING environment variable to
     9        1 (no tracing the C stack), 2 (trace one level of C code) or 3 (recursively
     10        trace all samples).
     11
     12        The profiler requires -fomit-frame-pointer to be removed from the build flags.
     13
     14        * JavaScriptCore.exp:
     15            - Removed an export.
     16        * JavaScriptCore.xcodeproj/project.pbxproj:
     17            - Added new files
     18        * bytecode/CodeBlock.cpp:
     19            - For baseline codeblocks, cache the result of canCompileWithDFG.
     20        * bytecode/CodeBlock.h:
     21            - For baseline codeblocks, cache the result of canCompileWithDFG.
     22        * jit/ExecutableAllocator.cpp:
     23        (JSC::ExecutableAllocator::initializeAllocator):
     24            - Notify the profiler when the allocator is created.
     25        (JSC::ExecutableAllocator::allocate):
     26            - Inform the allocated of the ownerUID.
     27        * jit/ExecutableAllocatorFixedVMPool.cpp:
     28        (JSC::ExecutableAllocator::initializeAllocator):
     29            - Notify the profiler when the allocator is created.
     30        (JSC::ExecutableAllocator::allocate):
     31            - Inform the allocated of the ownerUID.
     32        * jit/JITStubs.cpp:
     33            - If profiling, don't mask the return address in JIT code.
     34              (We do so to provide nicer backtraces in debug builds).
     35        * runtime/Completion.cpp:
     36        (JSC::evaluate):
     37            - Notify the profiler of script evaluations.
     38        * tools: Added.
     39        * tools/CodeProfile.cpp: Added.
     40        (JSC::symbolName):
     41            - Helper function to get the name of a symbol in the framework.
     42        (JSC::truncateTrace):
     43            - Helper to truncate traces into methods know to have uninformatively deep stacks.
     44        (JSC::CodeProfile::sample):
     45            - Record a stack trace classifying samples.
     46        (JSC::CodeProfile::report):
     47            - {Print profiler output.
     48        * tools/CodeProfile.h: Added.
     49            - new class, captures a set of samples associated with an evaluated script,
     50              and nested to record samples from subscripts.
     51        * tools/CodeProfiling.cpp: Added.
     52        (JSC::CodeProfiling::profilingTimer):
     53            - callback fired then a timer event occurs.
     54        (JSC::CodeProfiling::notifyAllocator):
     55            - called when the executable allocator is constructed.
     56        (JSC::CodeProfiling::getOwnerUIDForPC):
     57            - helper to lookup the codeblock from an address in JIT code
     58        (JSC::CodeProfiling::begin):
     59            - enter a profiling scope.
     60        (JSC::CodeProfiling::end):
     61            - exit a profiling scope.
     62        * tools/CodeProfiling.h: Added.
     63            - new class, instantialed from Completion to define a profiling scope.
     64        * tools/ProfileTreeNode.h: Added.
     65            - new class, used to construct a tree of samples.
     66        * tools/TieredMMapArray.h: Added.
     67            - new class, a malloc-free vector (can be used while the main thread is suspended,
     68              possibly holding the malloc heap lock).
     69        * wtf/MetaAllocator.cpp:
     70        (WTF::MetaAllocatorHandle::MetaAllocatorHandle):
     71        (WTF::MetaAllocator::allocate):
     72            - Allow allocation handles to track information about their owner.
     73        * wtf/MetaAllocator.h:
     74        (MetaAllocator):
     75            - Allow allocation handles to track information about their owner.
     76        * wtf/MetaAllocatorHandle.h:
     77        (MetaAllocatorHandle):
     78        (WTF::MetaAllocatorHandle::ownerUID):
     79            - Allow allocation handles to track information about their owner.
     80        * wtf/OSAllocator.h:
     81        (WTF::OSAllocator::reallocateCommitted):
     82            - reallocate an existing, committed memory allocation.
     83
    1842012-01-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    285
  • trunk/Source/JavaScriptCore/GNUmakefile.am

    r104289 r106197  
    6161        -I$(srcdir)/Source/JavaScriptCore/profiler \
    6262        -I$(srcdir)/Source/JavaScriptCore/runtime \
     63        -I$(srcdir)/Source/JavaScriptCore/tools \
    6364        -I$(srcdir)/Source/JavaScriptCore/wtf \
    6465        -I$(srcdir)/Source/JavaScriptCore/wtf \
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r106078 r106197  
    526526        Source/JavaScriptCore/runtime/WeakRandom.h \
    527527        Source/JavaScriptCore/runtime/WriteBarrier.h \
     528        Source/JavaScriptCore/tools/CodeProfile.cpp \
     529        Source/JavaScriptCore/tools/CodeProfile.h \
     530        Source/JavaScriptCore/tools/CodeProfiling.cpp \
     531        Source/JavaScriptCore/tools/CodeProfiling.h \
     532        Source/JavaScriptCore/tools/ProfileTreeNode.h \
     533        Source/JavaScriptCore/tools/TieredMMapArray.h \
    528534        Source/JavaScriptCore/wtf/Alignment.h \
    529535        Source/JavaScriptCore/wtf/AlwaysInline.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r106101 r106197  
    416416__ZN3WTF13MetaAllocator17freeFreeSpaceNodeEPNS0_13FreeSpaceNodeE
    417417__ZN3WTF13MetaAllocator18debugFreeSpaceSizeEv
    418 __ZN3WTF13MetaAllocator8allocateEm
    419418__ZN3WTF13MetaAllocatorC2Em
    420419__ZN3WTF13StringBuilder11shrinkToFitEv
  • trunk/Source/JavaScriptCore/JavaScriptCore.pri

    r105995 r106197  
    2424    $$SOURCE_DIR/profiler \
    2525    $$SOURCE_DIR/runtime \
     26    $$SOURCE_DIR/tools \
    2627    $$SOURCE_DIR/yarr \
    2728    $$SOURCE_DIR/API \
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r106078 r106197  
    14481448                </Filter>
    14491449                <Filter
     1450                        Name="tools"
     1451                        >
     1452                        <File
     1453                                RelativePath="..\..\tools\CodeProfile.cpp"
     1454                                >
     1455                        </File>
     1456                        <File
     1457                                RelativePath="..\..\tools\CodeProfile.h"
     1458                                >
     1459                        </File>
     1460                        <File
     1461                                RelativePath="..\..\tools\CodeProfiling.cpp"
     1462                                >
     1463                        </File>
     1464                        <File
     1465                                RelativePath="..\..\tools\CodeProfiling.h"
     1466                                >
     1467                        </File>
     1468                        <File
     1469                                RelativePath="..\..\tools\ProfileTreeNode.h"
     1470                                >
     1471                        </File>
     1472                        <File
     1473                                RelativePath="..\..\tools\TieredMMapArray.h"
     1474                                >
     1475                        </File>
     1476                </Filter>
     1477                <Filter
    14501478                        Name="bytecode"
    14511479                        >
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops

    r94559 r106197  
    77        <Tool
    88                Name="VCCLCompilerTool"
    9                 AdditionalIncludeDirectories="&quot;$(ConfigurationBuildDir)\obj\JavaScriptCore\DerivedSources\&quot;;../../;../../API/;../../parser/;../../bytecompiler/;../../dfg/;../../jit/;../../runtime/;../../bytecode/;../../interpreter/;../../wtf/;../../profiler;../../assembler/;../../debugger/;../../heap/;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(ConfigurationBuildDir)\include&quot;;&quot;$(ConfigurationBuildDir)\include\JavaScriptCore&quot;;&quot;$(ConfigurationBuildDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;"
     9                AdditionalIncludeDirectories="&quot;$(ConfigurationBuildDir)\obj\JavaScriptCore\DerivedSources\&quot;;../../;../../API/;../../parser/;../../bytecompiler/;../../dfg/;../../jit/;../../runtime/;../../tools/;../../bytecode/;../../interpreter/;../../wtf/;../../profiler;../../assembler/;../../debugger/;../../heap/;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitLibrariesDir)\include\private&quot;;&quot;$(ConfigurationBuildDir)\include&quot;;&quot;$(ConfigurationBuildDir)\include\JavaScriptCore&quot;;&quot;$(ConfigurationBuildDir)\include\private&quot;;&quot;$(WebKitLibrariesDir)\include\pthreads&quot;"
    1010                PreprocessorDefinitions="__STD_C"
    1111                ForcedIncludeFiles="ICUVersion.h"
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r106078 r106197  
    383383                86AE6C4D136A11E400963012 /* DFGFPRInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 86AE6C4B136A11E400963012 /* DFGFPRInfo.h */; };
    384384                86AE6C4E136A11E400963012 /* DFGGPRInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 86AE6C4C136A11E400963012 /* DFGGPRInfo.h */; };
     385                86B5826714D2796C00A9C306 /* CodeProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86B5822E14D2373B00A9C306 /* CodeProfile.cpp */; };
     386                86B5826914D2797000A9C306 /* CodeProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8603CEF214C7546400AE59E3 /* CodeProfiling.cpp */; };
    385387                86B99AE3117E578100DF5A90 /* StringBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 86B99AE1117E578100DF5A90 /* StringBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    386388                86BB09C0138E381B0056702F /* DFGRepatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BB09BE138E381B0056702F /* DFGRepatch.cpp */; };
     
    10431045                1AA9E5501498093500001A8A /* Functional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Functional.h; sourceTree = "<group>"; };
    10441046                1C9051420BA9E8A70081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
    1045                 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = JavaScriptCore.xcconfig; path = ../Configurations/JavaScriptCore.xcconfig; sourceTree = "<group>"; };
     1047                1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = JavaScriptCore.xcconfig; sourceTree = "<group>"; };
    10461048                1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
    10471049                1C9051450BA9E8A70081E9D0 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
     
    11391141                860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86_64.h; sourceTree = "<group>"; };
    11401142                860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86Common.h; sourceTree = "<group>"; };
     1143                8603CEF214C7546400AE59E3 /* CodeProfiling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeProfiling.cpp; sourceTree = "<group>"; };
     1144                8603CEF314C7546400AE59E3 /* CodeProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeProfiling.h; sourceTree = "<group>"; };
    11411145                8604F4F2143A6C4400B295F5 /* ChangeLog */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; };
    11421146                8604F503143CE1C100B295F5 /* JSGlobalThis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalThis.h; sourceTree = "<group>"; };
     
    11861190                86AE6C4B136A11E400963012 /* DFGFPRInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGFPRInfo.h; path = dfg/DFGFPRInfo.h; sourceTree = "<group>"; };
    11871191                86AE6C4C136A11E400963012 /* DFGGPRInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGGPRInfo.h; path = dfg/DFGGPRInfo.h; sourceTree = "<group>"; };
     1192                86B5822C14D22F5F00A9C306 /* ProfileTreeNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileTreeNode.h; sourceTree = "<group>"; };
     1193                86B5822E14D2373B00A9C306 /* CodeProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CodeProfile.cpp; sourceTree = "<group>"; };
     1194                86B5822F14D2373B00A9C306 /* CodeProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeProfile.h; sourceTree = "<group>"; };
     1195                86B5826A14D35D5100A9C306 /* TieredMMapArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TieredMMapArray.h; sourceTree = "<group>"; };
    11881196                86B99AE1117E578100DF5A90 /* StringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringBuffer.h; path = text/StringBuffer.h; sourceTree = "<group>"; };
    11891197                86BB09BE138E381B0056702F /* DFGRepatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGRepatch.cpp; path = dfg/DFGRepatch.cpp; sourceTree = "<group>"; };
     
    16811689                                7EF6E0BB0EB7A1EC0079AFAF /* runtime */,
    16821690                                141211000A48772600480255 /* tests */,
     1691                                8603CEF014C753EF00AE59E3 /* tools */,
    16831692                                65162EF108E6A21C007556CD /* wtf */,
    16841693                                86EAC48C0F93E8B9008EC948 /* yarr */,
     
    18271836                                1CAA8B4A0D32C39A0041BCFF /* JavaScript.h */,
    18281837                                1CAA8B4B0D32C39A0041BCFF /* JavaScriptCore.h */,
    1829                                 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */,
    18301838                                BC0894D50FAFBA2D00001865 /* JSAPIValueWrapper.cpp */,
    18311839                                BC0894D60FAFBA2D00001865 /* JSAPIValueWrapper.h */,
     
    19171925                                449097EE0F8F81B50076A327 /* FeatureDefines.xcconfig */,
    19181926                                5DAFD6CB146B686300FBEFB4 /* JSC.xcconfig */,
     1927                                1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */,
    19191928                                BC021BF2136900C300FC5467 /* TestAPI.xcconfig */,
    19201929                                5DAFD6CC146B68B900FBEFB4 /* TestRegExp.xcconfig */,
     
    23642373                        );
    23652374                        path = runtime;
     2375                        sourceTree = "<group>";
     2376                };
     2377                8603CEF014C753EF00AE59E3 /* tools */ = {
     2378                        isa = PBXGroup;
     2379                        children = (
     2380                                86B5822E14D2373B00A9C306 /* CodeProfile.cpp */,
     2381                                86B5822F14D2373B00A9C306 /* CodeProfile.h */,
     2382                                8603CEF214C7546400AE59E3 /* CodeProfiling.cpp */,
     2383                                8603CEF314C7546400AE59E3 /* CodeProfiling.h */,
     2384                                86B5822C14D22F5F00A9C306 /* ProfileTreeNode.h */,
     2385                                86B5826A14D35D5100A9C306 /* TieredMMapArray.h */,
     2386                        );
     2387                        path = tools;
    23662388                        sourceTree = "<group>";
    23672389                };
     
    36413663                                0F9332A314CA7DD70085F3C6 /* PutByIdStatus.cpp in Sources */,
    36423664                                0F55F0F414D1063900AC7649 /* AbstractPC.cpp in Sources */,
     3665                                86B5826714D2796C00A9C306 /* CodeProfile.cpp in Sources */,
     3666                                86B5826914D2797000A9C306 /* CodeProfiling.cpp in Sources */,
    36433667                        );
    36443668                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/Target.pri

    r106078 r106197  
    210210    runtime/TimeoutChecker.cpp \
    211211    runtime/UString.cpp \
     212    tools/CodeProfile.cpp \
     213    tools/CodeProfiling.cpp \
    212214    yarr/YarrJIT.cpp \
    213215
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r105698 r106197  
    14571457    , m_optimizationDelayCounter(0)
    14581458    , m_reoptimizationRetryCounter(0)
     1459    , m_canCompileWithDFGState(CompileWithDFGUnset)
    14591460{
    14601461    setNumParameters(other.numParameters());
     
    21652166}
    21662167
    2167 bool ProgramCodeBlock::canCompileWithDFG()
     2168bool ProgramCodeBlock::canCompileWithDFGInternal()
    21682169{
    21692170    return DFG::canCompileProgram(this);
    21702171}
    21712172
    2172 bool EvalCodeBlock::canCompileWithDFG()
     2173bool EvalCodeBlock::canCompileWithDFGInternal()
    21732174{
    21742175    return DFG::canCompileEval(this);
    21752176}
    21762177
    2177 bool FunctionCodeBlock::canCompileWithDFG()
     2178bool FunctionCodeBlock::canCompileWithDFGInternal()
    21782179{
    21792180    if (m_isConstructor)
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r106067 r106197  
    389389        virtual void jettison() = 0;
    390390        virtual CodeBlock* replacement() = 0;
    391         virtual bool canCompileWithDFG() = 0;
     391
     392        enum CompileWithDFGState {
     393            CompileWithDFGFalse,
     394            CompileWithDFGTrue,
     395            CompileWithDFGUnset
     396        };
     397
     398        virtual bool canCompileWithDFGInternal() = 0;
     399        bool canCompileWithDFG()
     400        {
     401            bool result = canCompileWithDFGInternal();
     402            m_canCompileWithDFGState = result ? CompileWithDFGTrue : CompileWithDFGFalse;
     403            return result;
     404        }
     405        CompileWithDFGState canCompileWithDFGState() { return m_canCompileWithDFGState; }
     406
    392407        bool hasOptimizedReplacement()
    393408        {
     
    11881203#endif
    11891204        OwnPtr<RareData> m_rareData;
     1205        CompileWithDFGState m_canCompileWithDFGState;
    11901206    };
    11911207
     
    12271243        virtual void jettison();
    12281244        virtual CodeBlock* replacement();
    1229         virtual bool canCompileWithDFG();
     1245        virtual bool canCompileWithDFGInternal();
    12301246#endif
    12311247    };
     
    12611277        virtual void jettison();
    12621278        virtual CodeBlock* replacement();
    1263         virtual bool canCompileWithDFG();
     1279        virtual bool canCompileWithDFGInternal();
    12641280#endif
    12651281
     
    12981314        virtual void jettison();
    12991315        virtual CodeBlock* replacement();
    1300         virtual bool canCompileWithDFG();
     1316        virtual bool canCompileWithDFGInternal();
    13011317#endif
    13021318    };
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp

    r105636 r106197  
    2929
    3030#if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
     31#include "CodeProfiling.h"
    3132#include <wtf/MetaAllocator.h>
    3233#include <wtf/PageReservation.h>
     
    9495    ASSERT(!allocator);
    9596    allocator = new DemandExecutableAllocator();
     97    CodeProfiling::notifyAllocator(allocator);
    9698}
    9799
     
    113115PassRefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(JSGlobalData&, size_t sizeInBytes, void* ownerUID)
    114116{
    115     UNUSED_PARAM(ownerUID);
    116 
    117     RefPtr<ExecutableMemoryHandle> result = allocator->allocate(sizeInBytes);
     117    RefPtr<ExecutableMemoryHandle> result = allocator->allocate(sizeInBytes, ownerUID);
    118118    if (!result)
    119119        CRASH();
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp

    r105636 r106197  
    3030#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
    3131
     32#include "CodeProfiling.h"
    3233#include <errno.h>
    33 
    3434#include <sys/mman.h>
    3535#include <unistd.h>
     
    9797    ASSERT(!allocator);
    9898    allocator = new FixedVMPoolExecutableAllocator();
     99    CodeProfiling::notifyAllocator(allocator);
    99100}
    100101
     
    117118PassRefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(JSGlobalData& globalData, size_t sizeInBytes, void* ownerUID)
    118119{
    119     UNUSED_PARAM(ownerUID);
    120 
    121     RefPtr<ExecutableMemoryHandle> result = allocator->allocate(sizeInBytes);
     120    RefPtr<ExecutableMemoryHandle> result = allocator->allocate(sizeInBytes, ownerUID);
    122121    if (!result) {
    123122        releaseExecutableMemory(globalData);
    124         result = allocator->allocate(sizeInBytes);
     123        result = allocator->allocate(sizeInBytes, ownerUID);
    125124        if (!result)
    126125            CRASH();
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r106185 r106197  
    3838#include "CallFrame.h"
    3939#include "CodeBlock.h"
     40#include "CodeProfiling.h"
    4041#include "DFGOSREntry.h"
    4142#include "Debugger.h"
     
    969970}
    970971
    971 #if !defined(NDEBUG) && !ENABLE(CODE_PROFILING)
     972#if !defined(NDEBUG)
    972973
    973974extern "C" {
     
    987988        , savedReturnAddress(*stackFrame.returnAddressSlot())
    988989    {
    989         *stackFrame.returnAddressSlot() = ReturnAddressPtr(FunctionPtr(jscGeneratedNativeCode));
     990        if (!CodeProfiling::enabled())
     991            *stackFrame.returnAddressSlot() = ReturnAddressPtr(FunctionPtr(jscGeneratedNativeCode));
    990992    }
    991993
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r94811 r106197  
    2525
    2626#include "CallFrame.h"
     27#include "CodeProfiling.h"
    2728#include "JSGlobalObject.h"
    2829#include "JSLock.h"
     
    5657    ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
    5758
     59    CodeProfiling profile(source);
     60
    5861    ProgramExecutable* program = ProgramExecutable::create(exec, source);
    5962    if (!program) {
  • trunk/Source/JavaScriptCore/wtf/MetaAllocator.cpp

    r105841 r106197  
    5656}
    5757
    58 MetaAllocatorHandle::MetaAllocatorHandle(MetaAllocator* allocator, void* start, size_t sizeInBytes)
     58MetaAllocatorHandle::MetaAllocatorHandle(MetaAllocator* allocator, void* start, size_t sizeInBytes, void* ownerUID)
    5959    : m_allocator(allocator)
    6060    , m_start(start)
    6161    , m_sizeInBytes(sizeInBytes)
     62    , m_ownerUID(ownerUID)
    6263{
    6364    ASSERT(allocator);
     
    130131}
    131132
    132 PassRefPtr<MetaAllocatorHandle> MetaAllocator::allocate(size_t sizeInBytes)
     133PassRefPtr<MetaAllocatorHandle> MetaAllocator::allocate(size_t sizeInBytes, void* ownerUID)
    133134{
    134135    SpinLockHolder locker(&m_lock);
     
    168169#endif
    169170
    170     MetaAllocatorHandle* handle = new MetaAllocatorHandle(this, start, sizeInBytes);
     171    MetaAllocatorHandle* handle = new MetaAllocatorHandle(this, start, sizeInBytes, ownerUID);
    171172    // FIXME: Implement a verifier scheme that groks MetaAllocatorHandles
    172173    handle->deprecatedTurnOffVerifier();
  • trunk/Source/JavaScriptCore/wtf/MetaAllocator.h

    r105841 r106197  
    6868    virtual ~MetaAllocator();
    6969   
    70     WTF_EXPORT_PRIVATE PassRefPtr<MetaAllocatorHandle> allocate(size_t sizeInBytes);
     70    WTF_EXPORT_PRIVATE PassRefPtr<MetaAllocatorHandle> allocate(size_t sizeInBytes, void* ownerUID);
    7171
    7272    void trackAllocations(MetaAllocatorTracker* tracker)
  • trunk/Source/JavaScriptCore/wtf/MetaAllocatorHandle.h

    r105841 r106197  
    4141class MetaAllocatorHandle : public RefCounted<MetaAllocatorHandle>, public RedBlackTree<MetaAllocatorHandle, void*>::Node {
    4242private:
    43     MetaAllocatorHandle(MetaAllocator*, void* start, size_t sizeInBytes);
     43    MetaAllocatorHandle(MetaAllocator*, void* start, size_t sizeInBytes, void* ownerUID);
    4444   
    4545public:
     
    7373        return m_allocator;
    7474    }
    75    
     75
     76    void* ownerUID()
     77    {
     78        return m_ownerUID;
     79    }
     80
    7681    void* key()
    7782    {
     
    8590    void* m_start;
    8691    size_t m_sizeInBytes;
     92    void* m_ownerUID;
    8793};
    8894
  • trunk/Source/JavaScriptCore/wtf/OSAllocator.h

    r104900 r106197  
    2727#define OSAllocator_h
    2828
     29#include <algorithm>
    2930#include <wtf/UnusedParam.h>
    3031#include <wtf/VMTags.h>
     
    6667    static void* reserveAndCommit(size_t reserveSize, size_t commitSize, Usage = UnknownUsage, bool writable = true, bool executable = false);
    6768    static void decommitAndRelease(void* releaseBase, size_t releaseSize, void* decommitBase, size_t decommitSize);
     69
     70    // Reallocate an existing, committed allocation.
     71    // The prior allocation must be fully comitted, and the new size will also be fully committed.
     72    // This interface is provided since it may be possible to optimize this operation on some platforms.
     73    template<typename T>
     74    static T* reallocateCommitted(T*, size_t oldSize, size_t newSize, Usage = UnknownUsage, bool writable = true, bool executable = false);
    6875};
    6976
     
    94101}
    95102
     103template<typename T>
     104inline T* OSAllocator::reallocateCommitted(T* oldBase, size_t oldSize, size_t newSize, Usage usage, bool writable, bool executable)
     105{
     106    void* newBase = reserveAndCommit(newSize, usage, writable, executable);
     107    memcpy(newBase, oldBase, std::min(oldSize, newSize));
     108    decommitAndRelease(oldBase, oldSize);
     109    return static_cast<T*>(newBase);
     110}
     111
    96112} // namespace WTF
    97113
Note: See TracChangeset for help on using the changeset viewer.