jdk/src/java.base/share/native/libjimage/imageFile.hpp
author ihse
Tue, 09 May 2017 12:57:30 +0200
changeset 45028 b0ea3c0bfb81
parent 36511 9d0388c6b336
permissions -rw-r--r--
8179889: Fix typographic errors in copyright headers Reviewed-by: erikj, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     1
/*
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 36511
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
35784
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
     3
 *
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
     5
 * modification, are permitted provided that the following conditions
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
     6
 * are met:
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
     7
 *
35784
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    10
 *
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    14
 *
35784
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    17
 *     from this software without specific prior written permission.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    18
 *
35784
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
ddeed53a1c5a 8149776: BSD license for jimage code
jlaskey
parents: 32757
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    30
 */
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    31
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    32
#ifndef LIBJIMAGE_IMAGEFILE_HPP
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    33
#define LIBJIMAGE_IMAGEFILE_HPP
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    34
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    35
#include <assert.h>
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    36
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    37
#include "endian.hpp"
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    38
#include "inttypes.hpp"
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    39
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    40
// Image files are an alternate file format for storing classes and resources. The
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    41
// goal is to supply file access which is faster and smaller than the jar format.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    42
// It should be noted that unlike jars, information stored in an image is in native
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    43
// endian format. This allows the image to be mapped into memory without endian
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    44
// translation.  This also means that images are platform dependent.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    45
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    46
// Image files are structured as three sections;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    47
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    48
//         +-----------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    49
//         |  Header   |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    50
//         +-----------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    51
//         |           |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    52
//         |   Index   |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    53
//         |           |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    54
//         +-----------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    55
//         |           |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    56
//         |           |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    57
//         | Resources |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    58
//         |           |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    59
//         |           |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    60
//         +-----------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    61
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    62
// The header contains information related to identification and description of
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    63
// contents.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    64
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    65
//         +-------------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    66
//         |   Magic (0xCAFEDADA)    |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    67
//         +------------+------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    68
//         | Major Vers | Minor Vers |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    69
//         +------------+------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    70
//         |          Flags          |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    71
//         +-------------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    72
//         |      Resource Count     |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    73
//         +-------------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    74
//         |       Table Length      |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    75
//         +-------------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    76
//         |      Attributes Size    |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    77
//         +-------------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    78
//         |       Strings Size      |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    79
//         +-------------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    80
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    81
// Magic - means of identifying validity of the file.  This avoids requiring a
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    82
//         special file extension.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    83
// Major vers, minor vers - differences in version numbers indicate structural
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    84
//                          changes in the image.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    85
// Flags - various image wide flags (future).
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    86
// Resource count - number of resources in the file.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    87
// Table length - the length of lookup tables used in the index.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    88
// Attributes size - number of bytes in the region used to store location attribute
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    89
//                   streams.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    90
// Strings size - the size of the region used to store strings used by the
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    91
//                index and meta data.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    92
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    93
// The index contains information related to resource lookup. The algorithm
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    94
// used for lookup is "A Practical Minimal Perfect Hashing Method"
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    95
// (http://homepages.dcc.ufmg.br/~nivio/papers/wea05.pdf). Given a path string
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    96
// in the form /<module>/<package>/<base>.<extension>  return the resource location
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    97
// information;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    98
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
    99
