This is a good time to bring up the other half of my original email because a 
number of other people have chimed in with their experiences with GC when 
attempting to develop more time critical applications without stutter.

The second part was a hint to tell the engine to always take the most 
aggressive route with optimization; for instance, in Safari’s engine, as I 
remember, I think there are three levels, interpreted, a half-n-half solution, 
and an actual full compile of the code.  This hint would say “always compile to 
native” or if an engine never goes that far, always compile to the VM soup 
(though I suspect at this point most engines can do a native version.)

This would be used, again, for trading time in one place for time in another.  
A longer start-up time is something you want for a thing that will run 
continually and will almost always be guaranteed to fall into the compile path 
eventually.  It’s not something you’d want for javascript that runs on a normal 
button click to post a form.

Being compiled gives you another benefit, say you have this class:

class ….
{
test()
{
let x,y,z;
…
….
return(x);
}

The locals y and z are never move beyond the function scope; in this manner 
they could be stack based variables that never touch the heap (yes, I know 
that’s probably a very difficult implementation.)  Or even variables that fall 
into a special section of the heap that only deals with locals that never scope 
outside the function and are always cleaned up automatically on function exit 
(basically, reference counting where you know the reference is always 0.)

This will basically reduce the amount of GCs by a good bit.  NOW, you’d also 
have to track any additional function calls that use these variables (to make 
sure they aren’t save out to a global.)  So everything underneath would be a 
force compile for this to work.  Engines might already do this or stuff like 
it, and if so, great!

This is probably something that is *much more* complicated to implement that 
most of us might realize, but it’s a thought.  Just being able to say “this 
class is always compiled” would be nice.

The second part of this is native primitive types; having int/etc means they 
can be passed by value which means these checks are easier, but that’s probably 
something others have argued back and forth for a long time :)

[>] Brian
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to