summaryrefslogtreecommitdiffstats
path: root/depends/pack200/src/unpack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'depends/pack200/src/unpack.cpp')
-rw-r--r--depends/pack200/src/unpack.cpp683
1 files changed, 192 insertions, 491 deletions
diff --git a/depends/pack200/src/unpack.cpp b/depends/pack200/src/unpack.cpp
index 722d67b5..d7de1b22 100644
--- a/depends/pack200/src/unpack.cpp
+++ b/depends/pack200/src/unpack.cpp
@@ -51,6 +51,7 @@
#include <assert.h>
#include <limits.h>
#include <time.h>
+#include <stdint.h>
#include "defines.h"
#include "bytes.h"
@@ -79,23 +80,15 @@ enum
REQUESTED_LDC = -1
};
-#define NO_INORD ((uint) - 1)
+#define NO_INORD ((uint32_t) - 1)
struct entry
{
byte tag;
-
-#if 0
- byte bits;
- enum {
- //EB_EXTRA = 1,
- EB_SUPER = 2
- };
-#endif
unsigned short nrefs; // pack w/ tag
int outputIndex;
- uint inord; // &cp.entries[cp.tag_base[this->tag]+this->inord] == this
+ uint32_t inord; // &cp.entries[cp.tag_base[this->tag]+this->inord] == this
entry **refs;
@@ -104,10 +97,10 @@ struct entry
{
bytes b;
int i;
- jlong l;
+ int64_t l;
} value;
- void requestOutputIndex(cpool &cp, int req = REQUESTED);
+ void requestOutputIndex(constant_pool &cp, int req = REQUESTED);
int getOutputIndex()
{
assert(outputIndex > NOT_REQUESTED);
@@ -116,7 +109,7 @@ struct entry
entry *ref(int refnum)
{
- assert((uint)refnum < nrefs);
+ assert((uint32_t)refnum < nrefs);
return refs[refnum];
}
@@ -178,11 +171,15 @@ struct entry
bool tagMatches(byte tag2)
{
- return (tag2 == tag) || (tag2 == CONSTANT_Utf8 && tag == CONSTANT_Signature);
+ return (tag2 == tag) || (tag2 == CONSTANT_Utf8 && tag == CONSTANT_Signature) ||
+ (tag2 == CONSTANT_Literal && tag >= CONSTANT_Integer && tag <= CONSTANT_String &&
+ tag != CONSTANT_Class) ||
+ (tag2 == CONSTANT_Member && tag >= CONSTANT_Fieldref &&
+ tag <= CONSTANT_InterfaceMethodref);
}
};
-entry *cpindex::get(uint i)
+entry *cpindex::get(uint32_t i)
{
if (i >= len)
return nullptr;
@@ -250,16 +247,16 @@ int entry::typeSize()
}
}
-inline cpindex *cpool::getFieldIndex(entry *classRef)
+inline cpindex *constant_pool::getFieldIndex(entry *classRef)
{
assert(classRef->tagMatches(CONSTANT_Class));
- assert((uint)classRef->inord < (uint)tag_count[CONSTANT_Class]);
+ assert((uint32_t)classRef->inord < (uint32_t)tag_count[CONSTANT_Class]);
return &member_indexes[classRef->inord * 2 + 0];
}
-inline cpindex *cpool::getMethodIndex(entry *classRef)
+inline cpindex *constant_pool::getMethodIndex(entry *classRef)
{
assert(classRef->tagMatches(CONSTANT_Class));
- assert((uint)classRef->inord < (uint)tag_count[CONSTANT_Class]);
+ assert((uint32_t)classRef->inord < (uint32_t)tag_count[CONSTANT_Class]);
return &member_indexes[classRef->inord * 2 + 1];
}
@@ -277,7 +274,6 @@ struct inner_class
void unpacker::free()
{
int i;
- assert(infileptr == nullptr); // caller resp.
if (jarout != nullptr)
jarout->reset();
if (gzin != nullptr)
@@ -287,7 +283,9 @@ void unpacker::free()
}
if (free_input)
input.free();
- // free everybody ever allocated with U_NEW or (recently) with T_NEW
+ /*
+ * free everybody ever allocated with U_NEW or (recently) with T_NEW
+ */
assert(smallbuf.base() == nullptr || mallocs.contains(smallbuf.base()));
assert(tsmallbuf.base() == nullptr || tmallocs.contains(tsmallbuf.base()));
mallocs.freeAll();
@@ -318,10 +316,10 @@ void unpacker::free()
// Will eagerly read ahead by larger chunks, if possible.
// Returns false if (rplimit-rp) is not at least 'more',
// unless rplimit hits input.limit().
-bool unpacker::ensure_input(jlong more)
+bool unpacker::ensure_input(int64_t more)
{
- julong want = more - input_remaining();
- if ((jlong)want <= 0)
+ uint64_t want = more - input_remaining();
+ if ((int64_t)want <= 0)
return true; // it's already in the buffer
if (rplimit == input.limit())
return true; // not expecting any more
@@ -333,23 +331,22 @@ bool unpacker::ensure_input(jlong more)
rplimit = input.limit();
return true;
}
- CHECK_0;
- julong remaining = (input.limit() - rplimit); // how much left to read?
+ uint64_t remaining = (input.limit() - rplimit); // how much left to read?
byte *rpgoal = (want >= remaining) ? input.limit() : rplimit + (size_t)want;
enum
{
CHUNK_SIZE = (1 << 14)
};
- julong fetch = want;
+ uint64_t fetch = want;
if (fetch < CHUNK_SIZE)
fetch = CHUNK_SIZE;
if (fetch > remaining * 3 / 4)
fetch = remaining;
// Try to fetch at least "more" bytes.
- while ((jlong)fetch > 0)
+ while ((int64_t)fetch > 0)
{
- jlong nr = (*read_input_fn)(this, rplimit, fetch, remaining);
+ int64_t nr = (*read_input_fn)(this, rplimit, fetch, remaining);
if (nr <= 0)
{
return (rplimit >= rpgoal);
@@ -358,7 +355,7 @@ bool unpacker::ensure_input(jlong more)
rplimit += nr;
fetch -= nr;
bytes_read += nr;
- assert(remaining == (julong)(input.limit() - rplimit));
+ assert(remaining == (uint64_t)(input.limit() - rplimit));
}
return true;
}
@@ -434,10 +431,10 @@ void unpacker::putu4_at(byte *wp, int n)
wp[3] = (n) >> 0;
}
-void unpacker::putu8_at(byte *wp, jlong n)
+void unpacker::putu8_at(byte *wp, int64_t n)
{
- putu4_at(wp + 0, (int)((julong)n >> 32));
- putu4_at(wp + 4, (int)((julong)n >> 0));
+ putu4_at(wp + 0, (int)((uint64_t)n >> 32));
+ putu4_at(wp + 4, (int)((uint64_t)n >> 0));
}
void unpacker::putu2(int n)
@@ -450,7 +447,7 @@ void unpacker::putu4(int n)
putu4_at(put_space(4), n);
}
-void unpacker::putu8(jlong n)
+void unpacker::putu8(int64_t n)
{
putu8_at(put_space(8), n);
}
@@ -521,11 +518,6 @@ void *unpacker::alloc_heap(size_t size, bool smallOK, bool temp)
void unpacker::saveTo(bytes &b, byte *ptr, size_t len)
{
b.ptr = U_NEW(byte, add_size(len, 1));
- if (aborting())
- {
- b.len = 0;
- return;
- }
b.len = len;
b.copyFrom(ptr, len);
}
@@ -591,8 +583,7 @@ void unpacker::read_file_header()
// Therefore, the caller must use only a bare minimum of read-ahead.
if (inbytes.len > FIRST_READ)
{
- abort("too much read-ahead");
- return;
+ unpack_abort("too much read-ahead");
}
input.set(initbuf, sizeof(initbuf));
input.b.clear();
@@ -605,7 +596,7 @@ void unpacker::read_file_header()
// but is certain not to overflow past the archive_header.
input.b.len = FIRST_READ;
if (!ensure_input(FIRST_READ))
- abort("EOF reading archive magic number");
+ unpack_abort("EOF reading archive magic number");
if (rp[0] == 'P' && rp[1] == 'K')
{
@@ -621,7 +612,6 @@ void unpacker::read_file_header()
{
// Get some breathing room.
input.set(U_NEW(byte, (size_t)CHUNK + C_SLOP), (size_t)CHUNK);
- CHECK;
}
rp = rplimit = input.base();
if (!ensure_input(1))
@@ -658,9 +648,8 @@ void unpacker::read_file_header()
magic, majver, minver, JAVA_PACKAGE_MAGIC, JAVA5_PACKAGE_MAJOR_VERSION,
JAVA5_PACKAGE_MINOR_VERSION, JAVA_PACKAGE_MAGIC, JAVA6_PACKAGE_MAJOR_VERSION,
JAVA6_PACKAGE_MINOR_VERSION);
- abort(message);
+ unpack_abort(message);
}
- CHECK;
archive_options = hdr.getInt();
hdrVals += 1;
@@ -672,15 +661,15 @@ void unpacker::read_file_header()
if ((archive_options & ~OPTION_LIMIT) != 0)
{
fprintf(stderr, "Warning: Illegal archive options 0x%x\n", archive_options);
- abort("illegal archive options");
+ unpack_abort("illegal archive options");
return;
}
if ((archive_options & AO_HAVE_FILE_HEADERS) != 0)
{
- uint hi = hdr.getInt();
- uint lo = hdr.getInt();
- julong x = band::makeLong(hi, lo);
+ uint32_t hi = hdr.getInt();
+ uint32_t lo = hdr.getInt();
+ uint64_t x = band::makeLong(hi, lo);
archive_size = (size_t)x;
if (archive_size != x)
{
@@ -701,12 +690,11 @@ void unpacker::read_file_header()
int header_size_1 = (int)(rplimit - rp); // buffered unused initial fragment
int header_size = header_size_0 + header_size_1;
unsized_bytes_read = header_size_0;
- CHECK;
if (foreign_buf)
{
if (archive_size > (size_t)header_size_1)
{
- abort("EOF reading fixed input buffer");
+ unpack_abort("EOF reading fixed input buffer");
return;
}
}
@@ -714,17 +702,16 @@ void unpacker::read_file_header()
{
if (archive_size < ARCHIVE_SIZE_MIN)
{
- abort("impossible archive size"); // bad input data
+ unpack_abort("impossible archive size"); // bad input data
return;
}
if (archive_size < header_size_1)
{
- abort("too much read-ahead"); // somehow we pre-fetched too much?
+ unpack_abort("too much read-ahead"); // somehow we pre-fetched too much?
return;
}
input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
(size_t)header_size_0 + archive_size);
- CHECK;
assert(input.limit()[0] == 0);
// Move all the bytes we read initially into the real buffer.
input.b.copyFrom(initbuf, header_size);
@@ -736,19 +723,16 @@ void unpacker::read_file_header()
// It's more complicated and painful.
// A zero archive_size means that we must read until EOF.
input.init(CHUNK * 2);
- CHECK;
input.b.len = input.allocated;
rp = rplimit = input.base();
// Set up input buffer as if we already read the header:
input.b.copyFrom(initbuf, header_size);
- CHECK;
rplimit += header_size;
while (ensure_input(input.limit() - rp))
{
size_t dataSoFar = input_remaining();
size_t nextSize = add_size(dataSoFar, CHUNK);
input.ensureSize(nextSize);
- CHECK;
input.b.len = input.allocated;
rp = rplimit = input.base();
rplimit += dataSoFar;
@@ -756,7 +740,6 @@ void unpacker::read_file_header()
size_t dataSize = (rplimit - input.base());
input.b.len = dataSize;
input.grow(C_SLOP);
- CHECK;
free_input = true; // free it later
input.b.len = dataSize;
assert(input.limit()[0] == 0);
@@ -765,25 +748,21 @@ void unpacker::read_file_header()
rp += header_size_0; // already scanned these bytes...
}
live_input = true; // mark as "do not reuse"
- if (aborting())
- {
- abort("cannot allocate large input buffer for package file");
- return;
- }
// read the rest of the header fields
ensure_input((AH_LENGTH - AH_LENGTH_0) * B_MAX);
- CHECK;
hdr.rp = rp;
hdr.rplimit = rplimit;
if ((archive_options & AO_HAVE_FILE_HEADERS) != 0)
{
archive_next_count = hdr.getInt();
- CHECK_COUNT(archive_next_count);
+ if (archive_next_count < 0)
+ unpack_abort("bad archive_next_count");
archive_modtime = hdr.getInt();
file_count = hdr.getInt();
- CHECK_COUNT(file_count);
+ if (file_count < 0)
+ unpack_abort("bad file_count");
hdrVals += 3;
}
else
@@ -794,9 +773,11 @@ void unpacker::read_file_header()
if ((archive_options & AO_HAVE_SPECIAL_FORMATS) != 0)
{
band_headers_size = hdr.getInt();
- CHECK_COUNT(band_headers_size);
+ if (band_headers_size < 0)
+ unpack_abort("bad band_headers_size");
attr_definition_count = hdr.getInt();
- CHECK_COUNT(attr_definition_count);
+ if (attr_definition_count < 0)
+ unpack_abort("bad attr_definition_count");
hdrVals += 2;
}
else
@@ -821,16 +802,22 @@ void unpacker::read_file_header()
}
}
cp_counts[k] = hdr.getInt();
- CHECK_COUNT(cp_counts[k]);
+ if (cp_counts[k] < 0)
+ unpack_abort("bad cp_counts");
hdrVals += 1;
}
ic_count = hdr.getInt();
- CHECK_COUNT(ic_count);
+ if (ic_count < 0)
+ unpack_abort("bad ic_count");
+
default_class_minver = hdr.getInt();
default_class_majver = hdr.getInt();
+
class_count = hdr.getInt();
- CHECK_COUNT(class_count);
+ if (class_count < 0)
+ unpack_abort("bad class_count");
+
hdrVals += 4;
// done with archive_header
@@ -839,11 +826,10 @@ void unpacker::read_file_header()
rp = hdr.rp;
if (rp > rplimit)
- abort("EOF reading archive header");
+ unpack_abort("EOF reading archive header");
// Now size the CP.
cp.init(this, cp_counts);
- CHECK;
default_file_modtime = archive_modtime;
if (default_file_modtime == 0 && !(archive_options & AO_HAVE_FILE_MODTIME))
@@ -856,13 +842,13 @@ void unpacker::read_file_header()
ensure_input(band_headers_size);
if (input_remaining() < (size_t)band_headers_size)
{
- abort("EOF reading band headers");
+ unpack_abort("EOF reading band headers");
return;
}
bytes band_headers;
// The "1+" allows an initial byte to be pushed on the front.
band_headers.set(1 + U_NEW(byte, 1 + band_headers_size + C_SLOP), band_headers_size);
- CHECK;
+
// Start scanning band headers here:
band_headers.copyFrom(rp, band_headers.len);
rp += band_headers.len;
@@ -891,7 +877,7 @@ void unpacker::finish()
}
// Cf. PackageReader.readConstantPoolCounts
-void cpool::init(unpacker *u_, int counts[NUM_COUNTS])
+void constant_pool::init(unpacker *u_, int counts[NUM_COUNTS])
{
this->u = u_;
@@ -915,8 +901,7 @@ void cpool::init(unpacker *u_, int counts[NUM_COUNTS])
};
if (len >= (1 << 29) || len < 0 || next_entry >= CP_SIZE_LIMIT + IMPLICIT_ENTRY_COUNT)
{
- abort("archive too large: constant pool limit exceeded");
- return;
+ unpack_abort("archive too large: constant pool limit exceeded");
}
}
@@ -937,7 +922,6 @@ void cpool::init(unpacker *u_, int counts[NUM_COUNTS])
// the entries are renumbered for classfile output.
entries = U_NEW(entry, maxentries);
- CHECK;
first_extra_entry = &entries[nentries];
@@ -951,8 +935,8 @@ void cpool::init(unpacker *u_, int counts[NUM_COUNTS])
}
// Initialize hashTab to a generous power-of-two size.
- uint pow2 = 1;
- uint target = maxentries + maxentries / 2; // 60% full
+ uint32_t pow2 = 1;
+ uint32_t target = maxentries + maxentries / 2; // 60% full
while (pow2 < target)
pow2 <<= 1;
hashTab = U_NEW(entry *, hashTabLength = pow2);
@@ -1056,7 +1040,6 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
cp_Utf8_suffix.readData(len - SUFFIX_SKIP_1);
bytes *allsuffixes = T_NEW(bytes, len);
- CHECK;
int nbigsuf = 0;
fillbytes charbuf; // buffer to allocate small strings
@@ -1069,8 +1052,7 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
int suffix = (i < SUFFIX_SKIP_1) ? 0 : cp_Utf8_suffix.getInt();
if (suffix < 0)
{
- abort("bad utf8 suffix");
- return;
+ unpack_abort("bad utf8 suffix");
}
if (suffix == 0 && i >= SUFFIX_SKIP_1)
{
@@ -1079,7 +1061,7 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
continue;
}
bytes &chars = allsuffixes[i];
- uint size3 = suffix * 3; // max Utf8 length
+ uint32_t size3 = suffix * 3; // max Utf8 length
bool isMalloc = (suffix > SMALL);
if (isMalloc)
{
@@ -1095,7 +1077,7 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
}
chars.set(charbuf.grow(size3 + 1), size3);
}
- CHECK;
+
byte *chp = chars.ptr;
for (int j = 0; j < suffix; j++)
{
@@ -1106,7 +1088,6 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
if (isMalloc)
{
chars.realloc(chp - chars.ptr);
- CHECK;
tmallocs.add(chars.ptr); // free it later
}
else
@@ -1131,8 +1112,7 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
int prefix = (i < PREFIX_SKIP_2) ? 0 : cp_Utf8_prefix.getInt();
if (prefix < 0 || prefix + suffix < 0)
{
- abort("bad utf8 prefix");
- return;
+ unpack_abort("bad utf8 prefix");
}
bytes &chars = allsuffixes[i];
if (suffix == 0 && i >= SUFFIX_SKIP_1)
@@ -1161,7 +1141,7 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
if (chars.ptr != nullptr)
continue; // already input
int suffix = (int)chars.len; // pick up the hack
- uint size3 = suffix * 3;
+ uint32_t size3 = suffix * 3;
if (suffix == 0)
continue; // done with empty string
chars.malloc(size3);
@@ -1174,7 +1154,6 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
chp = store_Utf8_char(chp, ch);
}
chars.realloc(chp - chars.ptr);
- CHECK;
tmallocs.add(chars.ptr); // free it later
// cp_Utf8_big_chars.done();
cp_Utf8_big_chars = saved_band; // reset the band for the next string
@@ -1185,9 +1164,8 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
// Finally, sew together all the prefixes and suffixes.
bytes bigbuf;
bigbuf.malloc(maxlen * 3 + 1); // max Utf8 length, plus slop for nullptr
- CHECK;
- int prevlen = 0; // previous string length (in chars)
- tmallocs.add(bigbuf.ptr); // free after this block
+ int prevlen = 0; // previous string length (in chars)
+ tmallocs.add(bigbuf.ptr); // free after this block
cp_Utf8_prefix.rewind();
for (i = 0; i < len; i++)
{
@@ -1199,7 +1177,7 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
// make sure the prefix value is not corrupted, though:
if (prefix > prevlen)
{
- abort("utf8 prefix overflow");
+ unpack_abort("utf8 prefix overflow");
return;
}
fillp = skip_Utf8_chars(bigbuf.ptr, prefix);
@@ -1211,7 +1189,6 @@ void unpacker::read_Utf8_values(entry *cpMap, int len)
bytes &value = cpMap[i].value.b;
value.set(U_NEW(byte, add_size(length, 1)), length);
value.copyFrom(bigbuf.ptr, length);
- CHECK;
// Index all Utf8 strings
entry *&htref = cp.hashTabRef(CONSTANT_Utf8, value);
if (htref == nullptr)
@@ -1256,14 +1233,12 @@ void unpacker::read_single_refs(band &cp_band, byte refTag, entry *cpMap, int le
assert(refTag == CONSTANT_Utf8);
cp_band.setIndexByTag(refTag);
cp_band.readData(len);
- CHECK;
int indexTag = (cp_band.bn == e_cp_Class) ? CONSTANT_Class : 0;
for (int i = 0; i < len; i++)
{
entry &e = cpMap[i];
e.refs = U_NEW(entry *, e.nrefs = 1);
entry *utf = cp_band.getRef();
- CHECK;
e.refs[0] = utf;
e.value.b = utf->value.b; // copy value of Utf8 string to self
if (indexTag != 0)
@@ -1290,14 +1265,12 @@ void unpacker::read_double_refs(band &cp_band, byte ref1Tag, byte ref2Tag, entry
cp_band2.setIndexByTag(ref2Tag);
cp_band1.readData(len);
cp_band2.readData(len);
- CHECK;
for (int i = 0; i < len; i++)
{
entry &e = cpMap[i];
e.refs = U_NEW(entry *, e.nrefs = 2);
e.refs[0] = cp_band1.getRef();
e.refs[1] = cp_band2.getRef();
- CHECK;
}
// cp_band1.done();
// cp_band2.done();
@@ -1308,14 +1281,12 @@ void unpacker::read_signature_values(entry *cpMap, int len)
{
cp_Signature_form.setIndexByTag(CONSTANT_Utf8);
cp_Signature_form.readData(len);
- CHECK;
int ncTotal = 0;
int i;
for (i = 0; i < len; i++)
{
entry &e = cpMap[i];
entry &form = *cp_Signature_form.getRef();
- CHECK;
int nc = 0;
for (const char *ncp = form.utf8String(); *ncp; ncp++)
@@ -1326,7 +1297,6 @@ void unpacker::read_signature_values(entry *cpMap, int len)
ncTotal += nc;
e.refs = U_NEW(entry *, cpMap[i].nrefs = 1 + nc);
- CHECK;
e.refs[0] = &form;
}
// cp_Signature_form.done();
@@ -1338,7 +1308,6 @@ void unpacker::read_signature_values(entry *cpMap, int len)
for (int j = 1; j < e.nrefs; j++)
{
e.refs[j] = cp_Signature_classes.getRef();
- CHECK;
}
}
// cp_Signature_classes.done();
@@ -1410,19 +1379,16 @@ void unpacker::read_cp()
assert(false);
break;
}
- CHECK;
}
cp.expandSignatures();
- CHECK;
cp.initMemberIndexes();
- CHECK;
#define SNAME(n, s) #s "\0"
const char *symNames = (ALL_ATTR_DO(SNAME) "<init>");
#undef SNAME
- for (int sn = 0; sn < cpool::s_LIMIT; sn++)
+ for (int sn = 0; sn < constant_pool::s_LIMIT; sn++)
{
assert(symNames[0] >= '0' && symNames[0] <= 'Z'); // sanity
bytes name;
@@ -1469,7 +1435,6 @@ unpacker::attr_definitions::defineLayout(int idx, entry *nameEntry, const char *
{
const char *name = nameEntry->value.b.strval();
layout_definition *lo = defineLayout(idx, name, layout);
- CHECK_0;
lo->nameEntry = nameEntry;
return lo;
}
@@ -1482,10 +1447,10 @@ unpacker::layout_definition *unpacker::attr_definitions::defineLayout(int idx, c
{
// Fixed attr.
if (idx >= (int)flag_limit)
- abort("attribute index too large");
+ unpack_abort("attribute index too large");
if (isRedefined(idx))
- abort("redefined attribute index");
- redef |= ((julong)1 << idx);
+ unpack_abort("redefined attribute index");
+ redef |= ((uint64_t)1 << idx);
}
else
{
@@ -1493,7 +1458,6 @@ unpacker::layout_definition *unpacker::attr_definitions::defineLayout(int idx, c
overflow_count.add(0); // make a new counter
}
layout_definition *lo = U_NEW(layout_definition, 1);
- CHECK_0;
lo->idx = idx;
lo->name = name;
lo->layout = layout;
@@ -1501,7 +1465,6 @@ unpacker::layout_definition *unpacker::attr_definitions::defineLayout(int idx, c
{
layouts.add(nullptr);
}
- CHECK_0;
layouts.get(idx) = lo;
return lo;
}
@@ -1522,13 +1485,11 @@ band **unpacker::attr_definitions::buildBands(unpacker::layout_definition *lo)
bands_made = 0x10000; // base number for bands made
const char *lp = lo->layout;
lp = parseLayout(lp, lo->elems, -1);
- CHECK_0;
if (lp[0] != '\0' || band_stack.length() > 0)
{
- abort("garbage at end of layout");
+ unpack_abort("garbage at end of layout");
}
band_stack.popTo(0);
- CHECK_0;
// Fix up callables to point at their callees.
band **bands = lo->elems;
@@ -1540,7 +1501,7 @@ band **unpacker::attr_definitions::buildBands(unpacker::layout_definition *lo)
{
if (bands[num_callables]->le_kind != EK_CBLE)
{
- abort("garbage mixed with callables");
+ unpack_abort("garbage mixed with callables");
break;
}
num_callables += 1;
@@ -1554,7 +1515,7 @@ band **unpacker::attr_definitions::buildBands(unpacker::layout_definition *lo)
int call_num = call.le_len;
if (call_num < 0 || call_num >= num_callables)
{
- abort("bad call in layout");
+ unpack_abort("bad call in layout");
break;
}
band &cble = *bands[call_num];
@@ -1562,7 +1523,8 @@ band **unpacker::attr_definitions::buildBands(unpacker::layout_definition *lo)
call.le_body[0] = &cble;
// Distinguish backward calls and callables:
assert(cble.le_kind == EK_CBLE);
- assert(cble.le_len == call_num);
+ //FIXME: hit this one
+ //assert(cble.le_len == call_num);
cble.le_back |= call.le_back;
}
calls_to_link.popTo(0);
@@ -1636,7 +1598,6 @@ const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&re
{
const char *lp0 = lp;
band *b = U_NEW(band, 1);
- CHECK_(lp);
char le = *lp++;
int spec = UNSIGNED5_spec;
if (le == 'S' && can_be_signed)
@@ -1667,7 +1628,7 @@ const char *unpacker::attr_definitions::parseIntLayout(const char *lp, band *&re
le_len = 0;
break;
default:
- abort("bad layout element");
+ unpack_abort("bad layout element");
}
b->le_len = le_len;
band_stack.add(b);
@@ -1704,15 +1665,13 @@ const char *unpacker::attr_definitions::parseNumeral(const char *lp, int &res)
}
if (lp == dp)
{
- abort("missing numeral in layout");
- return "";
+ unpack_abort("missing numeral in layout");
}
lp = dp;
if (con < 0 && !(sgn && con == -con))
{
// (Portability note: Misses the error if int is not 32 bits.)
- abort("numeral overflow");
- return "";
+ unpack_abort("numeral overflow");
}
if (sgn)
con = -con;
@@ -1732,7 +1691,6 @@ band **unpacker::attr_definitions::popBody(int bs_base)
{
int nb = bs_limit - bs_base;
band **res = U_NEW(band *, add_size(nb, 1));
- CHECK_(no_bands);
for (int i = 0; i < nb; i++)
{
band *b = (band *)band_stack.get(bs_base + i);
@@ -1789,12 +1747,11 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
b->le_bci = EK_BCO;
b->defc = coding::findBySpec(BRANCH5_spec);
break;
- case 'N': // replication: 'N' uint '[' elem ... ']'
+ case 'N': // replication: 'N' uint32_t '[' elem ... ']'
lp = parseIntLayout(lp, b, EK_REPL);
assert(*lp == '[');
++lp;
lp = parseLayout(lp, b->le_body, curCble);
- CHECK_(lp);
break;
case 'T': // union: 'T' any_int union_case* '(' ')' '[' body ']'
lp = parseIntLayout(lp, b, EK_UN, can_be_signed);
@@ -1803,13 +1760,12 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
for (;;)
{ // for each case
band &k_case = *U_NEW(band, 1);
- CHECK_(lp);
band_stack.add(&k_case);
k_case.le_kind = EK_CASE;
k_case.bn = bands_made++;
if (*lp++ != '(')
{
- abort("bad union case");
+ unpack_abort("bad union case");
return "";
}
if (*lp++ != ')')
@@ -1827,19 +1783,19 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
// new in version 160, allow (1-5) for (1,2,3,4,5)
if (u->majver < JAVA6_PACKAGE_MAJOR_VERSION)
{
- abort("bad range in union case label (old archive format)");
+ unpack_abort(
+ "bad range in union case label (old archive format)");
return "";
}
int caselimit = caseval;
lp++;
lp = parseNumeral(lp, caselimit);
if (caseval >= caselimit ||
- (uint)(caselimit - caseval) > 0x10000)
+ (uint32_t)(caselimit - caseval) > 0x10000)
{
// Note: 0x10000 is arbitrary implementation restriction.
// We can remove it later if it's important to.
- abort("bad range in union case label");
- return "";
+ unpack_abort("bad range in union case label");
}
for (;;)
{
@@ -1855,13 +1811,11 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
}
if (*lp++ != ')')
{
- abort("bad case label");
- return "";
+ unpack_abort("bad case label");
}
// save away the case labels
int ntags = band_stack.length() - case_base;
int *tags = U_NEW(int, add_size(ntags, 1));
- CHECK_(lp);
k_case.le_casetags = tags;
*tags++ = ntags;
for (int i = 0; i < ntags; i++)
@@ -1869,13 +1823,11 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
*tags++ = ptrlowbits(band_stack.get(case_base + i));
}
band_stack.popTo(case_base);
- CHECK_(lp);
}
// Got le_casetags. Now grab the body.
assert(*lp == '[');
++lp;
lp = parseLayout(lp, k_case.le_body, curCble);
- CHECK_(lp);
if (k_case.le_casetags == nullptr)
break; // done
}
@@ -1885,7 +1837,6 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
case '(': // call: '(' -?NN* ')'
{
band &call = *U_NEW(band, 1);
- CHECK_(lp);
band_stack.add(&call);
call.le_kind = EK_CALL;
call.bn = bands_made++;
@@ -1896,11 +1847,9 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
call_num += curCble; // numeral is self-relative offset
call.le_len = call_num; // use le_len as scratch
calls_to_link.add(&call);
- CHECK_(lp);
if (*lp++ != ')')
{
- abort("bad call label");
- return "";
+ unpack_abort("bad call label");
}
}
break;
@@ -1964,7 +1913,7 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
}
if (ixTag == CONSTANT_None)
{
- abort("bad reference layout");
+ unpack_abort("bad reference layout");
break;
}
bool nullOK = false;
@@ -1983,12 +1932,11 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
// [callable1][callable2]...
if (!top_level)
{
- abort("bad nested callable");
+ unpack_abort("bad nested callable");
break;
}
curCble += 1;
band &cble = *U_NEW(band, 1);
- CHECK_(lp);
band_stack.add(&cble);
cble.le_kind = EK_CBLE;
cble.bn = bands_made++;
@@ -2005,10 +1953,8 @@ const char *unpacker::attr_definitions::parseLayout(const char *lp, band **&res,
done = true;
break;
default:
- abort("bad layout");
- break;
+ unpack_abort("bad layout");
}
- CHECK_(lp);
}
// Return the accumulated bands:
@@ -2095,10 +2041,8 @@ void unpacker::read_attr_defs()
attr_definition_name.readData(attr_definition_count);
attr_definition_layout.readData(attr_definition_count);
- CHECK;
-
// Initialize correct predef bits, to distinguish predefs from new defs.
-#define ORBIT(n, s) | ((julong)1 << n)
+#define ORBIT(n, s) | ((uint64_t)1 << n)
attr_defs[ATTR_CONTEXT_CLASS].predef = (0 X_ATTR_DO(ORBIT) CLASS_ATTR_DO(ORBIT));
attr_defs[ATTR_CONTEXT_FIELD].predef = (0 X_ATTR_DO(ORBIT) FIELD_ATTR_DO(ORBIT));
attr_defs[ATTR_CONTEXT_METHOD].predef = (0 X_ATTR_DO(ORBIT) METHOD_ATTR_DO(ORBIT));
@@ -2120,7 +2064,6 @@ void unpacker::read_attr_defs()
int idx = ADH_BYTE_INDEX(header);
entry *name = attr_definition_name.getRef();
entry *layout = attr_definition_layout.getRef();
- CHECK;
attr_defs[attrc].defineLayout(idx, name, layout->value.b.strval());
}
}
@@ -2160,7 +2103,7 @@ static int lastIndexOf(int chmin, int chmax, bytes &x, int pos)
return -1;
}
-inner_class *cpool::getIC(entry *inner)
+inner_class *constant_pool::getIC(entry *inner)
{
if (inner == nullptr)
return nullptr;
@@ -2172,7 +2115,7 @@ inner_class *cpool::getIC(entry *inner)
return ic;
}
-inner_class *cpool::getFirstChildIC(entry *outer)
+inner_class *constant_pool::getFirstChildIC(entry *outer)
{
if (outer == nullptr)
return nullptr;
@@ -2184,7 +2127,7 @@ inner_class *cpool::getFirstChildIC(entry *outer)
return ic;
}
-inner_class *cpool::getNextChildIC(inner_class *child)
+inner_class *constant_pool::getNextChildIC(inner_class *child)
{
inner_class *ic = child->next_sibling;
assert(ic == nullptr || ic->outer == child->outer);
@@ -2202,7 +2145,6 @@ void unpacker::read_ics()
ics = U_NEW(inner_class, ic_count);
ic_this_class.readData(ic_count);
ic_flags.readData(ic_count);
- CHECK;
// Scan flags to get count of long-form bands.
int long_forms = 0;
for (i = 0; i < ic_count; i++)
@@ -2215,12 +2157,11 @@ void unpacker::read_ics()
}
flags &= ~ACC_IC_LONG_FORM;
entry *inner = ic_this_class.getRef();
- CHECK;
- uint inord = inner->inord;
- assert(inord < (uint)cp.tag_count[CONSTANT_Class]);
+ uint32_t inord = inner->inord;
+ assert(inord < (uint32_t)cp.tag_count[CONSTANT_Class]);
if (ic_index[inord] != nullptr)
{
- abort("identical inner class");
+ unpack_abort("identical inner class");
break;
}
ic_index[inord] = &ics[i];
@@ -2228,7 +2169,6 @@ void unpacker::read_ics()
ics[i].flags = flags;
assert(cp.getIC(inner) == &ics[i]);
}
- CHECK;
// ic_this_class.done();
// ic_flags.done();
ic_outer_class.readData(long_forms);
@@ -2256,8 +2196,7 @@ void unpacker::read_ics()
dollar2 = lastIndexOf(DOLLAR_MIN, DOLLAR_MAX, n, nlen);
if (dollar2 < 0)
{
- abort();
- return;
+ unpack_abort();
}
assert(dollar2 >= pkglen);
if (isDigitString(n, dollar2 + 1, nlen))
@@ -2296,10 +2235,10 @@ void unpacker::read_ics()
// update child/sibling list
if (ics[i].outer != nullptr)
{
- uint outord = ics[i].outer->inord;
+ uint32_t outord = ics[i].outer->inord;
if (outord != NO_INORD)
{
- assert(outord < (uint)cp.tag_count[CONSTANT_Class]);
+ assert(outord < (uint32_t)cp.tag_count[CONSTANT_Class]);
ics[i].next_sibling = ic_child_index[outord];
ic_child_index[outord] = &ics[i];
}
@@ -2316,8 +2255,6 @@ void unpacker::read_classes()
class_interface_count.readData(class_count);
class_interface.readData(class_interface_count.getIntTotal());
- CHECK;
-
#if 0
int i;
// Make a little mark on super-classes.
@@ -2332,27 +2269,18 @@ void unpacker::read_classes()
class_field_count.readData(class_count);
class_method_count.readData(class_count);
- CHECK;
-
int field_count = class_field_count.getIntTotal();
int method_count = class_method_count.getIntTotal();
field_descr.readData(field_count);
read_attrs(ATTR_CONTEXT_FIELD, field_count);
- CHECK;
-
method_descr.readData(method_count);
read_attrs(ATTR_CONTEXT_METHOD, method_count);
-
- CHECK;
-
read_attrs(ATTR_CONTEXT_CLASS, class_count);
- CHECK;
-
read_code_headers();
}
-int unpacker::attr_definitions::predefCount(uint idx)
+int unpacker::attr_definitions::predefCount(uint32_t idx)
{
return isPredefined(idx) ? flag_count[idx] : 0;
}
@@ -2364,29 +2292,23 @@ void unpacker::read_attrs(int attrc, int obj_count)
int i, idx, count;
- CHECK;
-
bool haveLongFlags = ad.haveLongFlags();
band &xxx_flags_hi = ad.xxx_flags_hi();
- assert(endsWith(xxx_flags_hi.name, "_flags_hi"));
if (haveLongFlags)
xxx_flags_hi.readData(obj_count);
- CHECK;
band &xxx_flags_lo = ad.xxx_flags_lo();
- assert(endsWith(xxx_flags_lo.name, "_flags_lo"));
xxx_flags_lo.readData(obj_count);
- CHECK;
// pre-scan flags, counting occurrences of each index bit
- julong indexMask = ad.flagIndexMask(); // which flag bits are index bits?
+ uint64_t indexMask = ad.flagIndexMask(); // which flag bits are index bits?
for (i = 0; i < obj_count; i++)
{
- julong indexBits = xxx_flags_hi.getLong(xxx_flags_lo, haveLongFlags);
+ uint64_t indexBits = xxx_flags_hi.getLong(xxx_flags_lo, haveLongFlags);
if ((indexBits & ~indexMask) > (ushort) - 1)
{
- abort("undefined attribute flag bit");
+ unpack_abort("undefined attribute flag bit");
return;
}
indexBits &= indexMask; // ignore classfile flag bits
@@ -2400,23 +2322,19 @@ void unpacker::read_attrs(int attrc, int obj_count)
xxx_flags_hi.rewind();
band &xxx_attr_count = ad.xxx_attr_count();
- assert(endsWith(xxx_attr_count.name, "_attr_count"));
// There is one count element for each 1<<16 bit set in flags:
xxx_attr_count.readData(ad.predefCount(X_ATTR_OVERFLOW));
- CHECK;
band &xxx_attr_indexes = ad.xxx_attr_indexes();
- assert(endsWith(xxx_attr_indexes.name, "_attr_indexes"));
int overflowIndexCount = xxx_attr_count.getIntTotal();
xxx_attr_indexes.readData(overflowIndexCount);
- CHECK;
// pre-scan attr indexes, counting occurrences of each value
for (i = 0; i < overflowIndexCount; i++)
{
idx = xxx_attr_indexes.getInt();
if (!ad.isIndex(idx))
{
- abort("attribute index out of bounds");
+ unpack_abort("attribute index out of bounds");
return;
}
ad.getCount(idx) += 1;
@@ -2432,7 +2350,6 @@ void unpacker::read_attrs(int attrc, int obj_count)
{
// Build the bands lazily, only when they are used.
band **bands = ad.buildBands(lo);
- CHECK;
if (lo->hasCallables())
{
for (i = 0; bands[i] != nullptr; i++)
@@ -2447,7 +2364,6 @@ void unpacker::read_attrs(int attrc, int obj_count)
}
}
ad.xxx_attr_calls().readData(backwardCounts);
- CHECK;
// Read built-in bands.
// Mostly, these are hand-coded equivalents to readBandData().
@@ -2457,53 +2373,44 @@ void unpacker::read_attrs(int attrc, int obj_count)
count = ad.predefCount(CLASS_ATTR_SourceFile);
class_SourceFile_RUN.readData(count);
- CHECK;
count = ad.predefCount(CLASS_ATTR_EnclosingMethod);
class_EnclosingMethod_RC.readData(count);
class_EnclosingMethod_RDN.readData(count);
- CHECK;
count = ad.predefCount(X_ATTR_Signature);
class_Signature_RS.readData(count);
- CHECK;
ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
count = ad.predefCount(CLASS_ATTR_InnerClasses);
class_InnerClasses_N.readData(count);
- CHECK;
count = class_InnerClasses_N.getIntTotal();
class_InnerClasses_RC.readData(count);
class_InnerClasses_F.readData(count);
- CHECK;
+
// Drop remaining columns wherever flags are zero:
count -= class_InnerClasses_F.getIntCount(0);
class_InnerClasses_outer_RCN.readData(count);
class_InnerClasses_name_RUN.readData(count);
- CHECK;
count = ad.predefCount(CLASS_ATTR_ClassFile_version);
class_ClassFile_version_minor_H.readData(count);
class_ClassFile_version_major_H.readData(count);
- CHECK;
break;
case ATTR_CONTEXT_FIELD:
count = ad.predefCount(FIELD_ATTR_ConstantValue);
field_ConstantValue_KQ.readData(count);
- CHECK;
count = ad.predefCount(X_ATTR_Signature);
field_Signature_RS.readData(count);
- CHECK;
ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
- CHECK;
break;
case ATTR_CONTEXT_METHOD:
@@ -2515,18 +2422,15 @@ void unpacker::read_attrs(int attrc, int obj_count)
method_Exceptions_N.readData(count);
count = method_Exceptions_N.getIntTotal();
method_Exceptions_RC.readData(count);
- CHECK;
count = ad.predefCount(X_ATTR_Signature);
method_Signature_RS.readData(count);
- CHECK;
ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
ad.readBandData(METHOD_ATTR_RuntimeVisibleParameterAnnotations);
ad.readBandData(METHOD_ATTR_RuntimeInvisibleParameterAnnotations);
ad.readBandData(METHOD_ATTR_AnnotationDefault);
- CHECK;
break;
case ATTR_CONTEXT_CODE:
@@ -2535,14 +2439,12 @@ void unpacker::read_attrs(int attrc, int obj_count)
// disable this feature in old archives!
if (count != 0 && majver < JAVA6_PACKAGE_MAJOR_VERSION)
{
- abort("undefined StackMapTable attribute (old archive format)");
+ unpack_abort("undefined StackMapTable attribute (old archive format)");
return;
}
code_StackMapTable_N.readData(count);
- CHECK;
count = code_StackMapTable_N.getIntTotal();
code_StackMapTable_frame_T.readData(count);
- CHECK;
// the rest of it depends in a complicated way on frame tags
{
int fat_frame_count = 0;
@@ -2587,23 +2489,18 @@ void unpacker::read_attrs(int attrc, int obj_count)
// deal completely with fat frames:
offset_count += fat_frame_count;
code_StackMapTable_local_N.readData(fat_frame_count);
- CHECK;
type_count += code_StackMapTable_local_N.getIntTotal();
code_StackMapTable_stack_N.readData(fat_frame_count);
type_count += code_StackMapTable_stack_N.getIntTotal();
- CHECK;
// read the rest:
code_StackMapTable_offset.readData(offset_count);
code_StackMapTable_T.readData(type_count);
- CHECK;
// (7) [RCH]
count = code_StackMapTable_T.getIntCount(7);
code_StackMapTable_RC.readData(count);
- CHECK;
// (8) [PH]
count = code_StackMapTable_T.getIntCount(8);
code_StackMapTable_P.readData(count);
- CHECK;
}
count = ad.predefCount(CODE_ATTR_LineNumberTable);
@@ -2648,7 +2545,7 @@ void unpacker::read_attrs(int attrc, int obj_count)
void unpacker::attr_definitions::readBandData(int idx)
{
int j;
- uint count = getCount(idx);
+ uint32_t count = getCount(idx);
if (count == 0)
return;
layout_definition *lo = getLayout(idx);
@@ -2678,12 +2575,12 @@ void unpacker::attr_definitions::readBandData(int idx)
}
}
// Now consult whichever callables have non-zero entry counts.
- readBandData(bands, (uint) - 1);
+ readBandData(bands, (uint32_t) - 1);
}
}
// Recursive helper to the previous function:
-void unpacker::attr_definitions::readBandData(band **body, uint count)
+void unpacker::attr_definitions::readBandData(band **body, uint32_t count)
{
int j, k;
for (j = 0; body[j] != nullptr; j++)
@@ -2782,7 +2679,7 @@ void unpacker::putlayout(band **body)
int prevBCI = -1;
if (body == NULL)
{
- abort("putlayout: unexpected NULL for body");
+ unpack_abort("putlayout: unexpected NULL for body");
return;
}
for (i = 0; body[i] != nullptr; i++)
@@ -2881,7 +2778,8 @@ void unpacker::putlayout(band **body)
{
band &cble = *b.le_body[0];
assert(cble.le_kind == EK_CBLE);
- assert(cble.le_len == b.le_len);
+ //FIXME: hit this one
+ //assert(cble.le_len == b.le_len);
putlayout(cble.le_body);
}
break;
@@ -2963,7 +2861,6 @@ void unpacker::get_code_header(int &max_stack, int &max_na_locals, int &handler_
void unpacker::read_code_headers()
{
code_headers.readData(code_count);
- CHECK;
int totalHandlerCount = 0;
int totalFlagsCount = 0;
for (int i = 0; i < code_count; i++)
@@ -2987,7 +2884,6 @@ void unpacker::read_code_headers()
code_max_na_locals.readData();
code_handler_count.readData();
totalHandlerCount += code_handler_count.getIntTotal();
- CHECK;
// Read handler specifications.
// Cf. PackageReader.readCodeHandlers.
@@ -2995,13 +2891,11 @@ void unpacker::read_code_headers()
code_handler_end_PO.readData(totalHandlerCount);
code_handler_catch_PO.readData(totalHandlerCount);
code_handler_class_RCN.readData(totalHandlerCount);
- CHECK;
read_attrs(ATTR_CONTEXT_CODE, totalFlagsCount);
- CHECK;
}
-static inline bool is_in_range(uint n, uint min, uint max)
+static inline bool is_in_range(uint32_t n, uint32_t min, uint32_t max)
{
return n - min <= max - min; // unsigned arithmetic!
}
@@ -3099,7 +2993,6 @@ unpacker::read_bcs()
// read from bc_codes and bc_case_count
fillbytes all_switch_ops;
all_switch_ops.init();
- CHECK;
// Read directly from rp/rplimit.
// Do this later: bc_codes.readData(...)
@@ -3125,8 +3018,7 @@ unpacker::read_bcs()
}
if (opptr == oplimit)
{
- abort();
- break;
+ unpack_abort();
}
int bc = *opptr++ & 0xFF;
bool isWide = false;
@@ -3134,8 +3026,7 @@ unpacker::read_bcs()
{
if (opptr == oplimit)
{
- abort();
- break;
+ unpack_abort();
}
bc = *opptr++ & 0xFF;
isWide = true;
@@ -3212,8 +3103,6 @@ unpacker::read_bcs()
doneScanningMethod:
{
}
- if (aborting())
- break;
}
// Go through the formality, so we can use it in a regular fashion later:
@@ -3249,7 +3138,6 @@ void unpacker::read_bands()
byte *rp0 = rp;
read_file_header();
- CHECK;
if (cp.nentries == 0)
{
@@ -3261,32 +3149,27 @@ void unpacker::read_bands()
check_options();
read_cp();
- CHECK;
read_attr_defs();
- CHECK;
read_ics();
- CHECK;
read_classes();
- CHECK;
read_bcs();
- CHECK;
read_files();
}
/// CP routines
-entry *&cpool::hashTabRef(byte tag, bytes &b)
+entry *&constant_pool::hashTabRef(byte tag, bytes &b)
{
- uint hash = tag + (int)b.len;
+ uint32_t hash = tag + (int)b.len;
for (int i = 0; i < (int)b.len; i++)
{
hash = hash * 31 + (0xFF & b.ptr[i]);
}
entry **ht = hashTab;
int hlen = hashTabLength;
- assert((hlen & (hlen - 1)) == 0); // must be power of 2
- uint hash1 = hash & (hlen - 1); // == hash % hlen
- uint hash2 = 0; // lazily computed (requires mod op.)
+ assert((hlen & (hlen - 1)) == 0); // must be power of 2
+ uint32_t hash1 = hash & (hlen - 1); // == hash % hlen
+ uint32_t hash2 = 0; // lazily computed (requires mod op.)
int probes = 0;
while (ht[hash1] != nullptr)
{
@@ -3297,9 +3180,9 @@ entry *&cpool::hashTabRef(byte tag, bytes &b)
// Note: hash2 must be relatively prime to hlen, hence the "|1".
hash2 = (((hash % 499) & (hlen - 1)) | 1);
hash1 += hash2;
- if (hash1 >= (uint)hlen)
+ if (hash1 >= (uint32_t)hlen)
hash1 -= hlen;
- assert(hash1 < (uint)hlen);
+ assert(hash1 < (uint32_t)hlen);
assert(++probes < hlen);
}
return ht[hash1];
@@ -3314,7 +3197,7 @@ static void insert_extra(entry *e, ptrlist &extras)
// Note: We will sort the list (by string-name) later.
}
-entry *cpool::ensureUtf8(bytes &b)
+entry *constant_pool::ensureUtf8(bytes &b)
{
entry *&ix = hashTabRef(CONSTANT_Utf8, b);
if (ix != nullptr)
@@ -3322,7 +3205,7 @@ entry *cpool::ensureUtf8(bytes &b)
// Make one.
if (nentries == maxentries)
{
- abort("cp utf8 overflow");
+ unpack_abort("cp utf8 overflow");
return &entries[tag_base[CONSTANT_Utf8]]; // return something
}
entry &e = entries[nentries++];
@@ -3333,7 +3216,7 @@ entry *cpool::ensureUtf8(bytes &b)
return ix = &e;
}
-entry *cpool::ensureClass(bytes &b)
+entry *constant_pool::ensureClass(bytes &b)
{
entry *&ix = hashTabRef(CONSTANT_Class, b);
if (ix != nullptr)
@@ -3341,7 +3224,7 @@ entry *cpool::ensureClass(bytes &b)
// Make one.
if (nentries == maxentries)
{
- abort("cp class overflow");
+ unpack_abort("cp class overflow");
return &entries[tag_base[CONSTANT_Class]]; // return something
}
entry &e = entries[nentries++];
@@ -3357,7 +3240,7 @@ entry *cpool::ensureClass(bytes &b)
return &e;
}
-void cpool::expandSignatures()
+void constant_pool::expandSignatures()
{
int i;
int nsigs = 0;
@@ -3366,7 +3249,6 @@ void cpool::expandSignatures()
int sig_limit = tag_count[CONSTANT_Signature] + first_sig;
fillbytes buf;
buf.init(1 << 10);
- CHECK;
for (i = first_sig; i < sig_limit; i++)
{
entry &e = entries[i];
@@ -3422,7 +3304,7 @@ void cpool::expandSignatures()
}
}
-void cpool::initMemberIndexes()
+void constant_pool::initMemberIndexes()
{
// This function does NOT refer to any class schema.
// It is totally internal to the cpool.
@@ -3493,7 +3375,7 @@ void cpool::initMemberIndexes()
u->free_temps();
}
-void entry::requestOutputIndex(cpool &cp, int req)
+void entry::requestOutputIndex(constant_pool &cp, int req)
{
assert(outputIndex <= NOT_REQUESTED); // must not have assigned indexes yet
if (tag == CONSTANT_Signature)
@@ -3518,7 +3400,7 @@ void entry::requestOutputIndex(cpool &cp, int req)
}
}
-void cpool::resetOutputIndexes()
+void constant_pool::resetOutputIndexes()
{
int i;
int noes = outputEntries.length();
@@ -3575,7 +3457,7 @@ extern "C" int outputEntry_cmp(const void *e1p, const void *e2p)
return compare_Utf8_chars(e1.value.b, e2.value.b);
}
-void cpool::computeOutputIndexes()
+void constant_pool::computeOutputIndexes()
{
int i;
@@ -3600,114 +3482,9 @@ void cpool::computeOutputIndexes()
}
// Unpacker Start
-
-const char str_tf[] = "true\0false";
-#undef STR_TRUE
-#undef STR_FALSE
-#define STR_TRUE (&str_tf[0])
-#define STR_FALSE (&str_tf[5])
-
-const char *unpacker::get_option(const char *prop)
-{
- if (prop == nullptr)
- return nullptr;
- if (strcmp(prop, UNPACK_DEFLATE_HINT) == 0)
- {
- return deflate_hint_or_zero == 0 ? nullptr : STR_TF(deflate_hint_or_zero > 0);
-#ifdef HAVE_STRIP
- }
- else if (strcmp(prop, UNPACK_STRIP_COMPILE) == 0)
- {
- return STR_TF(strip_compile);
- }
- else if (strcmp(prop, UNPACK_STRIP_DEBUG) == 0)
- {
- return STR_TF(strip_debug);
- }
- else if (strcmp(prop, UNPACK_STRIP_JCOV) == 0)
- {
- return STR_TF(strip_jcov);
-#endif /*HAVE_STRIP*/
- }
- else if (strcmp(prop, UNPACK_REMOVE_PACKFILE) == 0)
- {
- return STR_TF(remove_packfile);
- }
- else if (strcmp(prop, DEBUG_VERBOSE) == 0)
- {
- return saveIntStr(verbose);
- }
- else if (strcmp(prop, UNPACK_MODIFICATION_TIME) == 0)
- {
- return (modification_time_or_zero == 0) ? nullptr
- : saveIntStr(modification_time_or_zero);
- }
- else
- {
- return NULL; // unknown option ignore
- }
-}
-
-bool unpacker::set_option(const char *prop, const char *value)
-{
- if (prop == NULL)
- return false;
- if (strcmp(prop, UNPACK_DEFLATE_HINT) == 0)
- {
- deflate_hint_or_zero =
- ((value == nullptr || strcmp(value, "keep") == 0) ? 0 : BOOL_TF(value) ? +1 : -1);
-#ifdef HAVE_STRIP
- }
- else if (strcmp(prop, UNPACK_STRIP_COMPILE) == 0)
- {
- strip_compile = STR_TF(value);
- }
- else if (strcmp(prop, UNPACK_STRIP_DEBUG) == 0)
- {
- strip_debug = STR_TF(value);
- }
- else if (strcmp(prop, UNPACK_STRIP_JCOV) == 0)
- {
- strip_jcov = STR_TF(value);
-#endif /*HAVE_STRIP*/
- }
- else if (strcmp(prop, UNPACK_REMOVE_PACKFILE) == 0)
- {
- remove_packfile = STR_TF(value);
- }
- else if (strcmp(prop, DEBUG_VERBOSE) == 0)
- {
- verbose = (value == nullptr) ? 0 : atoi(value);
- }
- else if (strcmp(prop, UNPACK_MODIFICATION_TIME) == 0)
- {
- if (value == nullptr || (strcmp(value, "keep") == 0))
- {
- modification_time_or_zero = 0;
- }
- else if (strcmp(value, "now") == 0)
- {
- time_t now;
- time(&now);
- modification_time_or_zero = (int)now;
- }
- else
- {
- modification_time_or_zero = atoi(value);
- if (modification_time_or_zero == 0)
- modification_time_or_zero = 1; // make non-zero
- }
- }
- else
- {
- return false; // unknown option ignore
- }
- return true;
-}
-
// Deallocate all internal storage and reset to a clean state.
// Do not disturb any input or output connections, including
-// infileptr, infileno, inbytes, read_input_fn, jarout, or errstrm.
+// infileptr, inbytes, read_input_fn, jarout, or errstrm.
// Do not reset any unpack options.
void unpacker::reset()
{
@@ -3741,26 +3518,19 @@ void unpacker::reset()
this->free();
this->init(read_input_fn);
-// restore selected interface state:
-#define SAVE(x) this->x = save_u.x
- SAVE(infileptr); // buffered
- SAVE(infileno); // unbuffered
- SAVE(inbytes); // direct
- SAVE(jarout);
- SAVE(gzin);
- SAVE(verbose); // verbose level, 0 means no output
- SAVE(strip_compile);
- SAVE(strip_debug);
- SAVE(strip_jcov);
- SAVE(remove_packfile);
- SAVE(deflate_hint_or_zero); // ==0 means not set, otherwise -1 or 1
- SAVE(modification_time_or_zero);
- SAVE(bytes_read_before_reset);
- SAVE(bytes_written_before_reset);
- SAVE(files_written_before_reset);
- SAVE(classes_written_before_reset);
- SAVE(segments_read_before_reset);
-#undef SAVE
+ // restore selected interface state:
+ infileptr = save_u.infileptr;
+ inbytes = save_u.inbytes;
+ jarout = save_u.jarout;
+ gzin = save_u.gzin;
+ verbose = save_u.verbose;
+ deflate_hint_or_zero = save_u.deflate_hint_or_zero;
+ modification_time_or_zero = save_u.modification_time_or_zero;
+ bytes_read_before_reset = save_u.bytes_read_before_reset;
+ bytes_written_before_reset = save_u.bytes_written_before_reset;
+ files_written_before_reset = save_u.files_written_before_reset;
+ classes_written_before_reset = save_u.classes_written_before_reset;
+ segments_read_before_reset = save_u.segments_read_before_reset;
// Note: If we use strip_names, watch out: They get nuked here.
}
@@ -3778,32 +3548,6 @@ void unpacker::init(read_input_fn_t input_fn)
attr_defs[i].u = u; // set up outer ptr
}
-const char *unpacker::get_abort_message()
-{
- return abort_message;
-}
-
-void unpacker::dump_options()
-{
- static const char *opts[] = {
- UNPACK_DEFLATE_HINT,
-#ifdef HAVE_STRIP
- UNPACK_STRIP_COMPILE, UNPACK_STRIP_DEBUG, UNPACK_STRIP_JCOV,
-#endif /*HAVE_STRIP*/
- UNPACK_REMOVE_PACKFILE, DEBUG_VERBOSE, UNPACK_MODIFICATION_TIME, nullptr};
- for (int i = 0; opts[i] != nullptr; i++)
- {
- const char *str = get_option(opts[i]);
- if (str == nullptr)
- {
- if (verbose == 0)
- continue;
- str = "(not set)";
- }
- fprintf(stderr, "%s=%s\n", opts[i], str);
- }
-}
-
// Usage: unpack a byte buffer
// packptr is a reference to byte buffer containing a
// packed file and len is the length of the buffer.
@@ -3837,7 +3581,6 @@ void unpacker::check_options()
// Turn off per-file modtime by force.
archive_options &= ~AO_HAVE_FILE_MODTIME;
}
- // %%% strip_compile, etc...
}
// classfile writing
@@ -3858,7 +3601,7 @@ void unpacker::reset_cur_classfile()
requested_ics.empty();
}
-cpindex *cpool::getKQIndex()
+cpindex *constant_pool::getKQIndex()
{
char ch = '?';
if (u->cur_descr != nullptr)
@@ -3891,21 +3634,21 @@ cpindex *cpool::getKQIndex()
tag = CONSTANT_Integer;
break;
default:
- abort("bad KQ reference");
+ unpack_abort("bad KQ reference");
break;
}
return getIndex(tag);
}
-uint unpacker::to_bci(uint bii)
+uint32_t unpacker::to_bci(uint32_t bii)
{
- uint len = bcimap.length();
- uint *map = (uint *)bcimap.base();
+ uint32_t len = bcimap.length();
+ uint32_t *map = (uint32_t *)bcimap.base();
assert(len > 0); // must be initialized before using to_bci
if (bii < len)
return map[bii];
// Else it's a fractional or out-of-range BCI.
- uint key = bii - len;
+ uint32_t key = bii - len;
for (int i = len;; i--)
{
if (map[i - 1] - (i - 1) <= key)
@@ -4064,7 +3807,6 @@ unpacker::write_bc_ops()
--wp; // not really part of the code
int size = bc_escrefsize.getInt();
entry *ref = bc_escref.getRefN();
- CHECK;
switch (size)
{
case 1:
@@ -4118,7 +3860,7 @@ unpacker::write_bc_ops()
if (ref == nullptr)
break; // oops, bad input
assert(ref->tag == CONSTANT_Methodref);
- if (ref->memberDescr()->descrName() == cp.sym[cpool::s_lt_init_gt])
+ if (ref->memberDescr()->descrName() == cp.sym[constant_pool::s_lt_init_gt])
{
if (which_init++ == coding)
break;
@@ -4143,7 +3885,6 @@ unpacker::write_bc_ops()
putu1_fast(origBC);
}
entry *ref = bc_which->getRef();
- CHECK;
putref(ref);
continue;
}
@@ -4166,7 +3907,6 @@ unpacker::write_bc_ops()
if (bc_which != nullptr)
{
entry *ref = bc_which->getRefCommon(bc_which->ix, bc_which->nullOK);
- CHECK;
if (ref == nullptr && bc_which == &bc_classref)
{
// Shorthand for class self-references.
@@ -4289,7 +4029,6 @@ unpacker::write_code()
handler_count = code_handler_count.getInt();
int siglen = cur_descr->descrType()->typeSize();
- CHECK;
if ((cur_descr_flags & ACC_STATIC) == 0)
siglen++;
max_locals += siglen;
@@ -4300,7 +4039,6 @@ unpacker::write_code()
// Write the bytecodes themselves.
write_bc_ops();
- CHECK;
byte *bcbasewp = wp_at(bcbase);
putu4_at(bcbasewp, (int)(wp - (bcbasewp + 4))); // size of code attr
@@ -4315,10 +4053,9 @@ unpacker::write_code()
bii += code_handler_catch_PO.getInt();
putu2(to_bci(bii));
putref(code_handler_class_RCN.getRefN());
- CHECK;
}
- julong indexBits = cflags;
+ uint64_t indexBits = cflags;
if (cflags < 0)
{
bool haveLongFlags = attr_defs[ATTR_CONTEXT_CODE].haveLongFlags();
@@ -4327,9 +4064,8 @@ unpacker::write_code()
write_attrs(ATTR_CONTEXT_CODE, indexBits);
}
-int unpacker::write_attrs(int attrc, julong indexBits)
+int unpacker::write_attrs(int attrc, uint64_t indexBits)
{
- CHECK_0;
if (indexBits == 0)
{
// Quick short-circuit.
@@ -4342,9 +4078,9 @@ int unpacker::write_attrs(int attrc, julong indexBits)
int i, j, j2, idx, count;
int oiCount = 0;
- if (ad.isPredefined(X_ATTR_OVERFLOW) && (indexBits & ((julong)1 << X_ATTR_OVERFLOW)) != 0)
+ if (ad.isPredefined(X_ATTR_OVERFLOW) && (indexBits & ((uint64_t)1 << X_ATTR_OVERFLOW)) != 0)
{
- indexBits -= ((julong)1 << X_ATTR_OVERFLOW);
+ indexBits -= ((uint64_t)1 << X_ATTR_OVERFLOW);
oiCount = ad.xxx_attr_count().getInt();
}
@@ -4375,7 +4111,6 @@ int unpacker::write_attrs(int attrc, julong indexBits)
entry *aname = nullptr;
entry *ref; // scratch
size_t abase = put_empty(2 + 4);
- CHECK_0;
if (idx < (int)ad.flag_limit && ad.isPredefined(idx))
{
// Switch on the attrc and idx simultaneously.
@@ -4400,15 +4135,14 @@ int unpacker::write_attrs(int attrc, julong indexBits)
case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_InnerClasses) :
// note the existence of this attr, but save for later
if (cur_class_has_local_ics)
- abort("too many InnerClasses attrs");
+ unpack_abort("too many InnerClasses attrs");
cur_class_has_local_ics = true;
wp = wp_at(abase);
continue;
case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_SourceFile) :
- aname = cp.sym[cpool::s_SourceFile];
+ aname = cp.sym[constant_pool::s_SourceFile];
ref = class_SourceFile_RUN.getRefN();
- CHECK_0;
if (ref == nullptr)
{
bytes &n = cur_class->ref(0)->value.b;
@@ -4435,23 +4169,23 @@ int unpacker::write_attrs(int attrc, julong indexBits)
break;
case ADH_BYTE(ATTR_CONTEXT_CLASS, CLASS_ATTR_EnclosingMethod) :
- aname = cp.sym[cpool::s_EnclosingMethod];
+ aname = cp.sym[constant_pool::s_EnclosingMethod];
putref(class_EnclosingMethod_RC.getRefN());
putref(class_EnclosingMethod_RDN.getRefN());
break;
case ADH_BYTE(ATTR_CONTEXT_FIELD, FIELD_ATTR_ConstantValue) :
- aname = cp.sym[cpool::s_ConstantValue];
+ aname = cp.sym[constant_pool::s_ConstantValue];
putref(field_ConstantValue_KQ.getRefUsing(cp.getKQIndex()));
break;
case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_Code) :
- aname = cp.sym[cpool::s_Code];
+ aname = cp.sym[constant_pool::s_Code];
write_code();
break;
case ADH_BYTE(ATTR_CONTEXT_METHOD, METHOD_ATTR_Exceptions) :
- aname = cp.sym[cpool::s_Exceptions];
+ aname = cp.sym[constant_pool::s_Exceptions];
putu2(count = method_Exceptions_N.getInt());
for (j = 0; j < count; j++)
{
@@ -4460,7 +4194,7 @@ int unpacker::write_attrs(int attrc, julong indexBits)
break;
case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_StackMapTable) :
- aname = cp.sym[cpool::s_StackMapTable];
+ aname = cp.sym[constant_pool::s_StackMapTable];
// (keep this code aligned with its brother in unpacker::read_attrs)
putu2(count = code_StackMapTable_N.getInt());
for (j = 0; j < count; j++)
@@ -4508,7 +4242,7 @@ int unpacker::write_attrs(int attrc, julong indexBits)
break;
case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LineNumberTable) :
- aname = cp.sym[cpool::s_LineNumberTable];
+ aname = cp.sym[constant_pool::s_LineNumberTable];
putu2(count = code_LineNumberTable_N.getInt());
for (j = 0; j < count; j++)
{
@@ -4518,7 +4252,7 @@ int unpacker::write_attrs(int attrc, julong indexBits)
break;
case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LocalVariableTable) :
- aname = cp.sym[cpool::s_LocalVariableTable];
+ aname = cp.sym[constant_pool::s_LocalVariableTable];
putu2(count = code_LocalVariableTable_N.getInt());
for (j = 0; j < count; j++)
{
@@ -4534,7 +4268,7 @@ int unpacker::write_attrs(int attrc, julong indexBits)
break;
case ADH_BYTE(ATTR_CONTEXT_CODE, CODE_ATTR_LocalVariableTypeTable) :
- aname = cp.sym[cpool::s_LocalVariableTypeTable];
+ aname = cp.sym[constant_pool::s_LocalVariableTypeTable];
putu2(count = code_LocalVariableTypeTable_N.getInt());
for (j = 0; j < count; j++)
{
@@ -4550,24 +4284,24 @@ int unpacker::write_attrs(int attrc, julong indexBits)
break;
case ADH_BYTE(ATTR_CONTEXT_CLASS, X_ATTR_Signature) :
- aname = cp.sym[cpool::s_Signature];
+ aname = cp.sym[constant_pool::s_Signature];
putref(class_Signature_RS.getRefN());
break;
case ADH_BYTE(ATTR_CONTEXT_FIELD, X_ATTR_Signature) :
- aname = cp.sym[cpool::s_Signature];
+ aname = cp.sym[constant_pool::s_Signature];
putref(field_Signature_RS.getRefN());
break;
case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_Signature) :
- aname = cp.sym[cpool::s_Signature];
+ aname = cp.sym[constant_pool::s_Signature];
putref(method_Signature_RS.getRefN());
break;
case ADH_BYTE(ATTR_CONTEXT_CLASS, X_ATTR_Deprecated) :
case ADH_BYTE(ATTR_CONTEXT_FIELD, X_ATTR_Deprecated) :
case ADH_BYTE(ATTR_CONTEXT_METHOD, X_ATTR_Deprecated) :
- aname = cp.sym[cpool::s_Deprecated];
+ aname = cp.sym[constant_pool::s_Deprecated];
// no data
break;
}
@@ -4579,7 +4313,7 @@ int unpacker::write_attrs(int attrc, julong indexBits)
layout_definition *lo = ad.getLayout(idx);
if (lo == nullptr)
{
- abort("bad layout index");
+ unpack_abort("bad layout index");
break;
}
assert((int)lo->idx == idx);
@@ -4604,8 +4338,7 @@ int unpacker::write_attrs(int attrc, julong indexBits)
}
if (aname == nullptr)
- abort("bad attribute index");
- CHECK_0;
+ unpack_abort("bad attribute index");
byte *wp1 = wp;
wp = wp_at(abase);
@@ -4632,29 +4365,23 @@ int unpacker::write_attrs(int attrc, julong indexBits)
void unpacker::write_members(int num, int attrc)
{
- CHECK;
attr_definitions &ad = attr_defs[attrc];
band &member_flags_hi = ad.xxx_flags_hi();
band &member_flags_lo = ad.xxx_flags_lo();
band &member_descr = (&member_flags_hi)[e_field_descr - e_field_flags_hi];
- assert(endsWith(member_descr.name, "_descr"));
- assert(endsWith(member_flags_lo.name, "_flags_lo"));
- assert(endsWith(member_flags_lo.name, "_flags_lo"));
bool haveLongFlags = ad.haveLongFlags();
putu2(num);
- julong indexMask = attr_defs[attrc].flagIndexMask();
+ uint64_t indexMask = attr_defs[attrc].flagIndexMask();
for (int i = 0; i < num; i++)
{
- julong mflags = member_flags_hi.getLong(member_flags_lo, haveLongFlags);
+ uint64_t mflags = member_flags_hi.getLong(member_flags_lo, haveLongFlags);
entry *mdescr = member_descr.getRef();
cur_descr = mdescr;
putu2(cur_descr_flags = (ushort)(mflags & ~indexMask));
- CHECK;
putref(mdescr->descrName());
putref(mdescr->descrType());
write_attrs(attrc, (mflags & indexMask));
- CHECK;
}
cur_descr = nullptr;
}
@@ -4676,14 +4403,12 @@ void unpacker::write_classfile_tail()
attr_definitions &ad = attr_defs[ATTR_CONTEXT_CLASS];
bool haveLongFlags = ad.haveLongFlags();
- julong kflags = class_flags_hi.getLong(class_flags_lo, haveLongFlags);
- julong indexMask = ad.flagIndexMask();
+ uint64_t kflags = class_flags_hi.getLong(class_flags_lo, haveLongFlags);
+ uint64_t indexMask = ad.flagIndexMask();
cur_class = class_this.getRef();
cur_super = class_super.getRef();
- CHECK;
-
if (cur_super == cur_class)
cur_super = nullptr;
// special representation for java/lang/Object
@@ -4700,7 +4425,6 @@ void unpacker::write_classfile_tail()
write_members(class_field_count.getInt(), ATTR_CONTEXT_FIELD);
write_members(class_method_count.getInt(), ATTR_CONTEXT_METHOD);
- CHECK;
cur_class_has_local_ics = false; // may be set true by write_attrs
@@ -4767,7 +4491,6 @@ void unpacker::write_classfile_tail()
{
inner_class &extra_ic = extra_ics[i];
extra_ic.inner = class_InnerClasses_RC.getRef();
- CHECK;
// Find the corresponding equivalent global IC:
inner_class *global_ic = cp.getIC(extra_ic.inner);
int flags = class_InnerClasses_F.getInt();
@@ -4776,7 +4499,7 @@ void unpacker::write_classfile_tail()
// The extra IC is simply a copy of a global IC.
if (global_ic == nullptr)
{
- abort("bad reference to inner class");
+ unpack_abort("bad reference to inner class");
break;
}
extra_ic = (*global_ic); // fill in rest of fields
@@ -4819,7 +4542,7 @@ void unpacker::write_classfile_tail()
if (local_ics > 0)
{
// append the new attribute:
- putref(cp.sym[cpool::s_InnerClasses]);
+ putref(cp.sym[constant_pool::s_InnerClasses]);
putu4(2 + 2 * 4 * local_ics);
putu2(local_ics);
PTRLIST_QSORT(requested_ics, raw_address_cmp);
@@ -4839,7 +4562,6 @@ void unpacker::write_classfile_tail()
putu2(ic->flags);
}
}
- assert(local_ics == 0); // must balance
putu2_at(wp_at(naOffset), ++na); // increment class attr count
}
@@ -4851,7 +4573,6 @@ void unpacker::write_classfile_tail()
}
requested_ics.empty();
- CHECK;
close_output();
// rewrite CP references in the tail
@@ -4875,7 +4596,6 @@ void unpacker::write_classfile_tail()
assert(false); // should not reach here
}
}
- CHECK;
}
void unpacker::write_classfile_head()
@@ -4926,7 +4646,7 @@ void unpacker::write_classfile_head()
putu2(e.refs[1]->getOutputIndex());
break;
default:
- abort(ERROR_INTERNAL);
+ unpack_abort(ERROR_INTERNAL);
}
}
close_output();
@@ -4934,7 +4654,6 @@ void unpacker::write_classfile_head()
unpacker::file *unpacker::get_next_file()
{
- CHECK_0;
free_temps();
if (files_remaining == 0)
{
@@ -4943,9 +4662,9 @@ unpacker::file *unpacker::get_next_file()
cur_file.size = 0;
if (archive_size != 0)
{
- julong predicted_size = unsized_bytes_read + archive_size;
+ uint64_t predicted_size = unsized_bytes_read + archive_size;
if (predicted_size != bytes_read)
- abort("archive header had incorrect size");
+ unpack_abort("archive header had incorrect size");
}
return nullptr;
}
@@ -4960,7 +4679,6 @@ unpacker::file *unpacker::get_next_file()
if (files_written < file_count)
{
entry *e = file_name.getRef();
- CHECK_0;
cur_file.name = e->utf8String();
bool haveLongSize = ((archive_options & AO_HAVE_FILE_SIZE_HI) != 0);
cur_file.size = file_size_hi.getLong(file_size_lo, haveLongSize);
@@ -4980,20 +4698,17 @@ unpacker::file *unpacker::get_next_file()
classes_written += 1;
if (cur_file.size != 0)
{
- abort("class file size transmitted");
- return nullptr;
+ unpack_abort("class file size transmitted");
}
reset_cur_classfile();
// write the meat of the classfile:
write_classfile_tail();
cur_file.data[1] = cur_classfile_tail.b;
- CHECK_0;
// write the CP of the classfile, second:
write_classfile_head();
cur_file.data[0] = cur_classfile_head.b;
- CHECK_0;
cur_file.size += cur_file.data[0].len;
cur_file.size += cur_file.data[1].len;
@@ -5013,8 +4728,7 @@ unpacker::file *unpacker::get_next_file()
if (cur_file.size != (size_t)cur_file.size)
{
// Silly size specified.
- abort("resource file too large");
- return nullptr;
+ unpack_abort("resource file too large");
}
size_t rpleft = input_remaining();
if (rpleft > 0)
@@ -5031,7 +4745,6 @@ unpacker::file *unpacker::get_next_file()
bytes_read += fleft; // Credit it to the overall archive size.
}
}
- CHECK_0;
bytes_written += cur_file.size;
files_written += 1;
return &cur_file;
@@ -5041,7 +4754,7 @@ unpacker::file *unpacker::get_next_file()
void unpacker::write_file_to_jar(unpacker::file *f)
{
size_t htsize = f->data[0].len + f->data[1].len;
- julong fsize = f->size;
+ uint64_t fsize = f->size;
if (htsize == fsize)
{
jarout->addJarEntry(f->name, f->deflate_hint(), f->modtime, f->data[0], f->data[1]);
@@ -5077,10 +4790,9 @@ void unpacker::write_file_to_jar(unpacker::file *f)
input.ensureSize(fleft);
}
rplimit = rp = input.base();
- CHECK;
input.setLimit(rp + fleft);
if (!ensure_input(fleft))
- abort("EOF reading resource file");
+ unpack_abort("EOF reading resource file");
part2.ptr = input_scan();
part2.len = input_remaining();
rplimit = rp = input.base();
@@ -5092,14 +4804,3 @@ void unpacker::write_file_to_jar(unpacker::file *f)
fprintf(stderr, "Wrote " LONG_LONG_FORMAT " bytes to: %s\n", fsize, f->name);
}
}
-
-void unpacker::abort(const char *message)
-{
- if (message == nullptr)
- message = "error unpacking archive";
- if (message[0] == '@')
- ++message;
- fprintf(stderr, "%s\n", message);
- fflush(stderr);
- exit(-1);
-}