8140594: Various minor code improvements (compiler)
Various minor code improvements (compiler) Reviewed-by: thartmann, kvn
This commit is contained in:
parent
96c4dc3210
commit
1e4b00b1dc
@ -1913,9 +1913,10 @@ static bool _print_ascii_file(const char* filename, outputStream* st) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char buf[32];
|
||||
char buf[33];
|
||||
int bytes;
|
||||
while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) {
|
||||
buf[32] = '\0';
|
||||
while ((bytes = ::read(fd, buf, sizeof(buf)-1)) > 0) {
|
||||
st->print_raw(buf, bytes);
|
||||
}
|
||||
|
||||
@ -6033,8 +6034,8 @@ int os::get_core_path(char* buffer, size_t bufferSize) {
|
||||
|
||||
if (core_pattern[0] == '|') {
|
||||
written = jio_snprintf(buffer, bufferSize,
|
||||
"\"%s\" (or dumping to %s/core.%d)",
|
||||
&core_pattern[1], p, current_process_id());
|
||||
"\"%s\" (or dumping to %s/core.%d)",
|
||||
&core_pattern[1], p, current_process_id());
|
||||
} else {
|
||||
written = jio_snprintf(buffer, bufferSize, "%s/%s", p, core_pattern);
|
||||
}
|
||||
@ -6067,20 +6068,20 @@ bool os::start_debugging(char *buf, int buflen) {
|
||||
char *p = &buf[len];
|
||||
|
||||
jio_snprintf(p, buflen-len,
|
||||
"\n\n"
|
||||
"Do you want to debug the problem?\n\n"
|
||||
"To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " UINTX_FORMAT " (" INTPTR_FORMAT ")\n"
|
||||
"Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
|
||||
"Otherwise, press RETURN to abort...",
|
||||
os::current_process_id(), os::current_process_id(),
|
||||
os::current_thread_id(), os::current_thread_id());
|
||||
"\n\n"
|
||||
"Do you want to debug the problem?\n\n"
|
||||
"To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " UINTX_FORMAT " (" INTPTR_FORMAT ")\n"
|
||||
"Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
|
||||
"Otherwise, press RETURN to abort...",
|
||||
os::current_process_id(), os::current_process_id(),
|
||||
os::current_thread_id(), os::current_thread_id());
|
||||
|
||||
bool yes = os::message_box("Unexpected Error", buf);
|
||||
|
||||
if (yes) {
|
||||
// yes, user asked VM to launch debugger
|
||||
jio_snprintf(buf, sizeof(buf), "gdb /proc/%d/exe %d",
|
||||
os::current_process_id(), os::current_process_id());
|
||||
jio_snprintf(buf, sizeof(char)*buflen, "gdb /proc/%d/exe %d",
|
||||
os::current_process_id(), os::current_process_id());
|
||||
|
||||
os::fork_and_exec(buf);
|
||||
yes = false;
|
||||
|
@ -823,7 +823,7 @@ void os::print_context(outputStream *st, const void *context) {
|
||||
|
||||
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
|
||||
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
|
||||
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
|
||||
print_hex_dump(st, (address)sp, (address)(sp + 8), sizeof(intptr_t));
|
||||
st->cr();
|
||||
|
||||
// Note: it may be unsafe to inspect memory near pc. For example, pc may
|
||||
|
@ -1499,7 +1499,8 @@ void MachNodeForm::output(FILE *fp) {
|
||||
// twice, we need to check that the operands are pointer-eequivalent in
|
||||
// the DFA during the labeling process.
|
||||
Predicate *InstructForm::build_predicate() {
|
||||
char buf[1024], *s=buf;
|
||||
const int buflen = 1024;
|
||||
char buf[buflen], *s=buf;
|
||||
Dict names(cmpstr,hashstr,Form::arena); // Map Names to counts
|
||||
|
||||
MatchNode *mnode =
|
||||
@ -1508,12 +1509,12 @@ Predicate *InstructForm::build_predicate() {
|
||||
|
||||
uint first = 1;
|
||||
// Start with the predicate supplied in the .ad file.
|
||||
if( _predicate ) {
|
||||
if( first ) first=0;
|
||||
strcpy(s,"("); s += strlen(s);
|
||||
strcpy(s,_predicate->_pred);
|
||||
if (_predicate) {
|
||||
if (first) first = 0;
|
||||
strcpy(s, "("); s += strlen(s);
|
||||
strncpy(s, _predicate->_pred, buflen - strlen(s) - 1);
|
||||
s += strlen(s);
|
||||
strcpy(s,")"); s += strlen(s);
|
||||
strcpy(s, ")"); s += strlen(s);
|
||||
}
|
||||
for( DictI i(&names); i.test(); ++i ) {
|
||||
uintptr_t cnt = (uintptr_t)i._value;
|
||||
|
@ -5521,7 +5521,8 @@ int LinearScanWalker::find_locked_double_reg(int reg_needed_until, int interval_
|
||||
}
|
||||
}
|
||||
|
||||
if (_block_pos[max_reg] <= interval_to || _block_pos[max_reg + 1] <= interval_to) {
|
||||
if (max_reg != any_reg &&
|
||||
(_block_pos[max_reg] <= interval_to || _block_pos[max_reg + 1] <= interval_to)) {
|
||||
*need_split = true;
|
||||
}
|
||||
|
||||
@ -6497,8 +6498,9 @@ void LinearScanStatistic::print(const char* title) {
|
||||
if (_counters_sum[i] > 0 || _counters_max[i] >= 0) {
|
||||
tty->print("%25s: %8d", counter_name(i), _counters_sum[i]);
|
||||
|
||||
if (base_counter(i) != invalid_counter) {
|
||||
tty->print(" (%5.1f%%) ", _counters_sum[i] * 100.0 / _counters_sum[base_counter(i)]);
|
||||
LinearScanStatistic::Counter cntr = base_counter(i);
|
||||
if (cntr != invalid_counter) {
|
||||
tty->print(" (%5.1f%%) ", _counters_sum[i] * 100.0 / _counters_sum[cntr]);
|
||||
} else {
|
||||
tty->print(" ");
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ static const char *flagnames[] = {
|
||||
|
||||
void ciBlock::dump() {
|
||||
tty->print(" [%d .. %d), {", _start_bci, _limit_bci);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if ((_flags & (1 << i)) != 0) {
|
||||
tty->print(" %s", flagnames[i]);
|
||||
}
|
||||
|
@ -1401,9 +1401,11 @@ class ClassFileParser::FieldAllocationCount : public ResourceObj {
|
||||
|
||||
FieldAllocationType update(bool is_static, BasicType type) {
|
||||
FieldAllocationType atype = basic_type_to_atype(is_static, type);
|
||||
// Make sure there is no overflow with injected fields.
|
||||
assert(count[atype] < 0xFFFF, "More than 65535 fields");
|
||||
count[atype]++;
|
||||
if (atype != BAD_ALLOCATION_TYPE) {
|
||||
// Make sure there is no overflow with injected fields.
|
||||
assert(count[atype] < 0xFFFF, "More than 65535 fields");
|
||||
count[atype]++;
|
||||
}
|
||||
return atype;
|
||||
}
|
||||
};
|
||||
@ -3335,8 +3337,9 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
|
||||
}
|
||||
} else if (tag == vmSymbols::tag_bootstrap_methods() &&
|
||||
_major_version >= Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
|
||||
if (parsed_bootstrap_methods_attribute)
|
||||
if (parsed_bootstrap_methods_attribute) {
|
||||
classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
|
||||
}
|
||||
parsed_bootstrap_methods_attribute = true;
|
||||
parse_classfile_bootstrap_methods_attribute(cfs, cp, attribute_length, CHECK);
|
||||
} else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) {
|
||||
|
@ -305,11 +305,9 @@ u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TR
|
||||
}
|
||||
|
||||
if (is_multi_ver) {
|
||||
int n;
|
||||
char entry_name[JVM_MAXPATHLEN];
|
||||
if (version > 0) {
|
||||
n = jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", version, name);
|
||||
entry_name[n] = '\0';
|
||||
jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", version, name);
|
||||
buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL);
|
||||
if (buffer == NULL) {
|
||||
warning("Could not find %s in %s, try to find highest version instead", entry_name, _zip_name);
|
||||
@ -317,8 +315,7 @@ u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TR
|
||||
}
|
||||
if (buffer == NULL) {
|
||||
for (int i = cur_ver; i >= base_version; i--) {
|
||||
n = jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", i, name);
|
||||
entry_name[n] = '\0';
|
||||
jio_snprintf(entry_name, sizeof(entry_name), "META-INF/versions/%d/%s", i, name);
|
||||
buffer = open_entry((const char*)entry_name, filesize, false, CHECK_NULL);
|
||||
if (buffer != NULL) {
|
||||
break;
|
||||
|
@ -1160,10 +1160,10 @@ Klass* SystemDictionary::resolve_from_stream(Symbol* class_name,
|
||||
while ((index = strchr(name, '/')) != NULL) {
|
||||
*index = '.'; // replace '/' with '.' in package name
|
||||
}
|
||||
const char* fmt = "Prohibited package name: %s";
|
||||
size_t len = strlen(fmt) + strlen(name);
|
||||
const char* msg_text = "Prohibited package name: ";
|
||||
size_t len = strlen(msg_text) + strlen(name) + 1;
|
||||
char* message = NEW_RESOURCE_ARRAY(char, len);
|
||||
jio_snprintf(message, len, fmt, name);
|
||||
jio_snprintf(message, len, "%s%s", msg_text, name);
|
||||
Exceptions::_throw_msg(THREAD_AND_LOCATION,
|
||||
vmSymbols::java_lang_SecurityException(), message);
|
||||
}
|
||||
|
@ -2392,10 +2392,9 @@ void CompileBroker::print_times(bool per_compiler, bool aggregate) {
|
||||
|
||||
// Debugging output for failure
|
||||
void CompileBroker::print_last_compile() {
|
||||
if ( _last_compile_level != CompLevel_none &&
|
||||
compiler(_last_compile_level) != NULL &&
|
||||
_last_method_compiled != NULL &&
|
||||
_last_compile_type != no_compile) {
|
||||
if (_last_compile_level != CompLevel_none &&
|
||||
compiler(_last_compile_level) != NULL &&
|
||||
_last_compile_type != no_compile) {
|
||||
if (_last_compile_type == osr_compile) {
|
||||
tty->print_cr("Last parse: [osr]%d+++(%d) %s",
|
||||
_osr_compilation_id, _last_compile_level, _last_method_compiled);
|
||||
|
@ -231,7 +231,8 @@ void CompileLog::finish_log_on_error(outputStream* file, char* buf, int buflen)
|
||||
// Copy any remaining data inside a quote:
|
||||
bool saw_slop = false;
|
||||
int end_cdata = 0; // state machine [0..2] watching for too many "]]"
|
||||
while ((nr = read(partial_fd, buf, buflen)) > 0) {
|
||||
while ((nr = read(partial_fd, buf, buflen-1)) > 0) {
|
||||
buf[buflen-1] = '\0';
|
||||
if (!saw_slop) {
|
||||
file->print_raw_cr("<fragment>");
|
||||
file->print_raw_cr("<![CDATA[");
|
||||
|
@ -99,7 +99,7 @@ bool Disassembler::load_library() {
|
||||
const char* p = strrchr(buf, *os::file_separator());
|
||||
if (p != NULL) lib_offset = p - base + 1;
|
||||
p = strstr(p ? p : base, "jvm");
|
||||
if (p != NULL) jvm_offset = p - base;
|
||||
if (p != NULL) jvm_offset = p - base;
|
||||
}
|
||||
#endif
|
||||
// Find the disassembler shared library.
|
||||
@ -113,13 +113,13 @@ bool Disassembler::load_library() {
|
||||
strcpy(&buf[jvm_offset], hsdis_library_name);
|
||||
strcat(&buf[jvm_offset], os::dll_file_extension());
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
if (_library == NULL) {
|
||||
if (_library == NULL && lib_offset >= 0) {
|
||||
// 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
|
||||
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
}
|
||||
if (_library == NULL) {
|
||||
if (_library == NULL && lib_offset > 0) {
|
||||
// 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
|
||||
buf[lib_offset - 1] = '\0';
|
||||
const char* p = strrchr(buf, *os::file_separator());
|
||||
|
@ -104,12 +104,18 @@ void LogTagSet::vwrite(LogLevelType level, const char* fmt, va_list args) {
|
||||
va_copy(saved_args, args);
|
||||
size_t prefix_len = _write_prefix(buf, sizeof(buf));
|
||||
// Check that string fits in buffer; resize buffer if necessary
|
||||
int ret = os::log_vsnprintf(buf + prefix_len, sizeof(buf) - prefix_len, fmt, args);
|
||||
int ret;
|
||||
if (prefix_len < vwrite_buffer_size) {
|
||||
ret = os::log_vsnprintf(buf + prefix_len, sizeof(buf) - prefix_len, fmt, args);
|
||||
} else {
|
||||
// Buffer too small. Just call printf to find out the length for realloc below.
|
||||
ret = os::log_vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
}
|
||||
assert(ret >= 0, "Log message buffer issue");
|
||||
if ((size_t)ret >= sizeof(buf)) {
|
||||
size_t newbuf_len = prefix_len + ret + 1;
|
||||
char* newbuf = NEW_C_HEAP_ARRAY(char, newbuf_len, mtLogging);
|
||||
memcpy(newbuf, buf, prefix_len);
|
||||
prefix_len = _write_prefix(newbuf, newbuf_len);
|
||||
ret = os::log_vsnprintf(newbuf + prefix_len, newbuf_len - prefix_len, fmt, saved_args);
|
||||
assert(ret >= 0, "Log message buffer issue");
|
||||
log(level, newbuf);
|
||||
|
@ -80,7 +80,8 @@ static bool tag_array_is_zero_initialized(Array<u1>* tags) {
|
||||
|
||||
ConstantPool::ConstantPool(Array<u1>* tags) :
|
||||
_tags(tags),
|
||||
_length(tags->length()) {
|
||||
_length(tags->length()),
|
||||
_flags(0) {
|
||||
|
||||
assert(_tags != NULL, "invariant");
|
||||
assert(tags->length() == _length, "invariant");
|
||||
|
@ -1678,8 +1678,14 @@ void GenerateOopMap::ppdupswap(int poplen, const char *out) {
|
||||
CellTypeState actual[5];
|
||||
assert(poplen < 5, "this must be less than length of actual vector");
|
||||
|
||||
// pop all arguments
|
||||
for(int i = 0; i < poplen; i++) actual[i] = pop();
|
||||
// Pop all arguments.
|
||||
for (int i = 0; i < poplen; i++) {
|
||||
actual[i] = pop();
|
||||
}
|
||||
// Field _state is uninitialized when calling push.
|
||||
for (int i = poplen; i < 5; i++) {
|
||||
actual[i] = CellTypeState::uninit;
|
||||
}
|
||||
|
||||
// put them back
|
||||
char push_ch = *out++;
|
||||
|
@ -1430,7 +1430,7 @@ void PhaseBlockLayout::find_edges() {
|
||||
if (n->num_preds() != 1) break;
|
||||
|
||||
i++;
|
||||
assert(n = _cfg.get_block(i), "expecting next block");
|
||||
assert(n == _cfg.get_block(i), "expecting next block");
|
||||
tr->append(n);
|
||||
uf->map(n->_pre_order, tr->id());
|
||||
traces[n->_pre_order] = NULL;
|
||||
|
@ -256,6 +256,7 @@ uint TailJumpNode::match_edge(uint idx) const {
|
||||
JVMState::JVMState(ciMethod* method, JVMState* caller) :
|
||||
_method(method) {
|
||||
assert(method != NULL, "must be valid call site");
|
||||
_bci = InvocationEntryBci;
|
||||
_reexecute = Reexecute_Undefined;
|
||||
debug_only(_bci = -99); // random garbage value
|
||||
debug_only(_map = (SafePointNode*)-1);
|
||||
|
@ -1079,7 +1079,7 @@ bool GraphKit::compute_stack_effects(int& inputs, int& depth) {
|
||||
case Bytecodes::_freturn:
|
||||
case Bytecodes::_dreturn:
|
||||
case Bytecodes::_areturn:
|
||||
assert(rsize = -depth, "");
|
||||
assert(rsize == -depth, "");
|
||||
inputs = rsize;
|
||||
break;
|
||||
|
||||
|
@ -659,11 +659,14 @@ void Matcher::Fixup_Save_On_Entry( ) {
|
||||
uint reth_edge_cnt = TypeFunc::Parms+1;
|
||||
RegMask *reth_rms = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
|
||||
// Rethrow takes exception oop only, but in the argument 0 slot.
|
||||
reth_rms[TypeFunc::Parms] = mreg2regmask[find_receiver(false)];
|
||||
OptoReg::Name reg = find_receiver(false);
|
||||
if (reg >= 0) {
|
||||
reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
|
||||
#ifdef _LP64
|
||||
// Need two slots for ptrs in 64-bit land
|
||||
reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(find_receiver(false)),1));
|
||||
// Need two slots for ptrs in 64-bit land
|
||||
reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Input RegMask array shared by all TailCalls
|
||||
uint tail_call_edge_cnt = TypeFunc::Parms+2;
|
||||
|
@ -612,8 +612,8 @@ bool Relocator::relocate_code(int bci, int ilen, int delta) {
|
||||
// In case we have shrunken a tableswitch/lookupswitch statement, we store the last
|
||||
// bytes that get overwritten. We have to copy the bytes after the change_jumps method
|
||||
// has been called, since it is likely to update last offset in a tableswitch/lookupswitch
|
||||
if (delta < 0) {
|
||||
assert(delta>=-3, "we cannot overwrite more than 3 bytes");
|
||||
assert(delta >= -3, "We cannot overwrite more than 3 bytes.");
|
||||
if (delta < 0 && delta >= -3) {
|
||||
memcpy(_overwrite, addr_at(bci + ilen + delta), -delta);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user