Title: [200916] trunk/Source/_javascript_Core
- Revision
- 200916
- Author
- [email protected]
- Date
- 2016-05-13 22:51:38 -0700 (Fri, 13 May 2016)
Log Message
jsc: samplingProfilerStackTraces() without starting sampling should not cause jsc to crash
https://bugs.webkit.org/show_bug.cgi?id=157704
Patch by Joseph Pecoraro <[email protected]> on 2016-05-13
Reviewed by Saam Barati.
* jsc.cpp:
(functionStartSamplingProfiler):
(functionSamplingProfilerStackTraces):
Throw an exception instead of crashing if we haven't started sampling.
* inspector/agents/InspectorScriptProfilerAgent.cpp:
(Inspector::InspectorScriptProfilerAgent::startTracking):
* runtime/VM.h:
* runtime/VM.cpp:
(JSC::VM::ensureSamplingProfiler):
Switch ensure to returning a reference, like most other ensures.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (200915 => 200916)
--- trunk/Source/_javascript_Core/ChangeLog 2016-05-14 05:14:08 UTC (rev 200915)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-05-14 05:51:38 UTC (rev 200916)
@@ -1,3 +1,22 @@
+2016-05-13 Joseph Pecoraro <[email protected]>
+
+ jsc: samplingProfilerStackTraces() without starting sampling should not cause jsc to crash
+ https://bugs.webkit.org/show_bug.cgi?id=157704
+
+ Reviewed by Saam Barati.
+
+ * jsc.cpp:
+ (functionStartSamplingProfiler):
+ (functionSamplingProfilerStackTraces):
+ Throw an exception instead of crashing if we haven't started sampling.
+
+ * inspector/agents/InspectorScriptProfilerAgent.cpp:
+ (Inspector::InspectorScriptProfilerAgent::startTracking):
+ * runtime/VM.h:
+ * runtime/VM.cpp:
+ (JSC::VM::ensureSamplingProfiler):
+ Switch ensure to returning a reference, like most other ensures.
+
2016-05-13 Saam barati <[email protected]>
DFG/FTL have a few bugs in their reasoning about the scope
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorScriptProfilerAgent.cpp (200915 => 200916)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorScriptProfilerAgent.cpp 2016-05-14 05:14:08 UTC (rev 200915)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorScriptProfilerAgent.cpp 2016-05-14 05:51:38 UTC (rev 200916)
@@ -67,11 +67,9 @@
#if ENABLE(SAMPLING_PROFILER)
if (includeSamples && *includeSamples) {
VM& vm = m_environment.scriptDebugServer().vm();
- vm.ensureSamplingProfiler(m_environment.executionStopwatch());
+ SamplingProfiler& samplingProfiler = vm.ensureSamplingProfiler(m_environment.executionStopwatch());
- SamplingProfiler& samplingProfiler = *vm.samplingProfiler();
LockHolder locker(samplingProfiler.getLock());
-
samplingProfiler.setStopWatch(locker, m_environment.executionStopwatch());
samplingProfiler.noticeCurrentThreadAsJSCExecutionThread(locker);
samplingProfiler.start(locker);
Modified: trunk/Source/_javascript_Core/jsc.cpp (200915 => 200916)
--- trunk/Source/_javascript_Core/jsc.cpp 2016-05-14 05:14:08 UTC (rev 200915)
+++ trunk/Source/_javascript_Core/jsc.cpp 2016-05-14 05:51:38 UTC (rev 200916)
@@ -1848,15 +1848,17 @@
#if ENABLE(SAMPLING_PROFILER)
EncodedJSValue JSC_HOST_CALL functionStartSamplingProfiler(ExecState* exec)
{
- exec->vm().ensureSamplingProfiler(WTF::Stopwatch::create());
- exec->vm().samplingProfiler()->noticeCurrentThreadAsJSCExecutionThread();
- exec->vm().samplingProfiler()->start();
+ SamplingProfiler& samplingProfiler = exec->vm().ensureSamplingProfiler(WTF::Stopwatch::create());
+ samplingProfiler.noticeCurrentThreadAsJSCExecutionThread();
+ samplingProfiler.start();
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL functionSamplingProfilerStackTraces(ExecState* exec)
{
- RELEASE_ASSERT(exec->vm().samplingProfiler());
+ if (!exec->vm().samplingProfiler())
+ return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Sampling profiler was never started"))));
+
String jsonString = exec->vm().samplingProfiler()->stackTracesAsJSON();
EncodedJSValue result = JSValue::encode(JSONParse(exec, jsonString));
RELEASE_ASSERT(!exec->hadException());
Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (200915 => 200916)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2016-05-14 05:14:08 UTC (rev 200915)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2016-05-14 05:51:38 UTC (rev 200916)
@@ -453,10 +453,11 @@
}
#if ENABLE(SAMPLING_PROFILER)
-void VM::ensureSamplingProfiler(RefPtr<Stopwatch>&& stopwatch)
+SamplingProfiler& VM::ensureSamplingProfiler(RefPtr<Stopwatch>&& stopwatch)
{
if (!m_samplingProfiler)
m_samplingProfiler = adoptRef(new SamplingProfiler(*this, WTFMove(stopwatch)));
+ return *m_samplingProfiler;
}
#endif // ENABLE(SAMPLING_PROFILER)
Modified: trunk/Source/_javascript_Core/runtime/VM.h (200915 => 200916)
--- trunk/Source/_javascript_Core/runtime/VM.h 2016-05-14 05:14:08 UTC (rev 200915)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2016-05-14 05:51:38 UTC (rev 200916)
@@ -254,7 +254,7 @@
#if ENABLE(SAMPLING_PROFILER)
JS_EXPORT_PRIVATE SamplingProfiler* samplingProfiler() { return m_samplingProfiler.get(); }
- JS_EXPORT_PRIVATE void ensureSamplingProfiler(RefPtr<Stopwatch>&&);
+ JS_EXPORT_PRIVATE SamplingProfiler& ensureSamplingProfiler(RefPtr<Stopwatch>&&);
#endif
private:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes