<!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>[166218] 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/166218">166218</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-03-24 20:44:52 -0700 (Mon, 24 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>More scaffolding for a stub routine to have a stub recursively embedded inside it
https://bugs.webkit.org/show_bug.cgi?id=130770

Reviewed by Oliver Hunt.

* bytecode/CallLinkInfo.cpp:
(JSC::CallLinkInfo::unlink): VM&amp; argument is superfluous.
(JSC::CallLinkInfo::visitWeak): Factor this out, it used to be in CodeBlock::finalizeUnconditionally().
* bytecode/CallLinkInfo.h:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::finalizeUnconditionally): Factor out some functionality into CallLinkInfo::visitWeak(), and make sure we pass RepatchBuffer&amp; in more places.
(JSC::CodeBlock::unlinkCalls):
(JSC::CodeBlock::unlinkIncomingCalls):
* bytecode/PolymorphicGetByIdList.cpp: Pass RepatchBuffer&amp; through and call JITStubRoutine::visitWeak().
(JSC::GetByIdAccess::visitWeak):
(JSC::PolymorphicGetByIdList::visitWeak):
* bytecode/PolymorphicGetByIdList.h:
* bytecode/PolymorphicPutByIdList.cpp: Pass RepatchBuffer&amp; through and call JITStubRoutine::visitWeak().
(JSC::PutByIdAccess::visitWeak):
(JSC::PolymorphicPutByIdList::visitWeak):
* bytecode/PolymorphicPutByIdList.h:
* bytecode/StructureStubInfo.cpp: Pass RepatchBuffer&amp; through.
(JSC::StructureStubInfo::visitWeakReferences):
* bytecode/StructureStubInfo.h:
* jit/ClosureCallStubRoutine.cpp: isClosureCall is unused.
(JSC::ClosureCallStubRoutine::ClosureCallStubRoutine):
* jit/GCAwareJITStubRoutine.cpp:
(JSC::GCAwareJITStubRoutine::GCAwareJITStubRoutine):
(JSC::createJITStubRoutine):
* jit/GCAwareJITStubRoutine.h: Make it easier to construct one of these.
(JSC::GCAwareJITStubRoutine::isClosureCall): Deleted.
* jit/JITStubRoutine.cpp:
(JSC::JITStubRoutine::visitWeak): This will allow future JITStubRoutine subclasses to have stubs recursively embedded inside them.
* jit/JITStubRoutine.h:
* jit/Repatch.cpp:
(JSC::generateGetByIdStub): Fix a possible GC bug where we weren't making the stub routine GC aware.
(JSC::emitCustomSetterStub): Clean up some code.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCallLinkInfocpp">trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCallLinkInfoh">trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodePolymorphicGetByIdListcpp">trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodePolymorphicGetByIdListh">trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodePolymorphicPutByIdListcpp">trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodePolymorphicPutByIdListh">trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeStructureStubInfocpp">trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeStructureStubInfoh">trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitClosureCallStubRoutinecpp">trunk/Source/JavaScriptCore/jit/ClosureCallStubRoutine.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitGCAwareJITStubRoutinecpp">trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitGCAwareJITStubRoutineh">trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITStubRoutinecpp">trunk/Source/JavaScriptCore/jit/JITStubRoutine.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITStubRoutineh">trunk/Source/JavaScriptCore/jit/JITStubRoutine.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitRepatchcpp">trunk/Source/JavaScriptCore/jit/Repatch.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2014-03-24  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        More scaffolding for a stub routine to have a stub recursively embedded inside it
+        https://bugs.webkit.org/show_bug.cgi?id=130770
+
+        Reviewed by Oliver Hunt.
+
+        * bytecode/CallLinkInfo.cpp:
+        (JSC::CallLinkInfo::unlink): VM&amp; argument is superfluous.
+        (JSC::CallLinkInfo::visitWeak): Factor this out, it used to be in CodeBlock::finalizeUnconditionally().
+        * bytecode/CallLinkInfo.h:
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::finalizeUnconditionally): Factor out some functionality into CallLinkInfo::visitWeak(), and make sure we pass RepatchBuffer&amp; in more places.
+        (JSC::CodeBlock::unlinkCalls):
+        (JSC::CodeBlock::unlinkIncomingCalls):
+        * bytecode/PolymorphicGetByIdList.cpp: Pass RepatchBuffer&amp; through and call JITStubRoutine::visitWeak().
+        (JSC::GetByIdAccess::visitWeak):
+        (JSC::PolymorphicGetByIdList::visitWeak):
+        * bytecode/PolymorphicGetByIdList.h:
+        * bytecode/PolymorphicPutByIdList.cpp: Pass RepatchBuffer&amp; through and call JITStubRoutine::visitWeak().
+        (JSC::PutByIdAccess::visitWeak):
+        (JSC::PolymorphicPutByIdList::visitWeak):
+        * bytecode/PolymorphicPutByIdList.h:
+        * bytecode/StructureStubInfo.cpp: Pass RepatchBuffer&amp; through.
+        (JSC::StructureStubInfo::visitWeakReferences):
+        * bytecode/StructureStubInfo.h:
+        * jit/ClosureCallStubRoutine.cpp: isClosureCall is unused.
+        (JSC::ClosureCallStubRoutine::ClosureCallStubRoutine):
+        * jit/GCAwareJITStubRoutine.cpp:
+        (JSC::GCAwareJITStubRoutine::GCAwareJITStubRoutine):
+        (JSC::createJITStubRoutine):
+        * jit/GCAwareJITStubRoutine.h: Make it easier to construct one of these.
+        (JSC::GCAwareJITStubRoutine::isClosureCall): Deleted.
+        * jit/JITStubRoutine.cpp:
+        (JSC::JITStubRoutine::visitWeak): This will allow future JITStubRoutine subclasses to have stubs recursively embedded inside them.
+        * jit/JITStubRoutine.h:
+        * jit/Repatch.cpp:
+        (JSC::generateGetByIdStub): Fix a possible GC bug where we weren't making the stub routine GC aware.
+        (JSC::emitCustomSetterStub): Clean up some code.
+
</ins><span class="cx"> 2014-03-24  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Safari crashes in JavaScriptCore: JSC::JSObject::growOutOfLineStorage
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCallLinkInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #if ENABLE(JIT)
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-void CallLinkInfo::unlink(VM&amp; vm, RepatchBuffer&amp; repatchBuffer)
</del><ins>+void CallLinkInfo::unlink(RepatchBuffer&amp; repatchBuffer)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isLinked());
</span><span class="cx">     
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">     repatchBuffer.revertJumpReplacementToBranchPtrWithPatch(RepatchBuffer::startOfBranchPtrWithPatchOnRegister(hotPathBegin), static_cast&lt;MacroAssembler::RegisterID&gt;(calleeGPR), 0);
</span><span class="cx">     repatchBuffer.relink(
</span><span class="cx">         callReturnLocation,
</span><del>-        vm.getCTIStub(linkThunkGeneratorFor(
</del><ins>+        repatchBuffer.codeBlock()-&gt;vm()-&gt;getCTIStub(linkThunkGeneratorFor(
</ins><span class="cx">             callType == Construct ? CodeForConstruct : CodeForCall,
</span><span class="cx">             isFTL ? MustPreserveRegisters : RegisterPreservationNotRequired)).code());
</span><span class="cx">     hasSeenShouldRepatch = false;
</span><span class="lines">@@ -57,6 +57,35 @@
</span><span class="cx">         remove();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CallLinkInfo::visitWeak(RepatchBuffer&amp; repatchBuffer)
+{
+    if (isLinked()) {
+        if (stub) {
+            if (!Heap::isMarked(stub-&gt;structure())
+                || !Heap::isMarked(stub-&gt;executable())) {
+                if (Options::verboseOSR()) {
+                    dataLog(
+                        &quot;Clearing closure call from &quot;, *repatchBuffer.codeBlock(), &quot; to &quot;,
+                        stub-&gt;executable()-&gt;hashFor(specializationKind()),
+                        &quot;, stub routine &quot;, RawPointer(stub.get()), &quot;.\n&quot;);
+                }
+                unlink(repatchBuffer);
+            }
+        } else if (!Heap::isMarked(callee.get())) {
+            if (Options::verboseOSR()) {
+                dataLog(
+                    &quot;Clearing call from &quot;, *repatchBuffer.codeBlock(), &quot; to &quot;,
+                    RawPointer(callee.get()), &quot; (&quot;,
+                    callee.get()-&gt;executable()-&gt;hashFor(specializationKind()),
+                    &quot;).\n&quot;);
+            }
+            unlink(repatchBuffer);
+        }
+    }
+    if (!!lastSeenCallee &amp;&amp; !Heap::isMarked(lastSeenCallee.get()))
+        lastSeenCallee.clear();
+}
+
</ins><span class="cx"> CallLinkInfo&amp; CallLinkInfo::dummy()
</span><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;CallLinkInfo&gt; dummy;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCallLinkInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.h (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.h        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.h        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">     CodeOrigin codeOrigin;
</span><span class="cx"> 
</span><span class="cx">     bool isLinked() { return stub || callee; }
</span><del>-    void unlink(VM&amp;, RepatchBuffer&amp;);
</del><ins>+    void unlink(RepatchBuffer&amp;);
</ins><span class="cx"> 
</span><span class="cx">     bool seenOnce()
</span><span class="cx">     {
</span><span class="lines">@@ -100,6 +100,8 @@
</span><span class="cx">         hasSeenShouldRepatch = true;
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    void visitWeak(RepatchBuffer&amp;);
+    
</ins><span class="cx">     static CallLinkInfo&amp; dummy();
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -2241,39 +2241,14 @@
</span><span class="cx">     // Handle inline caches.
</span><span class="cx">     if (!!jitCode()) {
</span><span class="cx">         RepatchBuffer repatchBuffer(this);
</span><del>-        for (auto iter = callLinkInfosBegin(); !!iter; ++iter) {
-            CallLinkInfo&amp; info = **iter;
-            if (info.isLinked()) {
-                if (ClosureCallStubRoutine* stub = info.stub.get()) {
-                    if (!Heap::isMarked(stub-&gt;structure())
-                        || !Heap::isMarked(stub-&gt;executable())) {
-                        if (Options::verboseOSR()) {
-                            dataLog(
-                                &quot;Clearing closure call from &quot;, *this, &quot; to &quot;,
-                                stub-&gt;executable()-&gt;hashFor(info.specializationKind()),
-                                &quot;, stub routine &quot;, RawPointer(stub), &quot;.\n&quot;);
-                        }
-                        info.unlink(*m_vm, repatchBuffer);
-                    }
-                } else if (!Heap::isMarked(info.callee.get())) {
-                    if (Options::verboseOSR()) {
-                        dataLog(
-                            &quot;Clearing call from &quot;, *this, &quot; to &quot;,
-                            RawPointer(info.callee.get()), &quot; (&quot;,
-                            info.callee.get()-&gt;executable()-&gt;hashFor(info.specializationKind()),
-                            &quot;).\n&quot;);
-                    }
-                    info.unlink(*m_vm, repatchBuffer);
-                }
-            }
-            if (!!info.lastSeenCallee
-                &amp;&amp; !Heap::isMarked(info.lastSeenCallee.get()))
-                info.lastSeenCallee.clear();
-        }
</del><ins>+        
+        for (auto iter = callLinkInfosBegin(); !!iter; ++iter)
+            (*iter)-&gt;visitWeak(repatchBuffer);
+
</ins><span class="cx">         for (Bag&lt;StructureStubInfo&gt;::iterator iter = m_stubInfos.begin(); !!iter; ++iter) {
</span><span class="cx">             StructureStubInfo&amp; stubInfo = **iter;
</span><span class="cx">             
</span><del>-            if (stubInfo.visitWeakReferences())
</del><ins>+            if (stubInfo.visitWeakReferences(repatchBuffer))
</ins><span class="cx">                 continue;
</span><span class="cx">             
</span><span class="cx">             resetStubDuringGCInternal(repatchBuffer, stubInfo);
</span><span class="lines">@@ -2639,7 +2614,7 @@
</span><span class="cx">         CallLinkInfo&amp; info = **iter;
</span><span class="cx">         if (!info.isLinked())
</span><span class="cx">             continue;
</span><del>-        info.unlink(*m_vm, repatchBuffer);
</del><ins>+        info.unlink(repatchBuffer);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2661,7 +2636,7 @@
</span><span class="cx">         return;
</span><span class="cx">     RepatchBuffer repatchBuffer(this);
</span><span class="cx">     while (m_incomingCalls.begin() != m_incomingCalls.end())
</span><del>-        m_incomingCalls.begin()-&gt;unlink(*m_vm, repatchBuffer);
</del><ins>+        m_incomingCalls.begin()-&gt;unlink(repatchBuffer);
</ins><span class="cx"> #endif // ENABLE(JIT)
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodePolymorphicGetByIdListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -83,12 +83,14 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool GetByIdAccess::visitWeak() const
</del><ins>+bool GetByIdAccess::visitWeak(RepatchBuffer&amp; repatchBuffer) const
</ins><span class="cx"> {
</span><span class="cx">     if (m_structure &amp;&amp; !Heap::isMarked(m_structure.get()))
</span><span class="cx">         return false;
</span><span class="cx">     if (m_chain &amp;&amp; !Heap::isMarked(m_chain.get()))
</span><span class="cx">         return false;
</span><ins>+    if (!m_stubRoutine-&gt;visitWeak(repatchBuffer))
+        return false;
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -156,10 +158,10 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PolymorphicGetByIdList::visitWeak() const
</del><ins>+bool PolymorphicGetByIdList::visitWeak(RepatchBuffer&amp; repatchBuffer) const
</ins><span class="cx"> {
</span><span class="cx">     for (unsigned i = size(); i--;) {
</span><del>-        if (!at(i).visitWeak())
</del><ins>+        if (!at(i).visitWeak(repatchBuffer))
</ins><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodePolymorphicGetByIdListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.h (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.h        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.h        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx">         SimpleInline, // This is the patched inline access.
</span><span class="cx">         SimpleStub, // This is a stub.
</span><span class="cx">         Getter,
</span><ins>+        CustomGetter
</ins><span class="cx">     };
</span><span class="cx">     
</span><span class="cx">     GetByIdAccess()
</span><span class="lines">@@ -80,7 +81,7 @@
</span><span class="cx">     
</span><span class="cx">     bool doesCalls() const { return type() == Getter; }
</span><span class="cx">     
</span><del>-    bool visitWeak() const;
</del><ins>+    bool visitWeak(RepatchBuffer&amp;) const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     friend class CodeBlock;
</span><span class="lines">@@ -114,7 +115,7 @@
</span><span class="cx">     
</span><span class="cx">     bool didSelfPatching() const; // Are any of the accesses SimpleInline?
</span><span class="cx">     
</span><del>-    bool visitWeak() const;
</del><ins>+    bool visitWeak(RepatchBuffer&amp;) const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     friend class CodeBlock;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodePolymorphicPutByIdListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PutByIdAccess::visitWeak() const
</del><ins>+bool PutByIdAccess::visitWeak(RepatchBuffer&amp; repatchBuffer) const
</ins><span class="cx"> {
</span><span class="cx">     switch (m_type) {
</span><span class="cx">     case Replace:
</span><span class="lines">@@ -87,6 +87,8 @@
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><ins>+    if (!m_stubRoutine-&gt;visitWeak(repatchBuffer))
+        return false;
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -139,10 +141,10 @@
</span><span class="cx">     m_list.last() = putByIdAccess;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PolymorphicPutByIdList::visitWeak() const
</del><ins>+bool PolymorphicPutByIdList::visitWeak(RepatchBuffer&amp; repatchBuffer) const
</ins><span class="cx"> {
</span><span class="cx">     for (unsigned i = 0; i &lt; size(); ++i) {
</span><del>-        if (!at(i).visitWeak())
</del><ins>+        if (!at(i).visitWeak(repatchBuffer))
</ins><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodePolymorphicPutByIdListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.h (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.h        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/PolymorphicPutByIdList.h        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx"> 
</span><span class="cx">     PutPropertySlot::PutValueFunc customSetter() const { ASSERT(isCustom()); return m_customSetter; }
</span><span class="cx"> 
</span><del>-    bool visitWeak() const;
</del><ins>+    bool visitWeak(RepatchBuffer&amp;) const;
</ins><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     friend class CodeBlock;
</span><span class="lines">@@ -190,7 +190,7 @@
</span><span class="cx">     
</span><span class="cx">     PutKind kind() const { return m_kind; }
</span><span class="cx">     
</span><del>-    bool visitWeak() const;
</del><ins>+    bool visitWeak(RepatchBuffer&amp;) const;
</ins><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx">     friend class CodeBlock;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeStructureStubInfocpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool StructureStubInfo::visitWeakReferences()
</del><ins>+bool StructureStubInfo::visitWeakReferences(RepatchBuffer&amp; repatchBuffer)
</ins><span class="cx"> {
</span><span class="cx">     switch (accessType) {
</span><span class="cx">     case access_get_by_id_self:
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     case access_get_by_id_list: {
</span><del>-        if (!u.getByIdList.list-&gt;visitWeak())
</del><ins>+        if (!u.getByIdList.list-&gt;visitWeak(repatchBuffer))
</ins><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     case access_put_by_id_list:
</span><del>-        if (!u.putByIdList.list-&gt;visitWeak())
</del><ins>+        if (!u.putByIdList.list-&gt;visitWeak(repatchBuffer))
</ins><span class="cx">             return false;
</span><span class="cx">         break;
</span><span class="cx">     case access_in_list: {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeStructureStubInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -167,7 +167,15 @@
</span><span class="cx"> 
</span><span class="cx">     void deref();
</span><span class="cx"> 
</span><del>-    bool visitWeakReferences();
</del><ins>+    // Check if the stub has weak references that are dead. If there are dead ones that imply
+    // that the stub should be entirely reset, this should return false. If there are dead ones
+    // that can be handled internally by the stub and don't require a full reset, then this
+    // should reset them and return true. If there are no dead weak references, return true.
+    // If this method returns true it means that it has left the stub in a state where all
+    // outgoing GC pointers are known to point to currently marked objects; this method is
+    // allowed to accomplish this by either clearing those pointers somehow or by proving that
+    // they have already been marked. It is not allowed to mark new objects.
+    bool visitWeakReferences(RepatchBuffer&amp;);
</ins><span class="cx">         
</span><span class="cx">     bool seenOnce()
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitClosureCallStubRoutinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ClosureCallStubRoutine.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ClosureCallStubRoutine.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/jit/ClosureCallStubRoutine.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx"> ClosureCallStubRoutine::ClosureCallStubRoutine(
</span><span class="cx">     const MacroAssemblerCodeRef&amp; code, VM&amp; vm, const JSCell* owner,
</span><span class="cx">     Structure* structure, ExecutableBase* executable, const CodeOrigin&amp; codeOrigin)
</span><del>-    : GCAwareJITStubRoutine(code, vm, true)
</del><ins>+    : GCAwareJITStubRoutine(code, vm)
</ins><span class="cx">     , m_structure(vm, owner, structure)
</span><span class="cx">     , m_executable(vm, owner, executable)
</span><span class="cx">     , m_codeOrigin(codeOrigin)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitGCAwareJITStubRoutinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -37,11 +37,10 @@
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> GCAwareJITStubRoutine::GCAwareJITStubRoutine(
</span><del>-    const MacroAssemblerCodeRef&amp; code, VM&amp; vm, bool isClosureCall)
</del><ins>+    const MacroAssemblerCodeRef&amp; code, VM&amp; vm)
</ins><span class="cx">     : JITStubRoutine(code)
</span><span class="cx">     , m_mayBeExecuting(false)
</span><span class="cx">     , m_isJettisoned(false)
</span><del>-    , m_isClosureCall(isClosureCall)
</del><span class="cx"> {
</span><span class="cx">     vm.heap.m_jitStubRoutines.add(this);
</span><span class="cx"> }
</span><span class="lines">@@ -98,19 +97,6 @@
</span><span class="cx"> PassRefPtr&lt;JITStubRoutine&gt; createJITStubRoutine(
</span><span class="cx">     const MacroAssemblerCodeRef&amp; code,
</span><span class="cx">     VM&amp; vm,
</span><del>-    const JSCell*,
-    bool makesCalls)
-{
-    if (!makesCalls)
-        return adoptRef(new JITStubRoutine(code));
-
-    return static_pointer_cast&lt;JITStubRoutine&gt;(
-        adoptRef(new GCAwareJITStubRoutine(code, vm)));
-}
-
-PassRefPtr&lt;JITStubRoutine&gt; createJITStubRoutine(
-    const MacroAssemblerCodeRef&amp; code,
-    VM&amp; vm,
</del><span class="cx">     const JSCell* owner,
</span><span class="cx">     bool makesCalls,
</span><span class="cx">     JSCell* object)
</span><span class="lines">@@ -118,6 +104,11 @@
</span><span class="cx">     if (!makesCalls)
</span><span class="cx">         return adoptRef(new JITStubRoutine(code));
</span><span class="cx">     
</span><ins>+    if (!object) {
+        return static_pointer_cast&lt;JITStubRoutine&gt;(
+            adoptRef(new GCAwareJITStubRoutine(code, vm)));
+    }
+    
</ins><span class="cx">     return static_pointer_cast&lt;JITStubRoutine&gt;(
</span><span class="cx">         adoptRef(new MarkingGCAwareJITStubRoutineWithOneObject(code, vm, owner, object)));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitGCAwareJITStubRoutineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> // list which does not get reclaimed all at once).
</span><span class="cx"> class GCAwareJITStubRoutine : public JITStubRoutine {
</span><span class="cx"> public:
</span><del>-    GCAwareJITStubRoutine(const MacroAssemblerCodeRef&amp;, VM&amp;, bool isClosureCall = false);
</del><ins>+    GCAwareJITStubRoutine(const MacroAssemblerCodeRef&amp;, VM&amp;);
</ins><span class="cx">     virtual ~GCAwareJITStubRoutine();
</span><span class="cx">     
</span><span class="cx">     void markRequiredObjects(SlotVisitor&amp; visitor)
</span><span class="lines">@@ -62,8 +62,6 @@
</span><span class="cx">     
</span><span class="cx">     void deleteFromGC();
</span><span class="cx">     
</span><del>-    bool isClosureCall() const { return m_isClosureCall; }
-    
</del><span class="cx"> protected:
</span><span class="cx">     virtual void observeZeroRefCount() override;
</span><span class="cx">     
</span><span class="lines">@@ -74,7 +72,6 @@
</span><span class="cx"> 
</span><span class="cx">     bool m_mayBeExecuting;
</span><span class="cx">     bool m_isJettisoned;
</span><del>-    bool m_isClosureCall;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // Use this if you want to mark one additional object during GC if your stub
</span><span class="lines">@@ -112,11 +109,14 @@
</span><span class="cx"> // way.
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;JITStubRoutine&gt; createJITStubRoutine(
</span><del>-    const MacroAssemblerCodeRef&amp;, VM&amp;, const JSCell* owner, bool makesCalls);
-PassRefPtr&lt;JITStubRoutine&gt; createJITStubRoutine(
</del><span class="cx">     const MacroAssemblerCodeRef&amp;, VM&amp;, const JSCell* owner, bool makesCalls,
</span><del>-    JSCell*);
</del><ins>+    JSCell* = 0);
</ins><span class="cx"> 
</span><ins>+// Helper for the creation of simple stub routines that need no help from the GC. Note
+// that codeBlock gets &quot;executed&quot; more than once.
+#define FINALIZE_CODE_FOR_GC_AWARE_STUB(codeBlock, patchBuffer, makesCalls, cell, dataLogFArguments) \
+    (createJITStubRoutine(FINALIZE_CODE_FOR((codeBlock), (patchBuffer), dataLogFArguments), *(codeBlock)-&gt;vm(), (codeBlock)-&gt;ownerExecutable(), (makesCalls), (cell)))
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITStubRoutinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITStubRoutine.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITStubRoutine.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/jit/JITStubRoutine.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -36,6 +36,11 @@
</span><span class="cx"> 
</span><span class="cx"> JITStubRoutine::~JITStubRoutine() { }
</span><span class="cx"> 
</span><ins>+bool JITStubRoutine::visitWeak(RepatchBuffer&amp;)
+{
+    return true;
+}
+
</ins><span class="cx"> void JITStubRoutine::observeZeroRefCount()
</span><span class="cx"> {
</span><span class="cx">     RELEASE_ASSERT(!m_refCount);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITStubRoutineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITStubRoutine.h (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITStubRoutine.h        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/jit/JITStubRoutine.h        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> class JITStubRoutineSet;
</span><ins>+class RepatchBuffer;
</ins><span class="cx"> 
</span><span class="cx"> // This is a base-class for JIT stub routines, and also the class you want
</span><span class="cx"> // to instantiate directly if you have a routine that does not need any
</span><span class="lines">@@ -139,6 +140,8 @@
</span><span class="cx">         
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><ins>+    
+    virtual bool visitWeak(RepatchBuffer&amp;);
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     virtual void observeZeroRefCount();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitRepatchcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/Repatch.cpp (166217 => 166218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/Repatch.cpp        2014-03-25 03:27:46 UTC (rev 166217)
+++ trunk/Source/JavaScriptCore/jit/Repatch.cpp        2014-03-25 03:44:52 UTC (rev 166218)
</span><span class="lines">@@ -355,8 +355,8 @@
</span><span class="cx">         patchBuffer.link(handlerCall, lookupExceptionHandler);
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    stubRoutine = FINALIZE_CODE_FOR_STUB(
-        exec-&gt;codeBlock(), patchBuffer,
</del><ins>+    stubRoutine = FINALIZE_CODE_FOR_GC_AWARE_STUB(
+        exec-&gt;codeBlock(), patchBuffer, true, nullptr,
</ins><span class="cx">         (&quot;Get access stub for %s, return point %p&quot;,
</span><span class="cx">             toCString(*exec-&gt;codeBlock()).data(), successLabel.executableAddress()));
</span><span class="cx"> }
</span><span class="lines">@@ -966,9 +966,11 @@
</span><span class="cx">     patchBuffer.link(setterCall, FunctionPtr(slot.customSetter()));
</span><span class="cx">     patchBuffer.link(handlerCall, lookupExceptionHandler);
</span><span class="cx"> 
</span><del>-    stubRoutine = createJITStubRoutine(
-        FINALIZE_CODE_FOR(exec-&gt;codeBlock(), patchBuffer, (&quot;PutById custom setter stub for %s, return point %p&quot;,
-        toCString(*exec-&gt;codeBlock()).data(), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone).executableAddress())), *vm, exec-&gt;codeBlock()-&gt;ownerExecutable(), structure);
</del><ins>+    stubRoutine = FINALIZE_CODE_FOR_GC_AWARE_STUB(
+        exec-&gt;codeBlock(), patchBuffer, true, nullptr,
+        (&quot;PutById custom setter stub for %s, return point %p&quot;,
+            toCString(*exec-&gt;codeBlock()).data(),
+            stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone).executableAddress()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>