@@ -121,7 +121,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
121121 int mutable_data_size) :
122122 _oop_maps(nullptr ), // will be set by set_oop_maps() call
123123 _name(name),
124- _mutable_data(nullptr ),
124+ _mutable_data(header_begin() + size), // default value is blob_end()
125125 _size(size),
126126 _relocation_size(align_up(cb->total_relocation_size (), oopSize)),
127127 _content_offset(CodeBlob::align_code_offset(header_size)),
@@ -151,6 +151,9 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
151151 if (_mutable_data == nullptr ) {
152152 vm_exit_out_of_memory (_mutable_data_size, OOM_MALLOC_ERROR, " codebuffer: no space for mutable data" );
153153 }
154+ } else {
155+ // We need unique and valid not null address
156+ assert (_mutable_data = blob_end (), " sanity" );
154157 }
155158
156159 set_oop_maps (oop_maps);
@@ -160,7 +163,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
160163CodeBlob::CodeBlob (const char * name, CodeBlobKind kind, int size, uint16_t header_size) :
161164 _oop_maps(nullptr ),
162165 _name(name),
163- _mutable_data(nullptr ),
166+ _mutable_data(header_begin() + size), // default value is blob_end()
164167 _size(size),
165168 _relocation_size(0 ),
166169 _content_offset(CodeBlob::align_code_offset(header_size)),
@@ -175,12 +178,14 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t heade
175178{
176179 assert (is_aligned (size, oopSize), " unaligned size" );
177180 assert (is_aligned (header_size, oopSize), " unaligned size" );
181+ assert (_mutable_data = blob_end (), " sanity" );
178182}
179183
180184void CodeBlob::purge () {
181- if (_mutable_data != nullptr ) {
185+ assert (_mutable_data != nullptr , " should never be null" );
186+ if (_mutable_data != blob_end ()) {
182187 os::free (_mutable_data);
183- _mutable_data = nullptr ;
188+ _mutable_data = blob_end (); // Valid not null address
184189 }
185190 if (_oop_maps != nullptr ) {
186191 delete _oop_maps;
0 commit comments