On Apr 20, 2010, at 2:43 AM, Gabor Loki wrote:
On k, 2010-04-20 at 02:39 -0700, Maciej Stachowiak wrote:
On Apr 20, 2010, at 2:27 AM, Zoltan Herczeg wrote:
using getter setters and joined objects makes possible many sick JS constructions:
function bar() { var a = 3; foo(); print(a + 7 ); // will be 11
function foo() { a++; } } bar();
That's why you need dataflow information - you have to assume locals may be killed when you have any nested functions and you call a function. If you also do free variable analysis then you could figure out a subset of locals that might be killed.
That is true, but I think that there are still too many barriers to implement a cost efficient constant propagation at byte-code level.
Probably a simple peephole optimization can be used for that kind of sequences.
I think the problem is that there's not enough real performance- critical code that would benefit. So the most likely path to this optimization is if it gets done as part of a broader optimization, or reuses dataflow analysis done for a greater variety of optimizations.
Btw, you can see our old patch about this topic: https://bugs.webkit.org/show_bug.cgi?id=20764
Regards, Maciej