Module storage: randomly choose between Function and $.globalEval
authorOri Livneh <ori@wikimedia.org>
Tue, 10 Dec 2013 06:35:37 +0000 (22:35 -0800)
committerOri Livneh <ori@wikimedia.org>
Tue, 10 Dec 2013 07:00:02 +0000 (23:00 -0800)
commita20333cc4da04775db04b33407c88b4ccb5e5e74
treee8872315031ef8e9e106b3001438aa52633da33a
parentc2fde3d2f8132ef79f4bd61bc48706896b17976b
Module storage: randomly choose between Function and $.globalEval

V8 disables certain optimizations for eval()'d code because scope resolution is
tricky. The same is not true for code compiled via Function(), which always
runs in global scope. Let's see if Function() is faster.

This patch makes ResourceLoader randomly use either Function() or $.globalEval.
The choice is recorded in a boolean `useFunction` property on mw.loader.store
so its value can be logged with load timing measurements. The logging will be
done in WikimediaEvents.

Bug: 58259
Change-Id: I7183778cb65c421ee19dcd61ee1dc0085f86bf10
resources/mediawiki/mediawiki.js