<!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>[193890] trunk/Source</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/193890">193890</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2015-12-09 19:50:07 -0800 (Wed, 09 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>FTL B3 should have basic GetById support
https://bugs.webkit.org/show_bug.cgi?id=152035

Reviewed by Saam Barati.

Source/JavaScriptCore:

Adds basic GetById support. This was so easy to do. Unlike the LLVM code for this, the B3 code is
entirely self-contained within the getById() method in LowerDFG.

I discovered that we weren't folding Check(NotEqual(x, 0)) to Check(x). This was preventing us
from generating good code for Check(NotEqual(BitAnd(x, tagMask), 0)), since the BitAnd was
concealed. This was an easy strength reduction rule to add.

Finally, I found it easier to say append(value, rep) than append(ConstrainedValue(value, rep)), so
I added that API. The old ConstrainedValue form is still super useful in other places, like
compileCallOrConstruct(), where the two-argument form would be awkward. It's great to have both
APIs to pick from.

* b3/B3ReduceStrength.cpp:
* b3/B3StackmapValue.cpp:
(JSC::B3::StackmapValue::~StackmapValue):
(JSC::B3::StackmapValue::append):
* b3/B3StackmapValue.h:
* dfg/DFGCommon.h:
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::DFG::LowerDFGToLLVM::getById):

Source/WTF:

When dealing with shared task lambdas, you often want to force a value to be allocated so that it
has reference semantics, but you still want the lambda to execute OK when we pop stack. In PL we
usually call this a &quot;box&quot;. This is easy to do if the value that happened to be stack-allocated
is also RefCounted, but that's rare, since stack-allocated values often have copy semantics. So,
I've added a Box type to WTF. Behind the scenes, it allocates your object with fast malloc inside
a ThreadSAfeRefCounted. When you pass Box&lt;T&gt;, you're passing the reference. This makes it a lot
easier to work with by-reference capture.

