Abstract
Code embedding, as an emerging paradigm for source code analysis, has attracted much attention over the past few years. It aims to represent code semantics through distributed vector representations, which can be used to support a variety of program analysis tasks (e.g., code summarization and semantic labeling). However, existing code embedding approaches are intraprocedural, alias-unaware and ignoring the asymmetric transitivity of directed graphs abstracted from source code, thus they are still ineffective in preserving the structural information of code.
This paper presents FLOW2VEC, a new code embedding approach that precisely preserves interprocedural program dependence (a.k.a value-flows). By approximating the high-order proximity, i.e., the asymmetric transitivity of value-flows, FLOW2VEC embeds control-flows and alias-aware data-flows of a program in a low-dimensional vector space. Our value-flow embedding is formulated as matrix multiplication to preserve context-sensitive transitivity through CFL reachability by filtering out infeasible value-flow paths.
We have evaluated FLOW2VEC using 32 popular open-source projects. Results from our experiments show that FLOW2VEC successfully boosts the performance of two recent code embedding approaches codevec and codeseq for two client applications, i.e., code classification and code summarization. For code classification, FLOW2VEC improves codevec with an average increase of 21.2%, 20.1% and 20.7% in precision, recall and F1, respectively. For code summarization, FLOW2VEC outperforms codeseq by an average of 13.2%, 18.8% and 16.0% in precision, recall and F1, respectively.
| Original language | English |
|---|---|
| Article number | 233 |
| Pages (from-to) | 1-27 |
| Number of pages | 27 |
| Journal | Proceedings of the ACM on Programming Languages |
| Volume | 4 |
| Issue number | OOPSLA |
| DOIs | |
| Publication status | Published - 13 Nov 2020 |
| Externally published | Yes |
Bibliographical note
Copyright the Author(s) 2020. Version archived for private and non-commercial use with the permission of the author/s and according to publisher conditions. For further rights please contact the publisher.Keywords
- Flow2Vec
- code embedding
- value-flows
- asymmetric transitivity
Fingerprint
Dive into the research topics of 'Flow2Vec: value-flow-based precise code embedding'. Together they form a unique fingerprint.Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver