0

I am trying to build a mapping between SSA IR instructions to original instructions of a JavaScript file. I already got the IR of the JavaScript files. But the IR output is quite confusing to me. I am using Watson Libraries for Analysis (WALA) for generating SSA IR. The output IR is given below:

<Code body of function LhtmlPage.html1626059688264016411.js/__WINDOW_MAIN__/f>
CFG:
BB0[-1..-2]
    -> BB1
BB1[0..12]
    -> BB3
    -> BB2
BB2[13..13]
    -> BB4
BB3[14..14]
    -> BB4
BB4[-1..-2]
Instructions:


0   v3 = new <JavaScriptLoader,LArray>@0     [include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [304->423] (line 20) [3=[arguments]]
1   v6 = global:global $$undefined           [include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [323->334] (line 21) [6=[x, y]]
2   putfield v2.< JavaScriptLoader, LRoot, x, <JavaScriptLoader,LRoot> > = v6[include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [323->334] (line 21) [2=[this]6=[x, y]]
4   v10 = global:global $$undefined          [include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [339->345] (line 22) [10=[y]]
5   putfield v2.< JavaScriptLoader, LRoot, y, <JavaScriptLoader,LRoot> > = v10[include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [339->345] (line 22) [2=[this]10=[y]]
7   putfield v2.< JavaScriptLoader, LRoot, x, <JavaScriptLoader,LRoot> > = v13:#10.0[include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [323->334] (line 21) [2=[this]13=[x, y]]
9   putfield v2.< JavaScriptLoader, LRoot, y, <JavaScriptLoader,LRoot> > = v13:#10.0[include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [350->355] (line 23) [2=[this]13=[x, y]]
11   v15 = binaryop(eq) v13:#10.0 , v16:#100.0[include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [364->372] (line 24) [13=[x, y]]
12   conditional branch(eq, to iindex=14) v15,v17:#0[include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [361->402] (line 24)

13   return v18:#true                        [include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [384->396] (line 25)

14   return v19:#false                       [include:htmlPage.html [73->110] (line 6)]bundle-bg1.js [407->420] (line 27)

My test code is :

function f() { 
   var x = 10; 
   var y; 
   y = x; 
   if(y == 100) { 
       return true; 
   } 
   return false; 
} 
var b = f();

How can I map this code to the IR and identify the operands and the operators? Any help will be appreciated.

Barmar
  • 741,623
  • 53
  • 500
  • 612
Rubaiyat Jahan Mumu
  • 3,887
  • 1
  • 33
  • 35
  • It would be easier if you posted the IR as plain text instead of images. But it looks like it tells you exactly which line of the original JS each IR instruction corresponds to, and maps the JS variables to IR registers – Barmar Oct 17 '17 at 17:53
  • I attached the output text in my question. Can you please tell me how can I get the operands and operators from this IR and create a variable use graph? @Barmar – Rubaiyat Jahan Mumu Oct 17 '17 at 19:08
  • I have no idea how to read IR, but I'll bet `6=[x, y]` is telling you something about where the `x` and `y` variables are being stored. – Barmar Oct 17 '17 at 19:19
  • I found that too. But It is not enough for me. I wish I could get a specific way. Thanks to you :) @Barmar – Rubaiyat Jahan Mumu Oct 17 '17 at 19:37

0 Answers0