22
Retargetable Retargetable Binary Binary Translators Translators 10 Sep 2007 10 Sep 2007 National University of Singapore National University of Singapore School of Computing School of Computing OH KWANG SHIN OH KWANG SHIN

CS6270 Presentation - Retargetable binary translators

Embed Size (px)

DESCRIPTION

CS6270 Presentation - Retargetable binary translators

Citation preview

Page 1: CS6270 Presentation - Retargetable binary translators

Retargetable Retargetable Binary Binary

TranslatorsTranslators

10 Sep 200710 Sep 2007

National University of SingaporeNational University of SingaporeSchool of ComputingSchool of Computing

OH KWANG SHINOH KWANG SHIN

Page 2: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 2

AgendaAgenda

• Emulation Summary• Binary Translators - Example• Binary Translators - Weakness• Retargetable Binary Translator

Framework– Strata– Walkabout

Page 3: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 3

Emulation SummaryEmulation Summary

Decode-dispatch

Indirect Threaded

Direct Threaded

Binary Translation

Memory Low Low High High

Start-up Fast Fast Slow Slow

Steady-state

Slow Slow Medium Fast

Code Portability

Excellent Excellent Medium Poor

Page 4: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 4

Binary TranslatorsBinary TranslatorsExample IExample I

• Transmeta’s Code Morphing– Intel IA-32 binary to run on VLIW

Crusoe processor

• UQDBT System– Intel IA-32 binary to run on SPARC-

based processor

• FX!32– x86 binary to run on Alpha processor

Page 5: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 5

Binary TranslatorsBinary TranslatorsExample IIExample II

• Shade– Implement high-performance instruction set si

mulators• Embra

– Implement a high-performance operating system emulator

• Dynamo and Mojo– Improve the performance of native binaries

Page 6: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 6

Binary TranslatorBinary TranslatorWeaknessWeakness

• Code Portability - Poor– Typically, written for a single application

and/or platform– Specialized for the target ISA– Single-target, single-purpose approach– Reinvent the wheel!

• Have to develop a new system (Binary Translator) from scratch!

Page 7: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 7

Retargetable Binary TranslatorRetargetable Binary Translator

FrameworkFramework• Strata

– A cross-platform infrastructure for building software binary dynamic translators

• Walkabout– A retargetable binary translation

framework for experimenting with dynamic translation of binary code

Page 8: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 8

Strata - BackgroundStrata - Background

• Strata– Binary Translator implementation

infrastructure– Provides common framework for

software engineering principle, Code Reuse• Provides simple binary translator for a

variety of architectures• Allows code reuse through composition

Page 9: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 9

Strata - ArchitectureStrata - Architecture

Target-independentCommon services

Reconfigurable

Page 10: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 10

Strata-SPARCStrata-SPARC

• First Strata software dynamic translator

• For the SPARC V8/V9 instruction set architecture and the Solaris operating system

• A variety of target-independent techniques– Reduce the number of context switches

Page 11: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 11

Strata-SPARCStrata-SPARCPerformancePerformance

• Strata-SPARC with native execution– From 1.02x to 1.8x, average 1.32x

Page 12: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 12

Strata-MIPSStrata-MIPS

• For MIPS IV instruction set architecture and the IRIX 6.5.10 operating system

• In porting Strata to the MIPS– Found Strata’s structure to be flexible

and relatively easy to retarget

• Initial version– One person less than three weeks

Page 13: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 13

Strata-MIPSStrata-MIPSPerformancePerformance

• Strata-MIPS with native execution– From 1.09x to 3.0x, average 1.8x

Page 14: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 14

Strata-X86Strata-X86

• For Intel 80x86 instruction set architecture

• Difference between CISC and RISC– Still used Strata-SPARC as the basis for

retargeting to the x86• Focus on implementing the

instruction fetch and decode function– To do some amount of decoding of an

instruction to determine its length

Page 15: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 15

Strata-X86Strata-X86PerformancePerformance

• Strata-X86 with native execution– From 1.0x to 1.8x, average 1.35x

Page 16: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 16

Walkabout - BackgroundWalkabout - Background

• Walkabout– Retargetable binary translation

framework for experimenting with dynamic translation of binary code

– How to instrument interpreters in a retargetable way

– Inspiration• University of Queensland Binary Translator

(UQBT) framework– Enabled static translations of binary codes

Page 17: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 17

Walkabout - ArchitectureWalkabout - Architecture

• Designed with retargetability in mind

Page 18: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 18

Walkabout - RetargetabilityWalkabout - Retargetability

• Supporting binaries for different input and output machines

• Users could instantiate new translators out of the framework– Source and target machines of choice

• Supported through the specifications– Machine descriptions– Hot path selection method specifications

Page 19: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 19

Walkabout - InterpreterWalkabout - Interpreter

• Automatically generated from– Specifications of syntax and semantics of

machine instruction set

• Interpreter Generator

– SLED describes the instruction syntax– SSL describes the instruction semantics

Page 20: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 20

Walkabout - PerformanceWalkabout - Performance

Performance results for an automatically-generatedC Language interpreter for the SPARC architecture

(Static size in bytes, Interpreter running time in seconds,Path-Finder with dynamic optimization running time)

Page 21: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 21

ReferencesReferences

• K. Scott, N. Kumar, S. Velusamy, B. R. Childers, J. W. Davidson, and M. L. Soffa, Retargetable and Reconfigurable Software Dynamic Translation, International Symposium on Code Generation and Optimization, pp. 36–47 (March 2003).

• CIFUENTES, C., LEWIS, B., AND UNG, D. Walkabout – A Retargetable Dynamic Binary Translation Framework. In Proceedings of the 2002 Workshop on Binary Translation (2002).

• C. Cifuentes, M. Van Emmerik, N. Ramsey, and B. Lewis. Experience in the design, implementation and use of a retargetable static binary translation framework. Technical Report TR-2002-105, Sun Microsystems Laboratories, Palo Alto, CA 94303, January 2002.

• C. Cifuentes, B. Lewis. Walkabout – A framework for Experimental Dynamic Binary Translation. Sun Microsystems Inc, Palo Alto, CA 94303, January 2002.

Page 22: CS6270 Presentation - Retargetable binary translators

Retargetable Binary Translators 10 Sep 2007 22