Changeset 48905 in webkit
- Timestamp:
- Sep 29, 2009 2:48:52 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r48898 r48905 1 2009-09-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Gavin Barraclough. 4 5 Tidy up codeblock sampler 6 https://bugs.webkit.org/show_bug.cgi?id=29836 7 8 Some rather simple refactoring of codeblock sampler so that 9 it's easier for us to use it to find problems in non-jsc 10 environments 11 12 * JavaScriptCore.exp: 13 * bytecode/SamplingTool.h: 14 * debugger/Debugger.cpp: 15 (JSC::evaluateInGlobalCallFrame): 16 * debugger/DebuggerCallFrame.cpp: 17 (JSC::DebuggerCallFrame::evaluate): 18 * interpreter/Interpreter.cpp: 19 (JSC::Interpreter::Interpreter): 20 (JSC::Interpreter::execute): 21 (JSC::Interpreter::privateExecute): 22 (JSC::Interpreter::enableSampler): 23 (JSC::Interpreter::dumpSampleData): 24 (JSC::Interpreter::startSampling): 25 (JSC::Interpreter::stopSampling): 26 * interpreter/Interpreter.h: 27 (JSC::Interpreter::sampler): 28 * jit/JIT.h: 29 * jsc.cpp: 30 (runWithScripts): 31 * runtime/Completion.cpp: 32 (JSC::checkSyntax): 33 (JSC::evaluate): 34 * runtime/Executable.h: 35 (JSC::EvalExecutable::EvalExecutable): 36 (JSC::ProgramExecutable::create): 37 (JSC::ProgramExecutable::ProgramExecutable): 38 * runtime/JSGlobalData.cpp: 39 (JSC::JSGlobalData::startSampling): 40 (JSC::JSGlobalData::stopSampling): 41 (JSC::JSGlobalData::dumpSampleData): 42 * runtime/JSGlobalData.h: 43 * runtime/JSGlobalObjectFunctions.cpp: 44 (JSC::globalFuncEval): 45 1 46 2009-09-29 Jeremy Orlow <jorlow@chromium.org> 2 47 -
trunk/JavaScriptCore/JavaScriptCore.exp
r48883 r48905 107 107 __ZN3JSC12JSGlobalData10ClientDataD2Ev 108 108 __ZN3JSC12JSGlobalData12createLeakedEv 109 __ZN3JSC12JSGlobalData12stopSamplingEv 110 __ZN3JSC12JSGlobalData13startSamplingEv 111 __ZN3JSC12JSGlobalData14dumpSampleDataEPNS_9ExecStateE 109 112 __ZN3JSC12JSGlobalData14sharedInstanceEv 110 113 __ZN3JSC12JSGlobalData6createEb 111 114 __ZN3JSC12JSGlobalDataD1Ev 112 __ZN3JSC12SamplingTool4dumpEPNS_9ExecStateE113 115 __ZN3JSC12SamplingTool5setupEv 114 116 __ZN3JSC12SmallStrings17createEmptyStringEPNS_12JSGlobalDataE -
trunk/JavaScriptCore/bytecode/SamplingTool.h
r48662 r48905 114 114 void sample(CodeBlock*, Instruction*); 115 115 116 ScriptExecutable*m_executable;116 RefPtr<ScriptExecutable> m_executable; 117 117 CodeBlock* m_codeBlock; 118 118 int m_sampleCount; -
trunk/JavaScriptCore/debugger/Debugger.cpp
r48662 r48905 101 101 CallFrame* globalCallFrame = globalObject->globalExec(); 102 102 103 EvalExecutable eval(globalCallFrame, makeSource(script));104 JSObject* error = eval .compile(globalCallFrame, globalCallFrame->scopeChain());103 RefPtr<EvalExecutable> eval = EvalExecutable::create(globalCallFrame, makeSource(script)); 104 JSObject* error = eval->compile(globalCallFrame, globalCallFrame->scopeChain()); 105 105 if (error) 106 106 return error; 107 107 108 return globalObject->globalData()->interpreter->execute( &eval, globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception);108 return globalObject->globalData()->interpreter->execute(eval.get(), globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception); 109 109 } 110 110 -
trunk/JavaScriptCore/debugger/DebuggerCallFrame.cpp
r48662 r48905 80 80 return JSValue(); 81 81 82 EvalExecutable eval(m_callFrame, makeSource(script));83 JSObject* error = eval .compile(m_callFrame, m_callFrame->scopeChain());82 RefPtr<EvalExecutable> eval = EvalExecutable::create(m_callFrame, makeSource(script)); 83 JSObject* error = eval->compile(m_callFrame, m_callFrame->scopeChain()); 84 84 if (error) 85 85 return error; 86 86 87 return m_callFrame->scopeChain()->globalData->interpreter->execute( &eval, m_callFrame, thisObject(), m_callFrame->scopeChain(), &exception);87 return m_callFrame->scopeChain()->globalData->interpreter->execute(eval.get(), m_callFrame, thisObject(), m_callFrame->scopeChain(), &exception); 88 88 } 89 89 -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r48774 r48905 364 364 365 365 Interpreter::Interpreter() 366 : m_sample r(0)366 : m_sampleEntryDepth(0) 367 367 , m_reentryDepth(0) 368 368 { 369 369 privateExecute(InitializeAndReturn, 0, 0, 0); 370 #if ENABLE(OPCODE_SAMPLING) 371 enableSampler(); 372 #endif 370 373 } 371 374 … … 649 652 JSValue result; 650 653 { 651 SamplingTool::CallRecord callRecord(m_sampler );654 SamplingTool::CallRecord callRecord(m_sampler.get()); 652 655 653 656 m_reentryDepth++; … … 715 718 JSValue result; 716 719 { 717 SamplingTool::CallRecord callRecord(m_sampler );720 SamplingTool::CallRecord callRecord(m_sampler.get()); 718 721 719 722 m_reentryDepth++; … … 783 786 JSValue result; 784 787 { 785 SamplingTool::CallRecord callRecord(m_sampler );788 SamplingTool::CallRecord callRecord(m_sampler.get()); 786 789 787 790 m_reentryDepth++; … … 877 880 JSValue result; 878 881 { 879 SamplingTool::CallRecord callRecord(m_sampler );882 SamplingTool::CallRecord callRecord(m_sampler.get()); 880 883 881 884 m_reentryDepth++; … … 3057 3060 JSValue returnValue; 3058 3061 { 3059 SamplingTool::HostCallRecord callRecord(m_sampler );3062 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 3060 3063 returnValue = callData.native.function(newCallFrame, asObject(v), thisValue, args); 3061 3064 } … … 3211 3214 JSValue returnValue; 3212 3215 { 3213 SamplingTool::HostCallRecord callRecord(m_sampler );3216 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 3214 3217 returnValue = callData.native.function(newCallFrame, asObject(v), thisValue, args); 3215 3218 } … … 3463 3466 JSValue returnValue; 3464 3467 { 3465 SamplingTool::HostCallRecord callRecord(m_sampler );3468 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 3466 3469 returnValue = constructData.native.function(newCallFrame, asObject(v), args); 3467 3470 } … … 3915 3918 } 3916 3919 3920 void Interpreter::enableSampler() 3921 { 3922 #if ENABLE(OPCODE_SAMPLING) 3923 if (!m_sampler) { 3924 m_sampler.set(new SamplingTool(this)); 3925 m_sampler->setup(); 3926 } 3927 #endif 3928 } 3929 void Interpreter::dumpSampleData(ExecState* exec) 3930 { 3931 #if ENABLE(OPCODE_SAMPLING) 3932 if (m_sampler) 3933 m_sampler->dump(exec); 3934 #else 3935 UNUSED_PARAM(exec); 3936 #endif 3937 } 3938 void Interpreter::startSampling() 3939 { 3940 #if ENABLE(SAMPLING_THREAD) 3941 if (!m_sampleEntryDepth) 3942 SamplingThread::start(); 3943 3944 m_sampleEntryDepth++; 3945 #endif 3946 } 3947 void Interpreter::stopSampling() 3948 { 3949 #if ENABLE(SAMPLING_THREAD) 3950 m_sampleEntryDepth--; 3951 if (!m_sampleEntryDepth) 3952 SamplingThread::stop(); 3953 #endif 3954 } 3955 3917 3956 } // namespace JSC -
trunk/JavaScriptCore/interpreter/Interpreter.h
r47412 r48905 106 106 void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc); 107 107 108 void setSampler(SamplingTool* sampler) { m_sampler = sampler; } 109 SamplingTool* sampler() { return m_sampler; } 108 SamplingTool* sampler() { return m_sampler.get(); } 110 109 111 110 NEVER_INLINE JSValue callEval(CallFrame*, RegisterFile*, Register* argv, int argc, int registerOffset, JSValue& exceptionValue); … … 113 112 NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine); 114 113 114 void dumpSampleData(ExecState* exec); 115 void startSampling(); 116 void stopSampling(); 115 117 private: 116 118 enum ExecutionFlag { Normal, InitializeAndReturn }; … … 150 152 bool isCallBytecode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval); } 151 153 152 SamplingTool* m_sampler; 154 void enableSampler(); 155 int m_sampleEntryDepth; 156 OwnPtr<SamplingTool> m_sampler; 153 157 154 158 int m_reentryDepth; -
trunk/JavaScriptCore/jit/JIT.h
r48744 r48905 539 539 static const int patchOffsetGetByIdPutResult = 31; 540 540 #if ENABLE(OPCODE_SAMPLING) 541 static const int patchOffsetGetByIdSlowCaseCall = 6 3;541 static const int patchOffsetGetByIdSlowCaseCall = 64; 542 542 #else 543 543 static const int patchOffsetGetByIdSlowCaseCall = 41; -
trunk/JavaScriptCore/jsc.cpp
r48736 r48905 361 361 BytecodeGenerator::setDumpsGeneratedCode(true); 362 362 363 #if ENABLE(OPCODE_SAMPLING) 364 Interpreter* interpreter = globalObject->globalData()->interpreter; 365 interpreter->setSampler(new SamplingTool(interpreter)); 366 interpreter->sampler()->setup(); 367 #endif 363 JSGlobalData* globalData = globalObject->globalData(); 364 368 365 #if ENABLE(SAMPLING_FLAGS) 369 366 SamplingFlags::start(); … … 382 379 } 383 380 384 #if ENABLE(SAMPLING_THREAD) 385 SamplingThread::start(); 386 #endif 381 globalData->startSampling(); 387 382 388 383 Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName)); … … 395 390 } 396 391 397 #if ENABLE(SAMPLING_THREAD) 398 SamplingThread::stop(); 399 #endif 400 392 globalData->stopSampling(); 401 393 globalObject->globalExec()->clearException(); 402 394 } … … 405 397 SamplingFlags::stop(); 406 398 #endif 407 #if ENABLE(OPCODE_SAMPLING) 408 interpreter->sampler()->dump(globalObject->globalExec()); 409 delete interpreter->sampler(); 410 #endif 399 globalData->dumpSampleData(globalObject->globalExec()); 411 400 #if ENABLE(SAMPLING_COUNTERS) 412 401 AbstractSamplingCounter::dump(); -
trunk/JavaScriptCore/runtime/Completion.cpp
r48662 r48905 38 38 JSLock lock(exec); 39 39 40 ProgramExecutable program(exec, source);41 JSObject* error = program .checkSyntax(exec);40 RefPtr<ProgramExecutable> program = ProgramExecutable::create(exec, source); 41 JSObject* error = program->checkSyntax(exec); 42 42 if (error) 43 43 return Completion(Throw, error); … … 50 50 JSLock lock(exec); 51 51 52 ProgramExecutable program(exec, source);53 JSObject* error = program .compile(exec, scopeChain.node());52 RefPtr<ProgramExecutable> program = ProgramExecutable::create(exec, source); 53 JSObject* error = program->compile(exec, scopeChain.node()); 54 54 if (error) 55 55 return Completion(Throw, error); … … 58 58 59 59 JSValue exception; 60 JSValue result = exec->interpreter()->execute( &program, exec, scopeChain.node(), thisObj, &exception);60 JSValue result = exec->interpreter()->execute(program.get(), exec, scopeChain.node(), thisObj, &exception); 61 61 62 62 if (exception) { -
trunk/JavaScriptCore/runtime/Executable.h
r48662 r48905 159 159 class EvalExecutable : public ScriptExecutable { 160 160 public: 161 EvalExecutable(ExecState* exec, const SourceCode& source)162 : ScriptExecutable(exec, source)163 , m_evalCodeBlock(0)164 {165 }166 161 167 162 ~EvalExecutable(); … … 182 177 183 178 private: 179 EvalExecutable(ExecState* exec, const SourceCode& source) 180 : ScriptExecutable(exec, source) 181 , m_evalCodeBlock(0) 182 { 183 } 184 184 EvalCodeBlock* m_evalCodeBlock; 185 185 … … 200 200 class ProgramExecutable : public ScriptExecutable { 201 201 public: 202 ProgramExecutable(ExecState* exec, const SourceCode& source) 203 : ScriptExecutable(exec, source) 204 , m_programCodeBlock(0) 205 { 206 } 207 202 static PassRefPtr<ProgramExecutable> create(ExecState* exec, const SourceCode& source) 203 { 204 return adoptRef(new ProgramExecutable(exec, source)); 205 } 206 208 207 ~ProgramExecutable(); 209 208 … … 224 223 225 224 private: 225 ProgramExecutable(ExecState* exec, const SourceCode& source) 226 : ScriptExecutable(exec, source) 227 , m_programCodeBlock(0) 228 { 229 } 226 230 ProgramCodeBlock* m_programCodeBlock; 227 231 -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r48315 r48905 252 252 } 253 253 254 void JSGlobalData::startSampling() 255 { 256 interpreter->startSampling(); 257 } 258 259 void JSGlobalData::stopSampling() 260 { 261 interpreter->stopSampling(); 262 } 263 264 void JSGlobalData::dumpSampleData(ExecState* exec) 265 { 266 interpreter->dumpSampleData(exec); 267 } 268 254 269 } // namespace JSC -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r48315 r48905 156 156 #endif 157 157 158 void startSampling(); 159 void stopSampling(); 160 void dumpSampleData(ExecState* exec); 158 161 private: 159 162 JSGlobalData(bool isShared, const VPtrSet&); -
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r48662 r48905 287 287 return parsedObject; 288 288 289 EvalExecutable eval(exec, makeSource(s));290 JSObject* error = eval .compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node());289 RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s)); 290 JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node()); 291 291 if (error) 292 292 return throwError(exec, error); 293 293 294 return exec->interpreter()->execute( &eval, exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot());294 return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot()); 295 295 } 296 296
Note: See TracChangeset
for help on using the changeset viewer.