2

I have an inter-procedural control flow graph and I want to perform data flow analysis on it. I am using Hashtable for global (level=0), file (level=1) and method (level=2) levels etc. and I push them on the stack starting with level 0.

It works fine as long as I have only one method in the program. But if I have two methods and suppose basicblock#2 from method1 (M1) calls methods (M2), how should I treat this new method symbol table? Should I store the previous symbol table and create a new one for new method?

I see a more complexity when a method of another class is called or nested function calls are made. Can somebody suggest something that how should I handle it?

I am working in Java.

P.S. And I know there are some existing tools like WALA, Soot which might work for this but I am trying to learn that how does it work.

Junaid
  • 1,668
  • 7
  • 30
  • 51
  • You need a "symbol space" for every possible scope in your program (locals, classes, parameter lists, ...). It is easiest to associate the symbol space with the point in the program where that scope is first introduced. (The set of symbol spaces makes up what I would call "the symbol table"). The way that you construct the symbol spaces has nothing to do with how one entity is *called* by another. – Ira Baxter Nov 22 '13 at 15:11
  • Can you provide any link or reference where I can find some example? – Junaid Nov 22 '13 at 15:31
  • If you want examples that work for Java, look inside the Jikes Java compiler, or in Eclipse JDT. That's a lot of code, because Java symbol table construction is complex (this is your real problem). If you want theory, check out any compiler text, including the classic Aho/Ullman/Sethi "Compilers" book. – Ira Baxter Nov 22 '13 at 15:47
  • Useful pointers. I look into it. – Junaid Nov 22 '13 at 16:24
  • I have looked into http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.compiler.tool and Jikes (http://hg.code.sourceforge.net/p/jikesrvm/code/file/bc4e6f6713c4). I am not able to find SymbolTable definition or its working there. :s – Junaid Nov 23 '13 at 19:01
  • I can't help with that; I'm not familiar with those code bases. I can assure they build symbol tables somehow. I can assure the process of building it is complex (we have our own [non-open-source] Java front end, and have personal experience with this), as it is for most modern programming languages. The last easy language needing symbol tables was Kemeny-Kurtz Basic, with essentially only global symbols. Suggest the compiler book first, then you'll know what to look for. It won't be easy to find, not because its a symobl table, but because these are very big programs. – Ira Baxter Nov 23 '13 at 19:18
  • Thanks for responding again. You are right in that they will surely be handling symbol tables... – Junaid Nov 23 '13 at 23:27

0 Answers0