<!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>[162248] 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/162248">162248</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2014-01-17 23:26:58 -0800 (Fri, 17 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix 32-bit C loop LLINT.
https://bugs.webkit.org/show_bug.cgi?id=127086.

Reviewed by Geoffrey Garen.

* llint/LowLevelInterpreter32_64.asm:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter32_64asm">branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (162247 => 162248)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-18 06:54:40 UTC (rev 162247)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-18 07:26:58 UTC (rev 162248)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2014-01-16  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Fix 32-bit C loop LLINT.
+        https://bugs.webkit.org/show_bug.cgi?id=127086.
+
+        Reviewed by Geoffrey Garen.
+
+        * llint/LowLevelInterpreter32_64.asm:
+
</ins><span class="cx"> 2014-01-17  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         FTL mishandles (-2147483648 % 0) | 0
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreter32_64asm"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (162247 => 162248)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2014-01-18 06:54:40 UTC (rev 162247)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2014-01-18 07:26:58 UTC (rev 162248)
</span><span class="lines">@@ -159,7 +159,7 @@
</span><span class="cx">         const temp2 = t1 # Same as previousPC
</span><span class="cx">         const temp3 = t2
</span><span class="cx">         const temp4 = t3 # same as vm
</span><del>-    elsif ARM or ARMv7_TRADITIONAL
</del><ins>+    elsif ARM or ARMv7 or ARMv7_TRADITIONAL or C_LOOP
</ins><span class="cx">         const entry = a0
</span><span class="cx">         const vm = a1
</span><span class="cx">         const protoCallFrame = a2
</span><span class="lines">@@ -167,20 +167,9 @@
</span><span class="cx">         const previousCFR = t3
</span><span class="cx">         const previousPC = lr
</span><span class="cx">         const temp1 = t3 # Same as previousCFR
</span><del>-        const temp2 = a3 # Same as topOfStack
</del><ins>+        const temp2 = t4
</ins><span class="cx">         const temp3 = t5
</span><del>-        const temp4 = t4
-    elsif ARMv7
-        const entry = a0
-        const vm = a1
-        const protoCallFrame = a2
-
-        const previousCFR = t3
-        const previousPC = lr
-        const temp1 = t3 # Same as previousCFR
-        const temp2 = a3 # Same as topOfStack
-        const temp3 = t5
-        const temp4 = t4
</del><ins>+        const temp4 = t4 # Same as temp2
</ins><span class="cx">     elsif MIPS
</span><span class="cx">         const entry = a0
</span><span class="cx">         const vmTopCallFrame = a1
</span><span class="lines">@@ -214,7 +203,6 @@
</span><span class="cx">         loadp 32[sp], entry
</span><span class="cx">     else
</span><span class="cx">         move cfr, previousCFR
</span><del>-        move topOfStack, cfr
</del><span class="cx">     end
</span><span class="cx"> 
</span><span class="cx">     checkStackPointerAlignment(temp2, 0xbad0dc01)
</span><span class="lines">@@ -253,9 +241,17 @@
</span><span class="cx">     subp cfr, 8, sp
</span><span class="cx"> 
</span><span class="cx">     if C_LOOP
</span><del>-    # FIXME: Need to call stack check here to see if we can grow the stack.
-    # Will need to preserve registers so that we can recover if we do not end
-    # up throwing a StackOverflowError.
</del><ins>+        move entry, temp2
+        move vm, temp3
+        cloopCallSlowPath _llint_stack_check_at_vm_entry, vm, temp1
+        bpeq t0, 0, .stackCheckFailed
+        move temp2, entry
+        move temp3, vm
+        jmp .stackHeightOK
+
+.stackCheckFailed:
+        move temp2, entry
+        move temp3, vm
</ins><span class="cx">     end
</span><span class="cx"> 
</span><span class="cx">     cCall2(_llint_throw_stack_overflow_error, vm, protoCallFrame)
</span><span class="lines">@@ -318,30 +314,41 @@
</span><span class="cx"> macro makeJavaScriptCall(entry, temp, unused)
</span><span class="cx">     addp CallerFrameAndPCSize, sp
</span><span class="cx">     checkStackPointerAlignment(t2, 0xbad0dc02)
</span><del>-    call entry
</del><ins>+    if C_LOOP
+        cloopCallJSFunction entry
+    else
+        call entry
+    end
</ins><span class="cx">     checkStackPointerAlignment(t2, 0xbad0dc03)
</span><span class="cx">     subp CallerFrameAndPCSize, sp
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="cx"> macro makeHostFunctionCall(entry, temp1, temp2)
</span><span class="cx">     move entry, temp1
</span><del>-    if X86
-        # Put callee frame pointer on stack as arg0, also put it in ecx for &quot;fastcall&quot; targets
-        move 0, temp2
-        move temp2, 4[sp] # put 0 in ReturnPC
-        move cfr, [sp] # put caller frame pointer into callee frame since callee prologue can't
-        move sp, t2 # t2 is ecx
-        push temp2 # Push dummy arg1
-        push t2
-    else
</del><ins>+    if C_LOOP
</ins><span class="cx">         move sp, a0
</span><del>-        addp CallerFrameAndPCSize, sp
-    end
-    call temp1
-    if X86
-        addp 8, sp
</del><ins>+        storep cfr, [sp]
+        storep lr, PtrSize[sp]
+        cloopCallNative temp1
</ins><span class="cx">     else
</span><del>-        subp CallerFrameAndPCSize, sp
</del><ins>+        if X86
+            # Put callee frame pointer on stack as arg0, also put it in ecx for &quot;fastcall&quot; targets
+            move 0, temp2
+            move temp2, 4[sp] # put 0 in ReturnPC
+            move cfr, [sp] # put caller frame pointer into callee frame since callee prologue can't
+            move sp, t2 # t2 is ecx
+            push temp2 # Push dummy arg1
+            push t2
+        else
+            move sp, a0
+            addp CallerFrameAndPCSize, sp
+        end
+        call temp1
+        if X86
+            addp 8, sp
+        else
+            subp CallerFrameAndPCSize, sp
+        end
</ins><span class="cx">     end
</span><span class="cx"> end
</span><span class="cx"> 
</span><span class="lines">@@ -2118,39 +2125,27 @@
</span><span class="cx">         andp MarkedBlockMask, t3
</span><span class="cx">         loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
</span><span class="cx">         addp 8, sp
</span><del>-    elsif ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
-        loadp ScopeChain[cfr], t3
-        andp MarkedBlockMask, t3
-        loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
-        storep cfr, VM::topCallFrame[t3]
-        move t0, t2
</del><ins>+    elsif ARM or ARMv7 or ARMv7_TRADITIONAL or C_LOOP or MIPS or SH4
+        # t1 already contains the ScopeChain.
+        andp MarkedBlockMask, t1
+        loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t1], t1
+        storep cfr, VM::topCallFrame[t1]
+        move t0, t2 # t0 contains callerFrame
</ins><span class="cx">         preserveReturnAddressAfterCall(t3)
</span><span class="cx">         storep t3, ReturnPC[cfr]
</span><del>-        move cfr, t0
-        loadi Callee + PayloadOffset[cfr], t1
-        loadp JSFunction::m_executable[t1], t1
-        move t2, cfr
</del><span class="cx">         if MIPS or SH4
</span><del>-            move t0, a0
</del><ins>+            move cfr, a0
+        else
+            move cfr, t0
</ins><span class="cx">         end
</span><del>-        call executableOffsetToFunction[t1]
-        restoreReturnAddressBeforeReturn(t3)
-        loadp ScopeChain[cfr], t3
-        andp MarkedBlockMask, t3
-        loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
-    elsif C_LOOP
-        loadp ScopeChain[cfr], t3
-        andp MarkedBlockMask, t3
-        loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
-        storep cfr, VM::topCallFrame[t3]
-        move t0, t2
-        preserveReturnAddressAfterCall(t3)
-        storep t3, ReturnPC[cfr]
-        move cfr, t0
</del><span class="cx">         loadi Callee + PayloadOffset[cfr], t1
</span><span class="cx">         loadp JSFunction::m_executable[t1], t1
</span><span class="cx">         move t2, cfr
</span><del>-        cloopCallNative executableOffsetToFunction[t1]
</del><ins>+        if C_LOOP
+            cloopCallNative executableOffsetToFunction[t1]
+        else
+            call executableOffsetToFunction[t1]
+        end
</ins><span class="cx">         restoreReturnAddressBeforeReturn(t3)
</span><span class="cx">         loadp ScopeChain[cfr], t3
</span><span class="cx">         andp MarkedBlockMask, t3
</span></span></pre>
</div>
</div>

</body>
</html>