mmtk / mmtk-core

Memory Management ToolKit
https://www.mmtk.io
Other
374 stars 68 forks source link

Supporting VM-required Object Semantics / Spaces #53

Open qinsoon opened 4 years ago

qinsoon commented 4 years ago

In GitLab by @steveblackburn on Jan 22, 2020, 01:41

Spaces are principally an algorithm-specific (and thus VM-neutral) concept. Therefore the abstraction of spaces should be fully contained within MMTk.

On the other hand, VMs may demand special semantics which imply special spaces (and these demands are orthogonal to the chosen GC algorithm). For example:

These demands raise a few issues:

Possible solutions:

qinsoon commented 4 years ago

In GitLab by @steveblackburn on Jan 22, 2020, 01:41

changed the description

qinsoon commented 4 years ago

In GitLab by @steveblackburn on Jan 22, 2020, 01:42

changed the description

qinsoon commented 4 years ago

In GitLab by @qinsoon on Jan 22, 2020, 18:57

Though spaces are VM neutral, MMTk exposes Allocator (https://gitlab.anu.edu.au/mmtk/mmtk/blob/master/src/plan/plan.rs#L239), and allocator is internally mapped with spaces. If we need to attach some semantics with each allocation, we can encode those semantics with Allocator. We probably also need some options so MMTk knows what space needs to be created and what allocator is available.

qinsoon commented 4 years ago

In GitLab by @caizixian on Jan 22, 2020, 19:08

@qinsoon just a tip that it's better to reference a line via commit hash. Otherwise, the line you are referring to actually moves if there is a change.

https://gitlab.anu.edu.au/mmtk/mmtk/blob/9ae6429d953ba79f93d79ed722f40179628cf8d9/src/plan/plan.rs#L239

qinsoon commented 4 years ago

In GitLab by @qinsoon on Feb 7, 2020, 22:06

More insights from Steve:

  • One dimension of what we're discussing here is heap regions that exist independent of the GC algorithm. This is an important way to view this. Spaces X, Y, Z must exist, regardless of which GC algorithm I implement (i.e. even if I have NoGC, I still need X, Y, & Z and some minimal set of semantics associated with them).
  • The above statement is generally runtime-specific. So for all GC algorithms, when using runtime R, you need spaces X, Y & Z, but when using runtime S, you need spaces A & B (independent of GC algorithm).
  • We need to tease out precisely what semantics these spaces are supposed to support. For example, in Jikes RVM, there's an immortal heap (one part of the boot image (data) is essentially just a heap area that is never collected (but is a source of roots). There's also a code space. The same is basically true of V8. However, the semantics are often very muddled. I spent an hour or more with V8 people trying to tease out what semantics they really cared about (they were not really sure and had conflated lots of ideas without being clear about exactly what they needed semantically).
  • It may be the case that the space is opaque to MMTk (ie just a source of 'mysterious' roots, the way the stack is --- the runtime simply tells us "I looked in here and found this pile of roots"). It may also be pre-initialized (like in Jikes RVM's boot image), which has some interesting consequences in terms of object initialization, which needs to be done when the image is created). There's also the question of whether the space is enumerated (like stacks and statics are), or traced.

Furthermore we need to introduce the mechanics that allow the runtime to specify the set of such spaces that it must always have, regardless of GC algorithm.

qinsoon commented 4 years ago

https://github.com/mmtk/mmtk-core/pull/81 and https://github.com/mmtk/mmtk-core/pull/86 have done some work to separate gc-invariant spaces from specific plans.

It is unclear to me what is left to be done for this issue. Should we close this issue and create separate issues for implementing proper code space and read only space?

qinsoon commented 4 years ago

Also we should not use give all spaces execution permission. https://github.com/mmtk/mmtk-core/issues/7