Skip to content
GitLab
  • 菜单
项目 群组 代码片段
  • /
  • 帮助
    • 帮助
    • 支持
    • 社区论坛
    • 提交反馈
  • 登录/注册
  • S SPA Knowledge Base
  • 项目信息
    • 项目信息
    • 动态
    • 标记
    • 成员
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
    • 已锁定文件
  • 议题 46
    • 议题 46
    • 列表
    • 看板
    • 服务台
    • 里程碑
    • 需求
  • 合并请求 0
    • 合并请求 0
  • CI/CD
    • CI/CD
    • 流水线
    • 作业
    • 计划
    • 测试用例
  • 部署
    • 部署
    • 环境
    • 发布
  • 软件包与镜像库
    • 软件包与镜像库
    • 软件包库
    • 容器镜像库
    • 基础设施库
  • 监控
    • 监控
    • 事件
  • 分析
    • 分析
    • 价值流
    • CI/CD
    • 代码评审
    • 洞察
    • 议题
    • 仓库
  • Wiki
    • Wiki
  • 代码片段
    • 代码片段
  • 动态
  • 分支图
  • 创建新议题
  • 作业
  • 提交
  • 议题看板
收起侧边栏
  • Ricolove
  • SPA Knowledge Base
  • 议题
  • #35
已关闭
开放中
Created 11月 18, 2021 by Tianyun Zhang@doowzs

taie处理的if分支中字节码的对应行号有误

可复现的实例:

class A {

    int x;

    A foo(A a) {
        if (a.x > 0) {
            return null;
        } else {
            return new A();
        }
    }


    public static void main(String[] args) {
        A a = new A();
        a.x = 2;
        a.foo(a);
    }

}

Taie生成的字节码结果(.tir文件):

class A extends java.lang.Object {

    int x;

    A foo(A a) {
        int temp$0, %intconst0;
        A temp$1, temp$2;
        [0@L6] temp$0 = a.<A: int x>;
        [1@L6] %intconst0 = 0;
        [2@L6] if (temp$0 > %intconst0) goto 4;
        [3@L6] goto 7;
        [4@L6] nop;
        [5@L6] temp$1 = null;
        [6@L7] return temp$1;
        [7@L7] nop;
        [8@L7] temp$2 = new A;
        [9@L9] invokespecial temp$2.<A: void <init>()>();
        [10@L9] return temp$2;
    }

    public static void main(java.lang.String[] args) {
        A temp$0, a, temp$2;
        int temp$1;
        [0@L15] temp$0 = new A;
        [1@L15] invokespecial temp$0.<A: void <init>()>();
        [2@L15] a = temp$0;
        [3@L16] temp$1 = 2;
        [4@L16] a.<A: int x> = temp$1;
        [5@L17] temp$2 = invokevirtual a.<A: A foo(A)>(a);
        [6@L17] return;
    }

    void <init>() {
        [0@L1] invokespecial %this.<java.lang.Object: void <init>()>();
        [1@L1] return;
    }

}

A::foo函数中,new A应该出现在第9行而不是第7行。

%d位指派人
分配到
工时统计