@@ -121,7 +121,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
121
121
int mutable_data_size) :
122
122
_oop_maps(nullptr ), // will be set by set_oop_maps() call
123
123
_name(name),
124
- _mutable_data(nullptr ),
124
+ _mutable_data(header_begin() + size), // default value is blob_end()
125
125
_size(size),
126
126
_relocation_size(align_up(cb->total_relocation_size (), oopSize)),
127
127
_content_offset(CodeBlob::align_code_offset(header_size)),
@@ -151,6 +151,9 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
151
151
if (_mutable_data == nullptr ) {
152
152
vm_exit_out_of_memory (_mutable_data_size, OOM_MALLOC_ERROR, " codebuffer: no space for mutable data" );
153
153
}
154
+ } else {
155
+ // We need unique and valid not null address
156
+ assert (_mutable_data = blob_end (), " sanity" );
154
157
}
155
158
156
159
set_oop_maps (oop_maps);
@@ -160,7 +163,7 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size
160
163
CodeBlob::CodeBlob (const char * name, CodeBlobKind kind, int size, uint16_t header_size) :
161
164
_oop_maps(nullptr ),
162
165
_name(name),
163
- _mutable_data(nullptr ),
166
+ _mutable_data(header_begin() + size), // default value is blob_end()
164
167
_size(size),
165
168
_relocation_size(0 ),
166
169
_content_offset(CodeBlob::align_code_offset(header_size)),
@@ -175,12 +178,14 @@ CodeBlob::CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t heade
175
178
{
176
179
assert (is_aligned (size, oopSize), " unaligned size" );
177
180
assert (is_aligned (header_size, oopSize), " unaligned size" );
181
+ assert (_mutable_data = blob_end (), " sanity" );
178
182
}
179
183
180
184
void CodeBlob::purge () {
181
- if (_mutable_data != nullptr ) {
185
+ assert (_mutable_data != nullptr , " should never be null" );
186
+ if (_mutable_data != blob_end ()) {
182
187
os::free (_mutable_data);
183
- _mutable_data = nullptr ;
188
+ _mutable_data = blob_end (); // Valid not null address
184
189
}
185
190
if (_oop_maps != nullptr ) {
186
191
delete _oop_maps;
0 commit comments