We present JAttack, a framework that enables template-based testing for compilers. Using JAttack, a developer writes a template program that describes a set of programs to be generated and given as test inputs to a compiler. Such a framework enables developers to incorporate their domain knowledge on testing compilers, giving a basic program structure that allows for exploring complex programs that can trigger sophisticated compiler optimizations. A developer writes a template program in the host language (Java) that contains holes to be filled by JAttack. Each hole, written using a domain-specific language, constructs a node within an extended abstract syntax tree (eAST). An eAST node defines the search space for the hole, i.e., a set of expressions and values. JAttack generates programs by executing templates and filling each hole by randomly choosing expressions and values (available within the search space defined by the hole). Additionally, we introduce several optimizations to reduce JAttack's generation cost. While JAttack could be used to test various compiler features, we demonstrate its capabilities in helping test just-in-time (JIT) Java compilers, whose optimizations occur at runtime after a sufficient number of executions. Using JAttack, we have found six critical bugs that were confirmed by Oracle developers. Four of them were previously unknown, including two unknown CVEs (Common Vulnerabilities and Exposures). JAttack shows the power of combining developers' domain knowledge (via templates) with random testing to detect bugs in JIT compilers.
翻译:我们展示了 JAttack, 这个框架可以让编辑者进行基于模板的测试。 开发者使用 JAttack 撰写一个模板程序, 描述要生成的一组程序, 并将其作为测试输入给编译者。 这个框架可以让开发者在测试编译器上集其域知识, 提供一个基本的程序结构, 允许探索能够触发精密编译器优化的复杂程序。 一个开发者在主机语言( Java) 中写入一个模板程序, 包含由 JAttack 填补的洞。 每个洞, 使用域语言, 在一个扩展的抽象同步树( eAST) 中构建一个节点。 一个 eAST 节点可以定义用于测试一个洞的搜索空间, 即测试器的表达和值。 JAAttackt k 生成了一个程序, 通过随机选择表达式和值( 在洞里定义的搜索空间里可以找到的搜索器) 。 此外, 我们介绍几个优化了 JAttack 的生成器的成本 。 虽然 JAttack 可以用来测试各种编译器的精度, 我们在测试中使用了一个未知的精度, 的校验中找到了它的能力。