<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Tamarin Tracing Interals, Part II: Forth</title>
	<atom:link href="http://blog.mozilla.com/dmandelin/2008/05/21/tamarin-tracing-interals-part-ii-forth/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.com/dmandelin/2008/05/21/tamarin-tracing-interals-part-ii-forth/</link>
	<description>Just another Blog.mozilla.com weblog</description>
	<lastBuildDate>Wed, 25 Jan 2012 23:29:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Edwin Smith</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/21/tamarin-tracing-interals-part-ii-forth/comment-page-1/#comment-508</link>
		<dc:creator>Edwin Smith</dc:creator>
		<pubDate>Thu, 22 May 2008 19:36:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=15#comment-508</guid>
		<description>You can get int semantics in ES3 like this:

  ~~(a+b)

since &gt;&gt; (and the other bitwise operators) convert to int32 first.  

I prototyped adding an overflow check operator in TT&#039;s forth that translated into checking the condition codes at the ISA level, and guarding on not overflowing.  it generally works, and it worked well enough to pursue further.  

i did hit a snag optimizing it because that deepdown branch can cause a tree branch where you dont want one.  both sides of the branch will end up computing (a+b) after you optimize, but now you have two identical tree branches.

Without a technique like UCI&#039;s tree folding, which would eliminate those branches, the penalty for too many branches was higher than the penalty for doing extraneous doubleToInt32()&#039;s.  crypto-md5() is a case that showed this behavior.

this was one of the factors that led us to introduce a static abc-&gt;IL translation step.  in the case we&#039;re talking about its soo easy to handle staticaly, and really tricky to handle dynamicaly.</description>
		<content:encoded><![CDATA[<p>You can get int semantics in ES3 like this:</p>
<p>  ~~(a+b)</p>
<p>since &gt;&gt; (and the other bitwise operators) convert to int32 first.  </p>
<p>I prototyped adding an overflow check operator in TT&#8217;s forth that translated into checking the condition codes at the ISA level, and guarding on not overflowing.  it generally works, and it worked well enough to pursue further.  </p>
<p>i did hit a snag optimizing it because that deepdown branch can cause a tree branch where you dont want one.  both sides of the branch will end up computing (a+b) after you optimize, but now you have two identical tree branches.</p>
<p>Without a technique like UCI&#8217;s tree folding, which would eliminate those branches, the penalty for too many branches was higher than the penalty for doing extraneous doubleToInt32()&#8217;s.  crypto-md5() is a case that showed this behavior.</p>
<p>this was one of the factors that led us to introduce a static abc-&gt;IL translation step.  in the case we&#8217;re talking about its soo easy to handle staticaly, and really tricky to handle dynamicaly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dmandelin</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/21/tamarin-tracing-interals-part-ii-forth/comment-page-1/#comment-507</link>
		<dc:creator>dmandelin</dc:creator>
		<pubDate>Thu, 22 May 2008 18:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=15#comment-507</guid>
		<description>Cool, thanks for adding your comments, by the way. This really helps. 

I saw the email about Mike Pall&#039;s experience. We were talking about that the other day and array accesses was the one probable exception that came up.

So if you speculate non-overflow on integer addition, and use an integer addition ISA instruction, does that mean you have to add a check for overflow afterward? If so, is that costly?

The cipher thing is interesting. I guess it would be a lot easier if int semantics are available. But I guess there is no int type even in ES4? So are you thinking language extensions, or some kind of pattern recognizer for ES that encodes wraparound semantics for Number?</description>
		<content:encoded><![CDATA[<p>Cool, thanks for adding your comments, by the way. This really helps. </p>
<p>I saw the email about Mike Pall&#8217;s experience. We were talking about that the other day and array accesses was the one probable exception that came up.</p>
<p>So if you speculate non-overflow on integer addition, and use an integer addition ISA instruction, does that mean you have to add a check for overflow afterward? If so, is that costly?</p>
<p>The cipher thing is interesting. I guess it would be a lot easier if int semantics are available. But I guess there is no int type even in ES4? So are you thinking language extensions, or some kind of pattern recognizer for ES that encodes wraparound semantics for Number?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edwin Smith</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/21/tamarin-tracing-interals-part-ii-forth/comment-page-1/#comment-506</link>
		<dc:creator>Edwin Smith</dc:creator>
		<pubDate>Thu, 22 May 2008 17:20:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=15#comment-506</guid>
		<description>A forth subroutine is usually called a &quot;high level word&quot;.  the syntax is

   :  words ;

EXTERN: replaces : and marks the word as callable from C.  fc.py only compiles words reachable from the EXTERN entry points.  so EXTERN in a forth file is like the &quot;extern&quot; keyword in a C file. 

TT habit of appending &quot;vec&quot; to name cases comes from the forth notion of vectorized execution.  A CASE is basically a jump vector (table) definition - executing a case word is like &quot;goto *vec[*sp--]&quot;.

int(double(a)+double(b) used in an array index context is a hotspot in TT and would definitely benefit from statically optimizing out when possible, or adding an overflow check to dynamically keep things as ints as long as possible.  

when doing int + int it is usually a win to speculate that the result doesnt overflow.  in array index contexts, its always a win.  

for cyphers that count on wraparound, you want to have a way to optimize out the int-&gt;double-&gt;int conversion that happens in the overflow case.  (in other words cyphers want wraparound behavior).

outside of array index contexts, the jury is still out.  Mike Pall made a good case for leaving everything as double.</description>
		<content:encoded><![CDATA[<p>A forth subroutine is usually called a &#8220;high level word&#8221;.  the syntax is</p>
<p>   :  words ;</p>
<p>EXTERN: replaces : and marks the word as callable from C.  fc.py only compiles words reachable from the EXTERN entry points.  so EXTERN in a forth file is like the &#8220;extern&#8221; keyword in a C file. </p>
<p>TT habit of appending &#8220;vec&#8221; to name cases comes from the forth notion of vectorized execution.  A CASE is basically a jump vector (table) definition &#8211; executing a case word is like &#8220;goto *vec[*sp--]&#8220;.</p>
<p>int(double(a)+double(b) used in an array index context is a hotspot in TT and would definitely benefit from statically optimizing out when possible, or adding an overflow check to dynamically keep things as ints as long as possible.  </p>
<p>when doing int + int it is usually a win to speculate that the result doesnt overflow.  in array index contexts, its always a win.  </p>
<p>for cyphers that count on wraparound, you want to have a way to optimize out the int-&gt;double-&gt;int conversion that happens in the overflow case.  (in other words cyphers want wraparound behavior).</p>
<p>outside of array index contexts, the jury is still out.  Mike Pall made a good case for leaving everything as double.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

