230 likes | 323 Views
Extending The C Programming Language to Handle Multi-Formatted N-Bit Blocks. Jing Yang Department of Computer Science University of Virginia. Multi-Formatted N-Bit Blocks. Applications in a variety of domains need to represent and manipulate blocks of data at the bit level
E N D
Extending The C Programming Language to Handle Multi-Formatted N-Bit Blocks Jing Yang Department of Computer Science University of Virginia
Multi-Formatted N-Bit Blocks • Applications in a variety of domains need to represent and manipulate blocks of data at the bit level • Binary analysis – instruction encoding & decoding • Computer networks – packet classification (filtering) • Cryptography – the Rijndael algorithm (AES)
Characteristics • Continuously allocated in the memory • Variable-sized with an upper limit (a multiple of 8 bits) • Partitioned into several fields, each taking up a few bits (not necessarily continuous) – a format • Have multiple formats and the exact format of an instance may change during runtime – due to context or algorithm
Languages • C • Aggregate types • Bit shifting & masking • ML • Strong type system • C++ or Java • Class • Domain-specific languages
Simplex Type Checking • Static type checking • Dynamic type checking • Track the type during runtime • High overhead
Hybrid Type Checking – Static Analysis • The strict type system • The relaxed type system
Implementation • Build upon CIL • Bob -> array of unsigned char • Bob ref -> unsigned char ref • Interpret -> no visible code • Bob field access -> a sequence of bit shifting & masking • Optimization – several accesses combined to one single word implementation
Evaluation • Can only run trivial programs now, but • The revised code still shows: • Clearer structure • Shorter size • At least the same performance