Changeset 176836 in webkit for trunk/Source/JavaScriptCore/runtime/VM.cpp
- Timestamp:
- Dec 4, 2014, 9:58:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/VM.cpp
r176756 r176836 191 191 , m_builtinExecutables(std::make_unique<BuiltinExecutables>(*this)) 192 192 , m_typeProfilerEnabledCount(0) 193 , m_controlFlowProfilerEnabledCount(0) 193 194 { 194 195 interpreter = new Interpreter(*this); … … 282 283 if (Options::enableTypeProfiler()) 283 284 enableTypeProfiler(); 285 if (Options::enableControlFlowProfiler()) 286 enableControlFlowProfiler(); 284 287 } 285 288 … … 894 897 } 895 898 899 static bool enableProfilerWithRespectToCount(unsigned& counter, std::function<void()> doEnableWork) 900 { 901 bool needsToRecompile = false; 902 if (!counter) { 903 doEnableWork(); 904 needsToRecompile = true; 905 } 906 counter++; 907 908 return needsToRecompile; 909 } 910 911 static bool disableProfilerWithRespectToCount(unsigned& counter, std::function<void()> doDisableWork) 912 { 913 RELEASE_ASSERT(counter > 0); 914 bool needsToRecompile = false; 915 counter--; 916 if (!counter) { 917 doDisableWork(); 918 needsToRecompile = true; 919 } 920 921 return needsToRecompile; 922 } 923 896 924 bool VM::enableTypeProfiler() 897 925 { 898 bool needsToRecompile = false; 899 if (!m_typeProfilerEnabledCount) { 900 m_typeProfiler = std::make_unique<TypeProfiler>(); 901 m_typeProfilerLog = std::make_unique<TypeProfilerLog>(); 902 needsToRecompile = true; 903 } 904 m_typeProfilerEnabledCount++; 905 906 return needsToRecompile; 926 auto enableTypeProfiler = [this] () { 927 this->m_typeProfiler = std::make_unique<TypeProfiler>(); 928 this->m_typeProfilerLog = std::make_unique<TypeProfilerLog>(); 929 }; 930 931 return enableProfilerWithRespectToCount(m_typeProfilerEnabledCount, enableTypeProfiler); 907 932 } 908 933 909 934 bool VM::disableTypeProfiler() 910 935 { 911 RELEASE_ASSERT(m_typeProfilerEnabledCount > 0); 912 913 bool needsToRecompile = false; 914 m_typeProfilerEnabledCount--; 915 if (!m_typeProfilerEnabledCount) { 916 m_typeProfiler.reset(nullptr); 917 m_typeProfilerLog.reset(nullptr); 918 needsToRecompile = true; 919 } 920 921 return needsToRecompile; 936 auto disableTypeProfiler = [this] () { 937 this->m_typeProfiler.reset(nullptr); 938 this->m_typeProfilerLog.reset(nullptr); 939 }; 940 941 return disableProfilerWithRespectToCount(m_typeProfilerEnabledCount, disableTypeProfiler); 942 } 943 944 bool VM::enableControlFlowProfiler() 945 { 946 auto enableControlFlowProfiler = [this] () { 947 this->m_controlFlowProfiler = std::make_unique<ControlFlowProfiler>(); 948 }; 949 950 return enableProfilerWithRespectToCount(m_controlFlowProfilerEnabledCount, enableControlFlowProfiler); 951 } 952 953 bool VM::disableControlFlowProfiler() 954 { 955 auto disableControlFlowProfiler = [this] () { 956 this->m_controlFlowProfiler.reset(nullptr); 957 }; 958 959 return disableProfilerWithRespectToCount(m_controlFlowProfilerEnabledCount, disableControlFlowProfiler); 922 960 } 923 961 … … 928 966 929 967 typeProfilerLog()->processLogEntries(ASCIILiteral("VM Dump Types")); 930 typeProfiler()->dumpTypeProfilerData( );968 typeProfiler()->dumpTypeProfilerData(*this); 931 969 } 932 970
Note:
See TracChangeset
for help on using the changeset viewer.