@@ -55,23 +55,23 @@ static int pph_reading_includes = 0;
/* Wrapper for memory allocation calls that should have their results
registered in the PPH streamer cache. DATA is the pointer returned
by the memory allocation call in ALLOC_EXPR. IX is the cache slot
- in STREAM where the newly allocated DATA should be registered at. */
-#define ALLOC_AND_REGISTER(STREAM, IX, DATA, ALLOC_EXPR) \
+ in CACHE where the newly allocated DATA should be registered at. */
+#define ALLOC_AND_REGISTER(CACHE, IX, DATA, ALLOC_EXPR) \
do { \
(DATA) = (ALLOC_EXPR); \
- pph_cache_insert_at (STREAM, DATA, IX); \
+ pph_cache_insert_at (CACHE, DATA, IX); \
} while (0)
/* Same as ALLOC_AND_REGISTER, but instead of registering DATA into the
cache at slot IX, it registers ALT_DATA. Used to support mapping
- pointers to global data in the original STREAM that need to point
+ pointers to global data in the original CACHE that need to point
to a different instance when aggregating individual PPH files into
the current translation unit (see pph_in_binding_level for an
example). */
-#define ALLOC_AND_REGISTER_ALTERNATE(STREAM, IX, DATA, ALLOC_EXPR, ALT_DATA)\
+#define ALLOC_AND_REGISTER_ALTERNATE(CACHE, IX, DATA, ALLOC_EXPR, ALT_DATA)\
do { \
(DATA) = (ALLOC_EXPR); \
- pph_cache_insert_at (STREAM, ALT_DATA, IX); \
+ pph_cache_insert_at (CACHE, ALT_DATA, IX); \
} while (0)
/* Set in pph_in_and_merge_line_table. Represents the source_location offset
@@ -413,11 +413,11 @@ pph_in_cxx_binding_1 (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (cxx_binding *) pph_cache_get (stream, include_ix, ix);
+ return (cxx_binding *) pph_cache_get (&stream->cache, include_ix, ix);
value = pph_in_tree (stream);
type = pph_in_tree (stream);
- ALLOC_AND_REGISTER (stream, ix, cb, cxx_binding_make (value, type));
+ ALLOC_AND_REGISTER (&stream->cache, ix, cb, cxx_binding_make (value, type));
cb->scope = pph_in_binding_level (stream, NULL);
bp = pph_in_bitpack (stream);
cb->value_is_inherited = bp_unpack_value (&bp, 1);
@@ -461,9 +461,10 @@ pph_in_class_binding (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (cp_class_binding *) pph_cache_get (stream, image_ix, ix);
+ return (cp_class_binding *) pph_cache_get (&stream->cache, image_ix, ix);
- ALLOC_AND_REGISTER (stream, ix, cb, ggc_alloc_cleared_cp_class_binding ());
+ ALLOC_AND_REGISTER (&stream->cache, ix, cb,
+ ggc_alloc_cleared_cp_class_binding ());
cb->base = pph_in_cxx_binding (stream);
cb->identifier = pph_in_tree (stream);
@@ -484,9 +485,10 @@ pph_in_label_binding (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (cp_label_binding *) pph_cache_get (stream, image_ix, ix);
+ return (cp_label_binding *) pph_cache_get (&stream->cache, image_ix, ix);
- ALLOC_AND_REGISTER (stream, ix, lb, ggc_alloc_cleared_cp_label_binding ());
+ ALLOC_AND_REGISTER (&stream->cache, ix, lb,
+ ggc_alloc_cleared_cp_label_binding ());
lb->label = pph_in_tree (stream);
lb->prev_value = pph_in_tree (stream);
@@ -524,14 +526,15 @@ pph_in_binding_level (pph_stream *stream, cp_binding_level *to_register)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (cp_binding_level *) pph_cache_get (stream, image_ix, ix);
+ return (cp_binding_level *) pph_cache_get (&stream->cache, image_ix, ix);
/* If TO_REGISTER is set, register that binding level instead of the newly
allocated binding level into slot IX. */
if (to_register == NULL)
- ALLOC_AND_REGISTER (stream, ix, bl, ggc_alloc_cleared_cp_binding_level ());
+ ALLOC_AND_REGISTER (&stream->cache, ix, bl,
+ ggc_alloc_cleared_cp_binding_level ());
else
- ALLOC_AND_REGISTER_ALTERNATE (stream, ix, bl,
+ ALLOC_AND_REGISTER_ALTERNATE (&stream->cache, ix, bl,
ggc_alloc_cleared_cp_binding_level (),
to_register);
@@ -600,9 +603,10 @@ pph_in_c_language_function (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (struct c_language_function *) pph_cache_get (stream, image_ix, ix);
+ return (struct c_language_function *) pph_cache_get (&stream->cache,
+ image_ix, ix);
- ALLOC_AND_REGISTER (stream, ix, clf,
+ ALLOC_AND_REGISTER (&stream->cache, ix, clf,
ggc_alloc_cleared_c_language_function ());
clf->x_stmt_tree.x_cur_stmt_list = pph_in_tree_vec (stream);
clf->x_stmt_tree.stmts_are_full_exprs_p = pph_in_uint (stream);
@@ -625,9 +629,11 @@ pph_in_language_function (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (struct language_function *) pph_cache_get (stream, image_ix, ix);
+ return (struct language_function *) pph_cache_get (&stream->cache,
+ image_ix, ix);
- ALLOC_AND_REGISTER (stream, ix, lf, ggc_alloc_cleared_language_function ());
+ ALLOC_AND_REGISTER (&stream->cache, ix, lf,
+ ggc_alloc_cleared_language_function ());
memcpy (&lf->base, pph_in_c_language_function (stream),
sizeof (struct c_language_function));
lf->x_cdtor_label = pph_in_tree (stream);
@@ -822,7 +828,7 @@ pph_in_lang_specific (pph_stream *stream, tree decl)
else if (pph_is_reference_marker (marker))
{
DECL_LANG_SPECIFIC (decl) =
- (struct lang_decl *) pph_cache_get (stream, image_ix, ix);
+ (struct lang_decl *) pph_cache_get (&stream->cache, image_ix, ix);
return;
}
@@ -832,7 +838,7 @@ pph_in_lang_specific (pph_stream *stream, tree decl)
/* Now register it. We would normally use ALLOC_AND_REGISTER,
but retrofit_lang_decl does not return a pointer. */
- pph_cache_insert_at (stream, ld, ix);
+ pph_cache_insert_at (&stream->cache, ld, ix);
/* Read all the fields in lang_decl_base. */
ldb = &ld->u.base;
@@ -916,10 +922,12 @@ pph_in_sorted_fields_type (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (struct sorted_fields_type *) pph_cache_get (stream, image_ix, ix);
+ return (struct sorted_fields_type *) pph_cache_get (&stream->cache,
+ image_ix, ix);
num_fields = pph_in_uint (stream);
- ALLOC_AND_REGISTER (stream, ix, v, sorted_fields_type_new (num_fields));
+ ALLOC_AND_REGISTER (&stream->cache, ix, v,
+ sorted_fields_type_new (num_fields));
for (i = 0; i < num_fields; i++)
v->elts[i] = pph_in_tree (stream);
@@ -993,10 +1001,11 @@ pph_in_lang_type_class (pph_stream *stream, struct lang_type_class *ltc)
if (marker == PPH_RECORD_START)
{
ltc->nested_udts = pph_in_binding_table (stream);
- pph_cache_insert_at (stream, ltc->nested_udts, ix);
+ pph_cache_insert_at (&stream->cache, ltc->nested_udts, ix);
}
else if (pph_is_reference_marker (marker))
- ltc->nested_udts = (binding_table) pph_cache_get (stream, image_ix, ix);
+ ltc->nested_udts = (binding_table) pph_cache_get (&stream->cache,
+ image_ix, ix);
ltc->as_base = pph_in_tree (stream);
ltc->pure_virtuals = pph_in_tree_vec (stream);
@@ -1035,10 +1044,10 @@ pph_in_lang_type (pph_stream *stream)
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (struct lang_type *) pph_cache_get (stream, image_ix, ix);
+ return (struct lang_type *) pph_cache_get (&stream->cache, image_ix, ix);
- ALLOC_AND_REGISTER (stream, ix, lt,
- ggc_alloc_cleared_lang_type (sizeof (struct lang_type)));
+ ALLOC_AND_REGISTER (&stream->cache, ix, lt,
+ ggc_alloc_cleared_lang_type (sizeof (struct lang_type)));
pph_in_lang_type_header (stream, <->u.h);
if (lt->u.h.is_lang_type_class)
@@ -1902,7 +1911,7 @@ pph_read_tree_header (pph_stream *stream, tree *expr_p, unsigned ix)
}
/* Add *EXPR_P to the pickle cache at slot IX. */
- pph_cache_insert_at (stream, *expr_p, ix);
+ pph_cache_insert_at (&stream->cache, *expr_p, ix);
return fully_read_p;
}
@@ -1925,7 +1934,7 @@ pph_read_tree (struct lto_input_block *ib ATTRIBUTE_UNUSED,
if (marker == PPH_RECORD_END)
return NULL;
else if (pph_is_reference_marker (marker))
- return (tree) pph_cache_get (stream, image_ix, ix);
+ return (tree) pph_cache_get (&stream->cache, image_ix, ix);
/* We did not find the tree in the pickle cache, allocate the tree by
reading the header fields (different tree nodes need to be
@@ -200,7 +200,7 @@ pph_out_start_record (pph_stream *stream, void *data)
/* See if we have data in STREAM's cache. If so, write an internal
reference to it and inform the caller that it should not write a
physical representation for DATA. */
- if (pph_cache_lookup (stream, data, &ix))
+ if (pph_cache_lookup (&stream->cache, data, &ix))
{
pph_out_record_marker (stream, PPH_RECORD_IREF);
pph_out_uint (stream, ix);
@@ -221,7 +221,7 @@ pph_out_start_record (pph_stream *stream, void *data)
/* DATA is in none of the pickle caches, add it to STREAM's pickle
cache and tell the caller that it should pickle DATA out. */
- pph_cache_add (stream, data, &ix);
+ pph_cache_add (&stream->cache, data, &ix);
pph_out_record_marker (stream, PPH_RECORD_START);
pph_out_uint (stream, ix);
return true;
@@ -1042,7 +1042,7 @@ pph_out_scope_chain (pph_stream *stream)
reference to it, instead of writing its fields. */
{
unsigned ix;
- pph_cache_add (stream, scope_chain->bindings, &ix);
+ pph_cache_add (&stream->cache, scope_chain->bindings, &ix);
pph_out_record_marker (stream, PPH_RECORD_START);
pph_out_uint (stream, ix);
pph_out_binding_level_1 (stream, scope_chain->bindings, PPHF_NO_XREFS);
@@ -55,20 +55,20 @@ pph_cache_preload (pph_stream *stream)
unsigned i;
for (i = itk_char; i < itk_none; i++)
- pph_cache_add (stream, integer_types[i], NULL);
+ pph_cache_add (&stream->cache, integer_types[i], NULL);
for (i = 0; i < TYPE_KIND_LAST; i++)
- pph_cache_add (stream, sizetype_tab[i], NULL);
+ pph_cache_add (&stream->cache, sizetype_tab[i], NULL);
/* global_trees[] can have NULL entries in it. Skip them. */
for (i = 0; i < TI_MAX; i++)
if (global_trees[i])
- pph_cache_add (stream, global_trees[i], NULL);
+ pph_cache_add (&stream->cache, global_trees[i], NULL);
/* c_global_trees[] can have NULL entries in it. Skip them. */
for (i = 0; i < CTI_MAX; i++)
if (c_global_trees[i])
- pph_cache_add (stream, c_global_trees[i], NULL);
+ pph_cache_add (&stream->cache, c_global_trees[i], NULL);
/* cp_global_trees[] can have NULL entries in it. Skip them. */
for (i = 0; i < CPTI_MAX; i++)
@@ -78,13 +78,13 @@ pph_cache_preload (pph_stream *stream)
continue;
if (cp_global_trees[i])
- pph_cache_add (stream, cp_global_trees[i], NULL);
+ pph_cache_add (&stream->cache, cp_global_trees[i], NULL);
}
/* Add other well-known nodes that should always be taken from the
current compilation context. */
- pph_cache_add (stream, global_namespace, NULL);
- pph_cache_add (stream, DECL_CONTEXT (global_namespace), NULL);
+ pph_cache_add (&stream->cache, global_namespace, NULL);
+ pph_cache_add (&stream->cache, DECL_CONTEXT (global_namespace), NULL);
}
@@ -380,37 +380,36 @@ pph_trace_bitpack (pph_stream *stream, struct bitpack_d *bp)
}
-/* Insert DATA in STREAM's pickle cache at slot IX. If DATA already
- existed in the cache, IX must be the same as the previous entry. */
+/* Insert DATA in CACHE at slot IX. If DATA already existed in the CACHE, IX
+ must be the same as the previous entry. */
void
-pph_cache_insert_at (pph_stream *stream, void *data, unsigned ix)
+pph_cache_insert_at (pph_pickle_cache *cache, void *data, unsigned ix)
{
void **map_slot;
- map_slot = pointer_map_insert (stream->cache.m, data);
+ map_slot = pointer_map_insert (cache->m, data);
if (*map_slot == NULL)
{
*map_slot = (void *) (unsigned HOST_WIDE_INT) ix;
- if (ix + 1 > VEC_length (void_p, stream->cache.v))
- VEC_safe_grow_cleared (void_p, heap, stream->cache.v, ix + 1);
- VEC_replace (void_p, stream->cache.v, ix, data);
+ if (ix + 1 > VEC_length (void_p, cache->v))
+ VEC_safe_grow_cleared (void_p, heap, cache->v, ix + 1);
+ VEC_replace (void_p, cache->v, ix, data);
}
}
-/* Return true if DATA exists in STREAM's pickle cache. If IX_P is not
- NULL, store the cache slot where DATA resides in *IX_P (or (unsigned)-1
- if DATA is not found). */
+/* Return true if DATA exists in CACHE. If IX_P is not NULL, store the cache
+ slot where DATA resides in *IX_P (or (unsigned)-1 if DATA is not found). */
bool
-pph_cache_lookup (pph_stream *stream, void *data, unsigned *ix_p)
+pph_cache_lookup (pph_pickle_cache *cache, void *data, unsigned *ix_p)
{
void **map_slot;
unsigned ix;
bool existed_p;
- map_slot = pointer_map_contains (stream->cache.m, data);
+ map_slot = pointer_map_contains (cache->m, data);
if (map_slot == NULL)
{
existed_p = false;
@@ -455,7 +454,7 @@ pph_cache_lookup_in_includes (void *data, unsigned *include_ix_p,
found_it = false;
FOR_EACH_VEC_ELT (pph_stream_ptr, pph_read_images, include_ix, include)
- if (pph_cache_lookup (include, data, &ix))
+ if (pph_cache_lookup (&include->cache, data, &ix))
{
found_it = true;
break;
@@ -477,24 +476,23 @@ pph_cache_lookup_in_includes (void *data, unsigned *include_ix_p,
}
-/* Add pointer DATA to the pickle cache in STREAM. If IX_P is not
- NULL, on exit *IX_P will contain the slot number where DATA is
- stored. Return true if DATA already existed in the cache, false
- otherwise. */
+/* Add pointer DATA to CACHE. If IX_P is not NULL, on exit *IX_P will contain
+ the slot number where DATA is stored. Return true if DATA already existed
+ in the CACHE, false otherwise. */
bool
-pph_cache_add (pph_stream *stream, void *data, unsigned *ix_p)
+pph_cache_add (pph_pickle_cache *cache, void *data, unsigned *ix_p)
{
unsigned ix;
bool existed_p;
- if (pph_cache_lookup (stream, data, &ix))
+ if (pph_cache_lookup (cache, data, &ix))
existed_p = true;
else
{
existed_p = false;
- ix = VEC_length (void_p, stream->cache.v);
- pph_cache_insert_at (stream, data, ix);
+ ix = VEC_length (void_p, cache->v);
+ pph_cache_insert_at (cache, data, ix);
}
if (ix_p)
@@ -506,22 +504,22 @@ pph_cache_add (pph_stream *stream, void *data, unsigned *ix_p)
/* Return the pointer at slot IX in STREAM's pickle cache. If INCLUDE_IX
is not -1U, then instead of looking up in STREAM's pickle cache,
- the pointer is looked up in the pickle cache for
- STREAM->INCLUDES[INCLUDE_IX]. */
+ instead of looking up in CACHE, the pointer is looked up in the CACHE of
+ pph_read_images[INCLUDE_IX]. */
void *
-pph_cache_get (pph_stream *stream, unsigned include_ix, unsigned ix)
+pph_cache_get (pph_pickle_cache *cache, unsigned include_ix, unsigned ix)
{
void *data;
- pph_stream *image;
+ pph_pickle_cache *img_cache;
/* Determine which image's pickle cache to use. */
if (include_ix == (unsigned) -1)
- image = stream;
+ img_cache = cache;
else
- image = VEC_index (pph_stream_ptr, pph_read_images, include_ix);
+ img_cache = &VEC_index (pph_stream_ptr, pph_read_images, include_ix)->cache;
- data = VEC_index (void_p, image->cache.v, ix);
+ data = VEC_index (void_p, img_cache->v, ix);
gcc_assert (data);
return data;
}
@@ -223,11 +223,11 @@ void pph_trace_string_with_length (pph_stream *, const char *, unsigned);
void pph_trace_location (pph_stream *, location_t);
void pph_trace_chain (pph_stream *, tree);
void pph_trace_bitpack (pph_stream *, struct bitpack_d *);
-void pph_cache_insert_at (pph_stream *, void *, unsigned);
-bool pph_cache_lookup (pph_stream *, void *, unsigned *);
+void pph_cache_insert_at (pph_pickle_cache *, void *, unsigned);
+bool pph_cache_lookup (pph_pickle_cache *, void *, unsigned *);
bool pph_cache_lookup_in_includes (void *, unsigned *, unsigned *);
-bool pph_cache_add (pph_stream *, void *, unsigned *);
-void *pph_cache_get (pph_stream *, unsigned, unsigned);
+bool pph_cache_add (pph_pickle_cache *, void *, unsigned *);
+void *pph_cache_get (pph_pickle_cache *, unsigned, unsigned);
/* In pph-streamer-out.c. */
void pph_flush_buffers (pph_stream *);