[Webkit-unassigned] [Bug 124994] New: Would it be possible to optimize constant conditionals?
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Nov 28 20:03:53 PST 2013
https://bugs.webkit.org/show_bug.cgi?id=124994
Summary: Would it be possible to optimize constant
conditionals?
Product: WebKit
Version: 528+ (Nightly build)
Platform: All
OS/Version: All
Status: NEW
Severity: Minor
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: sirisian at gmail.com
Currently the Javascript engine in webkit can remove code that it determines will never be executed. As an example:
if (false)
{
// Tons of stuff
}
That code will never be executed and the engine is smart enough to remove it.
Webkit has support for the "const" keyword in Javascript but doesn't evaluate conditionals that use it. As an example:
http://jsfiddle.net/9LCra/
// Debug Off Control
{
console.time("benchmark control");
for (var i = 0; i < 10000000; ++i)
{
}
console.timeEnd("benchmark control");
}
// Debug Off
{
const debugOff = false;
var debugOffCounter = 0;
console.time("benchmark debug off");
for (var i = 0; i < 10000000; ++i)
{
if (debugOff)
{
debugOffCounter++;
}
}
console.timeEnd("benchmark debug off");
}
// Debug On
{
const debugOn = true;
var debugOnCounter = 0;
console.time("benchmark debug on");
for (var i = 0; i < 10000000; ++i)
{
if (debugOn)
{
debugOnCounter++;
}
}
console.timeEnd("benchmark debug on");
}
One would expect the first two code blocks to execute at the same time since "if (debugOff)" should be looked at identically as "if (false)" but it currently isn't. This is a useful property to have for easily removing huge chunks of debug code from libraries without having to generate two separate Javascript files or maintain preprocessor scripts.
This is more of an optimization request than a bug, but I imagine const optimizations like this would be useful in a few places.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list