jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
author ohair
Sun, 17 Aug 2008 17:02:04 -0700
changeset 1082 53833ff90c45
parent 2 90ce3da70b43
child 2624 1ae5a9028dd4
permissions -rw-r--r--
6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux Summary: Removal of compiler warnings and fixing of assert logic. Reviewed-by: jrose, ksrini, bristor
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1082
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
     2
 * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
// Global Structures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
struct jar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
struct gunzip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
struct band;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
struct cpool;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
struct entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
struct cpindex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
struct inner_class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
struct value_stream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
struct cpindex {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  uint    len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  entry*  base1;   // base of primary index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  entry** base2;   // base of secondary index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  byte    ixTag;   // type of entries (!= CONSTANT_None), plus 64 if sub-index
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  enum { SUB_TAG = 64 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  entry* get(uint i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  void init(int len_, entry* base1_, int ixTag_) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    len = len_;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    base1 = base1_;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    base2 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    ixTag = ixTag_;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  void init(int len_, entry** base2_, int ixTag_) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    len = len_;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    base1 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    base2 = base2_;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    ixTag = ixTag_;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
struct cpool {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  uint  nentries;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  entry* entries;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
  entry* first_extra_entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  uint maxentries;      // total allocated size of entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
  // Position and size of each homogeneous subrange:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
  int     tag_count[CONSTANT_Limit];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  int     tag_base[CONSTANT_Limit];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  cpindex tag_index[CONSTANT_Limit];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  ptrlist tag_extras[CONSTANT_Limit];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  cpindex* member_indexes;   // indexed by 2*CONSTANT_Class.inord
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  cpindex* getFieldIndex(entry* classRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  cpindex* getMethodIndex(entry* classRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  inner_class** ic_index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  inner_class** ic_child_index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  inner_class* getIC(entry* inner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  inner_class* getFirstChildIC(entry* outer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  inner_class* getNextChildIC(inner_class* child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  int outputIndexLimit;  // index limit after renumbering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  ptrlist outputEntries; // list of entry* needing output idx assigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  entry** hashTab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
  uint    hashTabLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  entry*& hashTabRef(byte tag, bytes& b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  entry*  ensureUtf8(bytes& b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  entry*  ensureClass(bytes& b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  // Well-known Utf8 symbols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    #define SNAME(n,s) s_##s,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    ALL_ATTR_DO(SNAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    #undef SNAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    s_lt_init_gt,  // <init>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    s_LIMIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  entry* sym[s_LIMIT];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  // read counts from hdr, allocate main arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  enum { NUM_COUNTS = 12 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  void init(unpacker* u, int counts[NUM_COUNTS]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
  // pointer to outer unpacker, for error checks etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  unpacker* u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  int getCount(byte tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    assert((uint)tag < CONSTANT_Limit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    return tag_count[tag];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  cpindex* getIndex(byte tag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    assert((uint)tag < CONSTANT_Limit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    return &tag_index[tag];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  cpindex* getKQIndex();  // uses cur_descr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  void expandSignatures();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  void initMemberIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  void computeOutputOrder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
  void computeOutputIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
  void resetOutputIndexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  // error handling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  inline void abort(const char* msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  inline bool aborting();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * The unpacker provides the entry points to the unpack engine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * as well as maintains the state of the engine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
struct unpacker {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  // One element of the resulting JAR.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  struct file {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    const char* name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    julong      size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    int         modtime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    int         options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    bytes       data[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    // Note:  If Sum(data[*].len) < size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    // remaining bytes must be read directly from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    bool deflate_hint() { return ((options & FO_DEFLATE_HINT) != 0); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  // back pointer to NativeUnpacker obj and Java environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
  void* jniobj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
  void* jnienv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  // global pointer to self, if not running under JNI (not multi-thread safe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  static unpacker* non_mt_current;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  // if running Unix-style, here are the inputs and outputs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  FILE* infileptr;  // buffered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  int   infileno;   // unbuffered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  bytes inbytes;    // direct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  gunzip* gzin;     // gunzip filter, if any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  jar*  jarout;     // output JAR file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#ifndef PRODUCT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  int   nowrite;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  int   skipfiles;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
  int   verbose_bands;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  // pointer to self, for U_NEW macro
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  unpacker* u;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  // private abort message string, allocated to PATH_MAX*2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  const char* abort_message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  ptrlist mallocs;      // list of guys to free when we are all done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  ptrlist tmallocs;     // list of guys to free on next client request
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  fillbytes smallbuf;   // supplies small alloc requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  fillbytes tsmallbuf;  // supplies temporary small alloc requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  // option management members
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  int   verbose;  // verbose level, 0 means no output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
  bool  strip_compile;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
  bool  strip_debug;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  bool  strip_jcov;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  bool  remove_packfile;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
  int   deflate_hint_or_zero;  // ==0 means not set, otherwise -1 or 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
  int   modification_time_or_zero;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
  FILE*       errstrm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
  const char* errstrm_name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
  const char* log_file;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
  // input stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
  fillbytes input;       // the whole block (size is predicted, has slop too)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  bool      live_input;  // is the data in this block live?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  bool      free_input;  // must the input buffer be freed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
  byte*     rp;          // read pointer (< rplimit <= input.limit())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
  byte*     rplimit;     // how much of the input block has been read?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
  julong    bytes_read;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  int       unsized_bytes_read;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  // callback to read at least one byte, up to available input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
  typedef jlong (*read_input_fn_t)(unpacker* self, void* buf, jlong minlen, jlong maxlen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
  read_input_fn_t read_input_fn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
  // archive header fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  int      magic, minver, majver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  julong   archive_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  int      archive_next_count, archive_options, archive_modtime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
  int      band_headers_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  int      file_count, attr_definition_count, ic_count, class_count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
  int      default_class_minver, default_class_majver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  int      default_file_options, suppress_file_options;  // not header fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  int      default_archive_modtime, default_file_modtime;  // not header fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  int      code_count;  // not a header field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
  int      files_remaining;  // not a header field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  // engine state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  band*        all_bands;   // indexed by band_number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  byte*        meta_rp;     // read-pointer into (copy of) band_headers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  cpool        cp;          // all constant pool information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  inner_class* ics;         // InnerClasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
  // output stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
  bytes    output;      // output block (either classfile head or tail)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  byte*    wp;          // write pointer (< wplimit == output.limit())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  byte*    wpbase;      // write pointer starting address (<= wp)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
  byte*    wplimit;     // how much of the output block has been written?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
  // output state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  file      cur_file;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
  entry*    cur_class;  // CONSTANT_Class entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  entry*    cur_super;  // CONSTANT_Class entry or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
  entry*    cur_descr;  // CONSTANT_NameandType entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  int       cur_descr_flags;  // flags corresponding to cur_descr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
  int       cur_class_minver, cur_class_majver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
  bool      cur_class_has_local_ics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
  fillbytes cur_classfile_head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
  fillbytes cur_classfile_tail;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
  int       files_written;   // also tells which file we're working on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  int       classes_written; // also tells which class we're working on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
  julong    bytes_written;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
  intlist   bcimap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
  fillbytes class_fixup_type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
  intlist   class_fixup_offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
  ptrlist   class_fixup_ref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
  fillbytes code_fixup_type;    // which format of branch operand?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
  intlist   code_fixup_offset;  // location of operand needing fixup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
  intlist   code_fixup_source;  // encoded ID of branch insn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
  ptrlist   requested_ics;      // which ics need output?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
  // stats pertaining to multiple segments (updated on reset)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
  julong    bytes_read_before_reset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
  julong    bytes_written_before_reset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
  int       files_written_before_reset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
  int       classes_written_before_reset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
  int       segments_read_before_reset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
  // attribute state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
  struct layout_definition {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    uint          idx;        // index (0..31...) which identifies this layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    const char*   name;       // name of layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    entry*        nameEntry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    const char*   layout;     // string of layout (not yet parsed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    band**        elems;      // array of top-level layout elems (or callables)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    bool hasCallables()   { return layout[0] == '['; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    band** bands()        { assert(elems != null); return elems; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
  };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  struct attr_definitions {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    unpacker* u;  // pointer to self, for U_NEW macro
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    int     xxx_flags_hi_bn;// locator for flags, count, indexes, calls bands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    int     attrc;          // ATTR_CONTEXT_CLASS, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    uint    flag_limit;     // 32 or 63, depending on archive_options bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    julong  predef;         // mask of built-in definitions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    julong  redef;          // mask of local flag definitions or redefinitions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    ptrlist layouts;        // local (compressor-defined) defs, in index order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    int     flag_count[X_ATTR_LIMIT_FLAGS_HI];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    intlist overflow_count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    ptrlist strip_names;    // what attribute names are being stripped?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    ptrlist band_stack;     // Temp., used during layout parsing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    ptrlist calls_to_link;  //  (ditto)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    int     bands_made;     //  (ditto)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    void free() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
      layouts.free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
      overflow_count.free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
      strip_names.free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
      band_stack.free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
      calls_to_link.free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    // Locate the five fixed bands.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    band& xxx_flags_hi();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    band& xxx_flags_lo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    band& xxx_attr_count();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    band& xxx_attr_indexes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    band& xxx_attr_calls();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    band& fixed_band(int e_class_xxx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    // Register a new layout, and make bands for it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    layout_definition* defineLayout(int idx, const char* name, const char* layout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    layout_definition* defineLayout(int idx, entry* nameEntry, const char* layout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    band** buildBands(layout_definition* lo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    // Parse a layout string or part of one, recursively if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    const char* parseLayout(const char* lp,    band** &res, int curCble);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    const char* parseNumeral(const char* lp,   int    &res);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    const char* parseIntLayout(const char* lp, band*  &res, byte le_kind,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                               bool can_be_signed = false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    band** popBody(int band_stack_base);  // pops a body off band_stack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    // Read data into the bands of the idx-th layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    void readBandData(int idx);  // parse layout, make bands, read data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    void readBandData(band** body, uint count);  // recursive helper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    layout_definition* getLayout(uint idx) {
1082
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   317
      if (idx >= (uint)layouts.length())  return null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
      return (layout_definition*) layouts.get(idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    void setHaveLongFlags(bool z) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
      assert(flag_limit == 0);  // not set up yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
      flag_limit = (z? X_ATTR_LIMIT_FLAGS_HI: X_ATTR_LIMIT_NO_FLAGS_HI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    bool haveLongFlags() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     assert(flag_limit == X_ATTR_LIMIT_NO_FLAGS_HI ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            flag_limit == X_ATTR_LIMIT_FLAGS_HI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      return flag_limit == X_ATTR_LIMIT_FLAGS_HI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    // Return flag_count if idx is predef and not redef, else zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    int predefCount(uint idx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    bool isRedefined(uint idx) {
1082
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   335
      if (idx >= flag_limit) return false;
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   336
      return (bool)((redef >> idx) & 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    bool isPredefined(uint idx) {
1082
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   339
      if (idx >= flag_limit) return false;
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   340
      return (bool)(((predef & ~redef) >> idx) & 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    julong flagIndexMask() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      return (predef | redef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    bool isIndex(uint idx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
      assert(flag_limit != 0);  // must be set up already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
      if (idx < flag_limit)
1082
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   348
        return (bool)(((predef | redef) >> idx) & 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
      else
1082
53833ff90c45 6496269: Many warnings generated from com/sun/java/util/jar/pack/*.cpp when compiled on Linux
ohair
parents: 2
diff changeset
   350
        return (idx - flag_limit < (uint)overflow_count.length());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    int& getCount(uint idx) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      assert(isIndex(idx));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      if (idx < flag_limit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        return flag_count[idx];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        return overflow_count.get(idx - flag_limit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    bool aborting()             { return u->aborting(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    void abort(const char* msg) { u->abort(msg); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
  };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
  attr_definitions attr_defs[ATTR_CONTEXT_LIMIT];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
  // Initialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
  void         init(read_input_fn_t input_fn = null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
  // Resets to a known sane state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
  void         reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
  // Deallocates all storage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
  void         free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
  // Deallocates temporary storage (volatile after next client call).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
  void         free_temps() { tsmallbuf.init(); tmallocs.freeAll(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
  // Option management methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
  bool         set_option(const char* option, const char* value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
  const char*  get_option(const char* option);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
  void         dump_options();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
  // Fetching input.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
  bool   ensure_input(jlong more);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
  byte*  input_scan()               { return rp; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
  size_t input_remaining()          { return rplimit - rp; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
  size_t input_consumed()           { return rp - input.base(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
  // Entry points to the unpack engine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
  static int   run(int argc, char **argv);   // Unix-style entry point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
  void         check_options();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
  void         start(void* packptr = null, size_t len = 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
  void         redirect_stdio();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
  void         write_file_to_jar(file* f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
  void         finish();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
  // Public post unpack methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
  int          get_files_remaining()    { return files_remaining; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
  int          get_segments_remaining() { return archive_next_count; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
  file*        get_next_file();  // returns null on last file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
  // General purpose methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
  void*        alloc(size_t size) { return alloc_heap(size, true); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
  void*        temp_alloc(size_t size) { return alloc_heap(size, true, true); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
  void*        alloc_heap(size_t size, bool smallOK = false, bool temp = false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
  void         saveTo(bytes& b, const char* str) { saveTo(b, (byte*)str, strlen(str)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
  void         saveTo(bytes& b, bytes& data) { saveTo(b, data.ptr, data.len); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
  void         saveTo(bytes& b, byte* ptr, size_t len); //{ b.ptr = U_NEW...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
  const char*  saveStr(const char* str) { bytes buf; saveTo(buf, str); return buf.strval(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
  const char*  saveIntStr(int num) { char buf[30]; sprintf(buf, "%d", num); return saveStr(buf); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
#ifndef PRODUCT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
  int printcr_if_verbose(int level, const char* fmt,...);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
  const char*  get_abort_message();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
  void         abort(const char* s = null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
  bool         aborting() { return abort_message != null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
  static unpacker* current();  // find current instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
  // Output management
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
  void set_output(fillbytes* which) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    assert(wp == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    which->ensureSize(1 << 12);  // covers the average classfile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    wpbase  = which->base();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    wp      = which->limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    wplimit = which->end();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
  fillbytes* close_output(fillbytes* which = null);  // inverse of set_output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
  // These take an implicit parameter of wp/wplimit, and resize as necessary:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
  byte*  put_space(size_t len);  // allocates space at wp, returns pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
  size_t put_empty(size_t s)    { byte* p = put_space(s); return p - wpbase; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
  void   ensure_put_space(size_t len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
  void   put_bytes(bytes& b)    { b.writeTo(put_space(b.len)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
  void   putu1(int n)           { putu1_at(put_space(1), n); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
  void   putu1_fast(int n)      { putu1_at(wp++,         n); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
  void   putu2(int n);       // { putu2_at(put_space(2), n); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
  void   putu4(int n);       // { putu4_at(put_space(4), n); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
  void   putu8(jlong n);     // { putu8_at(put_space(8), n); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
  void   putref(entry* e);   // { putu2_at(put_space(2), putref_index(e, 2)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
  void   putu1ref(entry* e); // { putu1_at(put_space(1), putref_index(e, 1)); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
  int    putref_index(entry* e, int size);  // size in [1..2]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
  void   put_label(int curIP, int size);    // size in {2,4}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  void   putlayout(band** body);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
  void   put_stackmap_type();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
  size_t wpoffset() { return (size_t)(wp - wpbase); }  // (unvariant across overflow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
  byte*  wp_at(size_t offset) { return wpbase + offset; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
  uint to_bci(uint bii);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
  void get_code_header(int& max_stack,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                       int& max_na_locals,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                       int& handler_count,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                       int& cflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
  band* ref_band_for_self_op(int bc, bool& isAloadVar, int& origBCVar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
  band* ref_band_for_op(int bc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
  // Definitions of standard classfile int formats:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
  static void putu1_at(byte* wp, int n) { assert(n == (n & 0xFF)); wp[0] = n; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
  static void putu2_at(byte* wp, int n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  static void putu4_at(byte* wp, int n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
  static void putu8_at(byte* wp, jlong n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
  // Private stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  void reset_cur_classfile();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  void write_classfile_tail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
  void write_classfile_head();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  void write_code();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  void write_bc_ops();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
  void write_members(int num, int attrc);  // attrc=ATTR_CONTEXT_FIELD/METHOD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  int  write_attrs(int attrc, julong indexBits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
  // The readers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
  void read_bands();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
  void read_file_header();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
  void read_cp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
  void read_cp_counts(value_stream& hdr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
  void read_attr_defs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
  void read_ics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  void read_attrs(int attrc, int obj_count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
  void read_classes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
  void read_code_headers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
  void read_bcs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
  void read_bc_ops();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
  void read_files();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
  void read_Utf8_values(entry* cpMap, int len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
  void read_single_words(band& cp_band, entry* cpMap, int len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
  void read_double_words(band& cp_bands, entry* cpMap, int len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
  void read_single_refs(band& cp_band, byte refTag, entry* cpMap, int len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
  void read_double_refs(band& cp_band, byte ref1Tag, byte ref2Tag, entry* cpMap, int len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
  void read_signature_values(entry* cpMap, int len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
inline void cpool::abort(const char* msg) { u->abort(msg); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
inline bool cpool::aborting()             { return u->aborting(); }