* WTF.xcodeproj/project.pbxproj:
* wtf/Box.h: Added.
(WTF::Box::Box):
(WTF::Box::create):
(WTF::Box::get):
(WTF::Box::operator*):
(WTF::Box::operator-&gt;):
(WTF::Box::operator bool):
(WTF::Box::Data::Data):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3ReduceStrengthcpp">trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3StackmapValuecpp">trunk/Source/JavaScriptCore/b3/B3StackmapValue.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreb3B3StackmapValueh">trunk/Source/JavaScriptCore/b3/B3StackmapValue.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfBoxh">trunk/Source/WTF/wtf/Box.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-12-08  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        FTL B3 should have basic GetById support
+        https://bugs.webkit.org/show_bug.cgi?id=152035
+
+        Reviewed by Saam Barati.
+
+        Adds basic GetById support. This was so easy to do. Unlike the LLVM code for this, the B3 code is
+        entirely self-contained within the getById() method in LowerDFG.
+
+        I discovered that we weren't folding Check(NotEqual(x, 0)) to Check(x). This was preventing us
+        from generating good code for Check(NotEqual(BitAnd(x, tagMask), 0)), since the BitAnd was
+        concealed. This was an easy strength reduction rule to add.
+
+        Finally, I found it easier to say append(value, rep) than append(ConstrainedValue(value, rep)), so
+        I added that API. The old ConstrainedValue form is still super useful in other places, like
+        compileCallOrConstruct(), where the two-argument form would be awkward. It's great to have both
+        APIs to pick from.
+
+        * b3/B3ReduceStrength.cpp:
+        * b3/B3StackmapValue.cpp:
+        (JSC::B3::StackmapValue::~StackmapValue):
+        (JSC::B3::StackmapValue::append):
+        * b3/B3StackmapValue.h:
+        * dfg/DFGCommon.h:
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::DFG::LowerDFGToLLVM::getById):
+
</ins><span class="cx"> 2015-12-09  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update generators' features.json to indicate that we have a spec compliant implementation
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3ReduceStrengthcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/JavaScriptCore/b3/B3ReduceStrength.cpp        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -861,6 +861,12 @@
</span><span class="cx">                 m_changed = true;
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><ins>+
+            if (m_value-&gt;child(0)-&gt;opcode() == NotEqual &amp;&amp; m_value-&gt;child(0)-&gt;child(1)-&gt;isInt(0)) {
+                m_value-&gt;child(0) = m_value-&gt;child(0)-&gt;child(0);
+                m_changed = true;
+                break;
+            }
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><span class="cx">         case Branch: {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3StackmapValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3StackmapValue.cpp (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3StackmapValue.cpp        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/JavaScriptCore/b3/B3StackmapValue.cpp        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -34,18 +34,18 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StackmapValue::append(const ConstrainedValue&amp; constrainedValue)
</del><ins>+void StackmapValue::append(Value* value, const ValueRep&amp; rep)
</ins><span class="cx"> {
</span><del>-    if (constrainedValue.rep() == ValueRep::ColdAny) {
-        children().append(constrainedValue.value());
</del><ins>+    if (rep == ValueRep::ColdAny) {
+        children().append(value);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     while (m_reps.size() &lt; numChildren())
</span><span class="cx">         m_reps.append(ValueRep::ColdAny);
</span><span class="cx"> 
</span><del>-    children().append(constrainedValue.value());
-    m_reps.append(constrainedValue.rep());
</del><ins>+    children().append(value);
+    m_reps.append(rep);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void StackmapValue::appendSomeRegister(Value* value)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreb3B3StackmapValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/b3/B3StackmapValue.h (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/b3/B3StackmapValue.h        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/JavaScriptCore/b3/B3StackmapValue.h        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -63,8 +63,13 @@
</span><span class="cx"> 
</span><span class="cx">     // Use this to add children. Note that you could also add children by doing
</span><span class="cx">     // children().append(). That will work fine, but it's not recommended.
</span><del>-    void append(const ConstrainedValue&amp;);
</del><ins>+    void append(const ConstrainedValue&amp; value)
+    {
+        append(value.value(), value.rep());
+    }
</ins><span class="cx"> 
</span><ins>+    void append(Value*, const ValueRep&amp;);
+
</ins><span class="cx">     template&lt;typename VectorType&gt;
</span><span class="cx">     void appendVector(const VectorType&amp; vector)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx"> #include &lt;dlfcn.h&gt;
</span><span class="cx"> #include &lt;llvm/InitializeLLVM.h&gt;
</span><span class="cx"> #include &lt;unordered_set&gt;
</span><ins>+#include &lt;wtf/Box.h&gt;
</ins><span class="cx"> #include &lt;wtf/ProcessID.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC { namespace FTL {
</span><span class="lines">@@ -6720,15 +6721,57 @@
</span><span class="cx">     
</span><span class="cx">     LValue getById(LValue base)
</span><span class="cx">     {
</span><ins>+        Node* node = m_node;
+        UniquedStringImpl* uid = m_graph.identifiers()[node-&gt;identifierNumber()];
+
</ins><span class="cx"> #if FTL_USES_B3
</span><del>-        UNUSED_PARAM(base);
</del><ins>+        // FIXME: Make this do exceptions.
+        // https://bugs.webkit.org/show_bug.cgi?id=151686
+        
+        B3::PatchpointValue* patchpoint = m_out.patchpoint(Int64);
+        patchpoint-&gt;append(base, ValueRep::SomeRegister);
+        patchpoint-&gt;clobber(RegisterSet::macroScratchRegisters());
</ins><span class="cx"> 
</span><del>-        if (verboseCompilationEnabled() || !verboseCompilationEnabled())
-            CRASH();
-        return nullptr;
</del><ins>+        State* state = &amp;m_ftlState;
+        patchpoint-&gt;setGenerator(
+            [=] (CCallHelpers&amp; jit, const StackmapGenerationParams&amp; params) {
+                AllowMacroScratchRegisterUsage allowScratch(jit);
+
+                auto generator = Box&lt;JITGetByIdGenerator&gt;::create(
+                    jit.codeBlock(), node-&gt;origin.semantic,
+                    state-&gt;jitCode-&gt;common.addUniqueCallSiteIndex(node-&gt;origin.semantic),
+                    params.usedRegisters(), JSValueRegs(params[1].gpr()), JSValueRegs(params[0].gpr()));
+
+                generator-&gt;generateFastPath(jit);
+                CCallHelpers::Label done = jit.label();
+
+                params.addLatePath(
+                    [=] (CCallHelpers&amp; jit) {
+                        AllowMacroScratchRegisterUsage allowScratch(jit);
+                        
+                        // FIXME: Make this do something.
+                        CCallHelpers::JumpList exceptions;
+
+                        generator-&gt;slowPathJump().link(&amp;jit);
+                        CCallHelpers::Label slowPathBegin = jit.label();
+                        CCallHelpers::Call slowPathCall = callOperation(
+                            *state, params.usedRegisters(), jit, node-&gt;origin.semantic, &amp;exceptions,
+                            operationGetByIdOptimize, params[0].gpr(),
+                            CCallHelpers::TrustedImmPtr(generator-&gt;stubInfo()), params[1].gpr(),
+                            CCallHelpers::TrustedImmPtr(uid)).call();
+                        jit.jump().linkTo(done, &amp;jit);
+
+                        generator-&gt;reportSlowPathCall(slowPathBegin, slowPathCall);
+
+                        jit.addLinkTask(
+                            [=] (LinkBuffer&amp; linkBuffer) {
+                                generator-&gt;finalize(linkBuffer);
+                            });
+                    });
+            });
+
+        return patchpoint;
</ins><span class="cx"> #else
</span><del>-        auto uid = m_graph.identifiers()[m_node-&gt;identifierNumber()];
-
</del><span class="cx">         // Arguments: id, bytes, target, numArgs, args...
</span><span class="cx">         unsigned stackmapID = m_stackmapIDs++;
</span><span class="cx">         
</span><span class="lines">@@ -6748,7 +6791,7 @@
</span><span class="cx">         LValue call = m_out.call(m_out.int64, m_out.patchpointInt64Intrinsic(), arguments);
</span><span class="cx">         setInstructionCallingConvention(call, LLVMAnyRegCallConv);
</span><span class="cx">         
</span><del>-        m_ftlState.getByIds.append(GetByIdDescriptor(stackmapID, m_node-&gt;origin.semantic, uid));
</del><ins>+        m_ftlState.getByIds.append(GetByIdDescriptor(stackmapID, node-&gt;origin.semantic, uid));
</ins><span class="cx">         
</span><span class="cx">         return call;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/WTF/ChangeLog        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-12-08  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        FTL B3 should have basic GetById support
+        https://bugs.webkit.org/show_bug.cgi?id=152035
+
+        Reviewed by Saam Barati.
+
+        When dealing with shared task lambdas, you often want to force a value to be allocated so that it
+        has reference semantics, but you still want the lambda to execute OK when we pop stack. In PL we
+        usually call this a &quot;box&quot;. This is easy to do if the value that happened to be stack-allocated
+        is also RefCounted, but that's rare, since stack-allocated values often have copy semantics. So,
+        I've added a Box type to WTF. Behind the scenes, it allocates your object with fast malloc inside
+        a ThreadSAfeRefCounted. When you pass Box&lt;T&gt;, you're passing the reference. This makes it a lot
+        easier to work with by-reference capture.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/Box.h: Added.
+        (WTF::Box::Box):
+        (WTF::Box::create):
+        (WTF::Box::get):
+        (WTF::Box::operator*):
+        (WTF::Box::operator-&gt;):
+        (WTF::Box::operator bool):
+        (WTF::Box::Data::Data):
+
</ins><span class="cx"> 2015-12-09  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] ResourceUsageOverlay should work on iOS.
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (193889 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2015-12-10 03:42:46 UTC (rev 193889)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">                 0F8F2B91172E00FC007DBDA5 /* CompilationThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8F2B90172E00F0007DBDA5 /* CompilationThread.h */; };
</span><span class="cx">                 0F8F2B92172E0103007DBDA5 /* CompilationThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F2B8F172E00F0007DBDA5 /* CompilationThread.cpp */; };
</span><span class="cx">                 0F8F2B9C172F2596007DBDA5 /* ConversionMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8F2B9B172F2594007DBDA5 /* ConversionMode.h */; };
</span><ins>+                0F93274B1C17F4B700CF6564 /* Box.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F93274A1C17F4B700CF6564 /* Box.h */; };
</ins><span class="cx">                 0F9D3360165DBA73005AD387 /* FilePrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9D335B165DBA73005AD387 /* FilePrintStream.cpp */; };
</span><span class="cx">                 0F9D3361165DBA73005AD387 /* FilePrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335C165DBA73005AD387 /* FilePrintStream.h */; };
</span><span class="cx">                 0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F9D335D165DBA73005AD387 /* PrintStream.cpp */; };
</span><span class="lines">@@ -334,6 +335,7 @@
</span><span class="cx">                 0F8F2B8F172E00F0007DBDA5 /* CompilationThread.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompilationThread.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F8F2B90172E00F0007DBDA5 /* CompilationThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompilationThread.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F8F2B9B172F2594007DBDA5 /* ConversionMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ConversionMode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                0F93274A1C17F4B700CF6564 /* Box.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Box.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 0F9D335B165DBA73005AD387 /* FilePrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FilePrintStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F9D335C165DBA73005AD387 /* FilePrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePrintStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0F9D335D165DBA73005AD387 /* PrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -748,6 +750,7 @@
</span><span class="cx">                                 A8A47261151A825A004123FF /* BitVector.h */,
</span><span class="cx">                                 A8A47264151A825A004123FF /* BlockStack.h */,
</span><span class="cx">                                 A8A47265151A825A004123FF /* BloomFilter.h */,
</span><ins>+                                0F93274A1C17F4B700CF6564 /* Box.h */,
</ins><span class="cx">                                 0F4570441BE834410062A629 /* BubbleSort.h */,
</span><span class="cx">                                 A8A47267151A825A004123FF /* BumpPointerAllocator.h */,
</span><span class="cx">                                 EB95E1EF161A72410089A2F5 /* ByteOrder.h */,
</span><span class="lines">@@ -1246,6 +1249,7 @@
</span><span class="cx">                                 A8A4743D151A825B004123FF /* StringBuilder.h in Headers */,
</span><span class="cx">                                 430B47891AAAAC1A001223DA /* StringCommon.h in Headers */,
</span><span class="cx">                                 A8A4743E151A825B004123FF /* StringConcatenate.h in Headers */,
</span><ins>+                                0F93274B1C17F4B700CF6564 /* Box.h in Headers */,
</ins><span class="cx">                                 A8A4742C151A825B004123FF /* StringExtras.h in Headers */,
</span><span class="cx">                                 A8A4743F151A825B004123FF /* StringHash.h in Headers */,
</span><span class="cx">                                 A748745417A0BDAE00FA04CB /* StringHashDumpContext.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfBoxh"></a>
<div class="addfile"><h4>Added: trunk/Source/WTF/wtf/Box.h (0 => 193890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Box.h                                (rev 0)
+++ trunk/Source/WTF/wtf/Box.h        2015-12-10 03:50:07 UTC (rev 193890)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * 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. 
+ */
+
+#ifndef WTF_Box_h
+#define WTF_Box_h
+
+#include &lt;wtf/RefPtr.h&gt;
+#include &lt;wtf/ThreadSafeRefCounted.h&gt;
+
+namespace WTF {
+
+// Box&lt;T&gt; is a reference-counted pointer to T that allocates T using FastMalloc and prepends a reference
+// count to it.
+template&lt;typename T&gt;
+class Box {
+public:
+    Box()
+    {
+    }
+
+    template&lt;typename... Arguments&gt;
+    static Box create(Arguments&amp;&amp;... arguments)
+    {
+        Box result;
+        result.m_data = adoptRef(new Data(std::forward&lt;Arguments&gt;(arguments)...));
+        return result;
+    }
+
+    T* get() const { return &amp;m_data-&gt;value; }
+
+    T&amp; operator*() const { return m_data-&gt;value; }
+    T* operator-&gt;() const { return &amp;m_data-&gt;value; }
+
+    explicit operator bool() { return m_data; }
+    
+private:
+    struct Data : ThreadSafeRefCounted&lt;Data&gt; {
+        template&lt;typename... Arguments&gt;
+        Data(Arguments&amp;&amp;... arguments)
+            : value(std::forward&lt;Arguments&gt;(arguments)...)
+        {
+        }
+        
+        T value;
+    };
+
+    RefPtr&lt;Data&gt; m_data;
+};
+
+} // namespace WTF
+
+using WTF::Box;
+
+#endif // WTF_Box_h
+
</ins></span></pre>
</div>
</div>

</body>
</html>