While working on a new backend for OCaml to generate Erlang sources, I
found the need to read the .cmi file back into a `Types.signature`
value.
@Drup spotted that I was reading the file and pointed out this value was
already being read during the type checking process.
A quick check at the `Typedtree.module_coercion` showed us that it would
be difficul to extract the same information that is readily available in
the signature value.
This change will expose the signature value directly, so other backends
relying on this signature information do not need to do the extra work
of reading it again.
dereference a pointer before checking it is not a naked pointer.
Algo fix a debug macro changed in PR9742 which could potentially
modify its parameter. It turns out this is not a bug, but the macro
was still particularly dangerous.
Before we ignored as-patterns in the flatten_* functions because
as-patterns would either be half-simplified or raise Cannot_flatten
(in any case, never reach the flattening functions).
Now the reasoning is a bit more subtle: the only non-simple matrices
we flatten are used as "ghost" information (default environments,
provenance) where variables do not matter, only the shape of matched values.
Note: we now use -dlambda rather than -drawlambda, because otherwise
the output is much more verbose and difficult to read.
(-drawlambda is closed to the inner workings of the pattern-matching
compiler, but the simplification in -dlambda make the output much more
readable. They are also fairly predictable/non-surprising, so I think
that we can still easily understand what the compiler did from that
output.)
Instead, we use a thread-local variable [callback_status] which
contains the index of the corresponding entry when a callback is
running. We can do this since there can only be one running callback
at the same time in a given thread.
This lifts the restriction forbidding the call of Thread.exit from a
memprof callback.
This is done by using a local entry array for each thread, containing
tracked blocks whose allocation callback has not yet been called.
This allows some simplification in the code running callbacks for
young allocations. Indeed, since the entry array is local to one
thread, we know for sure that it cannot be modified during a callback,
and therefore we no longer need to remember the indices of the
corresponding new entries.