Noticed this when reducing some testcase: -- js> ; dis() main: 00000: object  00003: popv -- And this: -- js> [-1]; dis() main: 00000: newarray 1 00004: zero 00005: int8 -1 00007: initelem 00008: endinit -- The problem seems to be that JSParseNode::getConstantValue does not support negative numbers. I don't know if this will win performance somewhere. SS base64 uses an array with negative numbers though and some benchmarks like to use arrays as vectors like this: [-1, 0, 1].
Created attachment 524651 [details] [diff] [review] Patch Brian asking your r? because you wrote JSParseNode::isConstant. The problem was that -10 is constant folded to one token after parsing the initializer.
This will I think break in JSParseNode::getConstantValue if it is not also updated. Can you add a testcase or update tests/basic/testInitSingleton?
6 years ago
Created attachment 584467 [details] [diff] [review] do FoldConstants for every node Brain is this a sensible approach to do this, or is there some reason that we can't doing folding there?
Comment on attachment 584467 [details] [diff] [review] do FoldConstants for every node I think FoldConstants is fine to use here, and should be more robust.
Created attachment 618364 [details] [diff] [review] Call FoldConstants of every node. Finally came around finishing this. I know the tests are kinda dense, but I hope we test constant folding in enough other places.