@@ -2565,8 +2565,7 @@ pph_in_tree (pph_stream *stream)
/* When reading a mutated tree, we only need to re-read its
body, the tree itself is already in the cache for another
PPH image. */
- expr = (tree) pph_cache_find (stream, PPH_RECORD_XREF, image_ix, ix,
- PPH_any_tree);
+ expr = (tree) pph_cache_find (stream, marker, image_ix, ix, PPH_any_tree);
}
else if (marker == PPH_RECORD_START_MERGE_BODY)
{
@@ -2600,7 +2599,7 @@ pph_in_tree (pph_stream *stream)
pph_trace_tree (expr, pph_trace_back,
marker == PPH_RECORD_START_MERGE_BODY ? pph_trace_merge_body
: marker == PPH_RECORD_START_MUTATED ? pph_trace_mutate
- : pph_trace_normal );
+ : pph_trace_normal);
/* If needed, sign the recently materialized tree to detect
mutations. Note that we only need to compute signatures
@@ -2612,8 +2611,13 @@ pph_in_tree (pph_stream *stream)
{
unsigned crc;
size_t nbytes;
+ pph_cache *cache;
+
+ /* Retrieve the cache to sign based on where we materialized
+ EXPR from. */
+ cache = pph_cache_select (stream, marker, image_ix);
crc = pph_get_signature (expr, &nbytes);
- pph_cache_sign (&stream->cache, ix, crc, nbytes);
+ pph_cache_sign (cache, ix, crc, nbytes);
}
return expr;
@@ -293,9 +293,16 @@ void pph_reader_finish (void);
/* Return the pickle cache in STREAM corresponding to MARKER.
- if MARKER is PPH_RECORD_IREF, it returns the cache in STREAM itself.
- If MARKER is PPH_RECORD_XREF, it returns the cache in
- STREAM->INCLUDES[INCLUDE_IX].
+ INCLUDE_IX is only used for MARKER values PPH_RECORD_XREF or
+ PPH_RECORD_START_MUTATED.
+
+ If MARKER is one of {PPH_RECORD_IREF, PPH_RECORD_START,
+ PPH_RECORD_START_MERGE_BODY, PPH_RECORD_START_MERGE_KEY}, it
+ returns the cache in STREAM itself.
+
+ If MARKER is one of {PPH_RECORD_XREF, PPH_RECORD_START_MUTATED}, it
+ returns the cache in STREAM->INCLUDES[INCLUDE_IX].
+
If MARKER is a PREF, it returns the preloaded cache. */
static inline pph_cache *
pph_cache_select (pph_stream *stream, enum pph_record_marker marker,
@@ -304,9 +311,13 @@ pph_cache_select (pph_stream *stream, enum pph_record_marker marker,
switch (marker)
{
case PPH_RECORD_IREF:
+ case PPH_RECORD_START:
+ case PPH_RECORD_START_MERGE_BODY:
+ case PPH_RECORD_START_MERGE_KEY:
return &stream->cache;
break;
case PPH_RECORD_XREF:
+ case PPH_RECORD_START_MUTATED:
return &VEC_index (pph_stream_ptr, stream->includes, include_ix)->cache;
break;
case PPH_RECORD_PREF: