<!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>[210537] trunk</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/210537">210537</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2017-01-09 21:58:19 -0800 (Mon, 09 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement JSSourceCode to propagate SourceCode in module pipeline
https://bugs.webkit.org/show_bug.cgi?id=166861

Reviewed by Saam Barati.

Source/JavaScriptCore:

Instead of propagating source code string, we propagate JSSourceCode
cell in the module pipeline. This allows us to attach a metadata
to the propagated source code string. In particular, it propagates
SourceOrigin through the module pipeline.

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/ModuleLoaderPrototype.js:
(fulfillFetch):
(requestFetch):
* jsc.cpp:
(GlobalObject::moduleLoaderFetch):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LowLevelInterpreter.asm:
* runtime/Completion.cpp:
(JSC::loadAndEvaluateModule):
(JSC::loadModule):
* runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::provide):
* runtime/JSModuleLoader.h:
* runtime/JSSourceCode.cpp: Added.
(JSC::JSSourceCode::destroy):
* runtime/JSSourceCode.h: Added.
(JSC::JSSourceCode::createStructure):
(JSC::JSSourceCode::create):
(JSC::JSSourceCode::sourceCode):
(JSC::JSSourceCode::JSSourceCode):
* runtime/JSType.h:
* runtime/ModuleLoaderPrototype.cpp:
(JSC::moduleLoaderPrototypeParseModule):
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:

Source/WebCore:

Now SourceOrigin is correctly propagated through the module pipeline.
So the error reported by http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.html
is updated.

* ForwardingHeaders/runtime/JSSourceCode.h: Added.
* bindings/js/JSDOMPromise.h:
(WebCore::DeferredPromise::resolveWithCallback):
* bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::notifyFinished):

LayoutTests:

