Commit 8d8385cf authored by Tristan Gingold's avatar Tristan Gingold

2011-08-01 Tristan Gingold <gingold@adacore.com>

	* frags.c (frag_grow): Simplify the code.
parent d2421a70
2011-08-01 Tristan Gingold <gingold@adacore.com>
* frags.c (frag_grow): Simplify the code.
2011-07-30 Richard Sandiford <rdsandiford@googlemail.com> 2011-07-30 Richard Sandiford <rdsandiford@googlemail.com>
* config/tc-mips.c (nops_for_vr4130): Revert previous commit. * config/tc-mips.c (nops_for_vr4130): Revert previous commit.
......
...@@ -85,31 +85,38 @@ frag_grow (unsigned int nchars) ...@@ -85,31 +85,38 @@ frag_grow (unsigned int nchars)
{ {
if (obstack_room (&frchain_now->frch_obstack) < nchars) if (obstack_room (&frchain_now->frch_obstack) < nchars)
{ {
unsigned int n;
long oldc; long oldc;
long newc;
frag_wane (frag_now);
frag_new (0);
oldc = frchain_now->frch_obstack.chunk_size;
/* Try to allocate a bit more than needed right now. But don't do /* Try to allocate a bit more than needed right now. But don't do
this if we would waste too much memory. Especially necessary this if we would waste too much memory. Especially necessary
for extremely big (like 2GB initialized) frags. */ for extremely big (like 2GB initialized) frags. */
if (nchars < 0x10000) if (nchars < 0x10000)
frchain_now->frch_obstack.chunk_size = 2 * nchars; newc = 2 * nchars;
else else
frchain_now->frch_obstack.chunk_size = nchars + 0x10000; newc = nchars + 0x10000;
frchain_now->frch_obstack.chunk_size += SIZEOF_STRUCT_FRAG; newc += SIZEOF_STRUCT_FRAG;
if (frchain_now->frch_obstack.chunk_size > 0)
while ((n = obstack_room (&frchain_now->frch_obstack)) < nchars /* Check for possible overflow. */
&& (unsigned long) frchain_now->frch_obstack.chunk_size > nchars) if (newc < 0)
{ as_fatal (_("can't extend frag %u chars"), nchars);
frag_wane (frag_now);
frag_new (0); /* Force to allocate at least NEWC bytes. */
} oldc = obstack_chunk_size (&frchain_now->frch_obstack);
frchain_now->frch_obstack.chunk_size = oldc; obstack_chunk_size (&frchain_now->frch_obstack) = newc;
while (obstack_room (&frchain_now->frch_obstack) < nchars)
{
/* Not enough room in this frag. Close it and start a new one.
This must be done in a loop because the created frag may not
be big enough if the current obstack chunk is used. */
frag_wane (frag_now);
frag_new (0);
}
/* Restore the old chunk size. */
obstack_chunk_size (&frchain_now->frch_obstack) = oldc;
} }
if (obstack_room (&frchain_now->frch_obstack) < nchars)
as_fatal (_("can't extend frag %u chars"), nchars);
} }
/* Call this to close off a completed frag, and start up a new (empty) /* Call this to close off a completed frag, and start up a new (empty)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment