Default to anonymous functions in release builds.

This commit is contained in:
Michael Bebenita 2015-08-24 11:59:10 -07:00
Родитель 0765f845fc
Коммит 86d3918e6a
1 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -1222,6 +1222,13 @@ module J2ME {
linkedMethods[methodInfo.id] = fn;
}
/**
* Enable this if you want your profiles to have nice function names. Naming eval'ed functions
* using: |new Function("return function displayName {}");| can cause performance problems and
* we keep it disabled by default.
*/
var nameJITFunctions = false;
/**
* Links up compiled method at runtime.
*/
@ -1230,8 +1237,14 @@ module J2ME {
enterTimeline("Eval Compiled Code");
// This overwrites the method on the global object.
// var fn = new Function(args.join(','), body);
var fn = new Function("return function fn_" + methodInfo.implKey.replace(/\W+/g, "_") + "(" + args.join(",") + "){ " + body + "}")();
var fn = null;
if (!release || nameJITFunctions) {
fn = new Function("return function fn_" + methodInfo.implKey.replace(/\W+/g, "_") + "(" + args.join(",") + "){ " + body + "}")();
} else {
fn = new Function(args.join(','), body);
}
leaveTimeline("Eval Compiled Code");
methodInfo.state = MethodState.Compiled;