<!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>[189703] releases/WebKitGTK/webkit-2.10/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/189703">189703</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-14 02:57:37 -0700 (Mon, 14 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/188849">r188849</a> - [JSC] Reduce the memory usage of BytecodeLivenessAnalysis
https://bugs.webkit.org/show_bug.cgi?id=148353

Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2015-08-23
Reviewed by Darin Adler.

BytecodeLivenessAnalysis easily takes kilobytes of memory for
non trivial blocks and that memory sticks around because
it stored on CodeBlock.

This patch reduces that memory use a bit.

Most of the memory is in the array of BytecodeBasicBlock.
BytecodeBasicBlock is shrunk by:
-Making it not ref-counted.
-Removing m_predecessors, it was only used for debugging and
 is usually big.
-Added a shrinkToFit() phase to shrink the vectors once we are
 done building the BytecodeBasicBlock.

There are more things we should do in the future:
-Store all the BytecodeBasicBlock direclty in the array.
 We know the size ahead of time, this would be a pure win.
 The only tricky part is changing m_successors to have the
 index of the successor instead of a pointer.
-Stop putting duplicates in m_successors.

* bytecode/BytecodeBasicBlock.cpp:
(JSC::computeBytecodeBasicBlocks):
(JSC::BytecodeBasicBlock::shrinkToFit): Deleted.
(JSC::linkBlocks): Deleted.
* bytecode/BytecodeBasicBlock.h:
(JSC::BytecodeBasicBlock::addSuccessor):
(JSC::BytecodeBasicBlock::addPredecessor): Deleted.
(JSC::BytecodeBasicBlock::predecessors): Deleted.
* bytecode/BytecodeLivenessAnalysis.cpp:
(JSC::getLeaderOffsetForBasicBlock):
(JSC::findBasicBlockWithLeaderOffset):
(JSC::findBasicBlockForBytecodeOffset):
(JSC::stepOverInstruction):
(JSC::computeLocalLivenessForBytecodeOffset):
(JSC::computeLocalLivenessForBlock):
(JSC::BytecodeLivenessAnalysis::dumpResults): Deleted.
* bytecode/BytecodeLivenessAnalysis.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeBasicBlockcpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeBasicBlockh">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeLivenessAnalysiscpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeLivenessAnalysish">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodePreciseJumpTargetscpp">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodePreciseJumpTargetsh">releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/ChangeLog        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2015-08-23  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        [JSC] Reduce the memory usage of BytecodeLivenessAnalysis
+        https://bugs.webkit.org/show_bug.cgi?id=148353
+
+        Reviewed by Darin Adler.
+
+        BytecodeLivenessAnalysis easily takes kilobytes of memory for
+        non trivial blocks and that memory sticks around because
+        it stored on CodeBlock.
+
+        This patch reduces that memory use a bit.
+
+        Most of the memory is in the array of BytecodeBasicBlock.
+        BytecodeBasicBlock is shrunk by:
+        -Making it not ref-counted.
+        -Removing m_predecessors, it was only used for debugging and
+         is usually big.
+        -Added a shrinkToFit() phase to shrink the vectors once we are
+         done building the BytecodeBasicBlock.
+
+        There are more things we should do in the future:
+        -Store all the BytecodeBasicBlock direclty in the array.
+         We know the size ahead of time, this would be a pure win.
+         The only tricky part is changing m_successors to have the
+         index of the successor instead of a pointer.
+        -Stop putting duplicates in m_successors.
+
+        * bytecode/BytecodeBasicBlock.cpp:
+        (JSC::computeBytecodeBasicBlocks):
+        (JSC::BytecodeBasicBlock::shrinkToFit): Deleted.
+        (JSC::linkBlocks): Deleted.
+        * bytecode/BytecodeBasicBlock.h:
+        (JSC::BytecodeBasicBlock::addSuccessor):
+        (JSC::BytecodeBasicBlock::addPredecessor): Deleted.
+        (JSC::BytecodeBasicBlock::predecessors): Deleted.
+        * bytecode/BytecodeLivenessAnalysis.cpp:
+        (JSC::getLeaderOffsetForBasicBlock):
+        (JSC::findBasicBlockWithLeaderOffset):
+        (JSC::findBasicBlockForBytecodeOffset):
+        (JSC::stepOverInstruction):
+        (JSC::computeLocalLivenessForBytecodeOffset):
+        (JSC::computeLocalLivenessForBlock):
+        (JSC::BytecodeLivenessAnalysis::dumpResults): Deleted.
+        * bytecode/BytecodeLivenessAnalysis.h:
+
</ins><span class="cx"> 2015-08-22  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Static hash tables should be 100% compile-time constant.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeBasicBlockcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2015 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">@@ -32,6 +32,12 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+void BytecodeBasicBlock::shrinkToFit()
+{
+    m_bytecodeOffsets.shrinkToFit();
+    m_successors.shrinkToFit();
+}
+
</ins><span class="cx"> static bool isBranch(OpcodeID opcodeID)
</span><span class="cx"> {
</span><span class="cx">     switch (opcodeID) {
</span><span class="lines">@@ -91,39 +97,37 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isJumpTarget(OpcodeID opcodeID, Vector&lt;unsigned, 32&gt;&amp; jumpTargets, unsigned bytecodeOffset)
</del><ins>+static bool isJumpTarget(OpcodeID opcodeID, const Vector&lt;unsigned, 32&gt;&amp; jumpTargets, unsigned bytecodeOffset)
</ins><span class="cx"> {
</span><span class="cx">     if (opcodeID == op_catch)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    for (unsigned i = 0; i &lt; jumpTargets.size(); i++) {
-        if (bytecodeOffset == jumpTargets[i])
-            return true;
-    }
-    return false;
</del><ins>+    return std::binary_search(jumpTargets.begin(), jumpTargets.end(), bytecodeOffset);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void linkBlocks(BytecodeBasicBlock* predecessor, BytecodeBasicBlock* successor)
</span><span class="cx"> {
</span><span class="cx">     predecessor-&gt;addSuccessor(successor);
</span><del>-    successor-&gt;addPredecessor(predecessor);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt;&amp; basicBlocks)
</del><ins>+void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks)
</ins><span class="cx"> {
</span><span class="cx">     Vector&lt;unsigned, 32&gt; jumpTargets;
</span><span class="cx">     computePreciseJumpTargets(codeBlock, jumpTargets);
</span><span class="cx"> 
</span><span class="cx">     // Create the entry and exit basic blocks.
</span><del>-    BytecodeBasicBlock* entry = new BytecodeBasicBlock(BytecodeBasicBlock::EntryBlock);
-    basicBlocks.append(adoptRef(entry));
-    BytecodeBasicBlock* exit = new BytecodeBasicBlock(BytecodeBasicBlock::ExitBlock);
</del><ins>+    basicBlocks.reserveCapacity(jumpTargets.size() + 2);
</ins><span class="cx"> 
</span><del>-    // Find basic block boundaries.
-    BytecodeBasicBlock* current = new BytecodeBasicBlock(0, 0);
-    linkBlocks(entry, current);
-    basicBlocks.append(adoptRef(current));
</del><ins>+    auto entry = std::make_unique&lt;BytecodeBasicBlock&gt;(BytecodeBasicBlock::EntryBlock);
+    auto firstBlock = std::make_unique&lt;BytecodeBasicBlock&gt;(0, 0);
+    linkBlocks(entry.get(), firstBlock.get());
</ins><span class="cx"> 
</span><ins>+    basicBlocks.append(WTF::move(entry));
+    BytecodeBasicBlock* current = firstBlock.get();
+    basicBlocks.append(WTF::move(firstBlock));
+
+    auto exit = std::make_unique&lt;BytecodeBasicBlock&gt;(BytecodeBasicBlock::ExitBlock);
+
</ins><span class="cx">     bool nextInstructionIsLeader = false;
</span><span class="cx"> 
</span><span class="cx">     Interpreter* interpreter = codeBlock-&gt;vm()-&gt;interpreter;
</span><span class="lines">@@ -136,9 +140,9 @@
</span><span class="cx">         bool createdBlock = false;
</span><span class="cx">         // If the current bytecode is a jump target, then it's the leader of its own basic block.
</span><span class="cx">         if (isJumpTarget(opcodeID, jumpTargets, bytecodeOffset) || nextInstructionIsLeader) {
</span><del>-            BytecodeBasicBlock* block = new BytecodeBasicBlock(bytecodeOffset, opcodeLength);
-            basicBlocks.append(adoptRef(block));
-            current = block;
</del><ins>+            auto newBlock = std::make_unique&lt;BytecodeBasicBlock&gt;(bytecodeOffset, opcodeLength);
+            current = newBlock.get();
+            basicBlocks.append(WTF::move(newBlock));
</ins><span class="cx">             createdBlock = true;
</span><span class="cx">             nextInstructionIsLeader = false;
</span><span class="cx">             bytecodeOffset += opcodeLength;
</span><span class="lines">@@ -171,7 +175,7 @@
</span><span class="cx">             // If we found a terminal bytecode, link to the exit block.
</span><span class="cx">             if (isTerminal(opcodeID)) {
</span><span class="cx">                 ASSERT(bytecodeOffset + opcodeLength == block-&gt;leaderBytecodeOffset() + block-&gt;totalBytecodeLength());
</span><del>-                linkBlocks(block, exit);
</del><ins>+                linkBlocks(block, exit.get());
</ins><span class="cx">                 fallsThrough = false;
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="lines">@@ -184,7 +188,7 @@
</span><span class="cx">                 HandlerInfo* handler = codeBlock-&gt;handlerForBytecodeOffset(bytecodeOffset);
</span><span class="cx">                 fallsThrough = false;
</span><span class="cx">                 if (!handler) {
</span><del>-                    linkBlocks(block, exit);
</del><ins>+                    linkBlocks(block, exit.get());
</ins><span class="cx">                     break;
</span><span class="cx">                 }
</span><span class="cx">                 for (unsigned i = 0; i &lt; basicBlocks.size(); i++) {
</span><span class="lines">@@ -225,7 +229,10 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    basicBlocks.append(adoptRef(exit));
</del><ins>+    basicBlocks.append(WTF::move(exit));
+    
+    for (auto&amp; basicBlock : basicBlocks)
+        basicBlock-&gt;shrinkToFit();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeBasicBlockh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2015 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,11 +36,13 @@
</span><span class="cx"> 
</span><span class="cx"> class CodeBlock;
</span><span class="cx"> 
</span><del>-class BytecodeBasicBlock : public RefCounted&lt;BytecodeBasicBlock&gt; {
</del><ins>+class BytecodeBasicBlock {
+    WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><span class="cx">     enum SpecialBlockType { EntryBlock, ExitBlock };
</span><span class="cx">     BytecodeBasicBlock(unsigned start, unsigned length);
</span><span class="cx">     BytecodeBasicBlock(SpecialBlockType);
</span><ins>+    void shrinkToFit();
</ins><span class="cx"> 
</span><span class="cx">     bool isEntryBlock() { return !m_leaderBytecodeOffset &amp;&amp; !m_totalBytecodeLength; }
</span><span class="cx">     bool isExitBlock() { return m_leaderBytecodeOffset == UINT_MAX &amp;&amp; m_totalBytecodeLength == UINT_MAX; }
</span><span class="lines">@@ -51,12 +53,9 @@
</span><span class="cx">     Vector&lt;unsigned&gt;&amp; bytecodeOffsets() { return m_bytecodeOffsets; }
</span><span class="cx">     void addBytecodeLength(unsigned);
</span><span class="cx"> 
</span><del>-    void addPredecessor(BytecodeBasicBlock* block) { m_predecessors.append(block); }
</del><ins>+    Vector&lt;BytecodeBasicBlock*&gt;&amp; successors() { return m_successors; }
</ins><span class="cx">     void addSuccessor(BytecodeBasicBlock* block) { m_successors.append(block); }
</span><span class="cx"> 
</span><del>-    Vector&lt;BytecodeBasicBlock*&gt;&amp; predecessors() { return m_predecessors; }
-    Vector&lt;BytecodeBasicBlock*&gt;&amp; successors() { return m_successors; }
-
</del><span class="cx">     FastBitVector&amp; in() { return m_in; }
</span><span class="cx">     FastBitVector&amp; out() { return m_out; }
</span><span class="cx"> 
</span><span class="lines">@@ -65,15 +64,13 @@
</span><span class="cx">     unsigned m_totalBytecodeLength;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;unsigned&gt; m_bytecodeOffsets;
</span><del>-
-    Vector&lt;BytecodeBasicBlock*&gt; m_predecessors;
</del><span class="cx">     Vector&lt;BytecodeBasicBlock*&gt; m_successors;
</span><span class="cx"> 
</span><span class="cx">     FastBitVector m_in;
</span><span class="cx">     FastBitVector m_out;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-void computeBytecodeBasicBlocks(CodeBlock*, Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt;&amp;);
</del><ins>+void computeBytecodeBasicBlocks(CodeBlock*, Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp;);
</ins><span class="cx"> 
</span><span class="cx"> inline BytecodeBasicBlock::BytecodeBasicBlock(unsigned start, unsigned length)
</span><span class="cx">     : m_leaderBytecodeOffset(start)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeLivenessAnalysiscpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -51,14 +51,14 @@
</span><span class="cx">     return virtualReg.isLocal();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static unsigned getLeaderOffsetForBasicBlock(RefPtr&lt;BytecodeBasicBlock&gt;* basicBlock)
</del><ins>+static unsigned getLeaderOffsetForBasicBlock(std::unique_ptr&lt;BytecodeBasicBlock&gt;* basicBlock)
</ins><span class="cx"> {
</span><span class="cx">     return (*basicBlock)-&gt;leaderBytecodeOffset();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static BytecodeBasicBlock* findBasicBlockWithLeaderOffset(Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt;&amp; basicBlocks, unsigned leaderOffset)
</del><ins>+static BytecodeBasicBlock* findBasicBlockWithLeaderOffset(Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned leaderOffset)
</ins><span class="cx"> {
</span><del>-    return (*tryBinarySearch&lt;RefPtr&lt;BytecodeBasicBlock&gt;, unsigned&gt;(basicBlocks, basicBlocks.size(), leaderOffset, getLeaderOffsetForBasicBlock)).get();
</del><ins>+    return (*tryBinarySearch&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;, unsigned&gt;(basicBlocks, basicBlocks.size(), leaderOffset, getLeaderOffsetForBasicBlock)).get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool blockContainsBytecodeOffset(BytecodeBasicBlock* block, unsigned bytecodeOffset)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     return bytecodeOffset &gt;= leaderOffset &amp;&amp; bytecodeOffset &lt; leaderOffset + block-&gt;totalBytecodeLength();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static BytecodeBasicBlock* findBasicBlockForBytecodeOffset(Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt;&amp; basicBlocks, unsigned bytecodeOffset)
</del><ins>+static BytecodeBasicBlock* findBasicBlockForBytecodeOffset(Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned bytecodeOffset)
</ins><span class="cx"> {
</span><span class="cx"> /*
</span><span class="cx">     for (unsigned i = 0; i &lt; basicBlocks.size(); i++) {
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     }
</span><span class="cx">     return 0;
</span><span class="cx"> */
</span><del>-    RefPtr&lt;BytecodeBasicBlock&gt;* basicBlock = approximateBinarySearch&lt;RefPtr&lt;BytecodeBasicBlock&gt;, unsigned&gt;(
</del><ins>+    std::unique_ptr&lt;BytecodeBasicBlock&gt;* basicBlock = approximateBinarySearch&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;, unsigned&gt;(
</ins><span class="cx">         basicBlocks, basicBlocks.size(), bytecodeOffset, getLeaderOffsetForBasicBlock);
</span><span class="cx">     // We found the block we were looking for.
</span><span class="cx">     if (blockContainsBytecodeOffset((*basicBlock).get(), bytecodeOffset))
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> // Simplified interface to bytecode use/def, which determines defs first and then uses, and includes
</span><span class="cx"> // exception handlers in the uses.
</span><span class="cx"> template&lt;typename UseFunctor, typename DefFunctor&gt;
</span><del>-static void stepOverInstruction(CodeBlock* codeBlock, Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned bytecodeOffset, const UseFunctor&amp; use, const DefFunctor&amp; def)
</del><ins>+static void stepOverInstruction(CodeBlock* codeBlock, Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned bytecodeOffset, const UseFunctor&amp; use, const DefFunctor&amp; def)
</ins><span class="cx"> {
</span><span class="cx">     // This abstractly execute the instruction in reverse. Instructions logically first use operands and
</span><span class="cx">     // then define operands. This logical ordering is necessary for operations that use and def the same
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void stepOverInstruction(CodeBlock* codeBlock, Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned bytecodeOffset, FastBitVector&amp; out)
</del><ins>+static void stepOverInstruction(CodeBlock* codeBlock, Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned bytecodeOffset, FastBitVector&amp; out)
</ins><span class="cx"> {
</span><span class="cx">     stepOverInstruction(
</span><span class="cx">         codeBlock, basicBlocks, bytecodeOffset,
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">         });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void computeLocalLivenessForBytecodeOffset(CodeBlock* codeBlock, BytecodeBasicBlock* block, Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt;&amp; basicBlocks, unsigned targetOffset, FastBitVector&amp; result)
</del><ins>+static void computeLocalLivenessForBytecodeOffset(CodeBlock* codeBlock, BytecodeBasicBlock* block, Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks, unsigned targetOffset, FastBitVector&amp; result)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!block-&gt;isExitBlock());
</span><span class="cx">     ASSERT(!block-&gt;isEntryBlock());
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx">     result.set(out);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void computeLocalLivenessForBlock(CodeBlock* codeBlock, BytecodeBasicBlock* block, Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt;&amp; basicBlocks)
</del><ins>+static void computeLocalLivenessForBlock(CodeBlock* codeBlock, BytecodeBasicBlock* block, Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt;&amp; basicBlocks)
</ins><span class="cx"> {
</span><span class="cx">     if (block-&gt;isExitBlock() || block-&gt;isEntryBlock())
</span><span class="cx">         return;
</span><span class="lines">@@ -294,12 +294,6 @@
</span><span class="cx">     for (unsigned i = 0; i &lt; m_basicBlocks.size(); i++) {
</span><span class="cx">         BytecodeBasicBlock* block = m_basicBlocks[i].get();
</span><span class="cx">         dataLogF(&quot;\nBytecode basic block %u: %p (offset: %u, length: %u)\n&quot;, i, block, block-&gt;leaderBytecodeOffset(), block-&gt;totalBytecodeLength());
</span><del>-        dataLogF(&quot;Predecessors: &quot;);
-        for (unsigned j = 0; j &lt; block-&gt;predecessors().size(); j++) {
-            BytecodeBasicBlock* predecessor = block-&gt;predecessors()[j];
-            dataLogF(&quot;%p &quot;, predecessor);
-        }
-        dataLogF(&quot;\n&quot;);
</del><span class="cx">         dataLogF(&quot;Successors: &quot;);
</span><span class="cx">         for (unsigned j = 0; j &lt; block-&gt;successors().size(); j++) {
</span><span class="cx">             BytecodeBasicBlock* successor = block-&gt;successors()[j];
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodeBytecodeLivenessAnalysish"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> 
</span><span class="cx"> class BytecodeLivenessAnalysis {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><ins>+    WTF_MAKE_NONCOPYABLE(BytecodeLivenessAnalysis);
</ins><span class="cx"> public:
</span><span class="cx">     BytecodeLivenessAnalysis(CodeBlock*);
</span><span class="cx">     
</span><span class="lines">@@ -56,7 +57,7 @@
</span><span class="cx">     void getLivenessInfoAtBytecodeOffset(unsigned bytecodeOffset, FastBitVector&amp;);
</span><span class="cx"> 
</span><span class="cx">     CodeBlock* m_codeBlock;
</span><del>-    Vector&lt;RefPtr&lt;BytecodeBasicBlock&gt; &gt; m_basicBlocks;
</del><ins>+    Vector&lt;std::unique_ptr&lt;BytecodeBasicBlock&gt;&gt; m_basicBlocks;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline bool operandIsAlwaysLive(int operand);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodePreciseJumpTargetscpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx">         lastValue = value;
</span><span class="cx">     }
</span><span class="cx">     out.resize(toIndex);
</span><ins>+    out.shrinkToFit();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void findJumpTargetsForBytecodeOffset(CodeBlock* codeBlock, unsigned bytecodeOffset, Vector&lt;unsigned, 1&gt;&amp; out)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceJavaScriptCorebytecodePreciseJumpTargetsh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.h (189702 => 189703)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.h        2015-09-14 09:46:37 UTC (rev 189702)
+++ releases/WebKitGTK/webkit-2.10/Source/JavaScriptCore/bytecode/PreciseJumpTargets.h        2015-09-14 09:57:37 UTC (rev 189703)
</span><span class="lines">@@ -30,7 +30,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+// Return a sorted list of bytecode index that are the destination of a jump.
</ins><span class="cx"> void computePreciseJumpTargets(CodeBlock*, Vector&lt;unsigned, 32&gt;&amp; out);
</span><ins>+
</ins><span class="cx"> void findJumpTargetsForBytecodeOffset(CodeBlock*, unsigned bytecodeOffset, Vector&lt;unsigned, 1&gt;&amp; out);
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>

</body>
</html>