<!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>[201830] 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/201830">201830</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-06-08 13:59:49 -0700 (Wed, 08 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Simplify Interpreter::StackFrame.
https://bugs.webkit.org/show_bug.cgi?id=158498

Reviewed by Saam Barati.

Previously, Interpreter::StackFrame (which is used to capture info for
Error.stack) eagerly extracts info out of CodeBlock and duplicates the work that
CodeBlock does to compute line and column numbers (amongst other things).

This patch does away with the eager extraction and only stashes the CodeBlock
pointer in the Interpreter::StackFrame.  Instead, Interpreter::StackFrame will
provide methods for computing the desired values on request later.

One difference in implementation: the old StackFrame offers a sourceURL and a
friendlySourceURL().  The only difference between the 2 is that for native
functions, sourceURL returns an empty string, and friendlySourceURL() returns
&quot;[native code]&quot;.  This is how it affects the clients of StackFrame:

    - In the old code, the Error object's addErrorInfoAndGetBytecodeOffset() and
      the inspector's createScriptCallStackFromException() would check if
      sourceURL is empty.  If so, they will use this as an indicator to use
      alternate source info in the Error object e.g. url and line numbers from
      the parser that produced a SyntaxError.

    - In the new implementation, StackFrame only has a sourceURL() function that
      behaves like the old friendlySourceURL().  The client code which were
      relying on sourceURL being empty, will now explicitly check if the
      StackFrame is for native code using a new isNative() query in addition to
      the sourceURL being empty.  This achieve functional parity with the old
      behavior.

Also fix Error.cpp's addErrorInfoAndGetBytecodeOffset() to take a bytecodeOffset
pointer instead of a reference.  The bytecodeOffset arg is supposed to be
optional, but was implemented in a unclear way.  This change clarifies it.

