[coop] New local handles implementation.
authorRodrigo Kumpera <kumpera@gmail.com>
Sat, 28 May 2016 01:03:56 +0000 (18:03 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 3 Jun 2016 21:28:05 +0000 (14:28 -0700)
commitea865faee1a67d7bb94dddff7dd563c3479bb4c2
tree58cfe565fec4e90cffccdac59ec3fc53e93d8643
parente81430a7d6fd74e862ef59965d9ad1e93000ed61
[coop] New local handles implementation.

This is the initial code drop of a new handles implementation.

It differs from the previous one is a few ways:

- It keeps a separate stack of handles which is shared by all "arenas".
This eliminates malloc in the majority of the cases without the need for any tuning

- Custom gc scanning code for the handles stack.
The original implementation registered the chunks as a GC roots. Which is a terribly
slow operation as it takes the GC lock.

Instead of allocating a new handle arena for each icall, we compute a stack mark,
which is the position in the handles stack at icall entry. On exit, we simply restore that
position, which is just a couple of stores.

Since the stack is implemented using arraylets, addressed are stable in the face of
expansion.

Only the typed handles function/macros are in as having both typed and untyped handles
adds extra complexity for no clear value.

The macros only handle what was needed to port a sizeable chunk of locales.c.

This commit just sets the stage for the feature, there's quite some work left
before we can start using it, as it can be seen in the big TODO in handle.c
mono/metadata/handle.c
mono/metadata/handle.h
mono/metadata/sgen-mono.c
mono/unit-tests/test-mono-handle.c
mono/utils/mono-threads.h