RESOLVED FIXED 16585
Optimize variable declarations
https://bugs.webkit.org/show_bug.cgi?id=16585
Summary Optimize variable declarations
Maciej Stachowiak
Reported 2007-12-23 07:51:49 PST
Variable declaration statements can be replaced at parse time with assignments if there are initializers, or nothing at all if there aren't. The actual declaration logic is handled on entering the function body anyway.
Attachments
optimize var statements - 3.7% speedup (26.43 KB, patch)
2007-12-23 07:55 PST, Maciej Stachowiak
no flags
cleaned up version (now measures as 3.5% speedup) (40.17 KB, patch)
2007-12-24 01:14 PST, Maciej Stachowiak
eric: review+
Maciej Stachowiak
Comment 1 2007-12-23 07:55:24 PST
Created attachment 18071 [details] optimize var statements - 3.7% speedup
Eric Seidel (no email)
Comment 2 2007-12-23 15:58:46 PST
Comment on attachment 18071 [details] optimize var statements - 3.7% speedup So my comments deal entirely with code readability. AFAICT, the functionality looks fine: ExprStatementNode<false> and ExprStatementNode<true> should have nicely named typdefs. Probably ExprStatementNode should also change names to some sort of ExprStatementNodeBase or the like. As part of that <isVar> needs a more descriptive name. Small functions would be better done using the typdef classes, larger functions can be defined using ExprStatementNode<betterNameThanIsVar>:: If you look at the formatted diff, it appears you added a whole bunch of extra whitespace. I think passing int attrs as part of appendToVarDeclarationList and using DeclarationStacks::IsConstant and DeclarationStacks::HasInitializerat the callsites would be clearer. At least at the callsites. :) 1807 ForNode(ExpressionNode* e1, ExpressionNode* e2, ExpressionNode* e3, StatementNode* s, bool e1WasVarDecl) KJS_FAST_CALL I was trying to come up with a cleaner way of expressing the same. Using an enum "FirstExprIsVarDecl" instead of a bool would lead to cleaner callsites... I guess that's about the best I can come up with for right now. If you fix at least some of those readability issues, this is totally fine for landing. Congrats on such an awesome speedup.
Maciej Stachowiak
Comment 3 2007-12-24 01:14:05 PST
Created attachment 18090 [details] cleaned up version (now measures as 3.5% speedup)
Eric Seidel (no email)
Comment 4 2007-12-24 01:44:33 PST
Comment on attachment 18090 [details] cleaned up version (now measures as 3.5% speedup) Looks good to me.
Note You need to log in before you can comment on or make changes to this bug.