Flow2Vec: value-flow-based precise code embedding
Yulei Sui, Xiao Cheng, Guanqin Zhang, Haoyu Wang
Abstract
and Telecommunications, China 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 code2vec and code2seq for two client applications, i.e., code classification and code summarization. For code classification, Flow2Vec improves code2vec with an average increase of 21.2%, 20.1% and 20.7% in precision, recall and F1, respectively. For code summarization, Flow2Vec outperforms code2seq by an average of 13.2%, 18.8% and 16.0% in precision, recall and F1, respectively.
CCS Concepts: • Software and its engineering → Automated static analysis; • Computing methodologies → Machine learning.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 1c3772b3-e946-4a1d-86b2-8c93ac7a0ab0Cited by top-tier papers14
- TFix: Learning to Fix Coding Errors with a Text-to-Text TransformerBerkay Berabi, Jingxuan He, Veselin Raychev, Martin T. VechevICML 2021 · 143 citations
- Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving TransformationsNghi D. Q. Bui, Yijun Yu, Lingxiao JiangSIGIR 2021 · 98 citations
- Path-sensitive code embedding via contrastive learning for software vulnerability detectionXiao Cheng, Guanqin Zhang, Haoyu Wang, Yulei SuiISSTA 2022 · 98 citations
- What Do They Capture? - A Structural Analysis of Pre-Trained Language Models for Source CodeYao Wan, Wei Zhao, Hongyu Zhang, Yulei Sui et al.ICSE 2022 · 66 citations
- Tare: Type-Aware Neural Program RepairQihao Zhu, Zeyu Sun, Wenjie Zhang, Yingfei Xiong et al.ICSE 2023 · 29 citations
Builds on1
Related papers
- Retrieval-based neural source code summarizationJian Zhang, Xu Wang, Hongyu Zhang, Hailong Sun et al.ICSE 2020 · 242 citations
- CC2Vec: Combining Typed Tokens with Contrastive Learning for Effective Code Clone DetectionShihan Dou, Yueming Wu, Haoxiang Jia, Yuhao Zhou et al.FSE 2024 · 9 citations
- Code Search based on Context-aware Code TranslationWeisong Sun, Chunrong Fang, Yuchen Chen, Guanhong Tao et al.ICSE 2022 · 53 citations
- MVD: Memory-Related Vulnerability Detection Based on Flow-Sensitive Graph Neural NetworksSicong Cao, Xiaobing Sun, Lili Bo, Rongxin Wu et al.ICSE 2022 · 100 citations
- Functional code clone detection with syntax and semantics fusion learningChunrong Fang, Zixi Liu, Yangyang Shi, Jeff Huang et al.ISSTA 2020 · 125 citations
