liusy58 / LearningCS

Creative Commons Attribution Share Alike 4.0 International
5 stars 0 forks source link

An Analysis of x86-64 Inline Assembly in C programs #50

Closed liusy58 closed 2 years ago

liusy58 commented 2 years ago

An Analysis of x86-64 Inline Assembly in C programs

Abstract

Introduction

2. Methodology

2.1 Research Questions

How common is inline assembly in C programs?

How long is the average inline assembly fragment?

In which domains is inline assembly used?

What is inline assembly used for?

Do projects use the same subset of inline assembly?

3. Quantitive Results

How common is inline assembly in C programs?

28.1% of the most popular and 11.2% of the keyword-selected projects contained inline assembly. C projects with inline assembly which were analyzed in detail contained on average 3.7 unique inline assembly fragments (median of 2).

How long is the average inline assembly fragment?

17.3% of all C projects with inline assembly contained macro-metaprogramming and many large inline assembly fragments that were omitted from our detailed analysis. Inline assembly fragments contained on average 9.9 instructions (median of 1) per fragment.

In which domains is inline assembly used?

Inline assembly is used in many domains, most commonly in projects for crypto, networking, media, databases, language implementations, concurrency, ssl, string and math libraries.

4. Use Cases of inline assembly Instructions

What is inline assembly used for?

Inline assembly is used to ensure correct semantics on multiple cores, for performance optimization, to access functionality that is unavailable in C, and to implement arithmetic operations.

Do projects use the same subset of inline assembly?

By implementing 50 instructions (5% of x86-64’s total number of instructions) tool writers could support 64.5% of all projects that contain inline assembly.