<!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>[162593] branches/jsCStack/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/162593">162593</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-01-22 21:11:09 -0800 (Wed, 22 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>FTL should support ToString
https://bugs.webkit.org/show_bug.cgi?id=127460

Reviewed by Geoffrey Garen.

* ftl/FTLAbstractHeapRepository.h:
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLIntrinsicRepository.h:
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileToString):
(JSC::FTL::LowerDFGToLLVM::speculate):
(JSC::FTL::LowerDFGToLLVM::speculateStringObject):
(JSC::FTL::LowerDFGToLLVM::speculateStringOrStringObject):
(JSC::FTL::LowerDFGToLLVM::speculateStringObjectForCell):
(JSC::FTL::LowerDFGToLLVM::speculateStringObjectForStructure):
* tests/stress/to-string-on-object-or-string.js: Added.
(Foo):
(Foo.prototype.toString):
(foo):
* tests/stress/to-string-on-object.js: Added.
(Foo):
(Foo.prototype.toString):
(foo):
* tests/stress/to-string-on-string-object.js: Added.
(foo):
* tests/stress/to-string-on-string-or-string-object.js: Added.
(foo):
* tests/stress/to-string-on-string-or-string-object-then-object.js: Added.
(foo):
(Foo):
(Foo.prototype.toString):
* tests/stress/to-string-on-value-or-string.js: Added.
(foo):
* tests/stress/to-string-on-value.js: Added.
(foo):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLAbstractHeapRepositoryh">branches/jsCStack/Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLCapabilitiescpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLIntrinsicRepositoryh">branches/jsCStack/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonobjectorstringjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object-or-string.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonobjectjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonstringobjectjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-object.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonstringorstringobjectthenobjectjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object-then-object.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonstringorstringobjectjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonvalueorstringjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value-or-string.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstresstostringonvaluejs">branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (162592 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-23 05:08:03 UTC (rev 162592)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -1,9 +1,49 @@
</span><span class="cx"> 2014-01-22  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        FTL should support ToString
+        https://bugs.webkit.org/show_bug.cgi?id=127460
+
+        Reviewed by Geoffrey Garen.
+
+        * ftl/FTLAbstractHeapRepository.h:
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLIntrinsicRepository.h:
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileNode):
+        (JSC::FTL::LowerDFGToLLVM::compileToString):
+        (JSC::FTL::LowerDFGToLLVM::speculate):
+        (JSC::FTL::LowerDFGToLLVM::speculateStringObject):
+        (JSC::FTL::LowerDFGToLLVM::speculateStringOrStringObject):
+        (JSC::FTL::LowerDFGToLLVM::speculateStringObjectForCell):
+        (JSC::FTL::LowerDFGToLLVM::speculateStringObjectForStructure):
+        * tests/stress/to-string-on-object-or-string.js: Added.
+        (Foo):
+        (Foo.prototype.toString):
+        (foo):
+        * tests/stress/to-string-on-object.js: Added.
+        (Foo):
+        (Foo.prototype.toString):
+        (foo):
+        * tests/stress/to-string-on-string-object.js: Added.
+        (foo):
+        * tests/stress/to-string-on-string-or-string-object.js: Added.
+        (foo):
+        * tests/stress/to-string-on-string-or-string-object-then-object.js: Added.
+        (foo):
+        (Foo):
+        (Foo.prototype.toString):
+        * tests/stress/to-string-on-value-or-string.js: Added.
+        (foo):
+        * tests/stress/to-string-on-value.js: Added.
+        (foo):
+
+2014-01-22  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
</ins><span class="cx">         FTL should support GetCallee
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=127459
</span><span class="cx"> 
</span><del>-        Not yet reviewed.
</del><ins>+        Reviewed by Geoffrey Garen.
</ins><span class="cx"> 
</span><span class="cx">         * ftl/FTLCapabilities.cpp:
</span><span class="cx">         (JSC::FTL::canCompile):
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLAbstractHeapRepositoryh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h (162592 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h        2014-01-23 05:08:03 UTC (rev 162592)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx">     macro(JSString_length, JSString::offsetOfLength()) \
</span><span class="cx">     macro(JSString_value, JSString::offsetOfValue()) \
</span><span class="cx">     macro(JSVariableObject_registers, JSVariableObject::offsetOfRegisters()) \
</span><ins>+    macro(JSWrapperObject_internalValue, JSWrapperObject::internalValueOffset()) \
</ins><span class="cx">     macro(MarkedAllocator_freeListHead, MarkedAllocator::offsetOfFreeListHead()) \
</span><span class="cx">     macro(StringImpl_data, StringImpl::dataOffset()) \
</span><span class="cx">     macro(StringImpl_hashAndFlags, StringImpl::flagsOffset()) \
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp (162592 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2014-01-23 05:08:03 UTC (rev 162592)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -238,6 +238,7 @@
</span><span class="cx">     case AllocationProfileWatchpoint:
</span><span class="cx">     case CheckArgumentsNotCreated:
</span><span class="cx">     case GetCallee:
</span><ins>+    case ToString:
</ins><span class="cx">         if (!Options::enableExperimentalFTLCoverage())
</span><span class="cx">             return CannotCompile;
</span><span class="cx">         break;
</span><span class="lines">@@ -297,6 +298,8 @@
</span><span class="cx">                 case ObjectUse:
</span><span class="cx">                 case ObjectOrOtherUse:
</span><span class="cx">                 case StringUse:
</span><ins>+                case StringObjectUse:
+                case StringOrStringObjectUse:
</ins><span class="cx">                 case FinalObjectUse:
</span><span class="cx">                     // These are OK.
</span><span class="cx">                     break;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLIntrinsicRepositoryh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h (162592 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h        2014-01-23 05:08:03 UTC (rev 162592)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     macro(x86SSE2CvtTSD2SI, &quot;llvm.x86.sse2.cvttsd2si&quot;, functionType(int32, vectorType(doubleType, 2)))
</span><span class="cx"> 
</span><span class="cx"> #define FOR_EACH_FUNCTION_TYPE(macro) \
</span><ins>+    macro(C_JITOperation_EC, functionType(intPtr, intPtr, intPtr)) \
+    macro(C_JITOperation_EJ, functionType(intPtr, intPtr, int64)) \
</ins><span class="cx">     macro(C_JITOperation_ESt, functionType(intPtr, intPtr, intPtr)) \
</span><span class="cx">     macro(I_JITOperation_EJss, functionType(intPtr, intPtr, intPtr)) \
</span><span class="cx">     macro(J_JITOperation_E, functionType(int64, intPtr)) \
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (162592 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2014-01-23 05:08:03 UTC (rev 162592)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -425,6 +425,9 @@
</span><span class="cx">         case AllocatePropertyStorage:
</span><span class="cx">             compileAllocatePropertyStorage();
</span><span class="cx">             break;
</span><ins>+        case ToString:
+            compileToString();
+            break;
</ins><span class="cx">         case StringCharAt:
</span><span class="cx">             compileStringCharAt();
</span><span class="cx">             break;
</span><span class="lines">@@ -2241,6 +2244,93 @@
</span><span class="cx">         setStorage(result);
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    void compileToString()
+    {
+        switch (m_node-&gt;child1().useKind()) {
+        case StringObjectUse: {
+            LValue cell = lowCell(m_node-&gt;child1());
+            speculateStringObjectForCell(m_node-&gt;child1(), cell);
+            m_interpreter.filter(m_node-&gt;child1(), SpecStringObject);
+            
+            setJSValue(m_out.loadPtr(cell, m_heaps.JSWrapperObject_internalValue));
+            return;
+        }
+            
+        case StringOrStringObjectUse: {
+            LValue cell = lowCell(m_node-&gt;child1());
+            LValue structure = m_out.loadPtr(cell, m_heaps.JSCell_structure);
+            
+            LBasicBlock notString = FTL_NEW_BLOCK(m_out, (&quot;ToString StringOrStringObject not string case&quot;));
+            LBasicBlock continuation = FTL_NEW_BLOCK(m_out, (&quot;ToString StringOrStringObject continuation&quot;));
+            
+            ValueFromBlock simpleResult = m_out.anchor(cell);
+            m_out.branch(
+                m_out.equal(structure, m_out.constIntPtr(vm().stringStructure.get())),
+                continuation, notString);
+            
+            LBasicBlock lastNext = m_out.appendTo(notString, continuation);
+            speculateStringObjectForStructure(m_node-&gt;child1(), structure);
+            ValueFromBlock unboxedResult = m_out.anchor(
+                m_out.loadPtr(cell, m_heaps.JSWrapperObject_internalValue));
+            m_out.jump(continuation);
+            
+            m_out.appendTo(continuation, lastNext);
+            setJSValue(m_out.phi(m_out.int64, simpleResult, unboxedResult));
+            
+            m_interpreter.filter(m_node-&gt;child1(), SpecString | SpecStringObject);
+            return;
+        }
+            
+        case CellUse:
+        case UntypedUse: {
+            LValue value;
+            if (m_node-&gt;child1().useKind() == CellUse)
+                value = lowCell(m_node-&gt;child1());
+            else
+                value = lowJSValue(m_node-&gt;child1());
+            
+            LBasicBlock isCell = FTL_NEW_BLOCK(m_out, (&quot;ToString CellUse/UntypedUse is cell&quot;));
+            LBasicBlock notString = FTL_NEW_BLOCK(m_out, (&quot;ToString CellUse/UntypedUse not string&quot;));
+            LBasicBlock continuation = FTL_NEW_BLOCK(m_out, (&quot;ToString CellUse/UntypedUse continuation&quot;));
+            
+            LValue isCellPredicate;
+            if (m_node-&gt;child1().useKind() == CellUse)
+                isCellPredicate = m_out.booleanTrue;
+            else
+                isCellPredicate = this-&gt;isCell(value);
+            m_out.branch(isCellPredicate, isCell, notString);
+            
+            LBasicBlock lastNext = m_out.appendTo(isCell, notString);
+            ValueFromBlock simpleResult = m_out.anchor(value);
+            LValue isStringPredicate;
+            if (m_node-&gt;child1()-&gt;prediction() &amp; SpecString) {
+                isStringPredicate = m_out.equal(
+                    m_out.loadPtr(value, m_heaps.JSCell_structure),
+                    m_out.constIntPtr(vm().stringStructure.get()));
+            } else
+                isStringPredicate = m_out.booleanFalse;
+            m_out.branch(isStringPredicate, continuation, notString);
+            
+            m_out.appendTo(notString, continuation);
+            LValue operation;
+            if (m_node-&gt;child1().useKind() == CellUse)
+                operation = m_out.operation(operationToStringOnCell);
+            else
+                operation = m_out.operation(operationToString);
+            ValueFromBlock convertedResult = m_out.anchor(vmCall(operation, m_callFrame, value));
+            m_out.jump(continuation);
+            
+            m_out.appendTo(continuation, lastNext);
+            setJSValue(m_out.phi(m_out.int64, simpleResult, convertedResult));
+            return;
+        }
+            
+        default:
+            RELEASE_ASSERT_NOT_REACHED();
+            break;
+        }
+    }
+    
</ins><span class="cx">     void compileStringCharAt()
</span><span class="cx">     {
</span><span class="cx">         LValue base = lowCell(m_node-&gt;child1());
</span><span class="lines">@@ -3909,6 +3999,12 @@
</span><span class="cx">         case StringUse:
</span><span class="cx">             speculateString(edge);
</span><span class="cx">             break;
</span><ins>+        case StringObjectUse:
+            speculateStringObject(edge);
+            break;
+        case StringOrStringObjectUse:
+            speculateStringOrStringObject(edge);
+            break;
</ins><span class="cx">         case RealNumberUse:
</span><span class="cx">             speculateRealNumber(edge);
</span><span class="cx">             break;
</span><span class="lines">@@ -4096,6 +4192,55 @@
</span><span class="cx">         speculateString(edge, lowCell(edge));
</span><span class="cx">     }
</span><span class="cx">     
</span><ins>+    void speculateStringObject(Edge edge)
+    {
+        if (!m_interpreter.needsTypeCheck(edge, SpecStringObject))
+            return;
+        
+        speculateStringObjectForCell(edge, lowCell(edge));
+        m_interpreter.filter(edge, SpecStringObject);
+    }
+    
+    void speculateStringOrStringObject(Edge edge)
+    {
+        if (!m_interpreter.needsTypeCheck(edge, SpecString | SpecStringObject))
+            return;
+        
+        LBasicBlock notString = FTL_NEW_BLOCK(m_out, (&quot;Speculate StringOrStringObject not string case&quot;));
+        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, (&quot;Speculate StringOrStringObject continuation&quot;));
+        
+        LValue structure = m_out.loadPtr(lowCell(edge), m_heaps.JSCell_structure);
+        m_out.branch(
+            m_out.equal(structure, m_out.constIntPtr(vm().stringStructure.get())),
+            continuation, notString);
+        
+        LBasicBlock lastNext = m_out.appendTo(notString, continuation);
+        speculateStringObjectForStructure(edge, structure);
+        m_out.jump(continuation);
+        
+        m_out.appendTo(continuation, lastNext);
+        
+        m_interpreter.filter(edge, SpecString | SpecStringObject);
+    }
+    
+    void speculateStringObjectForCell(Edge edge, LValue cell)
+    {
+        speculateStringObjectForStructure(edge, m_out.loadPtr(cell, m_heaps.JSCell_structure));
+    }
+    
+    void speculateStringObjectForStructure(Edge edge, LValue structure)
+    {
+        Structure* stringObjectStructure =
+            m_graph.globalObjectFor(m_node-&gt;codeOrigin)-&gt;stringObjectStructure();
+        
+        if (m_state.forNode(edge).m_currentKnownStructure.isSubsetOf(StructureSet(stringObjectStructure)))
+            return;
+        
+        speculate(
+            NotStringObject, noValue(), 0,
+            m_out.notEqual(structure, weakPointer(stringObjectStructure)));
+    }
+    
</ins><span class="cx">     void speculateNonNullObject(Edge edge, LValue cell)
</span><span class="cx">     {
</span><span class="cx">         LValue structure = m_out.loadPtr(cell, m_heaps.JSCell_structure);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonobjectorstringjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object-or-string.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object-or-string.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object-or-string.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+function Foo() { }
+
+Foo.prototype.toString = function() { return &quot;hello&quot; };
+
+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(new Foo());
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;hello&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+    
+    result = foo(&quot;world&quot;);
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;world&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonobjectjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-object.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+function Foo() { }
+
+Foo.prototype.toString = function() { return &quot;hello&quot; };
+
+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(new Foo());
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;hello&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonstringobjectjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-object.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-object.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-object.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(new String(&quot;hello&quot;));
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;hello&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonstringorstringobjectthenobjectjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object-then-object.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object-then-object.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object-then-object.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(new String(&quot;hello&quot;));
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;hello&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+    
+    result = foo(&quot;world&quot;);
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;world&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
+
+function Foo() { }
+
+Foo.prototype.toString = function() { return &quot;hello&quot; };
+
+var result = foo(new Foo());
+if (typeof result != &quot;string&quot;) {
+    describe(result);
+    throw &quot;Error: result isn't a string&quot;;
+}
+if (result != &quot;hello&quot;)
+    throw &quot;Error: bad result: &quot; + result;
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonstringorstringobjectjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-string-or-string-object.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(new String(&quot;hello&quot;));
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;hello&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+    
+    result = foo(&quot;world&quot;);
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;world&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonvalueorstringjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value-or-string.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value-or-string.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value-or-string.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(42);
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;42&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+    
+    result = foo(&quot;world&quot;);
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;world&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstresstostringonvaluejs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value.js (0 => 162593)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value.js                                (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/to-string-on-value.js        2014-01-23 05:11:09 UTC (rev 162593)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+function foo(o) {
+    return String(o);
+}
+
+noInline(foo);
+
+for (var i = 0; i &lt; 100000; ++i) {
+    var result = foo(42);
+    if (typeof result != &quot;string&quot;) {
+        describe(result);
+        throw &quot;Error: result isn't a string&quot;;
+    }
+    if (result != &quot;42&quot;)
+        throw &quot;Error: bad result: &quot; + result;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>