* inspector/ScriptCallStackFactory.cpp:
(Inspector::createScriptCallStackFromException):
* interpreter/Interpreter.cpp:
(JSC::StackFrame::sourceID):
(JSC::StackFrame::sourceURL):
(JSC::StackFrame::functionName):
(JSC::eval):
(JSC::Interpreter::isOpcode):
(JSC::StackFrame::computeLineAndColumn):
(JSC::StackFrame::toString):
(JSC::GetStackTraceFunctor::operator()):
(JSC::StackFrame::friendlySourceURL): Deleted.
(JSC::StackFrame::friendlyFunctionName): Deleted.
(JSC::getStackFrameCodeType): Deleted.
(JSC::StackFrame::expressionInfo): Deleted.
* interpreter/Interpreter.h:
(JSC::StackFrame::isNative):
* runtime/Error.cpp:
(JSC::addErrorInfoAndGetBytecodeOffset):
(JSC::addErrorInfo):
* runtime/Error.h:
* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::finishCreation):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorScriptCallStackFactorycpp">trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinterpreterInterpretercpp">trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinterpreterInterpreterh">trunk/Source/JavaScriptCore/interpreter/Interpreter.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeErrorcpp">trunk/Source/JavaScriptCore/runtime/Error.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeErrorh">trunk/Source/JavaScriptCore/runtime/Error.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeErrorInstancecpp">trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2016-06-08  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Simplify Interpreter::StackFrame.
+        https://bugs.webkit.org/show_bug.cgi?id=158498
+
+        Reviewed by Saam Barati.
+
+        Previously, Interpreter::StackFrame (which is used to capture info for
+        Error.stack) eagerly extracts info out of CodeBlock and duplicates the work that
+        CodeBlock does to compute line and column numbers (amongst other things).
+
+        This patch does away with the eager extraction and only stashes the CodeBlock
+        pointer in the Interpreter::StackFrame.  Instead, Interpreter::StackFrame will
+        provide methods for computing the desired values on request later.
+
+        One difference in implementation: the old StackFrame offers a sourceURL and a
+        friendlySourceURL().  The only difference between the 2 is that for native
+        functions, sourceURL returns an empty string, and friendlySourceURL() returns
+        &quot;[native code]&quot;.  This is how it affects the clients of StackFrame:
+
+            - In the old code, the Error object's addErrorInfoAndGetBytecodeOffset() and
+              the inspector's createScriptCallStackFromException() would check if
+              sourceURL is empty.  If so, they will use this as an indicator to use
+              alternate source info in the Error object e.g. url and line numbers from
+              the parser that produced a SyntaxError.
+
+            - In the new implementation, StackFrame only has a sourceURL() function that
+              behaves like the old friendlySourceURL().  The client code which were
+              relying on sourceURL being empty, will now explicitly check if the
+              StackFrame is for native code using a new isNative() query in addition to
+              the sourceURL being empty.  This achieve functional parity with the old
+              behavior.
+
+        Also fix Error.cpp's addErrorInfoAndGetBytecodeOffset() to take a bytecodeOffset
+        pointer instead of a reference.  The bytecodeOffset arg is supposed to be
+        optional, but was implemented in a unclear way.  This change clarifies it.
+
+        * inspector/ScriptCallStackFactory.cpp:
+        (Inspector::createScriptCallStackFromException):
+        * interpreter/Interpreter.cpp:
+        (JSC::StackFrame::sourceID):
+        (JSC::StackFrame::sourceURL):
+        (JSC::StackFrame::functionName):
+        (JSC::eval):
+        (JSC::Interpreter::isOpcode):
+        (JSC::StackFrame::computeLineAndColumn):
+        (JSC::StackFrame::toString):
+        (JSC::GetStackTraceFunctor::operator()):
+        (JSC::StackFrame::friendlySourceURL): Deleted.
+        (JSC::StackFrame::friendlyFunctionName): Deleted.
+        (JSC::getStackFrameCodeType): Deleted.
+        (JSC::StackFrame::expressionInfo): Deleted.
+        * interpreter/Interpreter.h:
+        (JSC::StackFrame::isNative):
+        * runtime/Error.cpp:
+        (JSC::addErrorInfoAndGetBytecodeOffset):
+        (JSC::addErrorInfo):
+        * runtime/Error.h:
+        * runtime/ErrorInstance.cpp:
+        (JSC::ErrorInstance::finishCreation):
+
</ins><span class="cx"> 2016-06-08  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         We should be able to lookup symbols by identifier in builtins
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorScriptCallStackFactorycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -143,8 +143,8 @@
</span><span class="cx">         unsigned line;
</span><span class="cx">         unsigned column;
</span><span class="cx">         stackTrace[i].computeLineAndColumn(line, column);
</span><del>-        String functionName = stackTrace[i].friendlyFunctionName(vm);
-        frames.append(ScriptCallFrame(functionName, stackTrace[i].friendlySourceURL(), static_cast&lt;SourceID&gt;(stackTrace[i].sourceID), line, column));
</del><ins>+        String functionName = stackTrace[i].functionName(vm);
+        frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL(), static_cast&lt;SourceID&gt;(stackTrace[i].sourceID()), line, column));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Fallback to getting at least the line and sourceURL from the exception object if it has values and the exceptionStack doesn't.
</span><span class="lines">@@ -158,10 +158,10 @@
</span><span class="cx">             extractSourceInformationFromException(exec, exceptionObject, &amp;lineNumber, &amp;columnNumber, &amp;exceptionSourceURL);
</span><span class="cx">             frames.append(ScriptCallFrame(String(), exceptionSourceURL, noSourceID, lineNumber, columnNumber));
</span><span class="cx">         } else {
</span><del>-            if (stackTrace[0].sourceURL.isEmpty()) {
</del><ins>+            if (stackTrace[0].isNative() || stackTrace[0].sourceURL().isEmpty()) {
</ins><span class="cx">                 const ScriptCallFrame&amp; firstCallFrame = frames.first();
</span><span class="cx">                 extractSourceInformationFromException(exec, exceptionObject, &amp;lineNumber, &amp;columnNumber, &amp;exceptionSourceURL);
</span><del>-                frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, stackTrace[0].sourceID, lineNumber, columnNumber);
</del><ins>+                frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, stackTrace[0].sourceID(), lineNumber, columnNumber);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinterpreterInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -87,49 +87,44 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-String StackFrame::friendlySourceURL() const
</del><ins>+intptr_t StackFrame::sourceID() const
</ins><span class="cx"> {
</span><del>-    String traceLine;
-    
-    switch (codeType) {
-    case StackFrameEvalCode:
-    case StackFrameModuleCode:
-    case StackFrameFunctionCode:
-    case StackFrameGlobalCode:
-        if (!sourceURL.isEmpty())
-            traceLine = sourceURL.impl();
-        break;
-    case StackFrameNativeCode:
-        traceLine = &quot;[native code]&quot;;
-        break;
-    }
-    return traceLine.isNull() ? emptyString() : traceLine;
</del><ins>+    if (!codeBlock)
+        return noSourceID;
+    return codeBlock-&gt;ownerScriptExecutable()-&gt;sourceID();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-String StackFrame::friendlyFunctionName(VM&amp; vm) const
</del><ins>+String StackFrame::sourceURL() const
</ins><span class="cx"> {
</span><del>-    String traceLine;
-    JSObject* stackFrameCallee = callee.get();
</del><ins>+    if (!codeBlock)
+        return ASCIILiteral(&quot;[native code]&quot;);
</ins><span class="cx"> 
</span><del>-    switch (codeType) {
-    case StackFrameEvalCode:
-        traceLine = &quot;eval code&quot;;
-        break;
-    case StackFrameModuleCode:
-        traceLine = &quot;module code&quot;;
-        break;
-    case StackFrameNativeCode:
-        if (callee)
-            traceLine = getCalculatedDisplayName(vm, stackFrameCallee).impl();
-        break;
-    case StackFrameFunctionCode:
-        traceLine = getCalculatedDisplayName(vm, stackFrameCallee).impl();
-        break;
-    case StackFrameGlobalCode:
-        traceLine = &quot;global code&quot;;
-        break;
</del><ins>+    String sourceURL = codeBlock-&gt;ownerScriptExecutable()-&gt;sourceURL();
+    if (!sourceURL.isNull())
+        return sourceURL;
+    return emptyString();
+}
+
+String StackFrame::functionName(VM&amp; vm) const
+{
+    if (codeBlock) {
+        switch (codeBlock-&gt;codeType()) {
+        case EvalCode:
+            return ASCIILiteral(&quot;eval code&quot;);
+        case ModuleCode:
+            return ASCIILiteral(&quot;module code&quot;);
+        case FunctionCode:
+            break;
+        case GlobalCode:
+            return ASCIILiteral(&quot;global code&quot;);
+        default:
+            ASSERT_NOT_REACHED();
+        }
</ins><span class="cx">     }
</span><del>-    return traceLine.isNull() ? emptyString() : traceLine;
</del><ins>+    String name;
+    if (callee)
+        name = getCalculatedDisplayName(vm, callee.get()).impl();
+    return name.isNull() ? emptyString() : name;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSValue eval(CallFrame* callFrame)
</span><span class="lines">@@ -449,25 +444,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static StackFrameCodeType getStackFrameCodeType(StackVisitor&amp; visitor)
-{
-    switch (visitor-&gt;codeType()) {
-    case StackVisitor::Frame::Eval:
-        return StackFrameEvalCode;
-    case StackVisitor::Frame::Module:
-        return StackFrameModuleCode;
-    case StackVisitor::Frame::Function:
-        return StackFrameFunctionCode;
-    case StackVisitor::Frame::Global:
-        return StackFrameGlobalCode;
-    case StackVisitor::Frame::Native:
-        ASSERT_NOT_REACHED();
-        return StackFrameNativeCode;
-    }
-    RELEASE_ASSERT_NOT_REACHED();
-    return StackFrameGlobalCode;
-}
-
</del><span class="cx"> void StackFrame::computeLineAndColumn(unsigned&amp; line, unsigned&amp; column)
</span><span class="cx"> {
</span><span class="cx">     if (!codeBlock) {
</span><span class="lines">@@ -479,34 +455,24 @@
</span><span class="cx">     int divot = 0;
</span><span class="cx">     int unusedStartOffset = 0;
</span><span class="cx">     int unusedEndOffset = 0;
</span><del>-    unsigned divotLine = 0;
-    unsigned divotColumn = 0;
-    expressionInfo(divot, unusedStartOffset, unusedEndOffset, divotLine, divotColumn);
</del><ins>+    codeBlock-&gt;expressionRangeForBytecodeOffset(bytecodeOffset, divot, unusedStartOffset, unusedEndOffset, line, column);
</ins><span class="cx"> 
</span><del>-    line = divotLine + lineOffset;
-    column = divotColumn + (divotLine ? 1 : firstLineColumnOffset);
-
</del><ins>+    ScriptExecutable* executable = codeBlock-&gt;ownerScriptExecutable();
</ins><span class="cx">     if (executable-&gt;hasOverrideLineNumber())
</span><span class="cx">         line = executable-&gt;overrideLineNumber();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StackFrame::expressionInfo(int&amp; divot, int&amp; startOffset, int&amp; endOffset, unsigned&amp; line, unsigned&amp; column)
-{
-    codeBlock-&gt;expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column);
-    divot += characterOffset;
-}
-
</del><span class="cx"> String StackFrame::toString(VM&amp; vm)
</span><span class="cx"> {
</span><span class="cx">     StringBuilder traceBuild;
</span><del>-    String functionName = friendlyFunctionName(vm);
-    String sourceURL = friendlySourceURL();
</del><ins>+    String functionName = this-&gt;functionName(vm);
+    String sourceURL = this-&gt;sourceURL();
</ins><span class="cx">     traceBuild.append(functionName);
</span><span class="cx">     if (!sourceURL.isEmpty()) {
</span><span class="cx">         if (!functionName.isEmpty())
</span><span class="cx">             traceBuild.append('@');
</span><span class="cx">         traceBuild.append(sourceURL);
</span><del>-        if (codeType != StackFrameNativeCode) {
</del><ins>+        if (codeBlock) {
</ins><span class="cx">             unsigned line;
</span><span class="cx">             unsigned column;
</span><span class="cx">             computeLineAndColumn(line, column);
</span><span class="lines">@@ -546,23 +512,18 @@
</span><span class="cx">             if (visitor-&gt;isJSFrame()
</span><span class="cx">                 &amp;&amp; !isWebAssemblyExecutable(visitor-&gt;codeBlock()-&gt;ownerExecutable())
</span><span class="cx">                 &amp;&amp; !visitor-&gt;codeBlock()-&gt;unlinkedCodeBlock()-&gt;isBuiltinFunction()) {
</span><del>-                CodeBlock* codeBlock = visitor-&gt;codeBlock();
</del><span class="cx">                 StackFrame s = {
</span><span class="cx">                     Strong&lt;JSObject&gt;(vm, visitor-&gt;callee()),
</span><del>-                    getStackFrameCodeType(visitor),
-                    Strong&lt;ScriptExecutable&gt;(vm, codeBlock-&gt;ownerScriptExecutable()),
-                    Strong&lt;UnlinkedCodeBlock&gt;(vm, codeBlock-&gt;unlinkedCodeBlock()),
-                    codeBlock-&gt;source(),
-                    codeBlock-&gt;ownerScriptExecutable()-&gt;firstLine(),
-                    codeBlock-&gt;firstLineColumnOffset(),
-                    codeBlock-&gt;sourceOffset(),
-                    visitor-&gt;bytecodeOffset(),
-                    visitor-&gt;sourceURL(),
-                    visitor-&gt;sourceID(),
</del><ins>+                    Strong&lt;CodeBlock&gt;(vm, visitor-&gt;codeBlock()),
+                    visitor-&gt;bytecodeOffset()
</ins><span class="cx">                 };
</span><span class="cx">                 m_results.append(s);
</span><span class="cx">             } else {
</span><del>-                StackFrame s = { Strong&lt;JSObject&gt;(vm, visitor-&gt;callee()), StackFrameNativeCode, Strong&lt;ScriptExecutable&gt;(), Strong&lt;UnlinkedCodeBlock&gt;(), 0, 0, 0, 0, 0, String(), noSourceID};
</del><ins>+                StackFrame s = {
+                    Strong&lt;JSObject&gt;(vm, visitor-&gt;callee()),
+                    Strong&lt;CodeBlock&gt;(),
+                    0 // unused value because codeBlock is null.
+                };
</ins><span class="cx">                 m_results.append(s);
</span><span class="cx">             }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinterpreterInterpreterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/interpreter/Interpreter.h (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/interpreter/Interpreter.h        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/interpreter/Interpreter.h        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2013, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2008, 2013, 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -85,23 +85,16 @@
</span><span class="cx"> 
</span><span class="cx">     struct StackFrame {
</span><span class="cx">         Strong&lt;JSObject&gt; callee;
</span><del>-        StackFrameCodeType codeType;
-        Strong&lt;ScriptExecutable&gt; executable;
-        Strong&lt;UnlinkedCodeBlock&gt; codeBlock;
-        RefPtr&lt;SourceProvider&gt; code;
-        int lineOffset;
-        unsigned firstLineColumnOffset;
-        unsigned characterOffset;
</del><ins>+        Strong&lt;CodeBlock&gt; codeBlock;
</ins><span class="cx">         unsigned bytecodeOffset;
</span><del>-        String sourceURL;
-        intptr_t sourceID;
-        String toString(VM&amp;);
-        String friendlySourceURL() const;
-        String friendlyFunctionName(VM&amp;) const;
-        JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned&amp; line, unsigned&amp; column);
</del><span class="cx"> 
</span><del>-    private:
-        void expressionInfo(int&amp; divot, int&amp; startOffset, int&amp; endOffset, unsigned&amp; line, unsigned&amp; column);
</del><ins>+        bool isNative() const { return !codeBlock; }
+
+        void computeLineAndColumn(unsigned&amp; line, unsigned&amp; column);
+        String functionName(VM&amp;) const;
+        intptr_t sourceID() const;
+        String sourceURL() const;
+        String toString(VM&amp;);
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     class SuspendExceptionScope {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Error.cpp (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Error.cpp        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/runtime/Error.cpp        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
</span><span class="cx">  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
</span><del>- *  Copyright (C) 2003, 2004, 2005, 2006, 2008, 2016 Apple Inc. All rights reserved.
</del><ins>+ *  Copyright (C) 2003-2006, 2008, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *  Copyright (C) 2007 Eric Seidel (eric@webkit.org)
</span><span class="cx">  *
</span><span class="cx">  *  This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -139,21 +139,19 @@
</span><span class="cx">     mutable unsigned m_index;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-bool addErrorInfoAndGetBytecodeOffset(ExecState* exec, VM&amp; vm, JSObject* obj, bool useCurrentFrame, CallFrame*&amp; callFrame, unsigned &amp;bytecodeOffset) 
</del><ins>+bool addErrorInfoAndGetBytecodeOffset(ExecState* exec, VM&amp; vm, JSObject* obj, bool useCurrentFrame, CallFrame*&amp; callFrame, unsigned* bytecodeOffset)
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;StackFrame&gt; stackTrace = Vector&lt;StackFrame&gt;();
</span><span class="cx"> 
</span><del>-    if (exec &amp;&amp; stackTrace.isEmpty())
-        vm.interpreter-&gt;getStackTrace(stackTrace);
-
</del><ins>+    vm.interpreter-&gt;getStackTrace(stackTrace);
</ins><span class="cx">     if (!stackTrace.isEmpty()) {
</span><span class="cx"> 
</span><span class="cx">         ASSERT(exec == vm.topCallFrame || exec == exec-&gt;lexicalGlobalObject()-&gt;globalExec() || exec == exec-&gt;vmEntryGlobalObject()-&gt;globalExec());
</span><span class="cx"> 
</span><del>-        StackFrame* stackFrame = nullptr;
</del><ins>+        StackFrame* firstNonNativeFrame;
</ins><span class="cx">         for (unsigned i = 0 ; i &lt; stackTrace.size(); ++i) {
</span><del>-            stackFrame = &amp;stackTrace.at(i);
-            if (stackFrame-&gt;bytecodeOffset)
</del><ins>+            firstNonNativeFrame = &amp;stackTrace.at(i);
+            if (!firstNonNativeFrame-&gt;isNative())
</ins><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -162,18 +160,19 @@
</span><span class="cx">             vm.topCallFrame-&gt;iterate(functor);
</span><span class="cx">             callFrame = functor.foundCallFrame();
</span><span class="cx">             unsigned stackIndex = functor.index();
</span><del>-            bytecodeOffset = stackTrace.at(stackIndex).bytecodeOffset;
</del><ins>+            *bytecodeOffset = stackTrace.at(stackIndex).bytecodeOffset;
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         unsigned line;
</span><span class="cx">         unsigned column;
</span><del>-        stackFrame-&gt;computeLineAndColumn(line, column);
</del><ins>+        firstNonNativeFrame-&gt;computeLineAndColumn(line, column);
</ins><span class="cx">         obj-&gt;putDirect(vm, vm.propertyNames-&gt;line, jsNumber(line), ReadOnly | DontDelete);
</span><span class="cx">         obj-&gt;putDirect(vm, vm.propertyNames-&gt;column, jsNumber(column), ReadOnly | DontDelete);
</span><span class="cx"> 
</span><del>-        if (!stackFrame-&gt;sourceURL.isEmpty())
-            obj-&gt;putDirect(vm, vm.propertyNames-&gt;sourceURL, jsString(&amp;vm, stackFrame-&gt;sourceURL), ReadOnly | DontDelete);
-    
</del><ins>+        String frameSourceURL = firstNonNativeFrame-&gt;sourceURL();
+        if (!frameSourceURL.isEmpty())
+            obj-&gt;putDirect(vm, vm.propertyNames-&gt;sourceURL, jsString(&amp;vm, frameSourceURL), ReadOnly | DontDelete);
+
</ins><span class="cx">         if (!useCurrentFrame)
</span><span class="cx">             stackTrace.remove(0);
</span><span class="cx">         obj-&gt;putDirect(vm, vm.propertyNames-&gt;stack, vm.interpreter-&gt;stackTraceAsString(vm.topCallFrame, stackTrace), DontEnum);
</span><span class="lines">@@ -186,8 +185,7 @@
</span><span class="cx"> void addErrorInfo(ExecState* exec, JSObject* obj, bool useCurrentFrame)
</span><span class="cx"> {
</span><span class="cx">     CallFrame* callFrame = nullptr;
</span><del>-    unsigned bytecodeOffset = 0;
-    addErrorInfoAndGetBytecodeOffset(exec, exec-&gt;vm(), obj, useCurrentFrame, callFrame, bytecodeOffset);
</del><ins>+    addErrorInfoAndGetBytecodeOffset(exec, exec-&gt;vm(), obj, useCurrentFrame, callFrame);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSObject* addErrorInfo(CallFrame* callFrame, JSObject* error, int line, const SourceCode&amp; source)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Error.h (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Error.h        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/runtime/Error.h        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx"> JS_EXPORT_PRIVATE JSObject* createOutOfMemoryError(ExecState*);
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-bool addErrorInfoAndGetBytecodeOffset(ExecState*, VM&amp;, JSObject*, bool, CallFrame*&amp;, unsigned&amp;);
</del><ins>+bool addErrorInfoAndGetBytecodeOffset(ExecState*, VM&amp;, JSObject*, bool, CallFrame*&amp;, unsigned* = nullptr);
</ins><span class="cx"> 
</span><span class="cx"> bool hasErrorInfo(ExecState*, JSObject* error);
</span><span class="cx"> JS_EXPORT_PRIVATE void addErrorInfo(ExecState*, JSObject*, bool); 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeErrorInstancecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp (201829 => 201830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp        2016-06-08 20:56:11 UTC (rev 201829)
+++ trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp        2016-06-08 20:59:49 UTC (rev 201830)
</span><span class="lines">@@ -142,9 +142,9 @@
</span><span class="cx">     if (!message.isNull())
</span><span class="cx">         putDirect(vm, vm.propertyNames-&gt;message, jsString(&amp;vm, message), DontEnum);
</span><span class="cx"> 
</span><del>-    unsigned bytecodeOffset = hasSourceAppender();
</del><ins>+    unsigned bytecodeOffset = 0;
</ins><span class="cx">     CallFrame* callFrame = nullptr;
</span><del>-    bool hasTrace = addErrorInfoAndGetBytecodeOffset(exec, vm, this, useCurrentFrame, callFrame, bytecodeOffset);
</del><ins>+    bool hasTrace = addErrorInfoAndGetBytecodeOffset(exec, vm, this, useCurrentFrame, callFrame, hasSourceAppender() ? &amp;bytecodeOffset : nullptr);
</ins><span class="cx"> 
</span><span class="cx">     if (hasTrace &amp;&amp; callFrame &amp;&amp; hasSourceAppender()) {
</span><span class="cx">         if (callFrame &amp;&amp; callFrame-&gt;codeBlock()) 
</span></span></pre>
</div>
</div>

</body>
</html>