36. MPS TRANSFORM DESIGN

Richard Brooksby, Ravenbrook Limited, 2012-09-04

36.1. Introduction

This document describes the Transform mechanism of the Memory Pool System. Transforms allow the client code to replace a set of object references on the heap. Transforms exist to satisfy a requirement from Configura, and are not intended to become part of the open source MPS.

The readership of this document is any developer intending to modify the Transform implementation.

This document is Configura client confidential.

36.2. Background

Göran Rydqvist of Configura originally expressed the requirement for the MPS to support the change of layout of objects in CET [[Crab 2010-02-25][]]. Ravenbrook proposed several methods [[RHSK 2010-09-21][]] but Configura selected idea 1:

> Make all objects “direct”, without IOHeaders. If you need to add fields, > then use a special new MPS function (that doesn’t exist yet): > > mps_arena_transform_objects(&my_transform_function); > > This traverses the object graph, lets your transform_function basically > “realloc()” the field-block, and MPS fixes up all references from other > objects to point to the new field-block. > > Unfortunately, this idea is probably killed off by ambiguous references > :-(. You could only run the patch if you could guarantee there are no > ambiguous refs you want. In other words, any object refs on the stack > would become instant death (or worse: subtle slow death :-). Therefore we > don’t really like this idea (unfortunately). There are safer and simpler > ways to do it, we think…

An initial implementation was made by RHSK and released to Configura as “experimental”, however Configura put it into production.

During work on adapting the MPS to 64-bit Windows, RB reformed and reimplemented transforms based on RHSK’s original work.

36.3. Overview

The client program builds a table mapping “old” references to “new” ones in a Transform object. This is then “applied”, causing a garbage collection trace in which the fix function is substituted by transformFix, which spots “old” references and replaces them with “new” ones, in addition to applying the usual garbage collection fix function.

36.4. NOT YET WRITTEN

Points to cover:

  • Ambiguous references and aborting the transform
    • How ambiguous references are avoided using stackAtEnter
  • How the implementation is an add-on to the MPS
  • How the code is kept separate from the mainstream MPS
  • Why it has its own hash table implementation (no good reason)
  • Why it does a garbage collection and not just a transforming scan
    • Nice side-effect is that “old” objects are killed
  • Why the arena must be parked

36.5. References

[Crab 2010-02-25]: http://info.ravenbrook.com/mail/2010/02/25/16-35-45/0/ [Crab 2010-02-25] “Incremental object” (email); Göran Rydqvist; Configura; 2010-02-25; <http://info.ravenbrook.com/mail/2010/02/25/16-35-45/0/>.

[RHSK 2010-09-21]: http://info.ravenbrook.com/mail/2010/09/21/16-54-59/0/ [RHSK 2010-09-21] “Incremental object ideas” (email); Richard Kistruck; Ravenbrook Limited; 2010-09-21; <http://info.ravenbrook.com/mail/2010/09/21/16-54-59/0/>.

[Crab 2010-09-22]: http://info.ravenbrook.com/mail/2010/09/22/09-27-53/0/ [Crab 2010-09-22] “Incremental object ideas” (email); Göran Rydqvist; Configura; 2010-09-22; <http://info.ravenbrook.com/mail/2010/09/22/09-27-53/0/>.