Changeset 34065 in webkit for trunk/JavaScriptCore
- Timestamp:
- May 23, 2008, 1:56:21 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r34062 r34065 1 2008-05-23 Oliver Hunt <[email protected]> 2 3 <rdar://problem/5951561> Turn on JavaScript Profiler 4 5 Reviewed by Kevin McCullough. 6 7 Flipped the switch on the profiler, rearranged how we 8 signal the the profiler is active so that calls aren't 9 needed in the general case. 10 11 Also fixed the entry point for Machine::execute(FunctionBodyNode..) 12 to correctly indicate function exit. 13 14 Results in a 0.7-1.0% regression in SunSpider :-( 15 16 * VM/Machine.cpp: 17 (KJS::callEval): 18 (KJS::Machine::unwindCallFrame): 19 (KJS::Machine::execute): 20 (KJS::Machine::privateExecute): 21 * kjs/config.h: 22 * profiler/Profiler.cpp: 23 (KJS::Profiler::profiler): 24 (KJS::Profiler::startProfiling): 25 (KJS::Profiler::stopProfiling): 26 * profiler/Profiler.h: 27 (KJS::Profiler::enabledProfilerReference): 28 1 29 2008-05-23 Simon Hausmann <[email protected]> 2 30 -
trunk/JavaScriptCore/VM/Machine.cpp
r34037 r34065 438 438 } 439 439 440 static NEVER_INLINE JSValue* callEval(ExecState* exec, JSObject* thisObj, ScopeChainNode* scopeChain, RegisterFile* registerFile, Register* r, int argv, int argc, JSValue*& exceptionValue) 441 { 440 442 #if JAVASCRIPT_PROFILING 441 static NEVER_INLINE JSValue* callEval(ExecState* exec, JSObject* evalFunction, JSObject* thisObj, ScopeChainNode* scopeChain, RegisterFile* registerFile, Register* r, int argv, int argc, JSValue*& exceptionValue) 442 { 443 Profiler::profiler()->willExecute(exec, evalFunction); 444 #else 445 static NEVER_INLINE JSValue* callEval(ExecState* exec, JSObject* thisObj, ScopeChainNode* scopeChain, RegisterFile* registerFile, Register* r, int argv, int argc, JSValue*& exceptionValue) 446 { 443 Profiler** profiler = Profiler::enabledProfilerReference(); 444 JSObject* evalFunction = scopeChain->globalObject()->evalFunction(); 445 if (*profiler) 446 (*profiler)->willExecute(exec, evalFunction); 447 447 #endif 448 448 … … 472 472 JSValue* result = machine().execute(evalNode.get(), exec, thisObj, registerFile, r - (*registerFile->basePointer()) + argv + argc, scopeChain, &exceptionValue); 473 473 474 Profiler::profiler()->didExecute(exec, evalFunction); 474 if ((*profiler)) 475 (*profiler)->didExecute(exec, evalFunction); 475 476 476 477 return result; … … 608 609 609 610 #if JAVASCRIPT_PROFILING 610 Profiler::profiler()->didExecute(exec, callFrame[Callee].u.jsObject); 611 if (Profiler* profiler = *Profiler::enabledProfilerReference()) 612 profiler->didExecute(exec, callFrame[Callee].u.jsObject); 611 613 #endif 612 614 return true; … … 658 660 } 659 661 660 #if JAVASCRIPT_PROFILING661 Profiler::profiler()->willExecute(exec, programNode->sourceURL(), programNode->lineNo());662 #endif663 664 662 RegisterFile* registerFile = registerFileStack->pushGlobalRegisterFile(); 665 663 ASSERT(registerFile->numGlobalSlots()); … … 674 672 if (codeBlock->needsFullScopeChain) 675 673 scopeChain = scopeChain->copy(); 676 674 675 #if JAVASCRIPT_PROFILING 676 Profiler** profiler = Profiler::enabledProfilerReference(); 677 if (*profiler) 678 (*profiler)->willExecute(exec, programNode->sourceURL(), programNode->lineNo()); 679 #endif 680 677 681 ExecState newExec(exec, this, registerFile, scopeChain, -1); 678 682 … … 684 688 685 689 #if JAVASCRIPT_PROFILING 686 Profiler::profiler()->didExecute(exec, programNode->sourceURL(), programNode->lineNo()); 690 if (*profiler) 691 (*profiler)->didExecute(exec, programNode->sourceURL(), programNode->lineNo()); 687 692 #endif 688 693 … … 696 701 return 0; 697 702 } 698 699 #if JAVASCRIPT_PROFILING700 Profiler::profiler()->willExecute(exec, function);701 #endif702 703 703 704 RegisterFile* registerFile = registerFileStack->current(); … … 738 739 739 740 ExecState newExec(exec, this, registerFile, scopeChain, callFrameOffset); 741 742 #if JAVASCRIPT_PROFILING 743 Profiler** profiler = Profiler::enabledProfilerReference(); 744 if (*profiler) 745 (*profiler)->willExecute(exec, function); 746 #endif 740 747 741 748 m_reentryDepth++; … … 743 750 m_reentryDepth--; 744 751 752 #if JAVASCRIPT_PROFILING 753 if (*profiler) 754 (*profiler)->didExecute(exec, function); 755 #endif 745 756 registerFile->shrink(oldSize); 746 757 return result; … … 753 764 return 0; 754 765 } 755 756 #if JAVASCRIPT_PROFILING757 Profiler::profiler()->willExecute(exec, evalNode->sourceURL(), evalNode->lineNo());758 #endif759 766 760 767 EvalCodeBlock* codeBlock = &evalNode->code(scopeChain); … … 798 805 scopeChain = scopeChain->copy(); 799 806 807 #if JAVASCRIPT_PROFILING 808 Profiler** profiler = Profiler::enabledProfilerReference(); 809 if (*profiler) 810 (*profiler)->willExecute(exec, evalNode->sourceURL(), evalNode->lineNo()); 811 #endif 812 800 813 ExecState newExec(exec, this, registerFile, scopeChain, -1); 801 814 … … 807 820 808 821 #if JAVASCRIPT_PROFILING 809 Profiler::profiler()->didExecute(exec, evalNode->sourceURL(), evalNode->lineNo()); 822 if (*profiler) 823 (*profiler)->didExecute(exec, evalNode->sourceURL(), evalNode->lineNo()); 810 824 #endif 811 825 … … 880 894 JSValue* exceptionValue = 0; 881 895 Instruction* handlerVPC = 0; 882 896 883 897 Register** registerBase = registerFile->basePointer(); 884 898 Instruction* vPC = codeBlock->instructions.begin(); 885 899 JSValue** k = codeBlock->jsValues.data(); 900 #if JAVASCRIPT_PROFILING 901 Profiler** enabledProfilerReference = Profiler::enabledProfilerReference(); 902 903 #if HAVE(COMPUTED_GOTO) 904 // Yet another hack around GCC's various foibles, in this case fetching the 905 // profiler reference results in a regression. Removing this indirection 906 // results in a 0.8% regression. 907 goto *(&&profilerFetchHack); 908 profilerFetchHack: 909 #endif 910 911 #endif 886 912 887 913 registerFile->setSafeForReentry(false); … … 1856 1882 1857 1883 registerFile->setSafeForReentry(true); 1858 #if JAVASCRIPT_PROFILING 1859 JSValue* result = callEval(exec, static_cast<JSObject*>(funcVal), thisObject, scopeChain, registerFile, r, argv, argc, exceptionValue); 1860 #else 1884 1861 1885 JSValue* result = callEval(exec, thisObject, scopeChain, registerFile, r, argv, argc, exceptionValue); 1862 #endif 1886 1863 1887 registerFile->setSafeForReentry(false); 1864 1888 r = (*registerBase) + registerOffset; … … 1901 1925 if (callType == CallTypeJS) { 1902 1926 #if JAVASCRIPT_PROFILING 1903 Profiler::profiler()->willExecute(exec, static_cast<JSObject*>(v)); 1927 if (*enabledProfilerReference) 1928 (*enabledProfilerReference)->willExecute(exec, static_cast<JSObject*>(v)); 1904 1929 #endif 1905 1930 int registerOffset = r - (*registerBase); … … 1929 1954 if (callType == CallTypeNative) { 1930 1955 #if JAVASCRIPT_PROFILING 1931 Profiler::profiler()->willExecute(exec, static_cast<JSObject*>(v)); 1956 if (*enabledProfilerReference) 1957 (*enabledProfilerReference)->willExecute(exec, static_cast<JSObject*>(v)); 1932 1958 #endif 1933 1959 int registerOffset = r - (*registerBase); … … 1946 1972 1947 1973 #if JAVASCRIPT_PROFILING 1948 Profiler::profiler()->didExecute(exec, static_cast<JSObject*>(v)); 1974 if (*enabledProfilerReference) 1975 (*enabledProfilerReference)->didExecute(exec, static_cast<JSObject*>(v)); 1949 1976 #endif 1950 1977 VM_CHECK_EXCEPTION(); … … 1995 2022 1996 2023 #if JAVASCRIPT_PROFILING 1997 Profiler::profiler()->didExecute(exec, callFrame[Callee].u.jsObject); 2024 if (*enabledProfilerReference) 2025 (*enabledProfilerReference)->didExecute(exec, callFrame[Callee].u.jsObject); 1998 2026 #endif 1999 2027 NEXT_OPCODE; … … 2015 2043 if (constructType == ConstructTypeJS) { 2016 2044 #if JAVASCRIPT_PROFILING 2017 Profiler::profiler()->willExecute(exec, constructor); 2045 if (*enabledProfilerReference) 2046 (*enabledProfilerReference)->willExecute(exec, constructor); 2018 2047 #endif 2019 2048 int registerOffset = r - (*registerBase); … … 2051 2080 if (constructType == ConstructTypeNative) { 2052 2081 #if JAVASCRIPT_PROFILING 2053 Profiler::profiler()->willExecute(exec, constructor); 2082 if (*enabledProfilerReference) 2083 (*enabledProfilerReference)->willExecute(exec, constructor); 2054 2084 #endif 2055 2085 int registerOffset = r - (*registerBase); … … 2065 2095 2066 2096 #if JAVASCRIPT_PROFILING 2067 Profiler::profiler()->didExecute(exec, constructor); 2097 if (*enabledProfilerReference) 2098 (*enabledProfilerReference)->didExecute(exec, constructor); 2068 2099 #endif 2069 2100 ++vPC; -
trunk/JavaScriptCore/kjs/config.h
r34004 r34065 87 87 #endif 88 88 89 #define JAVASCRIPT_PROFILING 089 #define JAVASCRIPT_PROFILING 1 -
trunk/JavaScriptCore/profiler/Profiler.cpp
r34054 r34065 40 40 namespace KJS { 41 41 42 static Profiler* sharedProfiler = 0;43 42 static const char* GlobalCodeExecution = "(program)"; 44 43 static const char* AnonymousFunction = "(anonymous function)"; … … 48 47 static CallIdentifier createCallIdentifierFromFunctionImp(FunctionImp*); 49 48 49 Profiler* Profiler::s_sharedProfiler = 0; 50 Profiler* Profiler::s_sharedEnabledProfilerReference = 0; 51 50 52 Profiler* Profiler::profiler() 51 53 { 52 if (!s haredProfiler)53 s haredProfiler = new Profiler;54 return s haredProfiler;55 } 56 54 if (!s_sharedProfiler) 55 s_sharedProfiler = new Profiler(); 56 return s_sharedProfiler; 57 } 58 57 59 Profile* Profiler::findProfile(ExecState* exec, const UString& title) const 58 60 { … … 74 76 if (m_currentProfiles[i]->originatingGlobalExec() == globalExec && m_currentProfiles[i]->title() == title) 75 77 return; 76 78 s_sharedEnabledProfilerReference = this; 77 79 RefPtr<Profile> profile = Profile::create(title, globalExec, exec->lexicalGlobalObject()->pageGroupIdentifier()); 78 80 m_currentProfiles.append(profile); … … 88 90 PassRefPtr<Profile> prpProfile = m_currentProfiles[i].release(); 89 91 m_currentProfiles.remove(i); 92 if (!m_currentProfiles.size()) 93 s_sharedEnabledProfilerReference = 0; 90 94 return prpProfile; 91 95 } -
trunk/JavaScriptCore/profiler/Profiler.h
r34013 r34065 40 40 class Profiler { 41 41 public: 42 static Profiler* profiler(); 42 static Profiler** enabledProfilerReference() 43 { 44 return &s_sharedEnabledProfilerReference; 45 } 46 47 static Profiler* profiler(); 43 48 44 49 void startProfiling(ExecState*, const UString& title); … … 56 61 private: 57 62 Vector<RefPtr<Profile> > m_currentProfiles; 63 static Profiler* s_sharedProfiler; 64 static Profiler* s_sharedEnabledProfilerReference; 58 65 }; 59 66
Note:
See TracChangeset
for help on using the changeset viewer.