University of Kansas
Source-to-Source Refactoring Framework for Local and Global Variables
Abstract
dc:description.abstractA global variable in C/C++ programs is one that is declared outside a function, and whose scope extends the lifetime of the entire program. Global variables have been shown to cause problems for program maintainability, extensibility, dependence, verification, and thread-safety. Consequently, the use of global variables has been disparaged in many programming textbooks and coding guides. However, employing global variables can also make coding more convenient. We have found that the use of global variables remains unabated and extensive in most real-world software programs. In this work we present our source-to-source refactoring tool to automatically detect and localize global variables in a program. Our tool implements a compiler based transformation algorithm that finds the best location to move and redefine each global variable as a local. For each global variable, our algorithm initializes the corresponding new local variable, and passes it as an argument to all functions that need it, and updates the source code lines that used the original global variable to now instead use the corresponding local or function argument, thus maintaining the original program semantics. In this work we further characterize the nature of how global variables are employed in common benchmark programs. We further study the effect of our transformation on static program properties, such as the change in the number of function arguments and visibility of program state. Additionally, we also quantify the effect of localizing global variables on dynamic program characteristics, including the change in data and stack memory usage and runtime program performance.
Degree
thesis:*- Name thesis:degree_name
- M.S.
- Discipline thesis:degree_discipline
- Electrical Engineering & Computer Science
- Grantor dc:publisher
- University of Kansas
- Year dc:date.issued
- 2012
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Sankaranarayanan, Hemaiyer
- Advisor dc:contributor.advisor
-
- Kulkarni, Prasad
- Committee members dc:contributor.committeemember
-
- Gill, Andrew
- Fu, Xin
Subjects
dc:subject × 6Rights
dc:rights.accessrights- Statement dc:rights.accessrights
-
- embargoedAccess
- Copyright held by the author.
- Language dc:language.iso
- en
Identifiers
dc:identifier.*- Dc Identifier Other
- https://www.proquest.com/docview/1015030078