/* This is an index for an exported entity. */
return (*modules)[0];
+ /* Do not include the current TU (not an off-by-one error). */
unsigned pos = 1;
unsigned len = modules->length () - pos;
while (len)
const char *dialect_str;
unsigned num_imports;
unsigned num_partitions;
+ unsigned num_entities;
unsigned ordinary_locs;
unsigned macro_locs;
unsigned ordinary_loc_align;
public:
module_state_config ()
:dialect_str (get_dialect ()),
- num_imports (0), num_partitions (0),
+ num_imports (0), num_partitions (0), num_entities (0),
ordinary_locs (0), macro_locs (0), ordinary_loc_align (0)
{
}
dump () && dump ("Reading entities");
dump.indent ();
- vec_safe_reserve (entity_ary, count);
- unsigned ix;
- for (ix = 0; ix != count; ix++)
+ for (binding_slot *slot = entity_ary->begin () + entity_lwm; count--; slot++)
{
unsigned snum = sec.u ();
if (snum && (snum - lwm) >= (hwm - lwm))
if (sec.get_overrun ())
break;
- binding_slot slot;
- slot.u.binding = NULL_TREE;
if (snum)
- slot.set_lazy (snum << 2);
- entity_ary->quick_push (slot);
+ slot->set_lazy (snum << 2);
}
- entity_num = ix;
dump.outdent ();
if (!sec.end (from ()))
cfg.u (config.num_imports);
cfg.u (config.num_partitions);
+ cfg.u (config.num_entities);
cfg.u (config.ordinary_locs);
cfg.u (config.macro_locs);
config.num_imports = cfg.u ();
config.num_partitions = cfg.u ();
+ config.num_entities = cfg.u ();
config.ordinary_locs = cfg.u ();
config.macro_locs = cfg.u ();
/* Write the entitites. None happens if we contain namespaces or
nothing. */
+ config.num_entities = counts[MSC_entities];
if (counts[MSC_entities])
write_entities (to, sccs, counts[MSC_entities], &crc);
gcc_checking_assert (mod == MODULE_UNKNOWN);
gcc_checking_assert (this != (*modules)[0]);
+ {
+ /* Allocate space in the entities array now -- that array must be
+ monotionically in step with the modules array. */
+ entity_lwm = vec_safe_length (entity_ary);
+ entity_num = config.num_entities;
+ gcc_checking_assert (modules->length () == 1
+ || modules->last ()->entity_lwm <= entity_lwm);
+ vec_safe_reserve (entity_ary, config.num_entities);
+
+ binding_slot slot;
+ slot.u.binding = NULL_TREE;
+ for (unsigned count = config.num_entities; count--;)
+ entity_ary->quick_push (slot);
+ }
+
/* We'll run out of other resources before we run out of module
indices. */
mod = modules->length ();
function_depth++; /* Prevent unexpected GCs. */
- /* Read the entity table. */
- entity_lwm = vec_safe_length (entity_ary);
+ if (counts[MSC_entities] != entity_num)
+ ok = false;
if (ok && counts[MSC_entities]
&& !read_entities (counts[MSC_entities],
counts[MSC_sec_lwm], counts[MSC_sec_hwm]))