All About Performance

and other stuff by Taras Glek

CPP Strikes Back

I have gotten used to dodging CPP-expansion issues by fudging column & line information until the position info in squash mostly matches the source positions in the original source code. That sufficed for rewriting declarations, but I have finally hit a brick wall.

CPP Fun

I got as far with call-site outparam rewriting as this patch. It demonstrates an interesting flaw.

1
2
3
4
5
6
@@ -8297,1 +8297,1 @@
-  GetInsertionPoint(parentFrame, nsnull, &insertionPoint, &multiple);
+  insertionPoint = GetInsertionPoint(parentFrame, &insertionPoint, &multiple);
@@ -8346,1 +8346,1 @@
-          GetInsertionPoint(parentFrame, child, &insertionPoint);
+          insertionPoint = GetInsertionPoint(parentFrame, child);

Due to macro expansion, nsnull contracts to 0 such that the .i file has &insertionpoint positioned right in the middle of nsnull (in the .cpp file). So when squash trims the param including the surrounding commas, it ends up removing the wrong parameter.

Elsa Limitation

I have mentioned lack of end-of-ast-node position information in Elsa. It also lacks start-of-ast-node information for most expressions. This makes selectively rewriting source code rather difficult.

Plan

Instead of fighting an uphill fudging battle against CPP, I am going to have to suspend outparam rewriting yet again to work on better position information and integrating a preprocessor into elsa. This is unfortunate because I was looking forward to finally doing something more sophisticated than renames. Now my elsa fork is going to grow even bigger before I get commit access.

Comments