Julian Dolby
IBM Thomas J. Watson Research Center
SOAP, PLDI, Barcelona, June 2017
Illustrate a small sample of being everywhere
hybrid apps
WALA on Web browsers
Swift
Soundy analysis framework for Android hybrid apps
support for most implicit inter-language flows (Backed by APIs and Dalvik VM source code)
support most type compatibility in browsers (backed by experiments with trials & errors)
Implementation on top of WALA
Uses generic WALA cross-language support
function Document_prototype_write(x) { } function id(x) { return x // line 6; } var document = { URL: "whatever" }; var url = id(document.URL); // line 10 Document_prototype_write(url); // line 11 var notUrl = id("not a url"); Document_prototype_write(notUrl);
Apple a dominant mobile platform
likely most popular phone in the audience
Swift primary programming language
WALA meant to be flexible
analyzing new language Swift a test
support Apple-IBM alliance
Use WALA to analyze Swift
Use open source Apple code
up-to-date with evolving language
written largely in C++, unlike WALA
Bridge C++ code to WALA
large code base, so explicit JNI tedious
generate wrappers with SWIG
Expose Apple Swift code to Java
%module example
int fact();
public class example {
public static int fact() {
return exampleJNI.fact();
}
}
public class exampleJNI {
static native int fact();
}
...Java_exampleJNI_fact(...) {
jint jresult = 0 ;
int result;
(void)jenv;
(void)jcls;
result = (int)fact();
jresult = (jint)result;
return jresult;
}
instance.performParseOnly();
if (instance.getASTContext().hadError())
System.out.println("Parse error");
ModuleDecl module = instance.getMainModule();
ASTWalker walker = new ASTWalker() {
@Override
public boolean walkToDeclPre(Decl s) {
// visited a declaration
return true;
}
// ...
};
module.walk(walker);
Beginnings of SWIG interface working
SWIG integrated into Apple build process
both AST and SIL partially wrapped
Interface not just for WALA
other Java tools could benefit
would love collaborators
World getting less monolingual, not more
domains have favorites, e.g. Python for ML
new languages like Swift arise
Analysis frameworks must adapt
need to analyze code people use
WALA has proven flexible