+ All Categories
Home > Documents > Fast JIT Code Generation -...

Fast JIT Code Generation -...

Date post: 16-Aug-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
14
Fast JIT Code Generation Tilmann Scheller
Transcript
Page 1: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Fast JIT Code Generation

Tilmann Scheller

Page 2: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Overview

Introduction

tiny-llvm-codegen

SkyEye

Performance Numbers

Summary

Page 3: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Introduction

Traditional LLVM JIT has a relatively high overhead since it's essentially using the same code generator like the static compiler

Only useful for really hot code

Fast-isel solves part of the problem but overhead still significant

It would be nice to just flip a switch and get a different tradeoff in terms of compile time/runtime performance

Page 4: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

tiny-llvm-codegen

Work is based on tiny-llvm-codegen

tiny-llvm-codegen is a really simple JIT for LLVM IR targeting x86-32

Developed by Mark Seaborn in March 2013

Ported tiny-llvm-codegen to x86-64

Added basic support for the AMD64 System V ABI

Page 5: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

tiny-llvm-codegen

Extremely simple translator

Very small (about 2000 LOC)

No register allocation

No instruction selection

No instruction scheduling

Just translating every LLVM IR instruction one by one

All values go into memory

Page 6: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Example

foo:push %rbpmov %rsp,%rbpsub $0x1c,%rspmov %rdi,-0x8(%rbp)mov %rsi,-0x10(%rbp)mov -0x10(%rbp),%raxmov -0x8(%rbp),%rcxadd %rcx,%raxmov %rax,-0x18(%rbp)mov -0x18(%rbp),%raxleaveqretq

define i64 @foo(i64 %a, i64 %b) { %1 = add i64 %b, %a ret i64 %1}

Page 7: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

tiny-llvm-codegen

Supported: Integer operations

Missing: Floating-point operations, Vector operations

No performance tuning yet

Probably lots of low hanging fruit

Supports i1, i8, i16, i32, i64

Page 8: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

SkyEye

Open Source full system simulator

Supports a wide range of different architectures: ARM, PowerPC, MIPS, x86, SPARC, ColdFire, Blackfin

Does interpretation as well as dynamic binary translation with LLVM (using a fork of the libcpu project)

Can run an ARM Android 2.2 build

Page 9: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

SkyEye Overview

ARM

Interpreter

Translate to LLVM IR

Optimize LLVM IR

LLVM JITtiny-llvm-codegen

x86-64 x86-64

Page 10: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Test workload

Simulating a Samsung S3C6410X SoC with an ARM11 core

Booting an ARMv6 Linux 3.0 kernel

This requires about 150 million instructions

Produces 33MB of optimized bitcode

Page 11: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Test workload

Compiling the 33MB of bitcode offline:

3.3 seconds with tiny-llvm-codegen

67 seconds with llc

JITing every basic block which is executed at least twice to compare the performance of both JITs

Booting the kernel on the simulated system: about 3x faster when using tiny-llvm-codegen (24 sec vs. 76 sec)

Measured on an Intel Core i7-4770K

Page 12: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Summary

Ported tiny-llvm-codegen to x86-64

Successfully compiles a substantial amount of LLVM IR

Performance numbers look promising

Future:

Support the remaining LLVM IR instructions

Performance tuning

Add support for another architecture

Add a simple register allocator?

Page 13: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

Thank you.

Page 14: Fast JIT Code Generation - LLVMllvm.org/devmtg/2014-04/PDFs/LightningTalks/fast-jit-code-generatio… · in terms of compile time/runtime performance. tiny-llvm-codegen ... No performance

References

http://github.com/mseaborn/tiny-llvm-codegen

http://skyeye.sourceforge.net

http://libcpu.org


Recommended