尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

[论文笔记] Precision-Guided Context Sensitivity for Pointer Analysis

[论文笔记] Precision-Guided Context Sensitivity for Pointer Analysis
📅 发布时间:2026/6/20 15:48:38

Introduction

Context-sensitivity 会带来静态分析的精度提升,但是也会带来巨大的开销,这引出一个关键的问题:能否在某些对整体分析的精度有重要影响的函数上选择性的使用 context-sensitivity?这个问题的难点在于识别具有这种性质的函数。文章总结了在 context-insensitive 的指针分析中引入不精确性的 value flow 的三种普遍模式,在此基础上实现了 Zipper 来高效地识别这三种模式从而识别关键函数。

CAUSES OF IMPRECISION IN CONTEXT-INSENSITIVE POINTER ANALYSIS

image

函数 m 在 context-insensitive 的指针分析中会使得 x2 和 y2 都指向对象 A() 和 B(),即 pts(x2) = pts(y2) = {o4, o6}。如果对 m 进行 context-sensitive 的分析就不会引入这个问题,m 会被看作有两个拷贝 m5 和 m7。

定义 In and Out methods:Given a class \(C\) and a method \(M\) that is declared in \(C\) or inherited from \(C\)’s super-classes, if \(M\) contains one or more parameters then \(M\) is an In method of C, and if \(M\)’s return type is non-void then \(M\) is an Out method of \(C\).

定义 Object wrapping and unwrapping:If an object \(O\) is stored in a field of an object \(W\) (or in an array entry of \(W\) , in case \(W\) is an array), then \(O\) is wrapped into \(W\) . Conversely, if an object \(O\) is loaded from a field of an object \(W\) (or from an array entry of \(W\) in case \(W\) is an array), then \(O\) is unwrapped from \(W\) .

定义 value flow 的第一种模式 Direct flow:If, in some execution of the program, an object \(O\) is passed as a parameter to an In method \(M_1\) of class \(C\), and then flows (via a series of assignments, field load/store operations, method calls, or returns) to the return value of an Out method, \(M_2\), of the same class \(C\), then we say the program has direct flow from \(M_1\) to \(M_2\). (The example in Figure 1 is a simple instance of this pattern.)

从上面的定义,容易猜出 wrapped flow 和 unwrapped flow 的定义:

If, in some execution of the program, an object \(O\) is passed as a parameter to an In method \(M_1\) of class \(C\) and then flows to a store operation that wraps \(O\) into an object \(W\) , where \(W\) subsequently flows to the result of an Out method, \(M_2\), of the same class \(C\), then we say the program has wrapped flow from \(M_1\) to \(M_2\).

If, in some execution of the program, an object \(O\) is passed as a parameter to an In method \(M_1\) of class \(C\) and then flows to a load operation that unwraps an object \(U\) from \(O\), where \(U\) subsequently flows to the return value of an Out method, \(M_2\), of the same class \(C\), then we say the program has unwrapped flow from \(M_1\) to \(M_2\)

文章给出了这三种 value flow 的图解:

image

Direct flow

以一个 Java 程序中常见的 getter/setter 方法为例,图中展示了不同的对象是怎么通过这个 direct flow 被合并的。如果能够对 direct flow 路径上的函数使用 context-sensitive 的指针分析就可以规避这种精确性的损失。

image

Wrapped flow

Wrapped flow 的不精确性只有在 load 外部对象的 field 的时候会被引入分析,对应这个例子的 (28) 和 (34) 行。Wrapped flow 路径上的函数并不都需要 context-sensitivity 来解决不精确性,在这个例子中,只需要对 Collection 中的方法做 context-sensitive 的分析。

image

三种 value flow 都只相对于一个 class 来定义,In 和 Out 方法都位于一个 class 中。这种设计使得能够通过逐个考虑每个类的方法高效识别不精确性。

Unwrapped flow

image

绿色箭头展示了这里例子中的 unwrapped flow。如果我们从 Box 类的角度考虑 In 和 Out 方法,则其构造函数 Box 仍将以 context-snesitive 的方式进行分析,因为它是 direct flow 的一部分。

有些不精确性不能仅通过一个 flow 来描述,而只能通过不同的 flow 组合来捕捉。

Zipper

image

Object flow graph

image

OFG 已经可以表达 direct flow,如果从结点 b 出发可以到达结点 e,那么说明 b 指向的对象可能流动到 e,也就说明 b 和 e 之间存在一个 direct flow;但是 OFG 并不容易表达 wrapped flow 和 unwrapped flow。Zipper 利用 OFG 的信息构建一个 precision flow graph。

Precision Flow Graphs and Graph Reachability

PFG 的构建算法如下:

image

对于某个 class \(c\),算法对 \(c\) 的每个方法 \(m\) 从每个参数 \(p\) 为起点深度遍历 OFG。依照 wrapped flow 和 unwrapped flow 的定义,对于 b = a.f,OFG 会在 b 和 a 指向的所有对象 o 的字段 o.f 上建立边关系,PFG 则会在 b 和 a 之间建立一个指向边来捕捉 unwrapped flow;b.f = a 也就是 wrapped flow 类似,不过需要在 a 和 b 可能指向的所有对象间建立边,否则可能会遗漏某些流。

这两种边的信息表示了不精确信息会如何被传递,试想,对于 b = a.f 假设 a 因为 context-insensitive 的分析变得不再精确,那么 b 的分析也不再精确;对于 b.f = a,如果 a 不精确,那么 b 指向的每个对象 o 也会变得不再精确。

下面的算法提取了所有 class 中的不精确方法:

image

对于 \(c\) 中的每个 Out 方法,PFG 上所有可达 Out 方法返回值的结点都可能因为其不精确性影响结果从而影响分析,收集这些结点所在的方法,并标记这些方法为 critical methods。

相关新闻

  • 朋友圈文案不会写?这个AI指令可能帮得上忙
  • 职责分离的艺术:剖析主从Reactor模型如何实现极致的并发性能
  • 数学题刷题记录(数学、数论、组合数学)

最新新闻

  • 怎样高效获取音乐歌词:3大实用技巧与专业工具实战指南
  • 2026南通防水补漏避坑指南:卫生间/厨房/阳台/屋顶/地下室漏水检测维修全攻略,正规施工+透明报价+口碑榜靠谱服务商推荐 - 安佳防水
  • Ice:重新定义macOS菜单栏的智能管家,让你的桌面回归极简
  • 2026行业内数控线切割机床厂家推荐排行 - 品牌排行榜
  • 学生寄电动车被骗?2026校园托运避坑指南 - 快递物流资讯
  • 嵌入式GUI开发实战:emWin配置、驱动与优化全解析

日新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

周新闻

  • Visual C++运行库修复终极指南:5分钟快速解决Windows软件启动错误
  • 手把手教你构建统计局地区经济数据爬虫:从环境搭建到数据持久化全指南
  • 2026多Agent深度解析:用AI团队替代单一模型,四种架构实战落地

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号