A Method for Initializing Objects
Original Publication Date: 2002-Jul-20
Included in the Prior Art Database: 2003-Jun-21
Strongly-typed languages, like Java, require objects to be properly initialized before their use, preventing programs from referencing invalid values. The cost of initialization can be high, depending on programs, Disclosed is a method for reducing the cost, involving the compiler and the memory management system. Objects are implicitly initialized by the allocator, a routine in the runtime system. When initializing an object, the allocator must be properly synchronized with the garbage collector. In particular, the collector must not be invoked when the allocator is initializing an object with a reference. Otherwise, the collector would cause invalid memory access in tracing the object. A separate initialization was previously proposed to reduce the implicit initialization. It exploits a property of object-oriented programs. That is, it is common that objects are explicitly initialized in their constructors. In the separate initialization, the allocator no longer performs implicit initialization, while the compiler generates intermediate code for implicit initialization at each allocation site. It is very likely that the compiler inlines one or more constructors and optimizes away the generated initialization code in the presence of explicit initialization code. However, it has a severely limited application. It cannot handle objects with references for the above-mentioned synchronization requirement. We propose two techniques to circumvent the limitation, one for the conservative collector and the other for the type-accurate collector.