//     redirectIndex = hash(path, DEFAULT_SEED) % table_length;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   100
//     redirect = redirectTable[redirectIndex];
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   101
//     if (redirect == 0) return not found;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   102
//     locationIndex = redirect < 0 ? -1 - redirect : hash(path, redirect) % table_length;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   103
//     location = locationTable[locationIndex];
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   104
//     if (!verify(location, path)) return not found;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   105
//     return location;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   106
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   107
// Note: The hash function takes an initial seed value.  A different seed value
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   108
// usually returns a different result for strings that would otherwise collide with
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   109
// other seeds. The verify function guarantees the found resource location is
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   110
// indeed the resource we are looking for.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   111
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   112
// The following is the format of the index;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   113
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   114
//         +-------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   115
//         |   Redirect Table  |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   116
//         +-------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   117
//         | Attribute Offsets |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   118
//         +-------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   119
//         |   Attribute Data  |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   120
//         +-------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   121
//         |      Strings      |
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   122
//         +-------------------+
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   123
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   124
// Redirect Table - Array of 32-bit signed values representing actions that
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   125
//                  should take place for hashed strings that map to that
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   126
//                  value.  Negative values indicate no hash collision and can be
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   127
//                  quickly converted to indices into attribute offsets.  Positive
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   128
//                  values represent a new seed for hashing an index into attribute
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   129
//                  offsets.  Zero indicates not found.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   130
// Attribute Offsets - Array of 32-bit unsigned values representing offsets into
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   131
//                     attribute data.  Attribute offsets can be iterated to do a
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   132
//                     full survey of resources in the image.  Offset of zero
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   133
//                     indicates no attributes.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   134
// Attribute Data - Bytes representing compact attribute data for locations. (See
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   135
//                  comments in ImageLocation.)
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   136
// Strings - Collection of zero terminated UTF-8 strings used by the index and
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   137
//           image meta data.  Each string is accessed by offset.  Each string is
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   138
//           unique.  Offset zero is reserved for the empty string.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   139
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   140
// Note that the memory mapped index assumes 32 bit alignment of each component
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   141
// in the index.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   142
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   143
// Endianness of an image.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   144
// An image booted by hotspot is always in native endian.  However, it is possible
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   145
// to read (by the JDK) in alternate endian format.  Primarily, this is during
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   146
// cross platform scenarios.  Ex, where javac needs to read an embedded image
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   147
// to access classes for crossing compilation.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   148
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   149
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   150
class ImageFileReader; // forward declaration
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   151
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   152
// Manage image file string table.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   153
class ImageStrings {
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   154
private:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   155
    u1* _data; // Data bytes for strings.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   156
    u4 _size;  // Number of bytes in the string table.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   157
public:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   158
    enum {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   159
        // Not found result from find routine.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   160
        NOT_FOUND = -1,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   161
        // Prime used to generate hash for Perfect Hashing.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   162
        HASH_MULTIPLIER = 0x01000193
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   163
    };
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   164
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   165
    ImageStrings(u1* data, u4 size) : _data(data), _size(size) {}
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   166
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   167
    // Return the UTF-8 string beginning at offset.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   168
    inline const char* get(u4 offset) const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   169
        assert(offset < _size && "offset exceeds string table size");
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   170
        return (const char*)(_data + offset);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   171
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   172
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   173
    // Compute the Perfect Hashing hash code for the supplied UTF-8 string.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   174
    inline static u4 hash_code(const char* string) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   175
        return hash_code(string, HASH_MULTIPLIER);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   176
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   177
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   178
    // Compute the Perfect Hashing hash code for the supplied string, starting at seed.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   179
    static s4 hash_code(const char* string, s4 seed);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   180
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   181
    // Match up a string in a perfect hash table.    Result still needs validation
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   182
    // for precise match.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   183
    static s4 find(Endian* endian, const char* name, s4* redirect, u4 length);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   184
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   185
    // Test to see if UTF-8 string begins with the start UTF-8 string.  If so,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   186
    // return non-NULL address of remaining portion of string.  Otherwise, return
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   187
    // NULL.    Used to test sections of a path without copying from image string
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   188
    // table.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   189
    static const char* starts_with(const char* string, const char* start);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   190
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   191
    // Test to see if UTF-8 string begins with start char.  If so, return non-NULL
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   192
    // address of remaining portion of string.  Otherwise, return NULL.  Used
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   193
    // to test a character of a path without copying.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   194
    inline static const char* starts_with(const char* string, const char ch) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   195
        return *string == ch ? string + 1 : NULL;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   196
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   197
};
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   198
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   199
// Manage image file location attribute data.    Within an image, a location's
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   200
// attributes are compressed into a stream of bytes.    An attribute stream is
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   201
// composed of individual attribute sequences.  Each attribute sequence begins with
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   202
// a header byte containing the attribute 'kind' (upper 5 bits of header) and the
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   203
// 'length' less 1 (lower 3 bits of header) of bytes that follow containing the
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   204
// attribute value.  Attribute values present as most significant byte first.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   205
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   206
// Ex. Container offset (ATTRIBUTE_OFFSET) 0x33562 would be represented as 0x22
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   207
// (kind = 4, length = 3), 0x03, 0x35, 0x62.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   208
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   209
// An attribute stream is terminated with a header kind of ATTRIBUTE_END (header
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   210
// byte of zero.)
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   211
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   212
// ImageLocation inflates the stream into individual values stored in the long
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   213
// array _attributes. This allows an attribute value can be quickly accessed by
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   214
// direct indexing. Unspecified values default to zero.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   215
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   216
// Notes:
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   217
//  - Even though ATTRIBUTE_END is used to mark the end of the attribute stream,
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   218
//      streams will contain zero byte values to represent lesser significant bits.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   219
//      Thus, detecting a zero byte is not sufficient to detect the end of an attribute
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   220
//      stream.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   221
//  - ATTRIBUTE_OFFSET represents the number of bytes from the beginning of the region
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   222
//      storing the resources.  Thus, in an image this represents the number of bytes
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   223
//      after the index.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   224
//  - Currently, compressed resources are represented by having a non-zero
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   225
//      ATTRIBUTE_COMPRESSED value.  This represents the number of bytes stored in the
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   226
//      image, and the value of ATTRIBUTE_UNCOMPRESSED represents number of bytes of the
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   227
//      inflated resource in memory. If the ATTRIBUTE_COMPRESSED is zero then the value
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   228
//      of ATTRIBUTE_UNCOMPRESSED represents both the number of bytes in the image and
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   229
//      in memory.  In the future, additional compression techniques will be used and
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   230
//      represented differently.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   231
//  - Package strings include trailing slash and extensions include prefix period.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   232
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   233
class ImageLocation {
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   234
public:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   235
    enum {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   236
        ATTRIBUTE_END,                  // End of attribute stream marker
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   237
        ATTRIBUTE_MODULE,               // String table offset of module name
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   238
        ATTRIBUTE_PARENT,               // String table offset of resource path parent
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   239
        ATTRIBUTE_BASE,                 // String table offset of resource path base
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   240
        ATTRIBUTE_EXTENSION,        // String table offset of resource path extension
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   241
        ATTRIBUTE_OFFSET,               // Container byte offset of resource
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   242
        ATTRIBUTE_COMPRESSED,       // In image byte size of the compressed resource
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   243
        ATTRIBUTE_UNCOMPRESSED, // In memory byte size of the uncompressed resource
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   244
        ATTRIBUTE_COUNT                 // Number of attribute kinds
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   245
    };
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   246
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   247
private:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   248
    // Values of inflated attributes.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   249
    u8 _attributes[ATTRIBUTE_COUNT];
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   250
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   251
    // Return the attribute value number of bytes.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   252
    inline static u1 attribute_length(u1 data) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   253
        return (data & 0x7) + 1;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   254
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   255
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   256
    // Return the attribute kind.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   257
    inline static u1 attribute_kind(u1 data) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   258
        u1 kind = data >> 3;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   259
        assert(kind < ATTRIBUTE_COUNT && "invalid attribute kind");
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   260
        return kind;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   261
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   262
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   263
    // Return the attribute length.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   264
    inline static u8 attribute_value(u1* data, u1 n) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   265
        assert(0 < n && n <= 8 && "invalid attribute value length");
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   266
        u8 value = 0;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   267
        // Most significant bytes first.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   268
        for (u1 i = 0; i < n; i++) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   269
            value <<= 8;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   270
            value |= data[i];
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   271
        }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   272
        return value;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   273
    }
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   274
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   275
public:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   276
    ImageLocation() {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   277
        clear_data();
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   278
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   279
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   280
    ImageLocation(u1* data) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   281
        clear_data();
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   282
        set_data(data);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   283
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   284
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   285
    // Inflates the attribute stream into individual values stored in the long
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   286
    // array _attributes. This allows an attribute value to be quickly accessed by
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   287
    // direct indexing. Unspecified values default to zero.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   288
    void set_data(u1* data);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   289
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   290
    // Zero all attribute values.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   291
    void clear_data();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   292
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   293
    // Retrieve an attribute value from the inflated array.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   294
    inline u8 get_attribute(u1 kind) const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   295
        assert(ATTRIBUTE_END < kind && kind < ATTRIBUTE_COUNT && "invalid attribute kind");
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   296
        return _attributes[kind];
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   297
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   298
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   299
    // Retrieve an attribute string value from the inflated array.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   300
    inline const char* get_attribute(u4 kind, const ImageStrings& strings) const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   301
        return strings.get((u4)get_attribute(kind));
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   302
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   303
};
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   304
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   305
//
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   306
// Manage the image module meta data.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   307
class ImageModuleData {
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   308
    const ImageFileReader* _image_file; // Source image file
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   309
    Endian* _endian;                    // Endian handler
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   310
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   311
public:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   312
    ImageModuleData(const ImageFileReader* image_file);
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   313
    ~ImageModuleData();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   314
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   315
    // Return the module in which a package resides.    Returns NULL if not found.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   316
    const char* package_to_module(const char* package_name);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   317
};
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   318
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   319
// Image file header, starting at offset 0.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   320
class ImageHeader {
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   321
private:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   322
    u4 _magic;          // Image file marker
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   323
    u4 _version;        // Image file major version number
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   324
    u4 _flags;          // Image file flags
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   325
    u4 _resource_count; // Number of resources in file
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   326
    u4 _table_length;   // Number of slots in index tables
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   327
    u4 _locations_size; // Number of bytes in attribute table
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   328
    u4 _strings_size;   // Number of bytes in string table
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   329
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   330
public:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   331
    u4 magic() const { return _magic; }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   332
    u4 magic(Endian* endian) const { return endian->get(_magic); }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   333
    void set_magic(Endian* endian, u4 magic) { return endian->set(_magic, magic); }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   334
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   335
    u4 major_version(Endian* endian) const { return endian->get(_version) >> 16; }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   336
    u4 minor_version(Endian* endian) const { return endian->get(_version) & 0xFFFF; }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   337
    void set_version(Endian* endian, u4 major_version, u4 minor_version) {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   338
        return endian->set(_version, major_version << 16 | minor_version);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   339
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   340
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   341
    u4 flags(Endian* endian) const { return endian->get(_flags); }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   342
    void set_flags(Endian* endian, u4 value) { return endian->set(_flags, value); }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   343
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   344
    u4 resource_count(Endian* endian) const { return endian->get(_resource_count); }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   345
    void set_resource_count(Endian* endian, u4 count) { return endian->set(_resource_count, count); }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   346
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   347
    u4 table_length(Endian* endian) const { return endian->get(_table_length); }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   348
    void set_table_length(Endian* endian, u4 count) { return endian->set(_table_length, count); }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   349
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   350
    u4 locations_size(Endian* endian) const { return endian->get(_locations_size); }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   351
    void set_locations_size(Endian* endian, u4 size) { return endian->set(_locations_size, size); }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   352
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   353
    u4 strings_size(Endian* endian) const { return endian->get(_strings_size); }
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   354
    void set_strings_size(Endian* endian, u4 size) { return endian->set(_strings_size, size); }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   355
};
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   356
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   357
// Max path length limit independent of platform.    Windows max path is 1024,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   358
// other platforms use 4096.    The JCK fails several tests when 1024 is used.
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   359
#define IMAGE_MAX_PATH 4096
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   360
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   361
class ImageFileReader;
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   362
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   363
// Manage a table of open image files.  This table allows multiple access points
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   364
// to share an open image.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   365
class ImageFileReaderTable {
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   366
private:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   367
    const static u4 _growth = 8; // Growth rate of the table
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   368
    u4 _count;                   // Number of entries in the table
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   369
    u4 _max;                     // Maximum number of entries allocated
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   370
    ImageFileReader** _table;    // Growable array of entries
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   371
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   372
public:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   373
    ImageFileReaderTable();
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   374
    ~ImageFileReaderTable();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   375
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   376
    // Return the number of entries.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   377
    inline u4 count() { return _count; }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   378
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   379
    // Return the ith entry from the table.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   380
    inline ImageFileReader* get(u4 i) { return _table[i]; }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   381
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   382
    // Add a new image entry to the table.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   383
    void add(ImageFileReader* image);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   384
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   385
    // Remove an image entry from the table.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   386
    void remove(ImageFileReader* image);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   387
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   388
    // Determine if image entry is in table.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   389
    bool contains(ImageFileReader* image);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   390
};
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   391
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   392
// Manage the image file.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   393
// ImageFileReader manages the content of an image file.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   394
// Initially, the header of the image file is read for validation.  If valid,
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   395
// values in the header are used calculate the size of the image index.  The
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   396
// index is then memory mapped to allow load on demand and sharing.  The
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   397
// -XX:+MemoryMapImage flag determines if the entire file is loaded (server use.)
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   398
// An image can be used by Hotspot and multiple reference points in the JDK, thus
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   399
// it is desirable to share a reader.    To accomodate sharing, a share table is
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   400
// defined (see ImageFileReaderTable in imageFile.cpp)  To track the number of
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   401
// uses, ImageFileReader keeps a use count (_use).  Use is incremented when
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   402
// 'opened' by reference point and decremented when 'closed'.    Use of zero
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   403
// leads the ImageFileReader to be actually closed and discarded.
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   404
class ImageFileReader {
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   405
private:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   406
    // Manage a number of image files such that an image can be shared across
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   407
    // multiple uses (ex. loader.)
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   408
    static ImageFileReaderTable _reader_table;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   409
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   410
    // true if image should be fully memory mapped.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   411
    static bool memory_map_image;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   412
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   413
    char* _name;         // Name of image
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   414
    s4 _use;             // Use count
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   415
    int _fd;             // File descriptor
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   416
    Endian* _endian;     // Endian handler
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   417
    u8 _file_size;       // File size in bytes
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   418
    ImageHeader _header; // Image header
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   419
    size_t _index_size;  // Total size of index
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   420
    u1* _index_data;     // Raw index data
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   421
    s4* _redirect_table; // Perfect hash redirect table
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   422
    u4* _offsets_table;  // Location offset table
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   423
    u1* _location_bytes; // Location attributes
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   424
    u1* _string_bytes;   // String table
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   425
    ImageModuleData *module_data;       // The ImageModuleData for this image
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   426
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   427
    ImageFileReader(const char* name, bool big_endian);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   428
    ~ImageFileReader();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   429
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   430
    // Compute number of bytes in image file index.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   431
    inline size_t index_size() {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   432
        return sizeof(ImageHeader) +
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   433
            table_length() * sizeof(u4) * 2 + locations_size() + strings_size();
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   434
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   435
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   436
public:
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   437
    enum {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   438
        // Image file marker.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   439
        IMAGE_MAGIC = 0xCAFEDADA,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   440
        // Endian inverted Image file marker.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   441
        IMAGE_MAGIC_INVERT = 0xDADAFECA,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   442
        // Image file major version number.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   443
        MAJOR_VERSION = 1,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   444
        // Image file minor version number.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   445
        MINOR_VERSION = 0
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   446
    };
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   447
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   448
    // Locate an image if file already open.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   449
    static ImageFileReader* find_image(const char* name);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   450
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   451
    // Open an image file, reuse structure if file already open.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   452
    static ImageFileReader* open(const char* name, bool big_endian = Endian::is_big_endian());
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   453
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   454
    // Close an image file if the file is not in use elsewhere.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   455
    static void close(ImageFileReader *reader);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   456
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   457
    // Return an id for the specifed ImageFileReader.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   458
    static u8 reader_to_ID(ImageFileReader *reader);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   459
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   460
    // Validate the image id.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   461
    static bool id_check(u8 id);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   462
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   463
    // Return an id for the specifed ImageFileReader.
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   464
    static ImageFileReader* id_to_reader(u8 id);
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   465
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   466
    // Open image file for read access.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   467
    bool open();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   468
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   469
    // Close image file.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   470
    void close();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   471
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   472
    // Read directly from the file.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   473
    bool read_at(u1* data, u8 size, u8 offset) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   474
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   475
    inline Endian* endian() const { return _endian; }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   476
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   477
    // Retrieve name of image file.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   478
    inline const char* name() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   479
        return _name;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   480
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   481
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   482
    // Retrieve size of image file.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   483
    inline u8 file_size() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   484
        return _file_size;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   485
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   486
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   487
    // Retrieve the size of the mapped image.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   488
    inline u8 map_size() const {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   489
        return (u8)(memory_map_image ? _file_size : _index_size);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   490
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 35784
diff changeset
   491
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   492
    // Return first address of index data.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   493
    inline u1* get_index_address() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   494
        return _index_data;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   495
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   496
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   497
    // Return first address of resource data.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   498
    inline u1* get_data_address() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   499
        return _index_data + _index_size;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   500
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   501
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   502
    // Get the size of the index data.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   503
    size_t get_index_size() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   504
        return _index_size;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   505
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   506
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   507
    inline u4 table_length() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   508
        return _header.table_length(_endian);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   509
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   510
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   511
    inline u4 locations_size() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   512
        return _header.locations_size(_endian);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   513
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   514
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   515
    inline u4 strings_size()const    {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   516
        return _header.strings_size(_endian);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   517
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   518
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   519
    inline u4* offsets_table() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   520
        return _offsets_table;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   521
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   522
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   523
    // Increment use count.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   524
    inline void inc_use() {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   525
        _use++;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   526
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   527
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   528
    // Decrement use count.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   529
    inline bool dec_use() {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   530
        return --_use == 0;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   531
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   532
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   533
    // Return a string table accessor.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   534
    inline const ImageStrings get_strings() const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   535
        return ImageStrings(_string_bytes, _header.strings_size(_endian));
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   536
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   537
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   538
    // Return location attribute stream at offset.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   539
    inline u1* get_location_offset_data(u4 offset) const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   540
        assert((u4)offset < _header.locations_size(_endian) &&
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   541
                            "offset exceeds location attributes size");
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   542
        return offset != 0 ? _location_bytes + offset : NULL;
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   543
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   544
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   545
    // Return location attribute stream for location i.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   546
    inline u1* get_location_data(u4 index) const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   547
        return get_location_offset_data(get_location_offset(index));
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   548
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   549
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   550
    // Return the location offset for index.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   551
    inline u4 get_location_offset(u4 index) const {
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   552
        assert((u4)index < _header.table_length(_endian) &&
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   553
                            "index exceeds location count");
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   554
        return _endian->get(_offsets_table[index]);
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   555
    }
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   556
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   557
    // Find the location attributes associated with the path.    Returns true if
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   558
    // the location is found, false otherwise.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   559
    bool find_location(const char* path, ImageLocation& location) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   560
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   561
    // Find the location index and size associated with the path.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   562
    // Returns the location index and size if the location is found,
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   563
    // ImageFileReader::NOT_FOUND otherwise.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   564
    u4 find_location_index(const char* path, u8 *size) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   565
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   566
    // Assemble the location path.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   567
    void location_path(ImageLocation& location, char* path, size_t max) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   568
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   569
    // Verify that a found location matches the supplied path.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   570
    bool verify_location(ImageLocation& location, const char* path) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   571
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   572
    // Return the resource for the supplied location index.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   573
    void get_resource(u4 index, u1* uncompressed_data) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   574
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   575
    // Return the resource for the supplied path.
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   576
    void get_resource(ImageLocation& location, u1* uncompressed_data) const;
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   577
32757
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   578
    // Return the ImageModuleData for this image
79d34d4b9627 8135197: libjimage code needs translation from hotspot-ish to jdk-ish
jlaskey
parents: 32641
diff changeset
   579
    ImageModuleData * get_image_module_data();
32641
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   580
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   581
};
ac2c73b45253 8087181: Move native jimage code to its own library (maybe libjimage)
jlaskey
parents:
diff changeset
   582
#endif // LIBJIMAGE_IMAGEFILE_HPP