Sadly the JavaScript fragments are outside of my control so I cannot
require that they include a return statement, and they are a bit more
complicated than "6+7" and do benefit from optimisation, especially as
they are executed many, many times.
Object.freeze() (thanks Toon) won't help because it stops the fragments
from defining their own variables. They need to be allowed to define
variables; I just don't want those variables to affect the next execution.
In the last message from this discussion in 2012
<https://groups.google.com/forum/#%21topic/v8-users/FfqgU3jEKf4>,
Andreas Rossberg suggests that v8 will need to allow arbitrary user
objects to be used as the global object in order to support ES6 module
loaders. Perhaps this will eventually give me what I want. In the
meantime I'll do the cleanup manually.
Thanks for all the suggestions,
Oliver
On 16/07/2014 9:40 PM, Jakob Kummerow wrote:
...which of course kills any chance you had at getting the code
optimized, but if the fragments are short enough, they probably didn't
get optimized anyway (because "6+7" executes waaaay to quickly to be
worth the overhead of firing up the optimizing compiler), so this may
not matter.
If you control the fragments, you could just change them to end with a
suitable "return whatever;" statement.
On Wed, Jul 16, 2014 at 1:30 PM, Sven Panne <[email protected]
<mailto:[email protected]>> wrote:
On Wed, Jul 16, 2014 at 12:29 PM, Oliver Bock <[email protected]
<mailto:[email protected]>> wrote:
Hi Jakob,
This is a good idea, but unfortunately my existing code relies
on the eval-like nature of fragments, in that they "return"
whatever the last line in the script evaluates to. [...]
Easily fixable via the highly readable one-liner: :-D :-P * * *
function myEval(body){"use strict"; return
eval("(function(){return eval(\""+body+"\");})()")}
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.