+1 to using globalThis, and falling back to the current approach or a more 
robust polyfilling mechanism <https://mathiasbynens.be/notes/globalthis>.

On Tuesday, June 25, 2019 at 5:29:21 PM UTC+2, Lilit Darbinyan wrote:
>
> embind currently generates the following glue code for accessing the 
> global object:
>
> function emval_get_global() { return (function(){
>     return Function;
>   })()('return this')(); }
>
>
> This function is called every time we access emscripten::val::global() 
> from C++, e.g. 
>
> val Object = val::global("Object");
>
> It turns out it's pretty slow in SpiderMonkey - running this function in a 
> loop 10,000 times we see that it takes on average 117 ms in SpiderMonkey 
> compared to 17 ms in V8.
>
> I shall raise this slowness issue with SpiderMonkey separately, but I am 
> wondering if there is room for improvement here on the emscripten side as 
> well - for example, would it make sense to cache this value, or make use of 
> the new globalThis 
> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis>
>  
> instead?

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/3a5e63e7-fc8c-48a4-9414-df6ad50a0eee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to