<?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 Internals V: Running Compiled Traces</title>
	<atom:link href="http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/</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: unutulmaz</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-16881</link>
		<dc:creator>unutulmaz</dc:creator>
		<pubDate>Fri, 05 Mar 2010 01:48:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-16881</guid>
		<description>On the issue of reentrancy and tracing. I can see how we
could pause/resume or halt a trace upon detecting reentrancy,
but it’s unclear to me how we can guarantee correctness when
tracing into a re-entrant call, if I understood you correctly.</description>
		<content:encoded><![CDATA[<p>On the issue of reentrancy and tracing. I can see how we<br />
could pause/resume or halt a trace upon detecting reentrancy,<br />
but it’s unclear to me how we can guarantee correctness when<br />
tracing into a re-entrant call, if I understood you correctly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dmandelin</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-584</link>
		<dc:creator>dmandelin</dc:creator>
		<pubDate>Tue, 10 Jun 2008 20:17:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-584</guid>
		<description>So it sounds like even the limitations on tracing aren&#039;t fundamental, but require increasingly hard engineering. Good to hear.</description>
		<content:encoded><![CDATA[<p>So it sounds like even the limitations on tracing aren&#8217;t fundamental, but require increasingly hard engineering. Good to hear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edwin Smith</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-583</link>
		<dc:creator>Edwin Smith</dc:creator>
		<pubDate>Tue, 10 Jun 2008 19:21:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-583</guid>
		<description>&gt; Could you give an example of an effect native methods can have that break tracing?

Say the call stack is Forth -&gt; Native C++ -&gt; Forth

We dont have a way of inlining the native C++ code, which would be required if we want to continue tracing down into the callee Forth code.

If we could inline the native C++ code, the inlined code would construct the C++ stack frame, such that if a Forth side exit were taken by teh callee, you&#039;d return to the interpter, which could &quot;return&quot; to the native C++, and eventually retrun back to the outer interpreter.

We haven&#039;t attempted anything like that.  The native C++ call is traced as a call rather than being inlined, which means the inner forth code would be interpreted even if the outer forth code was traced.  (altho the inner forth code could start looping, and be independently traced).  For simultaneous tracing to work, the Interpreter instance in AS3 would need to not be global but rather be stack allocated or at least one per C++ interpreter stack frame.</description>
		<content:encoded><![CDATA[<p>&gt; Could you give an example of an effect native methods can have that break tracing?</p>
<p>Say the call stack is Forth -&gt; Native C++ -&gt; Forth</p>
<p>We dont have a way of inlining the native C++ code, which would be required if we want to continue tracing down into the callee Forth code.</p>
<p>If we could inline the native C++ code, the inlined code would construct the C++ stack frame, such that if a Forth side exit were taken by teh callee, you&#8217;d return to the interpter, which could &#8220;return&#8221; to the native C++, and eventually retrun back to the outer interpreter.</p>
<p>We haven&#8217;t attempted anything like that.  The native C++ call is traced as a call rather than being inlined, which means the inner forth code would be interpreted even if the outer forth code was traced.  (altho the inner forth code could start looping, and be independently traced).  For simultaneous tracing to work, the Interpreter instance in AS3 would need to not be global but rather be stack allocated or at least one per C++ interpreter stack frame.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edwin Smith</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-551</link>
		<dc:creator>Edwin Smith</dc:creator>
		<pubDate>Tue, 03 Jun 2008 20:02:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-551</guid>
		<description>As you suspected, the reason LIR_loop updates the interp state is for recursion.  If we detect recursion then you&#039;ll be adding some amount to sp, rp, and f each time through the loop.  Recursion also forms a loop when unwinding, subtracting from the pointers.

recursion is detected by isRecursive() in the trace code for ENTERABC and EXITABC; if we&#039;re calling into or returning into a method that is already on the call stack, then we treat the ENTERABC or EXITABC as a backwards jump.

You might find it odd that SideExit has data to update the interpreter state, but the stores to the stacks are on the main trace.  This is an arbitrary decision, which is worth revisiting at some point.  We could store the interpState updates on the main trace too, and then SideExit would be just the target and other sundry items.  Then, store removal and store sinking could enable those stores to move to the side exits the same way stack stores could be moved.</description>
		<content:encoded><![CDATA[<p>As you suspected, the reason LIR_loop updates the interp state is for recursion.  If we detect recursion then you&#8217;ll be adding some amount to sp, rp, and f each time through the loop.  Recursion also forms a loop when unwinding, subtracting from the pointers.</p>
<p>recursion is detected by isRecursive() in the trace code for ENTERABC and EXITABC; if we&#8217;re calling into or returning into a method that is already on the call stack, then we treat the ENTERABC or EXITABC as a backwards jump.</p>
<p>You might find it odd that SideExit has data to update the interpreter state, but the stores to the stacks are on the main trace.  This is an arbitrary decision, which is worth revisiting at some point.  We could store the interpState updates on the main trace too, and then SideExit would be just the target and other sundry items.  Then, store removal and store sinking could enable those stores to move to the side exits the same way stack stores could be moved.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dmandelin</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-539</link>
		<dc:creator>dmandelin</dc:creator>
		<pubDate>Fri, 30 May 2008 18:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-539</guid>
		<description>LIR_loop: What I didn&#039;t understand is that if the jump to the header is a local jump, then I think the sp/rp have to have the same values as they did on entry, so no adjustment would be needed. And I haven&#039;t seen adjustments yet in the debugging output for my trivial examples. Under what circumstances do they occur? Recursive calls? That&#039;s another thing that I noticed in there but didn&#039;t totally figure out.

Reentry: I think I get the gist of what you&#039;re saying, but it feels like there is still a big gap in my understanding. Maybe I don&#039;t know enough about what effect native methods can have on the state--I didn&#039;t look into them too much. Could you give an example of an effect native methods can have that break tracing?

I think at the Tamarin summit you mentioned something along the lines of splitting the native method into 2 parts, a ES or Forth part and a native part, and then put the callback in the ES/Forth part. In principle this seems like a good solution, I guess the only question is what does it actually look like with the callbacks in question.</description>
		<content:encoded><![CDATA[<p>LIR_loop: What I didn&#8217;t understand is that if the jump to the header is a local jump, then I think the sp/rp have to have the same values as they did on entry, so no adjustment would be needed. And I haven&#8217;t seen adjustments yet in the debugging output for my trivial examples. Under what circumstances do they occur? Recursive calls? That&#8217;s another thing that I noticed in there but didn&#8217;t totally figure out.</p>
<p>Reentry: I think I get the gist of what you&#8217;re saying, but it feels like there is still a big gap in my understanding. Maybe I don&#8217;t know enough about what effect native methods can have on the state&#8211;I didn&#8217;t look into them too much. Could you give an example of an effect native methods can have that break tracing?</p>
<p>I think at the Tamarin summit you mentioned something along the lines of splitting the native method into 2 parts, a ES or Forth part and a native part, and then put the callback in the ES/Forth part. In principle this seems like a good solution, I guess the only question is what does it actually look like with the callbacks in question.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Reitmaier</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-536</link>
		<dc:creator>Rick Reitmaier</dc:creator>
		<pubDate>Fri, 30 May 2008 16:01:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-536</guid>
		<description>LIR_loop exits update the interpreter state because we don&#039;t  
have logic that hoists instructions out into a loop header.  
So when the code jumps back to the top of the trace its 
re-loading sp/rp etc, out of InterpState and thus we need
to keep this structure current.

On the issue of reentrancy and tracing.  I can see how we 
could pause/resume or halt a trace upon detecting reentrancy, 
but it&#039;s unclear to me how we can guarantee correctness when 
tracing into a re-entrant call, if I understood you correctly.</description>
		<content:encoded><![CDATA[<p>LIR_loop exits update the interpreter state because we don&#8217;t<br />
have logic that hoists instructions out into a loop header.<br />
So when the code jumps back to the top of the trace its<br />
re-loading sp/rp etc, out of InterpState and thus we need<br />
to keep this structure current.</p>
<p>On the issue of reentrancy and tracing.  I can see how we<br />
could pause/resume or halt a trace upon detecting reentrancy,<br />
but it&#8217;s unclear to me how we can guarantee correctness when<br />
tracing into a re-entrant call, if I understood you correctly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Reilly</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-532</link>
		<dc:creator>Tom Reilly</dc:creator>
		<pubDate>Thu, 29 May 2008 14:42:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-532</guid>
		<description>Great posting!   TT isn&#039;t re-entrant b/c we haven&#039;t implemented it.  Ie, interpMethodEnv assumes its using the whole stack and bad things happen if interpMethodEnv is re-entered on the same thread.   Initially we&#039;ll probably just exit in process traces on re-entrance but traces recorded in the re-entrant call will work, we could do more but that would be a good start.  We never plan to trace across re-entrant calls with unknown arbritrary C code between the exit of the VM and the next interpMethodEnv we can&#039;t guarantee a coherent trace.
Philosophically re-entrance should be avoided for that reason but in practice it will be necessary for certain situations.</description>
		<content:encoded><![CDATA[<p>Great posting!   TT isn&#8217;t re-entrant b/c we haven&#8217;t implemented it.  Ie, interpMethodEnv assumes its using the whole stack and bad things happen if interpMethodEnv is re-entered on the same thread.   Initially we&#8217;ll probably just exit in process traces on re-entrance but traces recorded in the re-entrant call will work, we could do more but that would be a good start.  We never plan to trace across re-entrant calls with unknown arbritrary C code between the exit of the VM and the next interpMethodEnv we can&#8217;t guarantee a coherent trace.<br />
Philosophically re-entrance should be avoided for that reason but in practice it will be necessary for certain situations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris</title>
		<link>http://blog.mozilla.com/dmandelin/2008/05/28/tamarin-tracing-internals-v-running-compiled-traces/comment-page-1/#comment-528</link>
		<dc:creator>Boris</dc:creator>
		<pubDate>Thu, 29 May 2008 03:16:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/dmandelin/?p=18#comment-528</guid>
		<description>Hmm.  Most of the commonly-used DOM methods can potentially reenter JS (e.g. via mutation events), though they usually do not.  What does that mean in terms of tracing the calls into those methods?</description>
		<content:encoded><![CDATA[<p>Hmm.  Most of the commonly-used DOM methods can potentially reenter JS (e.g. via mutation events), though they usually do not.  What does that mean in terms of tracing the calls into those methods?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

