What is the most efficient way to clean up the global object between
running fragments of JavaScript?
I am running a fragment of JavaScript in a tight loop to make a simple
calculation for each of hundreds of thousands of inputs. I don't want
variables set by one execution to bleed into the
How about wrapping the fragments in anonymous closures? Roughly:
script_to_execute = (function() { + fragment + })();;
That should get you most of what you want, except for undoing
monkey-patching of Array.prototype and stuff, but maybe that's good enough,
and it's certainly easy and fast.
On
V8 has no way to clean up a global object.
The global object is referenced in two ways: either directly (implicit
references from contexts), or indirectly via the global proxy (references
from JavaScript).
ReattachGlobal didn't do what you would have expected, reattached the
global object of a
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. e.g. the script
7 + 6
evaluates as 13. But the function
f = function() {
7 + 6;
}
f()
evaluates as
On Wed, Jul 16, 2014 at 12:29 PM, Oliver Bock oli...@g7.org 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
...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 wy to quickly to be worth the overhead
of firing up the optimizing compiler), so this may not matter.
If you
Thank you.
--
--
v8-users mailing list
v8-users@googlegroups.com
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
Thank you.
--
--
v8-users mailing list
v8-users@googlegroups.com
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
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
Why do I get a V8_Fatal when I twice reference an array out of bounds, if
the array is created by C++ code:
LocalArray a = Array::New(isolate);
context-Global()-Set(String::NewFromUtf8(isolate, a), a);
but not when it is created by JavaScript?
10 matches
Mail list logo