comparison src/share/vm/memory/filemap.hpp @ 20730:8210e5f2e21b

8044269: Analysis of archive files. Summary: Add checksum verification. Reviewed-by: iklam, dholmes, mschoene
author jiangli
date Tue, 12 Aug 2014 17:46:16 -0400
parents 85c1ca43713f
children 8cb56c8cb30d
comparison
equal deleted inserted replaced
20729:609faa407cfd 20730:8210e5f2e21b
52 _current_version = 1 52 _current_version = 1
53 }; 53 };
54 54
55 bool _file_open; 55 bool _file_open;
56 int _fd; 56 int _fd;
57 long _file_offset; 57 size_t _file_offset;
58 58
59 // FileMapHeader describes the shared space data in the file to be 59 // FileMapHeader describes the shared space data in the file to be
60 // mapped. This structure gets written to a file. It is not a class, so 60 // mapped. This structure gets written to a file. It is not a class, so
61 // that the compilers don't add any compiler-private data to it. 61 // that the compilers don't add any compiler-private data to it.
62 62
63 struct FileMapHeader { 63 struct FileMapHeader {
64 int _magic; // identify file type. 64 int _magic; // identify file type.
65 int _crc; // header crc checksum.
65 int _version; // (from enum, above.) 66 int _version; // (from enum, above.)
66 size_t _alignment; // how shared archive should be aligned 67 size_t _alignment; // how shared archive should be aligned
67 int _obj_alignment; // value of ObjectAlignmentInBytes 68 int _obj_alignment; // value of ObjectAlignmentInBytes
68 69
69 struct space_info { 70 struct space_info {
70 int _file_offset; // sizeof(this) rounded to vm page size 71 int _crc; // crc checksum of the current space
72 size_t _file_offset; // sizeof(this) rounded to vm page size
71 char* _base; // copy-on-write base address 73 char* _base; // copy-on-write base address
72 size_t _capacity; // for validity checking 74 size_t _capacity; // for validity checking
73 size_t _used; // for setting space top on read 75 size_t _used; // for setting space top on read
74 bool _read_only; // read only space? 76 bool _read_only; // read only space?
75 bool _allow_exec; // executable code in space? 77 bool _allow_exec; // executable code in space?
102 _file_open = false; 104 _file_open = false;
103 _header._version = _invalid_version; 105 _header._version = _invalid_version;
104 } 106 }
105 107
106 static int current_version() { return _current_version; } 108 static int current_version() { return _current_version; }
109 int compute_header_crc();
110 void set_header_crc(int crc) { _header._crc = crc; }
107 void populate_header(size_t alignment); 111 void populate_header(size_t alignment);
108 bool validate(); 112 bool validate();
109 void invalidate(); 113 void invalidate();
110 int version() { return _header._version; } 114 int version() { return _header._version; }
111 size_t alignment() { return _header._alignment; } 115 size_t alignment() { return _header._alignment; }
134 size_t capacity, bool read_only, bool allow_exec); 138 size_t capacity, bool read_only, bool allow_exec);
135 void write_bytes(const void* buffer, int count); 139 void write_bytes(const void* buffer, int count);
136 void write_bytes_aligned(const void* buffer, int count); 140 void write_bytes_aligned(const void* buffer, int count);
137 char* map_region(int i); 141 char* map_region(int i);
138 void unmap_region(int i); 142 void unmap_region(int i);
143 bool verify_region_checksum(int i);
139 void close(); 144 void close();
140 bool is_open() { return _file_open; } 145 bool is_open() { return _file_open; }
141 ReservedSpace reserve_shared_memory(); 146 ReservedSpace reserve_shared_memory();
142 147
143 // JVM/TI RedefineClasses() support: 148 // JVM/TI RedefineClasses() support: