<?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: Flash Internals: Just-in-time (JIT) compilation (part four)</title>
	<atom:link href="http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/</link>
	<description>Looking at the world of media: from music to RIA.</description>
	<lastBuildDate>Mon, 23 Nov 2009 08:39:09 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Lorenzo</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-988</link>
		<dc:creator>Lorenzo</dc:creator>
		<pubDate>Wed, 04 Nov 2009 15:25:34 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-988</guid>
		<description>&lt;p&gt;Dear James,&lt;/p&gt;

&lt;p&gt;thank you for your reply! :)&lt;/p&gt;

&lt;p&gt;Frames can be a tricky topic! They are difficult to understand. I will do research on them!!
Thank you again.
Best Regards.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dear James,</p>

<p>thank you for your reply! <img src='http://blog.vivisectingmedia.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>Frames can be a tricky topic! They are difficult to understand. I will do research on them!!
Thank you again.
Best Regards.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: James Polanco</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-987</link>
		<dc:creator>James Polanco</dc:creator>
		<pubDate>Tue, 03 Nov 2009 22:54:53 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-987</guid>
		<description>&lt;p&gt;Lorenzo,
From what I understand the concept of a SWF frame and a Player Frame are essentially the same.  When using Flash Authoring to create animations you are telling the Player to render the changes defined for each frame.  When the player runs the SWF, it will attempt to play each SWF frame as defined, i.e. render the content changes.&lt;/p&gt;

&lt;p&gt;The core difference between the frame in the SWF vs. the player frame is how the frame is constructed.  I recommend checking out Sean Christmann&#039;s article on how frames are synthesized in the player.  http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/&lt;/p&gt;

&lt;p&gt;Even with this approach, the frames still logically map together from a conceptual perspective.  For me, I look at them as one in the same... even though they maybe defined technically different under the hood.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Lorenzo,
From what I understand the concept of a SWF frame and a Player Frame are essentially the same.  When using Flash Authoring to create animations you are telling the Player to render the changes defined for each frame.  When the player runs the SWF, it will attempt to play each SWF frame as defined, i.e. render the content changes.</p>

<p>The core difference between the frame in the SWF vs. the player frame is how the frame is constructed.  I recommend checking out Sean Christmann&#8217;s article on how frames are synthesized in the player.  <a href="http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/" rel="nofollow">http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/</a></p>

<p>Even with this approach, the frames still logically map together from a conceptual perspective.  For me, I look at them as one in the same&#8230; even though they maybe defined technically different under the hood.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Lorenzo</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-986</link>
		<dc:creator>Lorenzo</dc:creator>
		<pubDate>Tue, 03 Nov 2009 22:38:08 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-986</guid>
		<description>&lt;p&gt;Dear James,&lt;/p&gt;

&lt;p&gt;I really appreciate your blog!!! :)
I have a question for you.
You talked about SWF Frame and Flash Player Frame. So, could you give me the definition for these terms?
SWF Frames are contained into a swf file and are like a logical units that contain assets and as code. Instead, a Flash Player frame is the time period between two consecutive enterframe events (controlled by frame rate).
So,what is the relationship between them?
In particular, I would know if they are paired each other or not.&lt;/p&gt;

&lt;p&gt;Thanks in advance. Best Regards.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dear James,</p>

<p>I really appreciate your blog!!! <img src='http://blog.vivisectingmedia.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> 
I have a question for you.
You talked about SWF Frame and Flash Player Frame. So, could you give me the definition for these terms?
SWF Frames are contained into a swf file and are like a logical units that contain assets and as code. Instead, a Flash Player frame is the time period between two consecutive enterframe events (controlled by frame rate).
So,what is the relationship between them?
In particular, I would know if they are paired each other or not.</p>

<p>Thanks in advance. Best Regards.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Annie</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-928</link>
		<dc:creator>Annie</dc:creator>
		<pubDate>Thu, 01 Oct 2009 02:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-928</guid>
		<description>&lt;p&gt;Hi, I have a question. In AVM2, both of the interpreter and JIT can compile the AS code.But when to use interpreter,when to use JIt?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi, I have a question. In AVM2, both of the interpreter and JIT can compile the AS code.But when to use interpreter,when to use JIt?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-890</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 11 May 2009 16:34:50 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-890</guid>
		<description>&lt;p&gt;You where correct in calling the AS3 to ByteCode process, compilation.  The issue semantical issue that we face is that there is technically two compilation passes in the new Flash Player world.  The first compilation pass is creating the SWF (which wraps the ByteCode) the second is when the AVM+ takes the ByteCode and compiles it to machine code for the specific platform the Player is running on.&lt;br&gt;&lt;br&gt;When the first SWF compilation is being run there are optimization being applied, but they are limited to what the ByteCode can represent.  I don&#039;t know exactly what optimizations are being made during this phase, but essentially all the Classes, objects, functions, properties, etc are being boiled down into commands that are executed by the AVM at run-time.  The AVM is then responsible for converting these commands into machine code (second compilation) that the specific OS can understand.  The reason we use the ByteCode interim step is that we want the same SWF to run on multiple OSs.  This is why the Flash Player is still considered an interpreter because the SWF is not an OS native compiled application.&lt;br&gt;&lt;br&gt;I feel your description is really close, what you are describing is the benefit of sealed classes versus dynamic classes.  MovieClip is marked as a dynamic class, which means that you can attach new properties to it at run-time.  Looking back at your first example, _nestedMovieClip is not a defined property on the MovieClip class, you have added this property.  To access this property the AVM has to lookup the property on the instance to first see if it exists and if so then it can access it.  This process is similar to using &quot;for in&quot; on an object, you have to loop over all the properties trying to see if it has the one you want.  This is a time consuming process as you have found out through your testing.&lt;br&gt;&lt;br&gt;More then likely, you are seeing the performance benefit by making a reference to the property and then accessing the reference because the lookup no longer has to occur every time you access the property.  This is the same principle of using a pre-calculated length value when looping over an array instead of accessing the &quot;.length&quot; property each time.  The act of accessing the property, i.e. &quot;myArray.length&quot; requires the lookup and calculation of the length to occur every time we perform a loop.  If we crate a variable before we start the loop and set it to &quot;myArray.length&quot; then the loop will no longer call the length getter during every pass, making our loop run a lot faster. If we apply this to your example, then we can avoid the lookup by storing the instance in a reference variable and therefore the AVM only has to lookup the value once, to set the reference and then can access it faster from there.&lt;br&gt;&lt;br&gt;We can actually take this one step further.  If you read or see most peoples articles/presentations on Flash performance they always start with &quot;use strong typing&quot;.  The reason behind using strong typing is the same as making a reference, it helps mitigate AVM lookup time.  If we take your BlueSquare example we want to make sure that BlueSquare has _nestedMovieClip declared as a property of the Class and that it is typed to MovieClip.  By having this reference on the BlueSquare Class the AVM will not have to do full scanning lookup (ex: for in) on the BlueSquare instance to see if _nestedMoveiClip is both declared and has a value and that the value &quot;x&quot; also exists on the _nesteMovieClip instance.&lt;br&gt;&lt;br&gt;By explicitly declaring _nestedMovieClip we have defined BlueSquare as a sealed class, which will give us a lot of performance gains at run-time.  Dynamic Classes are great (Classes that can have properties added at runtime) but they come with a huge cost.  I always recommend avoiding dynamic classes unless you absolutely have to and even then, try not to use them.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You where correct in calling the AS3 to ByteCode process, compilation.  The issue semantical issue that we face is that there is technically two compilation passes in the new Flash Player world.  The first compilation pass is creating the SWF (which wraps the ByteCode) the second is when the AVM+ takes the ByteCode and compiles it to machine code for the specific platform the Player is running on.<br /><br />When the first SWF compilation is being run there are optimization being applied, but they are limited to what the ByteCode can represent.  I don&#39;t know exactly what optimizations are being made during this phase, but essentially all the Classes, objects, functions, properties, etc are being boiled down into commands that are executed by the AVM at run-time.  The AVM is then responsible for converting these commands into machine code (second compilation) that the specific OS can understand.  The reason we use the ByteCode interim step is that we want the same SWF to run on multiple OSs.  This is why the Flash Player is still considered an interpreter because the SWF is not an OS native compiled application.<br /><br />I feel your description is really close, what you are describing is the benefit of sealed classes versus dynamic classes.  MovieClip is marked as a dynamic class, which means that you can attach new properties to it at run-time.  Looking back at your first example, _nestedMovieClip is not a defined property on the MovieClip class, you have added this property.  To access this property the AVM has to lookup the property on the instance to first see if it exists and if so then it can access it.  This process is similar to using &#8220;for in&#8221; on an object, you have to loop over all the properties trying to see if it has the one you want.  This is a time consuming process as you have found out through your testing.<br /><br />More then likely, you are seeing the performance benefit by making a reference to the property and then accessing the reference because the lookup no longer has to occur every time you access the property.  This is the same principle of using a pre-calculated length value when looping over an array instead of accessing the &#8220;.length&#8221; property each time.  The act of accessing the property, i.e. &#8220;myArray.length&#8221; requires the lookup and calculation of the length to occur every time we perform a loop.  If we crate a variable before we start the loop and set it to &#8220;myArray.length&#8221; then the loop will no longer call the length getter during every pass, making our loop run a lot faster. If we apply this to your example, then we can avoid the lookup by storing the instance in a reference variable and therefore the AVM only has to lookup the value once, to set the reference and then can access it faster from there.<br /><br />We can actually take this one step further.  If you read or see most peoples articles/presentations on Flash performance they always start with &#8220;use strong typing&#8221;.  The reason behind using strong typing is the same as making a reference, it helps mitigate AVM lookup time.  If we take your BlueSquare example we want to make sure that BlueSquare has _nestedMovieClip declared as a property of the Class and that it is typed to MovieClip.  By having this reference on the BlueSquare Class the AVM will not have to do full scanning lookup (ex: for in) on the BlueSquare instance to see if _nestedMoveiClip is both declared and has a value and that the value &#8220;x&#8221; also exists on the _nesteMovieClip instance.<br /><br />By explicitly declaring _nestedMovieClip we have defined BlueSquare as a sealed class, which will give us a lot of performance gains at run-time.  Dynamic Classes are great (Classes that can have properties added at runtime) but they come with a huge cost.  I always recommend avoiding dynamic classes unless you absolutely have to and even then, try not to use them.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: ultraky</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-889</link>
		<dc:creator>ultraky</dc:creator>
		<pubDate>Sun, 10 May 2009 21:07:34 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-889</guid>
		<description>&lt;p&gt;Thanks for taking the time to answer, I&#039;m no engineer but trying hard to understand. &lt;br&gt;&lt;br&gt;Before when I said &#039;Compiler&#039; I was thinking of when Flash converts AS3 into Byte Code, but I was wrong to call it that. When that .swf is created, is it doing anything else besides just converting AS3 into Byte Code? I thought it was also pre-allocating and organizing &#039;stuff&#039; for when that bytecode is loaded.&lt;br&gt;&lt;br&gt;Reading your article again, I can now see there there is a 2nd compilation when the Byte Code is loaded into Virtual Machine, and the VM then allocates &#039;stuff&#039;.    After that does the JIT take over and task out commands?  Am I close?&lt;br&gt;&lt;br&gt;So far, it seems that the situation I referred to before is an area of interest to those who are looking to optimize.   I have been doing lots of benchmarking using gSkinner&#039;s testing suite. So far my hypothesis has been correct, and I am seeing massive, massive performance gains when nested clips are declared before functions are performed on them. Also, the more objects that are inside that Movieclip ( either drawing objects, text fields, or symbols ) the more time it takes to access that specific object.&lt;br&gt;&lt;br&gt;If I understand how the JIT works, this makes sense because the JIT doesn&#039;t know about that nested object before being told to manipulate it, it has to search for it. Does that make sense?&lt;br&gt;&lt;br&gt;I will do a proper write up very shortly on my blog when I have really tested everything, when that happens I would love to hear your thoughts.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for taking the time to answer, I&#39;m no engineer but trying hard to understand. <br /><br />Before when I said &#39;Compiler&#39; I was thinking of when Flash converts AS3 into Byte Code, but I was wrong to call it that. When that .swf is created, is it doing anything else besides just converting AS3 into Byte Code? I thought it was also pre-allocating and organizing &#39;stuff&#39; for when that bytecode is loaded.<br /><br />Reading your article again, I can now see there there is a 2nd compilation when the Byte Code is loaded into Virtual Machine, and the VM then allocates &#39;stuff&#39;.    After that does the JIT take over and task out commands?  Am I close?<br /><br />So far, it seems that the situation I referred to before is an area of interest to those who are looking to optimize.   I have been doing lots of benchmarking using gSkinner&#39;s testing suite. So far my hypothesis has been correct, and I am seeing massive, massive performance gains when nested clips are declared before functions are performed on them. Also, the more objects that are inside that Movieclip ( either drawing objects, text fields, or symbols ) the more time it takes to access that specific object.<br /><br />If I understand how the JIT works, this makes sense because the JIT doesn&#39;t know about that nested object before being told to manipulate it, it has to search for it. Does that make sense?<br /><br />I will do a proper write up very shortly on my blog when I have really tested everything, when that happens I would love to hear your thoughts.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-888</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 08 May 2009 02:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-888</guid>
		<description>&lt;p&gt;Alan,&lt;br&gt;I assume by &quot;compile time&quot; you mean the Flash Player&#039;s compilation of the byte code to machine code so that it can be executed, not the Flash compiler you use to create the SWF.&lt;br&gt;&lt;br&gt;It depends upon when the construction of the nested clip occurs. By the time the Player gets to the your x value change the nested clip has had to be constructed and therefore the player will know about the instance.&lt;br&gt;&lt;br&gt;The bigger question is if the method will be compiled by the JIT or not.  JIT&#039;ing doesn&#039;t occur on an Object or Class level, but on a bytecode level. Its possible that setting the x value may be JIT&#039;ed but the MovieClip will not be compiled down entirely.&lt;br&gt;&lt;br&gt;What is not clear to me, is when the actual JIT and MIR process is applied.  Is it a look ahead process examines the entire app stack, or does it interpret every bytecode stack as its processed and on second execution does it apply the JIT?  I have a feeling that the MIR is built on the first pass of the bytecode execution and the next time the code is called JIT is applied.&lt;br&gt;&lt;br&gt;If that is the case, then your reference to the x value is not JIT&#039;ed the first time you make the call, but the second time you do it will be JIT&#039;ed.  This is a really interesting topic, because at DevelopmentArc we have begun looking at performance increases around JIT optimization and knowing this could really help.&lt;br&gt;&lt;br&gt;I hope this answered your question, or at least pointed you in the right direction.&lt;br&gt;&lt;br&gt;J.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Alan,<br />I assume by &#8220;compile time&#8221; you mean the Flash Player&#39;s compilation of the byte code to machine code so that it can be executed, not the Flash compiler you use to create the SWF.<br /><br />It depends upon when the construction of the nested clip occurs. By the time the Player gets to the your x value change the nested clip has had to be constructed and therefore the player will know about the instance.<br /><br />The bigger question is if the method will be compiled by the JIT or not.  JIT&#39;ing doesn&#39;t occur on an Object or Class level, but on a bytecode level. Its possible that setting the x value may be JIT&#39;ed but the MovieClip will not be compiled down entirely.<br /><br />What is not clear to me, is when the actual JIT and MIR process is applied.  Is it a look ahead process examines the entire app stack, or does it interpret every bytecode stack as its processed and on second execution does it apply the JIT?  I have a feeling that the MIR is built on the first pass of the bytecode execution and the next time the code is called JIT is applied.<br /><br />If that is the case, then your reference to the x value is not JIT&#39;ed the first time you make the call, but the second time you do it will be JIT&#39;ed.  This is a really interesting topic, because at DevelopmentArc we have begun looking at performance increases around JIT optimization and knowing this could really help.<br /><br />I hope this answered your question, or at least pointed you in the right direction.<br /><br />J.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://blog.vivisectingmedia.com/2007/11/flash-internals-jit-and-garbage-collection-part-four/comment-page-1/#comment-887</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Fri, 08 May 2009 00:25:31 +0000</pubDate>
		<guid isPermaLink="false">http://james.fakescience.com/blog/?p=76#comment-887</guid>
		<description>&lt;p&gt;Wow this is incredible stuff.  I just saw Jim talk at FITC in Toronto and I&#039;ve been thirsting for more since.&lt;br&gt;&lt;br&gt;I do have a question that maybe you can answer.  Suppose I have a movieclip in my library set to export, lets call the class BlueSquare.  In this example nothing is on the stage, and the library has a movieclip set to export. Nested in that class is another movieclip, and it has an instance name of &lt;em&gt;nestedMovieClip.&lt;br&gt;&lt;br&gt;Now somewhere in my code, I create an instance of that class BlueSquare:&lt;br&gt;&lt;br&gt;var square:BlueSquare = new BlueSquare();&lt;br&gt;&lt;br&gt;then I want to modify that nested movieclip:&lt;br&gt;&lt;br&gt;square.&lt;/em&gt;nestedMovieClip.x = 100;&lt;br&gt;&lt;br&gt;My question: At compile time, does the player know the existence of that nested movie clip, and therefore can the JIT create a reference to it on the first pass before it is used?&lt;br&gt;&lt;br&gt;Whew.&lt;br&gt;&lt;br&gt;Again, thanks for this article, I wish there was more stuff on this.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Wow this is incredible stuff.  I just saw Jim talk at FITC in Toronto and I&#39;ve been thirsting for more since.<br /><br />I do have a question that maybe you can answer.  Suppose I have a movieclip in my library set to export, lets call the class BlueSquare.  In this example nothing is on the stage, and the library has a movieclip set to export. Nested in that class is another movieclip, and it has an instance name of <em>nestedMovieClip.<br /><br />Now somewhere in my code, I create an instance of that class BlueSquare:<br /><br />var square:BlueSquare = new BlueSquare();<br /><br />then I want to modify that nested movieclip:<br /><br />square.</em>nestedMovieClip.x = 100;<br /><br />My question: At compile time, does the player know the existence of that nested movie clip, and therefore can the JIT create a reference to it on the first pass before it is used?<br /><br />Whew.<br /><br />Again, thanks for this article, I wish there was more stuff on this.</p>]]></content:encoded>
	</item>
</channel>
</rss>
