<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196147] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196147">196147</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-02-04 13:51:40 -0800 (Thu, 04 Feb 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>JSC Sampling Profiler: (host) is confusing in cases where I would expect to see JS name
https://bugs.webkit.org/show_bug.cgi?id=153663
<rdar://problem/24415092>
Reviewed by Geoffrey Garen.
We now collect the Callee in the processed StackFrame
when the Callee is a valid GC object. We later ask
the Callee for it's .displayName or .name property.
When we don't have a valid callee, we will still
use the Executable for this information.
This helps us come up with good names for frames where
the Callee object is a bound function or an InternalFunction.
* inspector/agents/InspectorScriptProfilerAgent.cpp:
(Inspector::InspectorScriptProfilerAgent::addEvent):
(Inspector::buildSamples):
(Inspector::InspectorScriptProfilerAgent::trackingComplete):
* runtime/SamplingProfiler.cpp:
(JSC::reportStats):
(JSC::FrameWalker::walk):
(JSC::SamplingProfiler::processUnverifiedStackTraces):
(JSC::SamplingProfiler::visit):
(JSC::SamplingProfiler::shutdown):
(JSC::SamplingProfiler::clearData):
(JSC::SamplingProfiler::StackFrame::nameFromCallee):
(JSC::SamplingProfiler::StackFrame::displayName):
(JSC::SamplingProfiler::StackFrame::displayNameForJSONTests):
(JSC::SamplingProfiler::stackTracesAsJSON):
* runtime/SamplingProfiler.h:
(JSC::SamplingProfiler::UnprocessedStackFrame::UnprocessedStackFrame):
(JSC::SamplingProfiler::StackFrame::StackFrame):
* tests/stress/sampling-profiler-basic.js:
(platformSupportsSamplingProfiler.nothing):
(platformSupportsSamplingProfiler.top):
* tests/stress/sampling-profiler-bound-function-name.js: Added.
(platformSupportsSamplingProfiler.foo):
(platformSupportsSamplingProfiler.bar):
(platformSupportsSamplingProfiler.let.baz):
(platformSupportsSamplingProfiler):
* tests/stress/sampling-profiler-display-name.js: Added.
(platformSupportsSamplingProfiler.foo):
(platformSupportsSamplingProfiler.baz):
(platformSupportsSamplingProfiler.):
(platformSupportsSamplingProfiler.bar):
(platformSupportsSamplingProfiler.jaz):
(platformSupportsSamplingProfiler.makeFunction.let.result):
(platformSupportsSamplingProfiler.makeFunction):
* tests/stress/sampling-profiler-internal-function-name.js: Added.
(platformSupportsSamplingProfiler.foo):
(platformSupportsSamplingProfiler.bar):
(platformSupportsSamplingProfiler):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorScriptProfilerAgentcpp">trunk/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeSamplingProfilercpp">trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeSamplingProfilerh">trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresssamplingprofilerbasicjs">trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-basic.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstresssamplingprofilerboundfunctionnamejs">trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-bound-function-name.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresssamplingprofilerdisplaynamejs">trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-display-name.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstresssamplingprofilerinternalfunctionnamejs">trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-internal-function-name.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196146 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-04 21:51:26 UTC (rev 196146)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2016-02-04 Saam barati <sbarati@apple.com>
+
+ JSC Sampling Profiler: (host) is confusing in cases where I would expect to see JS name
+ https://bugs.webkit.org/show_bug.cgi?id=153663
+ <rdar://problem/24415092>
+
+ Reviewed by Geoffrey Garen.
+
+ We now collect the Callee in the processed StackFrame
+ when the Callee is a valid GC object. We later ask
+ the Callee for it's .displayName or .name property.
+ When we don't have a valid callee, we will still
+ use the Executable for this information.
+
+ This helps us come up with good names for frames where
+ the Callee object is a bound function or an InternalFunction.
+
+ * inspector/agents/InspectorScriptProfilerAgent.cpp:
+ (Inspector::InspectorScriptProfilerAgent::addEvent):
+ (Inspector::buildSamples):
+ (Inspector::InspectorScriptProfilerAgent::trackingComplete):
+ * runtime/SamplingProfiler.cpp:
+ (JSC::reportStats):
+ (JSC::FrameWalker::walk):
+ (JSC::SamplingProfiler::processUnverifiedStackTraces):
+ (JSC::SamplingProfiler::visit):
+ (JSC::SamplingProfiler::shutdown):
+ (JSC::SamplingProfiler::clearData):
+ (JSC::SamplingProfiler::StackFrame::nameFromCallee):
+ (JSC::SamplingProfiler::StackFrame::displayName):
+ (JSC::SamplingProfiler::StackFrame::displayNameForJSONTests):
+ (JSC::SamplingProfiler::stackTracesAsJSON):
+ * runtime/SamplingProfiler.h:
+ (JSC::SamplingProfiler::UnprocessedStackFrame::UnprocessedStackFrame):
+ (JSC::SamplingProfiler::StackFrame::StackFrame):
+ * tests/stress/sampling-profiler-basic.js:
+ (platformSupportsSamplingProfiler.nothing):
+ (platformSupportsSamplingProfiler.top):
+ * tests/stress/sampling-profiler-bound-function-name.js: Added.
+ (platformSupportsSamplingProfiler.foo):
+ (platformSupportsSamplingProfiler.bar):
+ (platformSupportsSamplingProfiler.let.baz):
+ (platformSupportsSamplingProfiler):
+ * tests/stress/sampling-profiler-display-name.js: Added.
+ (platformSupportsSamplingProfiler.foo):
+ (platformSupportsSamplingProfiler.baz):
+ (platformSupportsSamplingProfiler.):
+ (platformSupportsSamplingProfiler.bar):
+ (platformSupportsSamplingProfiler.jaz):
+ (platformSupportsSamplingProfiler.makeFunction.let.result):
+ (platformSupportsSamplingProfiler.makeFunction):
+ * tests/stress/sampling-profiler-internal-function-name.js: Added.
+ (platformSupportsSamplingProfiler.foo):
+ (platformSupportsSamplingProfiler.bar):
+ (platformSupportsSamplingProfiler):
+
</ins><span class="cx"> 2016-02-04 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Object.getOwnPropertyDescriptor() returns incomplete descriptor for instance properties
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorScriptProfilerAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp (196146 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp        2016-02-04 21:51:26 UTC (rev 196146)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -157,7 +157,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SAMPLING_PROFILER)
</span><del>-static Ref<Protocol::ScriptProfiler::Samples> buildSamples(Vector<SamplingProfiler::StackTrace>&& samplingProfilerStackTraces, double totalTime)
</del><ins>+static Ref<Protocol::ScriptProfiler::Samples> buildSamples(VM& vm, Vector<SamplingProfiler::StackTrace>&& samplingProfilerStackTraces, double totalTime)
</ins><span class="cx"> {
</span><span class="cx"> Ref<Protocol::Array<Protocol::ScriptProfiler::StackTrace>> stackTraces = Protocol::Array<Protocol::ScriptProfiler::StackTrace>::create();
</span><span class="cx"> for (SamplingProfiler::StackTrace& stackTrace : samplingProfilerStackTraces) {
</span><span class="lines">@@ -165,7 +165,7 @@
</span><span class="cx"> for (SamplingProfiler::StackFrame& stackFrame : stackTrace.frames) {
</span><span class="cx"> Ref<Protocol::ScriptProfiler::StackFrame> frame = Protocol::ScriptProfiler::StackFrame::create()
</span><span class="cx"> .setSourceID(String::number(stackFrame.sourceID()))
</span><del>- .setName(stackFrame.displayName())
</del><ins>+ .setName(stackFrame.displayName(vm))
</ins><span class="cx"> .setLine(stackFrame.functionStartLine())
</span><span class="cx"> .setColumn(stackFrame.functionStartColumn())
</span><span class="cx"> .setUrl(stackFrame.url())
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx"> LockHolder locker(samplingProfiler->getLock());
</span><span class="cx"> samplingProfiler->stop(locker);
</span><span class="cx"> Vector<SamplingProfiler::StackTrace> stackTraces = samplingProfiler->releaseStackTraces(locker);
</span><del>- Ref<Protocol::ScriptProfiler::Samples> samples = buildSamples(WTFMove(stackTraces), samplingProfiler->totalTime(locker));
</del><ins>+ Ref<Protocol::ScriptProfiler::Samples> samples = buildSamples(m_environment.scriptDebugServer().vm(), WTFMove(stackTraces), samplingProfiler->totalTime(locker));
</ins><span class="cx">
</span><span class="cx"> locker.unlockEarly();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeSamplingProfilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp (196146 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp        2016-02-04 21:51:26 UTC (rev 196146)
+++ trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #include "PCToCodeOriginMap.h"
</span><span class="cx"> #include "SlotVisitor.h"
</span><span class="cx"> #include "SlotVisitorInlines.h"
</span><ins>+#include "StructureInlines.h"
</ins><span class="cx"> #include "VM.h"
</span><span class="cx"> #include "VMEntryScope.h"
</span><span class="cx">
</span><span class="lines">@@ -58,7 +59,6 @@
</span><span class="cx"> static const bool sReportStats = false;
</span><span class="cx">
</span><span class="cx"> using FrameType = SamplingProfiler::FrameType;
</span><del>-using UnprocessedFrameType = SamplingProfiler::UnprocessedFrameType;
</del><span class="cx"> using UnprocessedStackFrame = SamplingProfiler::UnprocessedStackFrame;
</span><span class="cx">
</span><span class="cx"> ALWAYS_INLINE static void reportStats()
</span><span class="lines">@@ -89,14 +89,14 @@
</span><span class="cx"> resetAtMachineFrame();
</span><span class="cx"> size_t maxStackTraceSize = stackTrace.size();
</span><span class="cx"> while (!isAtTop() && !m_bailingOut && m_depth < maxStackTraceSize) {
</span><del>- if (CodeBlock* codeBlock = m_callFrame->codeBlock()) {
</del><ins>+ CallSiteIndex callSiteIndex;
+ JSValue unsafeCallee = m_callFrame->unsafeCallee();
+ CodeBlock* codeBlock = m_callFrame->codeBlock();
+ if (codeBlock) {
</ins><span class="cx"> ASSERT(isValidCodeBlock(codeBlock));
</span><del>- stackTrace[m_depth] = UnprocessedStackFrame(codeBlock, m_callFrame->callSiteIndex());
- } else {
- RELEASE_ASSERT(codeBlock == nullptr);
- JSValue unsafeCallee = m_callFrame->unsafeCallee();
- stackTrace[m_depth] = UnprocessedStackFrame(JSValue::encode(unsafeCallee));
</del><ins>+ callSiteIndex = m_callFrame->callSiteIndex();
</ins><span class="cx"> }
</span><ins>+ stackTrace[m_depth] = UnprocessedStackFrame(codeBlock, JSValue::encode(unsafeCallee), callSiteIndex);
</ins><span class="cx"> m_depth++;
</span><span class="cx"> advanceToParentFrame();
</span><span class="cx"> resetAtMachineFrame();
</span><span class="lines">@@ -330,7 +330,7 @@
</span><span class="cx">
</span><span class="cx"> auto appendCodeBlock = [&] (CodeBlock* codeBlock, unsigned bytecodeIndex) {
</span><span class="cx"> stackTrace.frames.append(StackFrame(codeBlock->ownerExecutable()));
</span><del>- m_seenExecutables.add(codeBlock->ownerExecutable());
</del><ins>+ m_liveCellPointers.add(codeBlock->ownerExecutable());
</ins><span class="cx">
</span><span class="cx"> if (bytecodeIndex < codeBlock->instructionCount()) {
</span><span class="cx"> int divot;
</span><span class="lines">@@ -341,16 +341,24 @@
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="cx">
</span><del>- auto appendUnverifiedCallee = [&] (JSValue callee) {
</del><ins>+ auto appendEmptyFrame = [&] {
</ins><span class="cx"> stackTrace.frames.append(StackFrame());
</span><ins>+ };
+
+ auto storeCalleeIntoTopFrame = [&] (EncodedJSValue encodedCallee) {
+ // Set the callee if it's a valid GC object.
+ JSValue callee = JSValue::decode(encodedCallee);
</ins><span class="cx"> StackFrame& stackFrame = stackTrace.frames.last();
</span><ins>+ bool alreadyHasExecutable = !!stackFrame.executable;
</ins><span class="cx"> if (!Heap::isValueGCObject(filter, markedBlockSet, callee)) {
</span><del>- stackFrame.frameType = FrameType::Unknown;
</del><ins>+ if (!alreadyHasExecutable)
+ stackFrame.frameType = FrameType::Unknown;
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> JSCell* calleeCell = callee.asCell();
</span><del>- auto frameTypeFromCallData = [&] () -> FrameType {
</del><ins>+ auto setFallbackFrameType = [&] {
+ ASSERT(!alreadyHasExecutable);
</ins><span class="cx"> FrameType result = FrameType::Unknown;
</span><span class="cx"> CallData callData;
</span><span class="cx"> CallType callType;
</span><span class="lines">@@ -358,30 +366,47 @@
</span><span class="cx"> if (callType == CallTypeHost)
</span><span class="cx"> result = FrameType::Host;
</span><span class="cx">
</span><del>- return result;
</del><ins>+ stackFrame.frameType = result;
</ins><span class="cx"> };
</span><span class="cx">
</span><ins>+ auto addCallee = [&] (JSObject* callee) {
+ stackFrame.callee = callee;
+ m_liveCellPointers.add(callee);
+ };
+
</ins><span class="cx"> if (calleeCell->type() != JSFunctionType) {
</span><del>- stackFrame.frameType = frameTypeFromCallData();
</del><ins>+ if (JSObject* object = jsDynamicCast<JSObject*>(calleeCell))
+ addCallee(object);
+
+ if (!alreadyHasExecutable)
+ setFallbackFrameType();
+
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><del>- ExecutableBase* executable = static_cast<JSFunction*>(calleeCell)->executable();
</del><ins>+
+ addCallee(jsCast<JSFunction*>(calleeCell));
+
+ if (alreadyHasExecutable)
+ return;
+
+ ExecutableBase* executable = jsCast<JSFunction*>(calleeCell)->executable();
</ins><span class="cx"> if (!executable) {
</span><del>- stackFrame.frameType = frameTypeFromCallData();
</del><ins>+ setFallbackFrameType();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RELEASE_ASSERT(Heap::isPointerGCObject(filter, markedBlockSet, executable));
</span><span class="cx"> stackFrame.frameType = FrameType::Executable;
</span><span class="cx"> stackFrame.executable = executable;
</span><del>- m_seenExecutables.add(executable);
</del><ins>+ m_liveCellPointers.add(executable);
</ins><span class="cx"> };
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> // Prepend the top-most inlined frame if needed and gather
</span><span class="cx"> // location information about where the top frame is executing.
</span><span class="cx"> size_t startIndex = 0;
</span><del>- if (unprocessedStackTrace.frames.size() && unprocessedStackTrace.frames[0].frameType == UnprocessedFrameType::VerifiedCodeBlock) {
- CodeBlock* topCodeBlock = unprocessedStackTrace.frames[0].u.verifiedCodeBlock;
</del><ins>+ if (unprocessedStackTrace.frames.size() && !!unprocessedStackTrace.frames[0].verifiedCodeBlock) {
+ CodeBlock* topCodeBlock = unprocessedStackTrace.frames[0].verifiedCodeBlock;
</ins><span class="cx"> if (unprocessedStackTrace.topFrameIsLLInt) {
</span><span class="cx"> // We reuse LLInt CodeBlocks for the baseline JIT, so we need to check for both jit types.
</span><span class="cx"> // This might also be false for various reasons (known and unknown), even though
</span><span class="lines">@@ -403,20 +428,21 @@
</span><span class="cx"> UNUSED_PARAM(isValidPC); // FIXME: do something with this info for the web inspector: https://bugs.webkit.org/show_bug.cgi?id=153455
</span><span class="cx">
</span><span class="cx"> appendCodeBlock(topCodeBlock, bytecodeIndex);
</span><ins>+ storeCalleeIntoTopFrame(unprocessedStackTrace.frames[0].unverifiedCallee);
</ins><span class="cx"> startIndex = 1;
</span><span class="cx"> }
</span><span class="cx"> } else if (Optional<CodeOrigin> codeOrigin = topCodeBlock->findPC(unprocessedStackTrace.topPC)) {
</span><span class="cx"> codeOrigin->walkUpInlineStack([&] (const CodeOrigin& codeOrigin) {
</span><span class="cx"> appendCodeBlock(codeOrigin.inlineCallFrame ? codeOrigin.inlineCallFrame->baselineCodeBlock.get() : topCodeBlock, codeOrigin.bytecodeIndex);
</span><span class="cx"> });
</span><ins>+ storeCalleeIntoTopFrame(unprocessedStackTrace.frames[0].unverifiedCallee);
</ins><span class="cx"> startIndex = 1;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (size_t i = startIndex; i < unprocessedStackTrace.frames.size(); i++) {
</span><span class="cx"> UnprocessedStackFrame& unprocessedStackFrame = unprocessedStackTrace.frames[i];
</span><del>- if (unprocessedStackFrame.frameType == UnprocessedFrameType::VerifiedCodeBlock) {
- CodeBlock* codeBlock = unprocessedStackFrame.u.verifiedCodeBlock;
</del><ins>+ if (CodeBlock* codeBlock = unprocessedStackFrame.verifiedCodeBlock) {
</ins><span class="cx"> CallSiteIndex callSiteIndex = unprocessedStackFrame.callSiteIndex;
</span><span class="cx">
</span><span class="cx"> auto appendCodeBlockNoInlining = [&] {
</span><span class="lines">@@ -437,10 +463,12 @@
</span><span class="cx"> #else
</span><span class="cx"> appendCodeBlockNoInlining();
</span><span class="cx"> #endif
</span><del>- } else {
- ASSERT(unprocessedStackFrame.frameType == UnprocessedFrameType::UnverifiedCallee);
- appendUnverifiedCallee(JSValue::decode(unprocessedStackFrame.u.unverifiedCallee));
- }
</del><ins>+ } else
+ appendEmptyFrame();
+
+ // Note that this is okay to do if we walked the inline stack because
+ // the machine frame will be at the top of the processed stack trace.
+ storeCalleeIntoTopFrame(unprocessedStackFrame.unverifiedCallee);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -450,8 +478,8 @@
</span><span class="cx"> void SamplingProfiler::visit(SlotVisitor& slotVisitor)
</span><span class="cx"> {
</span><span class="cx"> RELEASE_ASSERT(m_lock.isLocked());
</span><del>- for (ExecutableBase* executable : m_seenExecutables)
- slotVisitor.appendUnbarrieredReadOnlyPointer(executable);
</del><ins>+ for (JSCell* cell : m_liveCellPointers)
+ slotVisitor.appendUnbarrieredReadOnlyPointer(cell);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SamplingProfiler::shutdown()
</span><span class="lines">@@ -539,12 +567,44 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_lock.isLocked());
</span><span class="cx"> m_stackTraces.clear();
</span><del>- m_seenExecutables.clear();
</del><ins>+ m_liveCellPointers.clear();
</ins><span class="cx"> m_unprocessedStackTraces.clear();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String SamplingProfiler::StackFrame::displayName()
</del><ins>+String SamplingProfiler::StackFrame::nameFromCallee(VM& vm)
</ins><span class="cx"> {
</span><ins>+ if (!callee)
+ return String();
+
+ ExecState* exec = callee->globalObject()->globalExec();
+ auto getPropertyIfPureOperation = [&] (const Identifier& ident) -> String {
+ PropertySlot slot(callee);
+ PropertyName propertyName(ident);
+ if (callee->getPropertySlot(exec, propertyName, slot)) {
+ if (slot.isValue()) {
+ JSValue nameValue = slot.getValue(exec, propertyName);
+ if (isJSString(nameValue))
+ return asString(nameValue)->tryGetValue();
+ }
+ }
+ return String();
+ };
+
+ String name = getPropertyIfPureOperation(vm.propertyNames->displayName);
+ if (!name.isEmpty())
+ return name;
+
+ return getPropertyIfPureOperation(vm.propertyNames->name);
+}
+
+String SamplingProfiler::StackFrame::displayName(VM& vm)
+{
+ {
+ String name = nameFromCallee(vm);
+ if (!name.isEmpty())
+ return name;
+ }
+
</ins><span class="cx"> if (frameType == FrameType::Unknown)
</span><span class="cx"> return ASCIILiteral("(unknown)");
</span><span class="cx"> if (frameType == FrameType::Host)
</span><span class="lines">@@ -564,8 +624,14 @@
</span><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String SamplingProfiler::StackFrame::displayNameForJSONTests()
</del><ins>+String SamplingProfiler::StackFrame::displayNameForJSONTests(VM& vm)
</ins><span class="cx"> {
</span><ins>+ {
+ String name = nameFromCallee(vm);
+ if (!name.isEmpty())
+ return name;
+ }
+
</ins><span class="cx"> if (frameType == FrameType::Unknown)
</span><span class="cx"> return ASCIILiteral("(unknown)");
</span><span class="cx"> if (frameType == FrameType::Host)
</span><span class="lines">@@ -674,7 +740,7 @@
</span><span class="cx"> for (StackFrame& stackFrame : stackTrace.frames) {
</span><span class="cx"> comma();
</span><span class="cx"> json.appendLiteral("\"");
</span><del>- json.append(stackFrame.displayNameForJSONTests());
</del><ins>+ json.append(stackFrame.displayNameForJSONTests(m_vm));
</ins><span class="cx"> json.appendLiteral("\"");
</span><span class="cx"> loopedOnce = true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeSamplingProfilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h (196146 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h        2016-02-04 21:51:26 UTC (rev 196146)
+++ trunk/Source/JavaScriptCore/runtime/SamplingProfiler.h        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -45,35 +45,20 @@
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">
</span><del>- enum class UnprocessedFrameType {
- UnverifiedCallee,
- VerifiedCodeBlock
- };
-
</del><span class="cx"> struct UnprocessedStackFrame {
</span><del>- UnprocessedStackFrame(EncodedJSValue callee)
- : frameType(UnprocessedFrameType::UnverifiedCallee)
- {
- u.unverifiedCallee = callee;
- }
- UnprocessedStackFrame(CodeBlock* codeBlock, CallSiteIndex callSiteIndex)
- : frameType(UnprocessedFrameType::VerifiedCodeBlock)
</del><ins>+ UnprocessedStackFrame(CodeBlock* codeBlock, EncodedJSValue callee, CallSiteIndex callSiteIndex)
+ : unverifiedCallee(callee)
+ , verifiedCodeBlock(codeBlock)
</ins><span class="cx"> , callSiteIndex(callSiteIndex)
</span><del>- {
- u.unverifiedCallee = JSValue::encode(JSValue());
- u.verifiedCodeBlock = codeBlock;
- }
</del><ins>+ { }
</ins><span class="cx"> UnprocessedStackFrame()
</span><del>- : frameType(UnprocessedFrameType::UnverifiedCallee)
</del><span class="cx"> {
</span><del>- u.unverifiedCallee = JSValue::encode(JSValue());
</del><ins>+ unverifiedCallee = JSValue::encode(JSValue());
+ verifiedCodeBlock = nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- UnprocessedFrameType frameType;
- union {
- EncodedJSValue unverifiedCallee;
- CodeBlock* verifiedCodeBlock;
- } u;
</del><ins>+ EncodedJSValue unverifiedCallee;
+ CodeBlock* verifiedCodeBlock;
</ins><span class="cx"> CallSiteIndex callSiteIndex;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -88,21 +73,21 @@
</span><span class="cx"> : frameType(FrameType::Executable)
</span><span class="cx"> , executable(executable)
</span><span class="cx"> { }
</span><ins>+
</ins><span class="cx"> StackFrame()
</span><del>- : frameType(FrameType::Unknown)
- , executable(nullptr)
</del><span class="cx"> { }
</span><span class="cx">
</span><del>- FrameType frameType;
- ExecutableBase* executable;
-
</del><ins>+ FrameType frameType { FrameType::Unknown };
+ ExecutableBase* executable { nullptr };
+ JSObject* callee { nullptr };
</ins><span class="cx"> // These attempt to be expression-level line and column number.
</span><span class="cx"> unsigned lineNumber { std::numeric_limits<unsigned>::max() };
</span><span class="cx"> unsigned columnNumber { std::numeric_limits<unsigned>::max() };
</span><span class="cx">
</span><span class="cx"> // These are function-level data.
</span><del>- String displayName();
- String displayNameForJSONTests(); // Used for JSC stress tests because they want the "(anonymous function)" string for anonymous functions and they want "(eval)" for eval'd code.
</del><ins>+ String nameFromCallee(VM&);
+ String displayName(VM&);
+ String displayNameForJSONTests(VM&); // Used for JSC stress tests because they want the "(anonymous function)" string for anonymous functions and they want "(eval)" for eval'd code.
</ins><span class="cx"> int functionStartLine();
</span><span class="cx"> unsigned functionStartColumn();
</span><span class="cx"> intptr_t sourceID();
</span><span class="lines">@@ -168,7 +153,7 @@
</span><span class="cx"> bool m_isActive;
</span><span class="cx"> bool m_isPaused;
</span><span class="cx"> bool m_hasDispatchedFunction;
</span><del>- HashSet<ExecutableBase*> m_seenExecutables;
</del><ins>+ HashSet<JSCell*> m_liveCellPointers;
</ins><span class="cx"> Vector<UnprocessedStackFrame> m_currentFrames;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresssamplingprofilerbasicjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-basic.js (196146 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-basic.js        2016-02-04 21:51:26 UTC (rev 196146)
+++ trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-basic.js        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx"> function nothing(x) { return x; }
</span><span class="cx"> noInline(nothing);
</span><span class="cx">
</span><del>- runTest(foo, ["(host)", "bar", "foo"]);
</del><ins>+ runTest(foo, ["Error", "bar", "foo"]);
</ins><span class="cx">
</span><span class="cx"> function top() {
</span><span class="cx"> let x = 0;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresssamplingprofilerboundfunctionnamejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-bound-function-name.js (0 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-bound-function-name.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-bound-function-name.js        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+if (platformSupportsSamplingProfiler()) {
+ load("./sampling-profiler/samplingProfiler.js");
+
+ function foo() {
+ let o = {};
+ for (let i = 0; i < 100; i++) {
+ o[i + "p"] = i;
+ }
+ }
+
+ function bar() {
+ let o = {};
+ for (let i = 0; i < 100; i++) {
+ o[i + "p"] = i;
+ }
+ }
+
+ let boundFoo = foo.bind(null);
+ let boundBar = bar.bind(null);
+
+ let baz = function() {
+ boundFoo();
+ boundBar();
+ }
+
+ runTest(baz, ["foo", "bound foo", "baz"]);
+ runTest(baz, ["bar", "bound bar", "baz"]);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresssamplingprofilerdisplaynamejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-display-name.js (0 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-display-name.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-display-name.js        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+if (platformSupportsSamplingProfiler()) {
+ load("./sampling-profiler/samplingProfiler.js");
+
+ function foo() {
+ let o = {};
+ for (let i = 0; i < 500; i++)
+ o[i + "p"] = i;
+ }
+ foo.displayName = "display foo";
+ runTest(foo, ["display foo"]);
+
+
+ function baz() {
+ let o = {};
+ for (let i = 0; i < 500; i++)
+ o[i + "p"] = i;
+ }
+ Object.defineProperty(baz, 'displayName', { get: function() { throw new Error("shouldnt be called"); } }); // We should ignore this because it's a getter.
+ runTest(baz, ["baz"]);
+
+
+ function bar() {
+ let o = {};
+ for (let i = 0; i < 500; i++)
+ o[i + "p"] = i;
+ }
+ bar.displayName = 20; // We should ignore this because it's not a string.
+ runTest(bar, ["bar"]);
+
+ function jaz() {
+ let o = {};
+ for (let i = 0; i < 500; i++)
+ o[i + "p"] = i;
+ }
+ jaz.displayName = ""; // We should ignore this because it's the empty string.
+ runTest(jaz, ["jaz"]);
+
+ function makeFunction(displayName) {
+ let result = function() {
+ let o = {};
+ for (let i = 0; i < 500; i++)
+ o[i + "p"] = i;
+ };
+ result.displayName = displayName;
+ return result;
+ }
+
+ runTest(makeFunction("hello world"), ["hello world"])
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstresssamplingprofilerinternalfunctionnamejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-internal-function-name.js (0 => 196147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-internal-function-name.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/sampling-profiler-internal-function-name.js        2016-02-04 21:51:40 UTC (rev 196147)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+if (platformSupportsSamplingProfiler()) {
+ load("./sampling-profiler/samplingProfiler.js");
+
+ function foo() {
+ let x;
+ for (let i = 0; i < 1000; i++)
+ x = new Error();
+ }
+ runTest(foo, ["Error", "foo"]);
+
+ function bar() {
+ let x;
+ for (let i = 0; i < 1000; i++)
+ x = new Function();
+ }
+ runTest(bar, ["Function", "bar"]);
+}
</ins></span></pre>
</div>
</div>
</body>
</html>