194 research outputs found
Context2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage Contexts
Most of the JavaScript code deployed in the wild has been minified, a process
in which identifier names are replaced with short, arbitrary and meaningless
names. Minified code occupies less space, but also makes the code extremely
difficult to manually inspect and understand. This paper presents Context2Name,
a deep learningbased technique that partially reverses the effect of
minification by predicting natural identifier names for minified names. The
core idea is to predict from the usage context of a variable a name that
captures the meaning of the variable. The approach combines a lightweight,
token-based static analysis with an auto-encoder neural network that summarizes
usage contexts and a recurrent neural network that predict natural names for a
given usage context. We evaluate Context2Name with a large corpus of real-world
JavaScript code and show that it successfully predicts 47.5% of all minified
identifiers while taking only 2.9 milliseconds on average to predict a name. A
comparison with the state-of-the-art tools JSNice and JSNaughty shows that our
approach performs comparably in terms of accuracy while improving in terms of
efficiency. Moreover, Context2Name complements the state-of-the-art by
predicting 5.3% additional identifiers that are missed by both existing tools
The Good, the Bad, and the Ugly: An Empirical Study of Implicit Type Conversions in JavaScript
Most popular programming languages support situations where a value of one type is converted into a value of another type without any explicit cast. Such implicit type conversions, or type coercions, are a highly controversial language feature. Proponents argue that type coercions enable writing concise code. Opponents argue that type coercions are error-prone and that they reduce the understandability of programs. This paper studies the use of type coercions in JavaScript, a language notorious for its widespread use of coercions. We dynamically analyze hundreds of programs, including real-world web applications and popular benchmark programs. We find that coercions are widely used (in 80.42% of all function executions) and that most coercions are likely to be harmless (98.85%). Furthermore, we identify a set of rarely occurring and potentially harmful coercions that safer subsets of JavaScript or future language designs may want to disallow. Our results suggest that type coercions are significantly less evil than commonly assumed and that analyses targeted at real-world JavaScript programs must consider coercions
LExecutor: Learning-Guided Execution
Executing code is essential for various program analysis tasks, e.g., to
detect bugs that manifest through exceptions or to obtain execution traces for
further dynamic analysis. However, executing an arbitrary piece of code is
often difficult in practice, e.g., because of missing variable definitions,
missing user inputs, and missing third-party dependencies. This paper presents
LExecutor, a learning-guided approach for executing arbitrary code snippets in
an underconstrained way. The key idea is to let a neural model predict missing
values that otherwise would cause the program to get stuck, and to inject these
values into the execution. For example, LExecutor injects likely values for
otherwise undefined variables and likely return values of calls to otherwise
missing functions. We evaluate the approach on Python code from popular
open-source projects and on code snippets extracted from Stack Overflow. The
neural model predicts realistic values with an accuracy between 79.5% and
98.2%, allowing LExecutor to closely mimic real executions. As a result, the
approach successfully executes significantly more code than any available
technique, such as simply executing the code as-is. For example, executing the
open-source code snippets as-is covers only 4.1% of all lines, because the code
crashes early on, whereas LExecutor achieves a coverage of 51.6%.Comment: Accepted in research track of the ACM Joint European Software
Engineering Conference and Symposium on the Foundations of Software
Engineering (ESEC/FSE) 202
Performance regression testing of concurrent classes
Developers of thread-safe classes struggle with two oppos-ing goals. The class must be correct, which requires syn-chronizing concurrent accesses, and the class should pro-vide reasonable performance, which is difficult to realize in the presence of unnecessary synchronization. Validating the performance of a thread-safe class is challenging because it requires diverse workloads that use the class, because ex-isting performance analysis techniques focus on individual bottleneck methods, and because reliably measuring the per-formance of concurrent executions is difficult. This paper presents SpeedGun, an automatic performance regression testing technique for thread-safe classes. The key idea is to generate multi-threaded performance tests and to com-pare two versions of a class with each other. The analysis notifies developers when changing a thread-safe class signif-icantly influences the performance of clients of this class. An evaluation with 113 pairs of classes from popular Java projects shows that the analysis effectively identifies 13 per-formance differences, including performance regressions that the respective developers were not aware of
- …