Tue 23 Mar 2021 14:00 - 14:30 at Virtual Space A - Optimizing Dynamic Languages Chair(s): Fabio Niephaus

In JavaScript, the user can add properties to objects after the objects are created. This means that we cannot know how much memory will be required for an object in the future execution when the object is allocated. Thus, a typical implementation uses external property arrays, which are reallocated if more properties than their sizes are added. This reallocation increases GC frequency and may advance memory fragmentation. Furthermore, copying the contents of the old array to the new one is time consuming. To address this problem, we propose to decide the initial size of an object according to the history of objects allocated at the same “new” Instruction. This approach is common to JavaScript implementations, and for instance used in V8 with the help of so-called Mementos. We implemented this technique in eJSVM, a JavaScript VM for memory constrained systems, and evaluated it in this context.

In our version of the approach, we cache hidden classes of objects as part of the “new” instructions that create them. We use a heuristic to determine the hidden class that is most commonly used by objects from a specific allocation site, preferring hidden classes including all commonly used properties. When an object is created at a “new” instruction where a hidden class is cached, the object is given the cached hidden class and sufficient space to store all properties in the hidden class in the object. These in-object properties are initialized with a special empty value to keep JavaScript semantics. Only when a property that is not in the hidden class is added, an external array is allocated for the object. The cache is updated in the next garbage collection.

Tue 23 Mar

Displayed time zone: Belfast change

12:55 - 14:30
Optimizing Dynamic LanguagesMoreVMs at Virtual Space A
Chair(s): Fabio Niephaus Hasso Plattner Institute, University of Potsdam
12:55
5m
Day opening
Welcome
MoreVMs
Fabio Niephaus Hasso Plattner Institute, University of Potsdam, David Leopoldseder Oracle Labs
13:00
60m
Talk
YJIT: Building a New JIT Compiler Inside CRubyMoreVMs Invited Talk
MoreVMs
Media Attached
14:00
30m
Talk
Caching Hidden Classes for Pre-transitioning Object Memory Layout in JavaScript
MoreVMs
Tomoharu Ugawa University of Tokyo, Stefan Marr University of Kent, Richard Jones University of Kent
Media Attached