提交 a5eefa17 编写于 作者: M morris

8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp

Summary: Fixed parfait initialization issue.
Reviewed-by: kvn, twisti
上级 917a87c4
...@@ -407,56 +407,66 @@ void Dependencies::check_valid_dependency_type(DepType dept) { ...@@ -407,56 +407,66 @@ void Dependencies::check_valid_dependency_type(DepType dept) {
// for the sake of the compiler log, print out current dependencies: // for the sake of the compiler log, print out current dependencies:
void Dependencies::log_all_dependencies() { void Dependencies::log_all_dependencies() {
if (log() == NULL) return; if (log() == NULL) return;
ciBaseObject* args[max_arg_count]; ResourceMark rm;
for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) {
DepType dept = (DepType)deptv; DepType dept = (DepType)deptv;
GrowableArray<ciBaseObject*>* deps = _deps[dept]; GrowableArray<ciBaseObject*>* deps = _deps[dept];
if (deps->length() == 0) continue; int deplen = deps->length();
if (deplen == 0) {
continue;
}
int stride = dep_args(dept); int stride = dep_args(dept);
GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(stride);
for (int i = 0; i < deps->length(); i += stride) { for (int i = 0; i < deps->length(); i += stride) {
for (int j = 0; j < stride; j++) { for (int j = 0; j < stride; j++) {
// flush out the identities before printing // flush out the identities before printing
args[j] = deps->at(i+j); ciargs->push(deps->at(i+j));
} }
write_dependency_to(log(), dept, stride, args); write_dependency_to(log(), dept, ciargs);
ciargs->clear();
} }
guarantee(deplen == deps->length(), "deps array cannot grow inside nested ResoureMark scope");
} }
} }
void Dependencies::write_dependency_to(CompileLog* log, void Dependencies::write_dependency_to(CompileLog* log,
DepType dept, DepType dept,
int nargs, DepArgument args[], GrowableArray<DepArgument>* args,
Klass* witness) { Klass* witness) {
if (log == NULL) { if (log == NULL) {
return; return;
} }
ResourceMark rm;
ciEnv* env = ciEnv::current(); ciEnv* env = ciEnv::current();
ciBaseObject* ciargs[max_arg_count]; GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(args->length());
assert(nargs <= max_arg_count, "oob"); for (GrowableArrayIterator<DepArgument> it = args->begin(); it != args->end(); ++it) {
for (int j = 0; j < nargs; j++) { DepArgument arg = *it;
if (args[j].is_oop()) { if (arg.is_oop()) {
ciargs[j] = env->get_object(args[j].oop_value()); ciargs->push(env->get_object(arg.oop_value()));
} else { } else {
ciargs[j] = env->get_metadata(args[j].metadata_value()); ciargs->push(env->get_metadata(arg.metadata_value()));
} }
} }
Dependencies::write_dependency_to(log, dept, nargs, ciargs, witness); int argslen = ciargs->length();
Dependencies::write_dependency_to(log, dept, ciargs, witness);
guarantee(argslen == ciargs->length(), "ciargs array cannot grow inside nested ResoureMark scope");
} }
void Dependencies::write_dependency_to(CompileLog* log, void Dependencies::write_dependency_to(CompileLog* log,
DepType dept, DepType dept,
int nargs, ciBaseObject* args[], GrowableArray<ciBaseObject*>* args,
Klass* witness) { Klass* witness) {
if (log == NULL) return; if (log == NULL) {
assert(nargs <= max_arg_count, "oob"); return;
int argids[max_arg_count]; }
int ctxkj = dep_context_arg(dept); // -1 if no context arg ResourceMark rm;
int j; GrowableArray<int>* argids = new GrowableArray<int>(args->length());
for (j = 0; j < nargs; j++) { for (GrowableArrayIterator<ciBaseObject*> it = args->begin(); it != args->end(); ++it) {
if (args[j]->is_object()) { ciBaseObject* obj = *it;
argids[j] = log->identify(args[j]->as_object()); if (obj->is_object()) {
argids->push(log->identify(obj->as_object()));
} else { } else {
argids[j] = log->identify(args[j]->as_metadata()); argids->push(log->identify(obj->as_metadata()));
} }
} }
if (witness != NULL) { if (witness != NULL) {
...@@ -465,16 +475,17 @@ void Dependencies::write_dependency_to(CompileLog* log, ...@@ -465,16 +475,17 @@ void Dependencies::write_dependency_to(CompileLog* log,
log->begin_elem("dependency"); log->begin_elem("dependency");
} }
log->print(" type='%s'", dep_name(dept)); log->print(" type='%s'", dep_name(dept));
if (ctxkj >= 0) { const int ctxkj = dep_context_arg(dept); // -1 if no context arg
log->print(" ctxk='%d'", argids[ctxkj]); if (ctxkj >= 0 && ctxkj < argids->length()) {
log->print(" ctxk='%d'", argids->at(ctxkj));
} }
// write remaining arguments, if any. // write remaining arguments, if any.
for (j = 0; j < nargs; j++) { for (int j = 0; j < argids->length(); j++) {
if (j == ctxkj) continue; // already logged if (j == ctxkj) continue; // already logged
if (j == 1) { if (j == 1) {
log->print( " x='%d'", argids[j]); log->print( " x='%d'", argids->at(j));
} else { } else {
log->print(" x%d='%d'", j, argids[j]); log->print(" x%d='%d'", j, argids->at(j));
} }
} }
if (witness != NULL) { if (witness != NULL) {
...@@ -486,9 +497,12 @@ void Dependencies::write_dependency_to(CompileLog* log, ...@@ -486,9 +497,12 @@ void Dependencies::write_dependency_to(CompileLog* log,
void Dependencies::write_dependency_to(xmlStream* xtty, void Dependencies::write_dependency_to(xmlStream* xtty,
DepType dept, DepType dept,
int nargs, DepArgument args[], GrowableArray<DepArgument>* args,
Klass* witness) { Klass* witness) {
if (xtty == NULL) return; if (xtty == NULL) {
return;
}
ResourceMark rm;
ttyLocker ttyl; ttyLocker ttyl;
int ctxkj = dep_context_arg(dept); // -1 if no context arg int ctxkj = dep_context_arg(dept); // -1 if no context arg
if (witness != NULL) { if (witness != NULL) {
...@@ -498,23 +512,24 @@ void Dependencies::write_dependency_to(xmlStream* xtty, ...@@ -498,23 +512,24 @@ void Dependencies::write_dependency_to(xmlStream* xtty,
} }
xtty->print(" type='%s'", dep_name(dept)); xtty->print(" type='%s'", dep_name(dept));
if (ctxkj >= 0) { if (ctxkj >= 0) {
xtty->object("ctxk", args[ctxkj].metadata_value()); xtty->object("ctxk", args->at(ctxkj).metadata_value());
} }
// write remaining arguments, if any. // write remaining arguments, if any.
for (int j = 0; j < nargs; j++) { for (int j = 0; j < args->length(); j++) {
if (j == ctxkj) continue; // already logged if (j == ctxkj) continue; // already logged
DepArgument arg = args->at(j);
if (j == 1) { if (j == 1) {
if (args[j].is_oop()) { if (arg.is_oop()) {
xtty->object("x", args[j].oop_value()); xtty->object("x", arg.oop_value());
} else { } else {
xtty->object("x", args[j].metadata_value()); xtty->object("x", arg.metadata_value());
} }
} else { } else {
char xn[10]; sprintf(xn, "x%d", j); char xn[10]; sprintf(xn, "x%d", j);
if (args[j].is_oop()) { if (arg.is_oop()) {
xtty->object(xn, args[j].oop_value()); xtty->object(xn, arg.oop_value());
} else { } else {
xtty->object(xn, args[j].metadata_value()); xtty->object(xn, arg.metadata_value());
} }
} }
} }
...@@ -525,7 +540,7 @@ void Dependencies::write_dependency_to(xmlStream* xtty, ...@@ -525,7 +540,7 @@ void Dependencies::write_dependency_to(xmlStream* xtty,
xtty->end_elem(); xtty->end_elem();
} }
void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], void Dependencies::print_dependency(DepType dept, GrowableArray<DepArgument>* args,
Klass* witness) { Klass* witness) {
ResourceMark rm; ResourceMark rm;
ttyLocker ttyl; // keep the following output all in one block ttyLocker ttyl; // keep the following output all in one block
...@@ -534,8 +549,8 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], ...@@ -534,8 +549,8 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[],
dep_name(dept)); dep_name(dept));
// print arguments // print arguments
int ctxkj = dep_context_arg(dept); // -1 if no context arg int ctxkj = dep_context_arg(dept); // -1 if no context arg
for (int j = 0; j < nargs; j++) { for (int j = 0; j < args->length(); j++) {
DepArgument arg = args[j]; DepArgument arg = args->at(j);
bool put_star = false; bool put_star = false;
if (arg.is_null()) continue; if (arg.is_null()) continue;
const char* what; const char* what;
...@@ -571,31 +586,33 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], ...@@ -571,31 +586,33 @@ void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[],
void Dependencies::DepStream::log_dependency(Klass* witness) { void Dependencies::DepStream::log_dependency(Klass* witness) {
if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime
ResourceMark rm; ResourceMark rm;
int nargs = argument_count(); const int nargs = argument_count();
DepArgument args[max_arg_count]; GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
for (int j = 0; j < nargs; j++) { for (int j = 0; j < nargs; j++) {
if (type() == call_site_target_value) { if (type() == call_site_target_value) {
args[j] = argument_oop(j); args->push(argument_oop(j));
} else { } else {
args[j] = argument(j); args->push(argument(j));
} }
} }
int argslen = args->length();
if (_deps != NULL && _deps->log() != NULL) { if (_deps != NULL && _deps->log() != NULL) {
Dependencies::write_dependency_to(_deps->log(), Dependencies::write_dependency_to(_deps->log(), type(), args, witness);
type(), nargs, args, witness);
} else { } else {
Dependencies::write_dependency_to(xtty, Dependencies::write_dependency_to(xtty, type(), args, witness);
type(), nargs, args, witness);
} }
guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope");
} }
void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) {
ResourceMark rm;
int nargs = argument_count(); int nargs = argument_count();
DepArgument args[max_arg_count]; GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
for (int j = 0; j < nargs; j++) { for (int j = 0; j < nargs; j++) {
args[j] = argument(j); args->push(argument(j));
} }
Dependencies::print_dependency(type(), nargs, args, witness); int argslen = args->length();
Dependencies::print_dependency(type(), args, witness);
if (verbose) { if (verbose) {
if (_code != NULL) { if (_code != NULL) {
tty->print(" code: "); tty->print(" code: ");
...@@ -603,6 +620,7 @@ void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { ...@@ -603,6 +620,7 @@ void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) {
tty->cr(); tty->cr();
} }
} }
guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope");
} }
......
...@@ -368,20 +368,36 @@ class Dependencies: public ResourceObj { ...@@ -368,20 +368,36 @@ class Dependencies: public ResourceObj {
void copy_to(nmethod* nm); void copy_to(nmethod* nm);
void log_all_dependencies(); void log_all_dependencies();
void log_dependency(DepType dept, int nargs, ciBaseObject* args[]) {
write_dependency_to(log(), dept, nargs, args); void log_dependency(DepType dept, GrowableArray<ciBaseObject*>* args) {
ResourceMark rm;
int argslen = args->length();
write_dependency_to(log(), dept, args);
guarantee(argslen == args->length(),
"args array cannot grow inside nested ResoureMark scope");
} }
void log_dependency(DepType dept, void log_dependency(DepType dept,
ciBaseObject* x0, ciBaseObject* x0,
ciBaseObject* x1 = NULL, ciBaseObject* x1 = NULL,
ciBaseObject* x2 = NULL) { ciBaseObject* x2 = NULL) {
if (log() == NULL) return; if (log() == NULL) {
ciBaseObject* args[max_arg_count]; return;
args[0] = x0; }
args[1] = x1; ResourceMark rm;
args[2] = x2; GrowableArray<ciBaseObject*>* ciargs =
assert(2 < max_arg_count, ""); new GrowableArray<ciBaseObject*>(dep_args(dept));
log_dependency(dept, dep_args(dept), args); assert (x0 != NULL, "no log x0");
ciargs->push(x0);
if (x1 != NULL) {
ciargs->push(x1);
}
if (x2 != NULL) {
ciargs->push(x2);
}
assert(ciargs->length() == dep_args(dept), "");
log_dependency(dept, ciargs);
} }
class DepArgument : public ResourceObj { class DepArgument : public ResourceObj {
...@@ -404,20 +420,8 @@ class Dependencies: public ResourceObj { ...@@ -404,20 +420,8 @@ class Dependencies: public ResourceObj {
Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; } Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; }
}; };
static void write_dependency_to(CompileLog* log,
DepType dept,
int nargs, ciBaseObject* args[],
Klass* witness = NULL);
static void write_dependency_to(CompileLog* log,
DepType dept,
int nargs, DepArgument args[],
Klass* witness = NULL);
static void write_dependency_to(xmlStream* xtty,
DepType dept,
int nargs, DepArgument args[],
Klass* witness = NULL);
static void print_dependency(DepType dept, static void print_dependency(DepType dept,
int nargs, DepArgument args[], GrowableArray<DepArgument>* args,
Klass* witness = NULL); Klass* witness = NULL);
private: private:
...@@ -426,6 +430,18 @@ class Dependencies: public ResourceObj { ...@@ -426,6 +430,18 @@ class Dependencies: public ResourceObj {
static Klass* ctxk_encoded_as_null(DepType dept, Metadata* x); static Klass* ctxk_encoded_as_null(DepType dept, Metadata* x);
static void write_dependency_to(CompileLog* log,
DepType dept,
GrowableArray<ciBaseObject*>* args,
Klass* witness = NULL);
static void write_dependency_to(CompileLog* log,
DepType dept,
GrowableArray<DepArgument>* args,
Klass* witness = NULL);
static void write_dependency_to(xmlStream* xtty,
DepType dept,
GrowableArray<DepArgument>* args,
Klass* witness = NULL);
public: public:
// Use this to iterate over an nmethod's dependency set. // Use this to iterate over an nmethod's dependency set.
// Works on new and old dependency sets. // Works on new and old dependency sets.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册