src/share/vm/code/dependencies.cpp

changeset 7030
3c048df3ef8b
parent 6911
ce8f6bb717c9
child 7380
bee8095780db
child 7714
d5b74c583ec1
     1.1 --- a/src/share/vm/code/dependencies.cpp	Tue Aug 12 22:29:36 2014 +0000
     1.2 +++ b/src/share/vm/code/dependencies.cpp	Thu Aug 07 18:09:12 2014 -0700
     1.3 @@ -407,56 +407,66 @@
     1.4  // for the sake of the compiler log, print out current dependencies:
     1.5  void Dependencies::log_all_dependencies() {
     1.6    if (log() == NULL)  return;
     1.7 -  ciBaseObject* args[max_arg_count];
     1.8 +  ResourceMark rm;
     1.9    for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) {
    1.10      DepType dept = (DepType)deptv;
    1.11      GrowableArray<ciBaseObject*>* deps = _deps[dept];
    1.12 -    if (deps->length() == 0)  continue;
    1.13 +    int deplen = deps->length();
    1.14 +    if (deplen == 0) {
    1.15 +      continue;
    1.16 +    }
    1.17      int stride = dep_args(dept);
    1.18 +    GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(stride);
    1.19      for (int i = 0; i < deps->length(); i += stride) {
    1.20        for (int j = 0; j < stride; j++) {
    1.21          // flush out the identities before printing
    1.22 -        args[j] = deps->at(i+j);
    1.23 +        ciargs->push(deps->at(i+j));
    1.24        }
    1.25 -      write_dependency_to(log(), dept, stride, args);
    1.26 +      write_dependency_to(log(), dept, ciargs);
    1.27 +      ciargs->clear();
    1.28      }
    1.29 +    guarantee(deplen == deps->length(), "deps array cannot grow inside nested ResoureMark scope");
    1.30    }
    1.31  }
    1.32  
    1.33  void Dependencies::write_dependency_to(CompileLog* log,
    1.34                                         DepType dept,
    1.35 -                                       int nargs, DepArgument args[],
    1.36 +                                       GrowableArray<DepArgument>* args,
    1.37                                         Klass* witness) {
    1.38    if (log == NULL) {
    1.39      return;
    1.40    }
    1.41 +  ResourceMark rm;
    1.42    ciEnv* env = ciEnv::current();
    1.43 -  ciBaseObject* ciargs[max_arg_count];
    1.44 -  assert(nargs <= max_arg_count, "oob");
    1.45 -  for (int j = 0; j < nargs; j++) {
    1.46 -    if (args[j].is_oop()) {
    1.47 -      ciargs[j] = env->get_object(args[j].oop_value());
    1.48 +  GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(args->length());
    1.49 +  for (GrowableArrayIterator<DepArgument> it = args->begin(); it != args->end(); ++it) {
    1.50 +    DepArgument arg = *it;
    1.51 +    if (arg.is_oop()) {
    1.52 +      ciargs->push(env->get_object(arg.oop_value()));
    1.53      } else {
    1.54 -      ciargs[j] = env->get_metadata(args[j].metadata_value());
    1.55 +      ciargs->push(env->get_metadata(arg.metadata_value()));
    1.56      }
    1.57    }
    1.58 -  Dependencies::write_dependency_to(log, dept, nargs, ciargs, witness);
    1.59 +  int argslen = ciargs->length();
    1.60 +  Dependencies::write_dependency_to(log, dept, ciargs, witness);
    1.61 +  guarantee(argslen == ciargs->length(), "ciargs array cannot grow inside nested ResoureMark scope");
    1.62  }
    1.63  
    1.64  void Dependencies::write_dependency_to(CompileLog* log,
    1.65                                         DepType dept,
    1.66 -                                       int nargs, ciBaseObject* args[],
    1.67 +                                       GrowableArray<ciBaseObject*>* args,
    1.68                                         Klass* witness) {
    1.69 -  if (log == NULL)  return;
    1.70 -  assert(nargs <= max_arg_count, "oob");
    1.71 -  int argids[max_arg_count];
    1.72 -  int ctxkj = dep_context_arg(dept);  // -1 if no context arg
    1.73 -  int j;
    1.74 -  for (j = 0; j < nargs; j++) {
    1.75 -    if (args[j]->is_object()) {
    1.76 -      argids[j] = log->identify(args[j]->as_object());
    1.77 +  if (log == NULL) {
    1.78 +    return;
    1.79 +  }
    1.80 +  ResourceMark rm;
    1.81 +  GrowableArray<int>* argids = new GrowableArray<int>(args->length());
    1.82 +  for (GrowableArrayIterator<ciBaseObject*> it = args->begin(); it != args->end(); ++it) {
    1.83 +    ciBaseObject* obj = *it;
    1.84 +    if (obj->is_object()) {
    1.85 +      argids->push(log->identify(obj->as_object()));
    1.86      } else {
    1.87 -      argids[j] = log->identify(args[j]->as_metadata());
    1.88 +      argids->push(log->identify(obj->as_metadata()));
    1.89      }
    1.90    }
    1.91    if (witness != NULL) {
    1.92 @@ -465,16 +475,17 @@
    1.93      log->begin_elem("dependency");
    1.94    }
    1.95    log->print(" type='%s'", dep_name(dept));
    1.96 -  if (ctxkj >= 0) {
    1.97 -    log->print(" ctxk='%d'", argids[ctxkj]);
    1.98 +  const int ctxkj = dep_context_arg(dept);  // -1 if no context arg
    1.99 +  if (ctxkj >= 0 && ctxkj < argids->length()) {
   1.100 +    log->print(" ctxk='%d'", argids->at(ctxkj));
   1.101    }
   1.102    // write remaining arguments, if any.
   1.103 -  for (j = 0; j < nargs; j++) {
   1.104 +  for (int j = 0; j < argids->length(); j++) {
   1.105      if (j == ctxkj)  continue;  // already logged
   1.106      if (j == 1) {
   1.107 -      log->print(  " x='%d'",    argids[j]);
   1.108 +      log->print(  " x='%d'",    argids->at(j));
   1.109      } else {
   1.110 -      log->print(" x%d='%d'", j, argids[j]);
   1.111 +      log->print(" x%d='%d'", j, argids->at(j));
   1.112      }
   1.113    }
   1.114    if (witness != NULL) {
   1.115 @@ -486,9 +497,12 @@
   1.116  
   1.117  void Dependencies::write_dependency_to(xmlStream* xtty,
   1.118                                         DepType dept,
   1.119 -                                       int nargs, DepArgument args[],
   1.120 +                                       GrowableArray<DepArgument>* args,
   1.121                                         Klass* witness) {
   1.122 -  if (xtty == NULL)  return;
   1.123 +  if (xtty == NULL) {
   1.124 +    return;
   1.125 +  }
   1.126 +  ResourceMark rm;
   1.127    ttyLocker ttyl;
   1.128    int ctxkj = dep_context_arg(dept);  // -1 if no context arg
   1.129    if (witness != NULL) {
   1.130 @@ -498,23 +512,24 @@
   1.131    }
   1.132    xtty->print(" type='%s'", dep_name(dept));
   1.133    if (ctxkj >= 0) {
   1.134 -    xtty->object("ctxk", args[ctxkj].metadata_value());
   1.135 +    xtty->object("ctxk", args->at(ctxkj).metadata_value());
   1.136    }
   1.137    // write remaining arguments, if any.
   1.138 -  for (int j = 0; j < nargs; j++) {
   1.139 +  for (int j = 0; j < args->length(); j++) {
   1.140      if (j == ctxkj)  continue;  // already logged
   1.141 +    DepArgument arg = args->at(j);
   1.142      if (j == 1) {
   1.143 -      if (args[j].is_oop()) {
   1.144 -        xtty->object("x", args[j].oop_value());
   1.145 +      if (arg.is_oop()) {
   1.146 +        xtty->object("x", arg.oop_value());
   1.147        } else {
   1.148 -        xtty->object("x", args[j].metadata_value());
   1.149 +        xtty->object("x", arg.metadata_value());
   1.150        }
   1.151      } else {
   1.152        char xn[10]; sprintf(xn, "x%d", j);
   1.153 -      if (args[j].is_oop()) {
   1.154 -        xtty->object(xn, args[j].oop_value());
   1.155 +      if (arg.is_oop()) {
   1.156 +        xtty->object(xn, arg.oop_value());
   1.157        } else {
   1.158 -        xtty->object(xn, args[j].metadata_value());
   1.159 +        xtty->object(xn, arg.metadata_value());
   1.160        }
   1.161      }
   1.162    }
   1.163 @@ -525,7 +540,7 @@
   1.164    xtty->end_elem();
   1.165  }
   1.166  
   1.167 -void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[],
   1.168 +void Dependencies::print_dependency(DepType dept, GrowableArray<DepArgument>* args,
   1.169                                      Klass* witness) {
   1.170    ResourceMark rm;
   1.171    ttyLocker ttyl;   // keep the following output all in one block
   1.172 @@ -534,8 +549,8 @@
   1.173                  dep_name(dept));
   1.174    // print arguments
   1.175    int ctxkj = dep_context_arg(dept);  // -1 if no context arg
   1.176 -  for (int j = 0; j < nargs; j++) {
   1.177 -    DepArgument arg = args[j];
   1.178 +  for (int j = 0; j < args->length(); j++) {
   1.179 +    DepArgument arg = args->at(j);
   1.180      bool put_star = false;
   1.181      if (arg.is_null())  continue;
   1.182      const char* what;
   1.183 @@ -571,31 +586,33 @@
   1.184  void Dependencies::DepStream::log_dependency(Klass* witness) {
   1.185    if (_deps == NULL && xtty == NULL)  return;  // fast cutout for runtime
   1.186    ResourceMark rm;
   1.187 -  int nargs = argument_count();
   1.188 -  DepArgument args[max_arg_count];
   1.189 +  const int nargs = argument_count();
   1.190 +  GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
   1.191    for (int j = 0; j < nargs; j++) {
   1.192      if (type() == call_site_target_value) {
   1.193 -      args[j] = argument_oop(j);
   1.194 +      args->push(argument_oop(j));
   1.195      } else {
   1.196 -      args[j] = argument(j);
   1.197 +      args->push(argument(j));
   1.198      }
   1.199    }
   1.200 +  int argslen = args->length();
   1.201    if (_deps != NULL && _deps->log() != NULL) {
   1.202 -    Dependencies::write_dependency_to(_deps->log(),
   1.203 -                                      type(), nargs, args, witness);
   1.204 +    Dependencies::write_dependency_to(_deps->log(), type(), args, witness);
   1.205    } else {
   1.206 -    Dependencies::write_dependency_to(xtty,
   1.207 -                                      type(), nargs, args, witness);
   1.208 +    Dependencies::write_dependency_to(xtty, type(), args, witness);
   1.209    }
   1.210 +  guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope");
   1.211  }
   1.212  
   1.213  void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) {
   1.214 +  ResourceMark rm;
   1.215    int nargs = argument_count();
   1.216 -  DepArgument args[max_arg_count];
   1.217 +  GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
   1.218    for (int j = 0; j < nargs; j++) {
   1.219 -    args[j] = argument(j);
   1.220 +    args->push(argument(j));
   1.221    }
   1.222 -  Dependencies::print_dependency(type(), nargs, args, witness);
   1.223 +  int argslen = args->length();
   1.224 +  Dependencies::print_dependency(type(), args, witness);
   1.225    if (verbose) {
   1.226      if (_code != NULL) {
   1.227        tty->print("  code: ");
   1.228 @@ -603,6 +620,7 @@
   1.229        tty->cr();
   1.230      }
   1.231    }
   1.232 +  guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope");
   1.233  }
   1.234  
   1.235  

mercurial