Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit b5c0f98

Browse files
author
Yuri Nesterenko
committed
8222079: Don't use memset to initialize fields decode_env constructor in disassembler.cpp
Backport-of: 9c2e153
1 parent be68489 commit b5c0f98

File tree

1 file changed

+76
-36
lines changed

1 file changed

+76
-36
lines changed

src/hotspot/share/compiler/disassembler.cpp

Lines changed: 76 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -315,56 +315,96 @@ void decode_env::print_hook_comments(address pc, bool newline) {
315315
}
316316
}
317317

318-
decode_env::decode_env(CodeBuffer* code, outputStream* output) {
319-
memset(this, 0, sizeof(*this));
320-
_output = output ? output : tty;
321-
_codeBlob = NULL;
322-
_codeBuffer = code;
323-
_helpPrinted = false;
324-
318+
decode_env::decode_env(CodeBuffer* code, outputStream* output) :
319+
_output(output ? output : tty),
320+
_codeBuffer(code),
321+
_codeBlob(NULL),
322+
_nm(NULL),
323+
_strings(),
324+
_start(NULL),
325+
_end(NULL),
326+
_option_buf(),
327+
_print_raw(0),
328+
_cur_insn(NULL),
329+
_bytes_per_line(0),
330+
_pre_decode_alignment(0),
331+
_post_decode_alignment(0),
332+
_print_file_name(false),
333+
_print_help(false),
334+
_helpPrinted(false) {
335+
336+
memset(_option_buf, 0, sizeof(_option_buf));
325337
process_options(_output);
326338
}
327339

328-
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
329-
memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields.
330-
_output = output ? output : tty;
331-
_codeBlob = code;
332-
_codeBuffer = NULL;
333-
_helpPrinted = false;
334-
if (_codeBlob != NULL && _codeBlob->is_nmethod()) {
335-
_nm = (nmethod*) code;
336-
}
340+
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) :
341+
_output(output ? output : tty),
342+
_codeBuffer(NULL),
343+
_codeBlob(code),
344+
_nm(_codeBlob != NULL && _codeBlob->is_nmethod() ? (nmethod*) code : NULL),
345+
_strings(),
346+
_start(NULL),
347+
_end(NULL),
348+
_option_buf(),
349+
_print_raw(0),
350+
_cur_insn(NULL),
351+
_bytes_per_line(0),
352+
_pre_decode_alignment(0),
353+
_post_decode_alignment(0),
354+
_print_file_name(false),
355+
_print_help(false),
356+
_helpPrinted(false) {
357+
358+
memset(_option_buf, 0, sizeof(_option_buf));
337359
_strings.copy(c);
338-
339360
process_options(_output);
340361
}
341362

342-
decode_env::decode_env(nmethod* code, outputStream* output, CodeStrings c) {
343-
memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields.
344-
_output = output ? output : tty;
345-
_codeBlob = NULL;
346-
_codeBuffer = NULL;
347-
_nm = code;
348-
_start = _nm->code_begin();
349-
_end = _nm->code_end();
350-
_helpPrinted = false;
363+
decode_env::decode_env(nmethod* code, outputStream* output, CodeStrings c) :
364+
_output(output ? output : tty),
365+
_codeBuffer(NULL),
366+
_codeBlob(NULL),
367+
_nm(code),
368+
_strings(),
369+
_start(_nm->code_begin()),
370+
_end(_nm->code_end()),
371+
_option_buf(),
372+
_print_raw(0),
373+
_cur_insn(NULL),
374+
_bytes_per_line(0),
375+
_pre_decode_alignment(0),
376+
_post_decode_alignment(0),
377+
_print_file_name(false),
378+
_print_help(false),
379+
_helpPrinted(false) {
380+
381+
memset(_option_buf, 0, sizeof(_option_buf));
351382
_strings.copy(c);
352-
353383
process_options(_output);
354384
}
355385

356386
// Constructor for a 'decode_env' to decode a memory range [start, end)
357387
// of unknown origin, assuming it contains code.
358-
decode_env::decode_env(address start, address end, outputStream* output) {
359-
assert(start < end, "Range must have a positive size, [" PTR_FORMAT ".." PTR_FORMAT ").", p2i(start), p2i(end));
360-
memset(this, 0, sizeof(*this));
361-
_output = output ? output : tty;
362-
_codeBlob = NULL;
363-
_codeBuffer = NULL;
364-
_start = start;
365-
_end = end;
366-
_helpPrinted = false;
388+
decode_env::decode_env(address start, address end, outputStream* output) :
389+
_output(output ? output : tty),
390+
_codeBuffer(NULL),
391+
_codeBlob(NULL),
392+
_nm(NULL),
393+
_strings(),
394+
_start(start),
395+
_end(end),
396+
_option_buf(),
397+
_print_raw(0),
398+
_cur_insn(NULL),
399+
_bytes_per_line(0),
400+
_pre_decode_alignment(0),
401+
_post_decode_alignment(0),
402+
_print_file_name(false),
403+
_print_help(false),
404+
_helpPrinted(false) {
367405

406+
assert(start < end, "Range must have a positive size, [" PTR_FORMAT ".." PTR_FORMAT ").", p2i(start), p2i(end));
407+
memset(_option_buf, 0, sizeof(_option_buf));
368408
process_options(_output);
369409
}
370410

0 commit comments

Comments
 (0)