* http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicymoduleevalblockedexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsModuleLoaderPrototypejs">trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLLIntDatacpp">trunk/Source/JavaScriptCore/llint/LLIntData.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreterasm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCompletioncpp">trunk/Source/JavaScriptCore/runtime/Completion.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSModuleLoadercpp">trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSModuleLoaderh">trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSTypeh">trunk/Source/JavaScriptCore/runtime/JSType.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeModuleLoaderPrototypecpp">trunk/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMcpp">trunk/Source/JavaScriptCore/runtime/VM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMh">trunk/Source/JavaScriptCore/runtime/VM.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMPromiseh">trunk/Source/WebCore/bindings/js/JSDOMPromise.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptModuleLoadercpp">trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSSourceCodecpp">trunk/Source/JavaScriptCore/runtime/JSSourceCode.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSSourceCodeh">trunk/Source/JavaScriptCore/runtime/JSSourceCode.h</a></li>
<li><a href="#trunkSourceWebCoreForwardingHeadersruntimeJSSourceCodeh">trunk/Source/WebCore/ForwardingHeaders/runtime/JSSourceCode.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/LayoutTests/ChangeLog        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-01-09  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Implement JSSourceCode to propagate SourceCode in module pipeline
+        https://bugs.webkit.org/show_bug.cgi?id=166861
+
+        Reviewed by Saam Barati.
+
+        * http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.txt:
+
</ins><span class="cx"> 2017-01-09  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r189555): ImageDocument title no longer includes the size of the image
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicymoduleevalblockedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.txt (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.txt        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.txt        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -1,37 +1,37 @@
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 16: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 17: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 34: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 35: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 36: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 37: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 38: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 39: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 40: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 41: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 42: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 43: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 44: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 45: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 46: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 47: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 48: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><del>-CONSOLE MESSAGE: line 1: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</del><ins>+CONSOLE MESSAGE: line 49: EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'unsafe-inline'&quot;.
</ins><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -788,6 +788,7 @@
</span><span class="cx">     runtime/JSSegmentedVariableObject.cpp
</span><span class="cx">     runtime/JSSet.cpp
</span><span class="cx">     runtime/JSSetIterator.cpp
</span><ins>+    runtime/JSSourceCode.cpp
</ins><span class="cx">     runtime/JSString.cpp
</span><span class="cx">     runtime/JSStringIterator.cpp
</span><span class="cx">     runtime/JSStringJoiner.cpp
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -1,5 +1,47 @@
</span><span class="cx"> 2017-01-09  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><ins>+        Implement JSSourceCode to propagate SourceCode in module pipeline
+        https://bugs.webkit.org/show_bug.cgi?id=166861
+
+        Reviewed by Saam Barati.
+
+        Instead of propagating source code string, we propagate JSSourceCode
+        cell in the module pipeline. This allows us to attach a metadata
+        to the propagated source code string. In particular, it propagates
+        SourceOrigin through the module pipeline.
+
+        * CMakeLists.txt:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * builtins/ModuleLoaderPrototype.js:
+        (fulfillFetch):
+        (requestFetch):
+        * jsc.cpp:
+        (GlobalObject::moduleLoaderFetch):
+        * llint/LLIntData.cpp:
+        (JSC::LLInt::Data::performAssertions):
+        * llint/LowLevelInterpreter.asm:
+        * runtime/Completion.cpp:
+        (JSC::loadAndEvaluateModule):
+        (JSC::loadModule):
+        * runtime/JSModuleLoader.cpp:
+        (JSC::JSModuleLoader::provide):
+        * runtime/JSModuleLoader.h:
+        * runtime/JSSourceCode.cpp: Added.
+        (JSC::JSSourceCode::destroy):
+        * runtime/JSSourceCode.h: Added.
+        (JSC::JSSourceCode::createStructure):
+        (JSC::JSSourceCode::create):
+        (JSC::JSSourceCode::sourceCode):
+        (JSC::JSSourceCode::JSSourceCode):
+        * runtime/JSType.h:
+        * runtime/ModuleLoaderPrototype.cpp:
+        (JSC::moduleLoaderPrototypeParseModule):
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * runtime/VM.h:
+
+2017-01-09  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
</ins><span class="cx">         REGRESSION (r210522): ASSERTION FAILED: divot.offset &gt;= divotStart.offset seen with stress/import-basic.js and stress/import-from-eval.js
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=166873
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -2372,6 +2372,8 @@
</span><span class="cx">                 FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
</span><span class="cx">                 FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                FA3AB211C8494524AB390267 /* JSSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */; };
+                BDFCB2BBE90F41349E1B0BED /* JSSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3032175DF1AD47D8998B34E1 /* JSSourceCode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx"> /* End PBXBuildFile section */
</span><span class="cx"> 
</span><span class="cx"> /* Begin PBXContainerItemProxy section */
</span><span class="lines">@@ -4900,6 +4902,8 @@
</span><span class="cx">                 FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSSourceCode.cpp; path = JSSourceCode.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                3032175DF1AD47D8998B34E1 /* JSSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSSourceCode.h; path = JSSourceCode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx"> /* End PBXFileReference section */
</span><span class="cx"> 
</span><span class="cx"> /* Begin PBXFrameworksBuildPhase section */
</span><span class="lines">@@ -6740,6 +6744,8 @@
</span><span class="cx">                                 A7DCB77912E3D90500911940 /* WriteBarrier.h */,
</span><span class="cx">                                 C2B6D75218A33793004A9301 /* WriteBarrierInlines.h */,
</span><span class="cx">                                 425BA1337E4344E1B269A671 /* SourceOrigin.h */,
</span><ins>+                                F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */,
+                                3032175DF1AD47D8998B34E1 /* JSSourceCode.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = runtime;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -9114,6 +9120,7 @@
</span><span class="cx">                                 86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */,
</span><span class="cx">                                 86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
</span><span class="cx">                                 2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */,
</span><ins>+                                BDFCB2BBE90F41349E1B0BED /* JSSourceCode.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="lines">@@ -10502,6 +10509,7 @@
</span><span class="cx">                                 86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
</span><span class="cx">                                 86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
</span><span class="cx">                                 86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
</span><ins>+                                FA3AB211C8494524AB390267 /* JSSourceCode.cpp in Sources */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsModuleLoaderPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx">         @fulfillPromise(promise, value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function fulfillFetch(entry, payload)
</del><ins>+function fulfillFetch(entry, source)
</ins><span class="cx"> {
</span><span class="cx">     // https://whatwg.github.io/loader/#fulfill-fetch
</span><span class="cx"> 
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!entry.fetch)
</span><span class="cx">         entry.fetch = @newPromiseCapability(@InternalPromise).@promise;
</span><del>-    this.forceFulfillPromise(entry.fetch, payload);
</del><ins>+    this.forceFulfillPromise(entry.fetch, source);
</ins><span class="cx">     @setStateToMax(entry, @ModuleInstantiate);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -220,9 +220,9 @@
</span><span class="cx">     //     Take the key and fetch the resource actually.
</span><span class="cx">     //     For example, JavaScriptCore shell can provide the hook fetching the resource
</span><span class="cx">     //     from the local file system.
</span><del>-    var fetchPromise = this.fetch(key, initiator).then((payload) =&gt; {
</del><ins>+    var fetchPromise = this.fetch(key, initiator).then((source) =&gt; {
</ins><span class="cx">         @setStateToMax(entry, @ModuleInstantiate);
</span><del>-        return payload;
</del><ins>+        return source;
</ins><span class="cx">     });
</span><span class="cx">     entry.fetch = fetchPromise;
</span><span class="cx">     return fetchPromise;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> #include &quot;JSNativeStdFunction.h&quot;
</span><span class="cx"> #include &quot;JSONObject.h&quot;
</span><span class="cx"> #include &quot;JSProxy.h&quot;
</span><ins>+#include &quot;JSSourceCode.h&quot;
</ins><span class="cx"> #include &quot;JSString.h&quot;
</span><span class="cx"> #include &quot;JSTypedArrays.h&quot;
</span><span class="cx"> #include &quot;JSWebAssemblyCallee.h&quot;
</span><span class="lines">@@ -1576,7 +1577,7 @@
</span><span class="cx">     if (!fetchModuleFromLocalFileSystem(moduleKey, utf8))
</span><span class="cx">         return deferred-&gt;reject(exec, createError(exec, makeString(&quot;Could not open file '&quot;, moduleKey, &quot;'.&quot;)));
</span><span class="cx"> 
</span><del>-    return deferred-&gt;resolve(exec, jsString(exec, stringFromUTF(utf8)));
</del><ins>+    return deferred-&gt;resolve(exec, JSSourceCode::create(exec-&gt;vm(), makeSource(stringFromUTF(utf8), SourceOrigin { moduleKey })));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLLIntDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LLIntData.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LLIntData.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/llint/LLIntData.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -156,21 +156,21 @@
</span><span class="cx">     
</span><span class="cx">     STATIC_ASSERT(StringType == 6);
</span><span class="cx">     STATIC_ASSERT(SymbolType == 7);
</span><del>-    STATIC_ASSERT(ObjectType == 21);
-    STATIC_ASSERT(FinalObjectType == 22);
-    STATIC_ASSERT(JSFunctionType == 24);
-    STATIC_ASSERT(ArrayType == 32);
-    STATIC_ASSERT(DerivedArrayType == 33);
-    STATIC_ASSERT(ProxyObjectType == 51);
-    STATIC_ASSERT(Int8ArrayType == 34);
-    STATIC_ASSERT(Int16ArrayType == 35);
-    STATIC_ASSERT(Int32ArrayType == 36);
-    STATIC_ASSERT(Uint8ArrayType == 37);
-    STATIC_ASSERT(Uint8ClampedArrayType == 38);
-    STATIC_ASSERT(Uint16ArrayType == 39);
-    STATIC_ASSERT(Uint32ArrayType == 40);
-    STATIC_ASSERT(Float32ArrayType == 41);
-    STATIC_ASSERT(Float64ArrayType == 42);
</del><ins>+    STATIC_ASSERT(ObjectType == 22);
+    STATIC_ASSERT(FinalObjectType == 23);
+    STATIC_ASSERT(JSFunctionType == 25);
+    STATIC_ASSERT(ArrayType == 33);
+    STATIC_ASSERT(DerivedArrayType == 34);
+    STATIC_ASSERT(ProxyObjectType == 52);
+    STATIC_ASSERT(Int8ArrayType == 35);
+    STATIC_ASSERT(Int16ArrayType == 36);
+    STATIC_ASSERT(Int32ArrayType == 37);
+    STATIC_ASSERT(Uint8ArrayType == 38);
+    STATIC_ASSERT(Uint8ClampedArrayType == 39);
+    STATIC_ASSERT(Uint16ArrayType == 40);
+    STATIC_ASSERT(Uint32ArrayType == 41);
+    STATIC_ASSERT(Float32ArrayType == 42);
+    STATIC_ASSERT(Float64ArrayType == 43);
</ins><span class="cx">     STATIC_ASSERT(MasqueradesAsUndefined == 1);
</span><span class="cx">     STATIC_ASSERT(ImplementsDefaultHasInstance == 2);
</span><span class="cx">     STATIC_ASSERT(FirstConstantRegisterIndex == 0x40000000);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreterasm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -345,24 +345,24 @@
</span><span class="cx"> # Type constants.
</span><span class="cx"> const StringType = 6
</span><span class="cx"> const SymbolType = 7
</span><del>-const ObjectType = 21
-const FinalObjectType = 22
-const JSFunctionType = 24
-const ArrayType = 32
-const DerivedArrayType = 33
-const ProxyObjectType = 51
</del><ins>+const ObjectType = 22
+const FinalObjectType = 23
+const JSFunctionType = 25
+const ArrayType = 33
+const DerivedArrayType = 34
+const ProxyObjectType = 52
</ins><span class="cx"> 
</span><span class="cx"> # The typed array types need to be numbered in a particular order because of the manually written
</span><span class="cx"> # switch statement in get_by_val and put_by_val.
</span><del>-const Int8ArrayType = 34
-const Int16ArrayType = 35
-const Int32ArrayType = 36
-const Uint8ArrayType = 37
-const Uint8ClampedArrayType = 38
-const Uint16ArrayType = 39
-const Uint32ArrayType = 40
-const Float32ArrayType = 41
-const Float64ArrayType = 42
</del><ins>+const Int8ArrayType = 35
+const Int16ArrayType = 36
+const Int32ArrayType = 37
+const Uint8ArrayType = 38
+const Uint8ClampedArrayType = 39
+const Uint16ArrayType = 40
+const Uint32ArrayType = 41
+const Float32ArrayType = 42
+const Float64ArrayType = 43
</ins><span class="cx"> 
</span><span class="cx"> const FirstArrayType = Int8ArrayType
</span><span class="cx"> const LastArrayType = Float64ArrayType
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCompletioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Completion.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Completion.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/Completion.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx">     JSGlobalObject* globalObject = exec-&gt;vmEntryGlobalObject();
</span><span class="cx"> 
</span><span class="cx">     // Insert the given source code to the ModuleLoader registry as the fetched registry entry.
</span><del>-    globalObject-&gt;moduleLoader()-&gt;provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
</del><ins>+    globalObject-&gt;moduleLoader()-&gt;provide(exec, key, JSModuleLoader::Status::Fetch, source);
</ins><span class="cx">     RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
</span><span class="cx"> 
</span><span class="cx">     return loadAndEvaluateModule(lock, exec, globalObject, key, jsUndefined(), initiator);
</span><span class="lines">@@ -232,7 +232,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Insert the given source code to the ModuleLoader registry as the fetched registry entry.
</span><span class="cx">     // FIXME: Introduce JSSourceCode object to wrap around this source.
</span><del>-    globalObject-&gt;moduleLoader()-&gt;provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
</del><ins>+    globalObject-&gt;moduleLoader()-&gt;provide(exec, key, JSModuleLoader::Status::Fetch, source);
</ins><span class="cx">     RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
</span><span class="cx"> 
</span><span class="cx">     return loadModule(lock, exec, globalObject, key, jsUndefined(), initiator);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSModuleLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;JSMap.h&quot;
</span><span class="cx"> #include &quot;JSModuleEnvironment.h&quot;
</span><span class="cx"> #include &quot;JSModuleRecord.h&quot;
</span><ins>+#include &quot;JSSourceCode.h&quot;
</ins><span class="cx"> #include &quot;ModuleAnalyzer.h&quot;
</span><span class="cx"> #include &quot;ModuleLoaderPrototype.h&quot;
</span><span class="cx"> #include &quot;Nodes.h&quot;
</span><span class="lines">@@ -75,17 +76,19 @@
</span><span class="cx">     return exec-&gt;propertyNames().emptyIdentifier.impl();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue JSModuleLoader::provide(ExecState* exec, JSValue key, Status status, const String&amp; source)
</del><ins>+JSValue JSModuleLoader::provide(ExecState* exec, JSValue key, Status status, const SourceCode&amp; sourceCode)
</ins><span class="cx"> {
</span><ins>+    VM&amp; vm = exec-&gt;vm();
</ins><span class="cx">     JSObject* function = jsCast&lt;JSObject*&gt;(get(exec, exec-&gt;propertyNames().builtinNames().providePublicName()));
</span><span class="cx">     CallData callData;
</span><span class="cx">     CallType callType = JSC::getCallData(function, callData);
</span><span class="cx">     ASSERT(callType != CallType::None);
</span><span class="cx"> 
</span><ins>+    SourceCode source { sourceCode };
</ins><span class="cx">     MarkedArgumentBuffer arguments;
</span><span class="cx">     arguments.append(key);
</span><span class="cx">     arguments.append(jsNumber(status));
</span><del>-    arguments.append(jsString(exec, source));
</del><ins>+    arguments.append(JSSourceCode::create(vm, WTFMove(source)));
</ins><span class="cx"> 
</span><span class="cx">     return call(exec, function, callType, callData, this, arguments);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSModuleLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> class JSInternalPromise;
</span><span class="cx"> class JSModuleNamespaceObject;
</span><ins>+class SourceCode;
</ins><span class="cx"> 
</span><span class="cx"> class JSModuleLoader : public JSNonFinalObject {
</span><span class="cx"> private:
</span><span class="lines">@@ -62,7 +63,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // APIs to control the module loader.
</span><del>-    JSValue provide(ExecState*, JSValue key, Status, const String&amp;);
</del><ins>+    JSValue provide(ExecState*, JSValue key, Status, const SourceCode&amp;);
</ins><span class="cx">     JSInternalPromise* loadAndEvaluateModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue initiator);
</span><span class="cx">     JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue initiator);
</span><span class="cx">     JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue initiator);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSSourceCodecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/runtime/JSSourceCode.cpp (0 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSSourceCode.cpp                                (rev 0)
+++ trunk/Source/JavaScriptCore/runtime/JSSourceCode.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2016 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;JSSourceCode.h&quot;
+
+#include &quot;JSCInlines.h&quot;
+
+namespace JSC {
+
+const ClassInfo JSSourceCode::s_info = { &quot;JSSourceCode&quot;, nullptr, nullptr, CREATE_METHOD_TABLE(JSSourceCode) };
+
+void JSSourceCode::destroy(JSCell* cell)
+{
+    static_cast&lt;JSSourceCode*&gt;(cell)-&gt;~JSSourceCode();
+}
+
+} // namespace JSC
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSSourceCodeh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/runtime/JSSourceCode.h (0 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSSourceCode.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/runtime/JSSourceCode.h        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * Copyright (C) 2016 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &quot;JSGlobalObject.h&quot;
+#include &quot;JSObject.h&quot;
+#include &quot;SourceCode.h&quot;
+
+namespace JSC {
+
+class JSSourceCode : public JSCell {
+public:
+    using Base = JSCell;
+
+    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
+    static const bool needsDestruction = true;
+
+    DECLARE_EXPORT_INFO;
+
+    static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(vm, globalObject, prototype, TypeInfo(JSSourceCodeType, StructureFlags), info());
+    }
+
+    static JSSourceCode* create(VM&amp; vm, Structure* structure, SourceCode&amp;&amp; sourceCode)
+    {
+        auto* result = new (NotNull, allocateCell&lt;JSSourceCode&gt;(vm.heap)) JSSourceCode(vm, structure, WTFMove(sourceCode));
+        result-&gt;finishCreation(vm);
+        return result;
+    }
+
+    static JSSourceCode* create(VM&amp; vm, SourceCode&amp;&amp; sourceCode)
+    {
+        return create(vm, vm.sourceCodeStructure.get(), WTFMove(sourceCode));
+    }
+
+    const SourceCode&amp; sourceCode() const
+    {
+        return m_sourceCode;
+    }
+
+    static void destroy(JSCell*);
+
+private:
+    JSSourceCode(VM&amp; vm, Structure* structure, SourceCode&amp;&amp; sourceCode)
+        : Base(vm, structure)
+        , m_sourceCode(WTFMove(sourceCode))
+    {
+    }
+
+    SourceCode m_sourceCode;
+};
+
+} // namespace JSC
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSType.h (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSType.h        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/JSType.h        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     UnlinkedFunctionCodeBlockType,
</span><span class="cx"> 
</span><span class="cx">     JSFixedArrayType,
</span><ins>+    JSSourceCodeType,
</ins><span class="cx"> 
</span><span class="cx">     // The ObjectType value must come before any JSType that is a subclass of JSObject.
</span><span class="cx">     ObjectType,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeModuleLoaderPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;JSModuleLoader.h&quot;
</span><span class="cx"> #include &quot;JSModuleNamespaceObject.h&quot;
</span><span class="cx"> #include &quot;JSModuleRecord.h&quot;
</span><ins>+#include &quot;JSSourceCode.h&quot;
</ins><span class="cx"> #include &quot;ModuleAnalyzer.h&quot;
</span><span class="cx"> #include &quot;Nodes.h&quot;
</span><span class="cx"> #include &quot;Parser.h&quot;
</span><span class="lines">@@ -112,11 +113,11 @@
</span><span class="cx">     const Identifier moduleKey = exec-&gt;argument(0).toPropertyKey(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> 
</span><del>-    String source = exec-&gt;argument(1).toWTFString(exec);
-    RETURN_IF_EXCEPTION(scope, encodedJSValue());
</del><ins>+    auto* jsSourceCode = jsDynamicCast&lt;JSSourceCode*&gt;(exec-&gt;argument(1));
+    if (!jsSourceCode)
+        return throwVMTypeError(exec, scope);
+    SourceCode sourceCode = jsSourceCode-&gt;sourceCode();
</ins><span class="cx"> 
</span><del>-    SourceCode sourceCode = makeSource(source, SourceOrigin { moduleKey.impl() }, moduleKey.impl(), TextPosition(), SourceProviderSourceType::Module);
-
</del><span class="cx">     CodeProfiling profile(sourceCode);
</span><span class="cx"> 
</span><span class="cx">     ParserError error;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> #include &quot;JSMap.h&quot;
</span><span class="cx"> #include &quot;JSPromiseDeferred.h&quot;
</span><span class="cx"> #include &quot;JSPropertyNameEnumerator.h&quot;
</span><ins>+#include &quot;JSSourceCode.h&quot;
</ins><span class="cx"> #include &quot;JSTemplateRegistryKey.h&quot;
</span><span class="cx"> #include &quot;JSWebAssembly.h&quot;
</span><span class="cx"> #include &quot;JSWithScope.h&quot;
</span><span class="lines">@@ -238,6 +239,7 @@
</span><span class="cx">     symbolStructure.set(*this, Symbol::createStructure(*this, 0, jsNull()));
</span><span class="cx">     symbolTableStructure.set(*this, SymbolTable::createStructure(*this, 0, jsNull()));
</span><span class="cx">     fixedArrayStructure.set(*this, JSFixedArray::createStructure(*this, 0, jsNull()));
</span><ins>+    sourceCodeStructure.set(*this, JSSourceCode::createStructure(*this, 0, jsNull()));
</ins><span class="cx">     structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
</span><span class="cx">     sparseArrayValueMapStructure.set(*this, SparseArrayValueMap::createStructure(*this, 0, jsNull()));
</span><span class="cx">     templateRegistryKeyStructure.set(*this, JSTemplateRegistryKey::createStructure(*this, 0, jsNull()));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/JavaScriptCore/runtime/VM.h        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -326,6 +326,7 @@
</span><span class="cx">     Strong&lt;Structure&gt; symbolStructure;
</span><span class="cx">     Strong&lt;Structure&gt; symbolTableStructure;
</span><span class="cx">     Strong&lt;Structure&gt; fixedArrayStructure;
</span><ins>+    Strong&lt;Structure&gt; sourceCodeStructure;
</ins><span class="cx">     Strong&lt;Structure&gt; structureChainStructure;
</span><span class="cx">     Strong&lt;Structure&gt; sparseArrayValueMapStructure;
</span><span class="cx">     Strong&lt;Structure&gt; templateRegistryKeyStructure;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/WebCore/ChangeLog        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2017-01-09  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        Implement JSSourceCode to propagate SourceCode in module pipeline
+        https://bugs.webkit.org/show_bug.cgi?id=166861
+
+        Reviewed by Saam Barati.
+
+        Now SourceOrigin is correctly propagated through the module pipeline.
+        So the error reported by http/tests/security/contentSecurityPolicy/module-eval-blocked-expected.html
+        is updated.
+
+        * ForwardingHeaders/runtime/JSSourceCode.h: Added.
+        * bindings/js/JSDOMPromise.h:
+        (WebCore::DeferredPromise::resolveWithCallback):
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::notifyFinished):
+
</ins><span class="cx"> 2017-01-09  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r189555): ImageDocument title no longer includes the size of the image
</span></span></pre></div>
<a id="trunkSourceWebCoreForwardingHeadersruntimeJSSourceCodeh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/ForwardingHeaders/runtime/JSSourceCode.h (0 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ForwardingHeaders/runtime/JSSourceCode.h                                (rev 0)
+++ trunk/Source/WebCore/ForwardingHeaders/runtime/JSSourceCode.h        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+/*
+ * Copyright (C) 2016 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+#include &lt;JavaScriptCore/JSSourceCode.h&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMPromiseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.h (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMPromise.h        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.h        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -94,6 +94,18 @@
</span><span class="cx">     void reject(ExceptionCode, const String&amp; = { });
</span><span class="cx">     void reject(const JSC::PrivateName&amp;);
</span><span class="cx"> 
</span><ins>+    template&lt;typename Callback, typename Value&gt;
+    void resolveWithCallback(Callback callback, Value value)
+    {
+        if (isSuspended())
+            return;
+        ASSERT(m_deferred);
+        ASSERT(m_globalObject);
+        JSC::ExecState* exec = m_globalObject-&gt;globalExec();
+        JSC::JSLockHolder locker(exec);
+        resolve(*exec, callback(*exec, *m_globalObject.get(), std::forward&lt;Value&gt;(value)));
+    }
+
</ins><span class="cx">     JSC::JSValue promise() const;
</span><span class="cx"> 
</span><span class="cx">     bool isSuspended() { return !m_deferred || !canInvokeCallback(); } // The wrapper world has gone away or active DOM objects have been suspended.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptModuleLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp (210536 => 210537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp        2017-01-10 05:04:36 UTC (rev 210536)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp        2017-01-10 05:58:19 UTC (rev 210537)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include &lt;runtime/JSInternalPromise.h&gt;
</span><span class="cx"> #include &lt;runtime/JSInternalPromiseDeferred.h&gt;
</span><span class="cx"> #include &lt;runtime/JSModuleRecord.h&gt;
</span><ins>+#include &lt;runtime/JSSourceCode.h&gt;
</ins><span class="cx"> #include &lt;runtime/JSString.h&gt;
</span><span class="cx"> #include &lt;runtime/Symbol.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -245,8 +246,10 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_requestURLToResponseURLMap.add(cachedScript.url(), cachedScript.response().url());
</span><del>-    // FIXME: Let's wrap around ScriptSourceCode to propagate it directly through the module pipeline.
-    promise-&gt;resolve&lt;IDLDOMString&gt;(ScriptSourceCode(&amp;cachedScript, JSC::SourceProviderSourceType::Module).source().toString());
</del><ins>+    ScriptSourceCode scriptSourceCode(&amp;cachedScript, JSC::SourceProviderSourceType::Module);
+    promise-&gt;resolveWithCallback([] (JSC::ExecState&amp; state, JSDOMGlobalObject&amp;, JSC::SourceCode sourceCode) {
+        return JSC::JSSourceCode::create(state.vm(), WTFMove(sourceCode));
+    }, scriptSourceCode.jsSourceCode());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>