OK, that's not unexpected. There are optimizations that work for code in
the global scope but not when you move it inside a function. For instance,
if you have |var x = 1| in the global scope and don't modify x anywhere,
the JIT can inline this constant directly without any guards. If you wrap
it in a function, this no longer works inside inner functions because we
don't currently track this information.

There's one exception: we detect IIFEs and optimize them more like global
code, so try to use this pattern:

(function() {
    ... your code here...
})();

Hope this helps.

Jan

On Thu, Jun 4, 2015 at 11:32 PM, Jason Hill <jamesjasonh...@gmail.com>
wrote:

> CASE:
>
> function x () {
> SOURCES OF STANDARD OCTANE BENCH. GOES HERE
> }
>
> x();
>
> You should see aprox 40% drop on performance on standard JSShell.
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> dev-tech-js-engine-internals@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals
>
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to