Bug 105232 - Constant fold !{number} in the parser
Summary: Constant fold !{number} in the parser
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-17 17:11 PST by Geoffrey Garen
Modified: 2012-12-18 09:23 PST (History)
1 user (show)

See Also:


Attachments
Patch (2.16 KB, patch)
2012-12-17 17:18 PST, Geoffrey Garen
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2012-12-17 17:11:01 PST
Constant fold !{number} in the parser
Comment 1 Geoffrey Garen 2012-12-17 17:18:10 PST
Created attachment 179839 [details]
Patch
Comment 2 Filip Pizlo 2012-12-17 17:21:49 PST
Comment on attachment 179839 [details]
Patch

R=me

We should have the parser do more extensive constant folding.  It will reduce (a) reduce amount of bytecode, (b) reduce amount of baseline JIT machine code, and (c) reduce the amount of work that the DFG has to do.
Comment 3 Geoffrey Garen 2012-12-17 22:55:50 PST
Committed r137988: <http://trac.webkit.org/changeset/137988>
Comment 4 Darin Adler 2012-12-18 09:23:55 PST
The comment makes it sound like you’d want to do this for other constant nodes such as NullNode, BooleanNode, StringNode, RegExpNode, ThisNode, and ArrayNode.

I’m assuming we don’t do that because the only cases that are actually common are !0 and !1, not, say !null or !true or !false. Since we’re already calling a virtual function just to find out it’s a number node it seems like we could do a version with more coverage. The only cost of this seems to be more code in Nodes.h/cpp.