Exploring Commonalities Across Programming Languages Using Intermediate Representation-Based Semantic Graphs
Cross-language code-to-code search has significant potential to enhance software development and maintenance by helping developers implement specific functionalities or migrate code between programming languages. Existing approaches, however, have notable limitations: static approaches relying on textual or syntactic information often lack effectiveness due to significant cross-language differences, while dynamic approaches relying on input-output behavior have limited applicability as they require executable code, which is difficult to guarantee in real-world projects.In this paper, we introduce CRDSER, a fully static cross-language code searcher designed to address these challenges. Our key insight is that, while code snippets in different languages may vary considerably in token sequences or syntactic structures, those with identical functionality can still share similarities in their Intermediate Representations (IRs). To capture this, we build a semantic graph that effectively models code semantics across languages by leveraging data flow and control flow information from IRs. We further design a hierarchical pooling mechanism to represent this graph structure, inspired by the way human developers hierarchically understand code snippets. Our large-scale evaluation demonstrates that CRDSER achieves both scalability (applicable to any code snippet) and high effectiveness, outperforming the best existing static approaches by up to 20% in Mean Reciprocal Rank. Additionally, ablation studies confirm that each module in our approach contributes substantially to CRDSER ’s overall effectiveness.
Authors
- Hongyang Chen (ORCID: https://orcid.org/0000-0002-7626-0162)
- Bo Duan
- Bo Liu
- Yunlong Guo
- Zhenshun Shi (ORCID: https://orcid.org/0000-0001-6250-1351)
- Mingyang Geng (ORCID: https://orcid.org/0000-0001-9020-4581)
Institutions
- Xichang University (CN)
Publication Details
- Published
- 2024-11-22
- DOI
- https://doi.org/10.1109/icicml63543.2024.10958089
- Primary Topic
- Natural Language Processing Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00