<!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>[209357] 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/209357">209357</a></dd>
<dt>Author</dt> <dd>ggaren@apple.com</dd>
<dt>Date</dt> <dd>2016-12-05 15:00:36 -0800 (Mon, 05 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Renamed source =&gt; parentSource
https://bugs.webkit.org/show_bug.cgi?id=165419

Reviewed by Saam Barati.

This should help clarify that a FunctionExecutable holds the source
code to its *parent* scope, and not its own SourceCode.

* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::UnlinkedFunctionExecutable::link):
* bytecode/UnlinkedFunctionExecutable.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsBuiltinExecutablescpp">trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedFunctionExecutablecpp">trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedFunctionExecutableh">trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209356 => 209357)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-05 22:56:14 UTC (rev 209356)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-05 23:00:36 UTC (rev 209357)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2016-12-05  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Renamed source =&gt; parentSource
+        https://bugs.webkit.org/show_bug.cgi?id=165419
+
+        Reviewed by Saam Barati.
+
+        This should help clarify that a FunctionExecutable holds the source
+        code to its *parent* scope, and not its own SourceCode.
+
+        * builtins/BuiltinExecutables.cpp:
+        (JSC::BuiltinExecutables::createExecutable):
+        * bytecode/UnlinkedFunctionExecutable.cpp:
+        (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
+        (JSC::UnlinkedFunctionExecutable::link):
+        * bytecode/UnlinkedFunctionExecutable.h:
+
+2016-12-05  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
</ins><span class="cx">         ScriptExecutable should not contain a copy of firstLine and startColumn
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=165415
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsBuiltinExecutablescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp (209356 => 209357)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp        2016-12-05 22:56:14 UTC (rev 209356)
+++ trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp        2016-12-05 23:00:36 UTC (rev 209357)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     bool isParsingDefaultConstructor = constructorKind != ConstructorKind::None;
</span><span class="cx">     JSParserBuiltinMode builtinMode = isParsingDefaultConstructor ? JSParserBuiltinMode::NotBuiltin : JSParserBuiltinMode::Builtin;
</span><span class="cx">     UnlinkedFunctionKind kind = isParsingDefaultConstructor ? UnlinkedNormalFunction : UnlinkedBuiltinFunction;
</span><del>-    RefPtr&lt;SourceProvider&gt; sourceOverride = isParsingDefaultConstructor ? source.provider() : nullptr;
</del><ins>+    SourceCode parentSourceOverride = isParsingDefaultConstructor ? source : SourceCode();
</ins><span class="cx">     std::unique_ptr&lt;ProgramNode&gt; program = parse&lt;ProgramNode&gt;(
</span><span class="cx">         &amp;vm, source, Identifier(), builtinMode,
</span><span class="cx">         JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, error,
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">     RELEASE_ASSERT(metadata);
</span><span class="cx">     metadata-&gt;overrideName(name);
</span><span class="cx">     VariableEnvironment dummyTDZVariables;
</span><del>-    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&amp;vm, source, metadata, kind, constructAbility, JSParserScriptMode::Classic, dummyTDZVariables, DerivedContextType::None, WTFMove(sourceOverride));
</del><ins>+    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&amp;vm, source, metadata, kind, constructAbility, JSParserScriptMode::Classic, dummyTDZVariables, DerivedContextType::None, WTFMove(parentSourceOverride));
</ins><span class="cx">     return functionExecutable;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedFunctionExecutablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp (209356 => 209357)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp        2016-12-05 22:56:14 UTC (rev 209356)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp        2016-12-05 23:00:36 UTC (rev 209357)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode&amp; source, RefPtr&lt;SourceProvider&gt;&amp;&amp; sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment&amp; parentScopeTDZVariables, DerivedContextType derivedContextType)
</del><ins>+UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode&amp; source, SourceCode&amp;&amp; parentSourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment&amp; parentScopeTDZVariables, DerivedContextType derivedContextType)
</ins><span class="cx">     : Base(*vm, structure)
</span><span class="cx">     , m_firstLineOffset(node-&gt;firstLine() - source.firstLine())
</span><span class="cx">     , m_lineCount(node-&gt;lastLine() - node-&gt;firstLine())
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     , m_name(node-&gt;ident())
</span><span class="cx">     , m_ecmaName(node-&gt;ecmaName())
</span><span class="cx">     , m_inferredName(node-&gt;inferredName())
</span><del>-    , m_sourceOverride(WTFMove(sourceOverride))
</del><ins>+    , m_parentSourceOverride(WTFMove(parentSourceOverride))
</ins><span class="cx">     , m_classSource(node-&gt;classSource())
</span><span class="cx"> {
</span><span class="cx">     // Make sure these bitfields are adequately wide.
</span><span class="lines">@@ -131,35 +131,35 @@
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_unlinkedCodeBlockForConstruct);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FunctionExecutable* UnlinkedFunctionExecutable::link(VM&amp; vm, const SourceCode&amp; ownerSource, std::optional&lt;int&gt; overrideLineNumber, Intrinsic intrinsic)
</del><ins>+FunctionExecutable* UnlinkedFunctionExecutable::link(VM&amp; vm, const SourceCode&amp; passedParentSource, std::optional&lt;int&gt; overrideLineNumber, Intrinsic intrinsic)
</ins><span class="cx"> {
</span><del>-    SourceCode source = m_sourceOverride ? SourceCode(m_sourceOverride) : ownerSource;
-    unsigned firstLine = source.firstLine() + m_firstLineOffset;
-    unsigned startOffset = source.startOffset() + m_startOffset;
</del><ins>+    const SourceCode&amp; parentSource = m_parentSourceOverride.isNull() ? passedParentSource : m_parentSourceOverride;
+    unsigned firstLine = parentSource.firstLine() + m_firstLineOffset;
+    unsigned startOffset = parentSource.startOffset() + m_startOffset;
</ins><span class="cx">     unsigned lineCount = m_lineCount;
</span><span class="cx"> 
</span><span class="cx">     // Adjust to one-based indexing.
</span><span class="cx">     bool startColumnIsOnFirstSourceLine = !m_firstLineOffset;
</span><del>-    unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? source.startColumn() : 1);
</del><ins>+    unsigned startColumn = m_unlinkedBodyStartColumn + (startColumnIsOnFirstSourceLine ? parentSource.startColumn() : 1);
</ins><span class="cx">     bool endColumnIsOnStartLine = !lineCount;
</span><span class="cx">     unsigned endColumn = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? startColumn : 1);
</span><span class="cx"> 
</span><del>-    SourceCode code(source.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn);
</del><ins>+    SourceCode source(parentSource.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn);
</ins><span class="cx">     FunctionOverrides::OverrideInfo overrideInfo;
</span><span class="cx">     bool hasFunctionOverride = false;
</span><span class="cx"> 
</span><span class="cx">     if (UNLIKELY(Options::functionOverrides())) {
</span><del>-        hasFunctionOverride = FunctionOverrides::initializeOverrideFor(code, overrideInfo);
</del><ins>+        hasFunctionOverride = FunctionOverrides::initializeOverrideFor(source, overrideInfo);
</ins><span class="cx">         if (UNLIKELY(hasFunctionOverride)) {
</span><span class="cx">             firstLine = overrideInfo.firstLine;
</span><span class="cx">             lineCount = overrideInfo.lineCount;
</span><span class="cx">             startColumn = overrideInfo.startColumn;
</span><span class="cx">             endColumn = overrideInfo.endColumn;
</span><del>-            code = overrideInfo.sourceCode;
</del><ins>+            source = overrideInfo.sourceCode;
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    FunctionExecutable* result = FunctionExecutable::create(vm, code, this, firstLine + lineCount, endColumn, intrinsic);
</del><ins>+    FunctionExecutable* result = FunctionExecutable::create(vm, source, this, firstLine + lineCount, endColumn, intrinsic);
</ins><span class="cx">     if (overrideLineNumber)
</span><span class="cx">         result-&gt;setOverrideLineNumber(*overrideLineNumber);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedFunctionExecutableh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h (209356 => 209357)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h        2016-12-05 22:56:14 UTC (rev 209356)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h        2016-12-05 23:00:36 UTC (rev 209357)
</span><span class="lines">@@ -64,10 +64,10 @@
</span><span class="cx">     typedef JSCell Base;
</span><span class="cx">     static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
</span><span class="cx"> 
</span><del>-    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode&amp; source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment&amp; parentScopeTDZVariables, DerivedContextType derivedContextType, RefPtr&lt;SourceProvider&gt;&amp;&amp; sourceOverride = nullptr)
</del><ins>+    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode&amp; source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, VariableEnvironment&amp; parentScopeTDZVariables, DerivedContextType derivedContextType, SourceCode&amp;&amp; parentSourceOverride = SourceCode())
</ins><span class="cx">     {
</span><span class="cx">         UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell&lt;UnlinkedFunctionExecutable&gt;(vm-&gt;heap))
</span><del>-            UnlinkedFunctionExecutable(vm, vm-&gt;unlinkedFunctionExecutableStructure.get(), source, WTFMove(sourceOverride), node, unlinkedFunctionKind, constructAbility, scriptMode, parentScopeTDZVariables, derivedContextType);
</del><ins>+            UnlinkedFunctionExecutable(vm, vm-&gt;unlinkedFunctionExecutableStructure.get(), source, WTFMove(parentSourceOverride), node, unlinkedFunctionKind, constructAbility, scriptMode, parentScopeTDZVariables, derivedContextType);
</ins><span class="cx">         instance-&gt;finishCreation(*vm);
</span><span class="cx">         return instance;
</span><span class="cx">     }
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">         const Identifier&amp;, ExecState&amp;, const SourceCode&amp;, JSObject*&amp; exception, 
</span><span class="cx">         int overrideLineNumber);
</span><span class="cx"> 
</span><del>-    JS_EXPORT_PRIVATE FunctionExecutable* link(VM&amp;, const SourceCode&amp;, std::optional&lt;int&gt; overrideLineNumber = std::nullopt, Intrinsic = NoIntrinsic);
</del><ins>+    JS_EXPORT_PRIVATE FunctionExecutable* link(VM&amp;, const SourceCode&amp; parentSource, std::optional&lt;int&gt; overrideLineNumber = std::nullopt, Intrinsic = NoIntrinsic);
</ins><span class="cx"> 
</span><span class="cx">     void clearCode()
</span><span class="cx">     {
</span><span class="lines">@@ -142,7 +142,7 @@
</span><span class="cx">     void setSourceMappingURLDirective(const String&amp; sourceMappingURL) { m_sourceMappingURLDirective = sourceMappingURL; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&amp;, RefPtr&lt;SourceProvider&gt;&amp;&amp; sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, VariableEnvironment&amp;,  JSC::DerivedContextType);
</del><ins>+    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&amp;, SourceCode&amp;&amp; parentSourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, VariableEnvironment&amp;,  JSC::DerivedContextType);
</ins><span class="cx"> 
</span><span class="cx">     unsigned m_firstLineOffset;
</span><span class="cx">     unsigned m_lineCount;
</span><span class="lines">@@ -174,7 +174,7 @@
</span><span class="cx">     Identifier m_name;
</span><span class="cx">     Identifier m_ecmaName;
</span><span class="cx">     Identifier m_inferredName;
</span><del>-    RefPtr&lt;SourceProvider&gt; m_sourceOverride;
</del><ins>+    SourceCode m_parentSourceOverride;
</ins><span class="cx">     SourceCode m_classSource;
</span><span class="cx"> 
</span><span class="cx">     String m_sourceURLDirective;
</span></span></pre>
</div>
</div>

</body>
</html>