src/share/vm/runtime/globals.cpp

Mon, 01 Feb 2010 17:35:05 -0700

author
dcubed
date
Mon, 01 Feb 2010 17:35:05 -0700
changeset 1648
6deeaebad47a
parent 1585
f62a22282a47
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6902182: 4/4 Starting with jdwp agent should not incur performance penalty
Summary: Rename can_post_exceptions support to can_post_on_exceptions. Add support for should_post_on_exceptions flag to permit per JavaThread optimizations.
Reviewed-by: never, kvn, dcubed
Contributed-by: tom.deneau@amd.com

     1 /*
     2  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_globals.cpp.incl"
    29 RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
    30               MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
    31               MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
    32               MATERIALIZE_NOTPRODUCT_FLAG, \
    33               MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \
    34               MATERIALIZE_LP64_PRODUCT_FLAG)
    36 RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
    37                  MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
    38                  MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
    40 bool Flag::is_unlocker() const {
    41   return strcmp(name, "UnlockDiagnosticVMOptions") == 0     ||
    42          strcmp(name, "UnlockExperimentalVMOptions") == 0;
    44 }
    46 bool Flag::is_unlocked() const {
    47   if (strcmp(kind, "{diagnostic}") == 0) {
    48     return UnlockDiagnosticVMOptions;
    49   } else if (strcmp(kind, "{experimental}") == 0 ||
    50              strcmp(kind, "{C2 experimental}") == 0) {
    51     return UnlockExperimentalVMOptions;
    52   } else {
    53     return true;
    54   }
    55 }
    57 bool Flag::is_writeable() const {
    58   return (strcmp(kind, "{manageable}") == 0 || strcmp(kind, "{product rw}") == 0);
    59 }
    61 // All flags except "manageable" are assumed internal flags.
    62 // Long term, we need to define a mechanism to specify which flags
    63 // are external/stable and change this function accordingly.
    64 bool Flag::is_external() const {
    65   return (strcmp(kind, "{manageable}") == 0);
    66 }
    68 // Length of format string (e.g. "%.1234s") for printing ccstr below
    69 #define FORMAT_BUFFER_LEN 16
    71 void Flag::print_on(outputStream* st) {
    72   st->print("%5s %-35s %c= ", type, name, (origin != DEFAULT ? ':' : ' '));
    73   if (is_bool())     st->print("%-16s", get_bool() ? "true" : "false");
    74   if (is_intx())     st->print("%-16ld", get_intx());
    75   if (is_uintx())    st->print("%-16lu", get_uintx());
    76   if (is_uint64_t()) st->print("%-16lu", get_uint64_t());
    77   if (is_ccstr()) {
    78     const char* cp = get_ccstr();
    79     if (cp != NULL) {
    80       const char* eol;
    81       while ((eol = strchr(cp, '\n')) != NULL) {
    82         char format_buffer[FORMAT_BUFFER_LEN];
    83         size_t llen = pointer_delta(eol, cp, sizeof(char));
    84         jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
    85                      "%%." SIZE_FORMAT "s", llen);
    86         st->print(format_buffer, cp);
    87         st->cr();
    88         cp = eol+1;
    89         st->print("%5s %-35s += ", "", name);
    90       }
    91       st->print("%-16s", cp);
    92     }
    93   }
    94   st->print(" %s", kind);
    95   st->cr();
    96 }
    98 void Flag::print_as_flag(outputStream* st) {
    99   if (is_bool()) {
   100     st->print("-XX:%s%s", get_bool() ? "+" : "-", name);
   101   } else if (is_intx()) {
   102     st->print("-XX:%s=" INTX_FORMAT, name, get_intx());
   103   } else if (is_uintx()) {
   104     st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
   105   } else if (is_uint64_t()) {
   106     st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t());
   107   } else if (is_ccstr()) {
   108     st->print("-XX:%s=", name);
   109     const char* cp = get_ccstr();
   110     if (cp != NULL) {
   111       // Need to turn embedded '\n's back into separate arguments
   112       // Not so efficient to print one character at a time,
   113       // but the choice is to do the transformation to a buffer
   114       // and print that.  And this need not be efficient.
   115       for (; *cp != '\0'; cp += 1) {
   116         switch (*cp) {
   117           default:
   118             st->print("%c", *cp);
   119             break;
   120           case '\n':
   121             st->print(" -XX:%s=", name);
   122             break;
   123         }
   124       }
   125     }
   126   } else {
   127     ShouldNotReachHere();
   128   }
   129 }
   131 // 4991491 do not "optimize out" the was_set false values: omitting them
   132 // tickles a Microsoft compiler bug causing flagTable to be malformed
   134 #define RUNTIME_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{product}", DEFAULT },
   135 #define RUNTIME_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, "{pd product}", DEFAULT },
   136 #define RUNTIME_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{diagnostic}", DEFAULT },
   137 #define RUNTIME_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{experimental}", DEFAULT },
   138 #define RUNTIME_MANAGEABLE_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{manageable}", DEFAULT },
   139 #define RUNTIME_PRODUCT_RW_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{product rw}", DEFAULT },
   141 #ifdef PRODUCT
   142   #define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
   143   #define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
   144   #define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
   145 #else
   146   #define RUNTIME_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "", DEFAULT },
   147   #define RUNTIME_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, "{pd}", DEFAULT },
   148   #define RUNTIME_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{notproduct}", DEFAULT },
   149 #endif
   151 #ifdef _LP64
   152   #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{lp64_product}", DEFAULT },
   153 #else
   154   #define RUNTIME_LP64_PRODUCT_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
   155 #endif // _LP64
   157 #define C1_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C1 product}", DEFAULT },
   158 #define C1_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, "{C1 pd product}", DEFAULT },
   159 #ifdef PRODUCT
   160   #define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
   161   #define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
   162   #define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
   163 #else
   164   #define C1_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C1}", DEFAULT },
   165   #define C1_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, "{C1 pd}", DEFAULT },
   166   #define C1_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C1 notproduct}", DEFAULT },
   167 #endif
   170 #define C2_PRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 product}", DEFAULT },
   171 #define C2_PD_PRODUCT_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, "{C2 pd product}", DEFAULT },
   172 #define C2_DIAGNOSTIC_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 diagnostic}", DEFAULT },
   173 #define C2_EXPERIMENTAL_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 experimental}", DEFAULT },
   174 #ifdef PRODUCT
   175   #define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) /* flag is constant */
   176   #define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     /* flag is constant */
   177   #define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc)
   178 #else
   179   #define C2_DEVELOP_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2}", DEFAULT },
   180   #define C2_PD_DEVELOP_FLAG_STRUCT(type, name, doc)     { #type, XSTR(name), &name, "{C2 pd}", DEFAULT },
   181   #define C2_NOTPRODUCT_FLAG_STRUCT(type, name, value, doc) { #type, XSTR(name), &name, "{C2 notproduct}", DEFAULT },
   182 #endif
   185 static Flag flagTable[] = {
   186  RUNTIME_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT, RUNTIME_LP64_PRODUCT_FLAG_STRUCT)
   187  RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT)
   188 #ifndef SERIALGC
   189  G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, RUNTIME_PD_DEVELOP_FLAG_STRUCT, RUNTIME_PRODUCT_FLAG_STRUCT, RUNTIME_PD_PRODUCT_FLAG_STRUCT, RUNTIME_DIAGNOSTIC_FLAG_STRUCT, RUNTIME_EXPERIMENTAL_FLAG_STRUCT, RUNTIME_NOTPRODUCT_FLAG_STRUCT, RUNTIME_MANAGEABLE_FLAG_STRUCT, RUNTIME_PRODUCT_RW_FLAG_STRUCT)
   190 #endif // SERIALGC
   191 #ifdef COMPILER1
   192  C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, C1_PD_DEVELOP_FLAG_STRUCT, C1_PRODUCT_FLAG_STRUCT, C1_PD_PRODUCT_FLAG_STRUCT, C1_NOTPRODUCT_FLAG_STRUCT)
   193 #endif
   194 #ifdef COMPILER2
   195  C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, C2_PD_DEVELOP_FLAG_STRUCT, C2_PRODUCT_FLAG_STRUCT, C2_PD_PRODUCT_FLAG_STRUCT, C2_DIAGNOSTIC_FLAG_STRUCT, C2_EXPERIMENTAL_FLAG_STRUCT, C2_NOTPRODUCT_FLAG_STRUCT)
   196 #endif
   197  {0, NULL, NULL}
   198 };
   200 Flag* Flag::flags = flagTable;
   201 size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag));
   203 inline bool str_equal(const char* s, char* q, size_t len) {
   204   // s is null terminated, q is not!
   205   if (strlen(s) != (unsigned int) len) return false;
   206   return strncmp(s, q, len) == 0;
   207 }
   209 Flag* Flag::find_flag(char* name, size_t length) {
   210   for (Flag* current = &flagTable[0]; current->name; current++) {
   211     if (str_equal(current->name, name, length)) {
   212       if (!(current->is_unlocked() || current->is_unlocker())) {
   213         // disable use of diagnostic or experimental flags until they
   214         // are explicitly unlocked
   215         return NULL;
   216       }
   217       return current;
   218     }
   219   }
   220   return NULL;
   221 }
   223 // Returns the address of the index'th element
   224 static Flag* address_of_flag(CommandLineFlagWithType flag) {
   225   assert((size_t)flag < Flag::numFlags, "bad command line flag index");
   226   return &Flag::flags[flag];
   227 }
   229 bool CommandLineFlagsEx::is_default(CommandLineFlag flag) {
   230   assert((size_t)flag < Flag::numFlags, "bad command line flag index");
   231   Flag* f = &Flag::flags[flag];
   232   return (f->origin == DEFAULT);
   233 }
   235 bool CommandLineFlagsEx::is_ergo(CommandLineFlag flag) {
   236   assert((size_t)flag < Flag::numFlags, "bad command line flag index");
   237   Flag* f = &Flag::flags[flag];
   238   return (f->origin == ERGONOMIC);
   239 }
   241 bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
   242   assert((size_t)flag < Flag::numFlags, "bad command line flag index");
   243   Flag* f = &Flag::flags[flag];
   244   return (f->origin == COMMAND_LINE);
   245 }
   247 bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
   248   Flag* result = Flag::find_flag((char*)name, strlen(name));
   249   if (result == NULL) return false;
   250   *value = (result->origin == COMMAND_LINE);
   251   return true;
   252 }
   254 bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) {
   255   Flag* result = Flag::find_flag(name, len);
   256   if (result == NULL) return false;
   257   if (!result->is_bool()) return false;
   258   *value = result->get_bool();
   259   return true;
   260 }
   262 bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, FlagValueOrigin origin) {
   263   Flag* result = Flag::find_flag(name, len);
   264   if (result == NULL) return false;
   265   if (!result->is_bool()) return false;
   266   bool old_value = result->get_bool();
   267   result->set_bool(*value);
   268   *value = old_value;
   269   result->origin = origin;
   270   return true;
   271 }
   273 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, FlagValueOrigin origin) {
   274   Flag* faddr = address_of_flag(flag);
   275   guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
   276   faddr->set_bool(value);
   277   faddr->origin = origin;
   278 }
   280 bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) {
   281   Flag* result = Flag::find_flag(name, len);
   282   if (result == NULL) return false;
   283   if (!result->is_intx()) return false;
   284   *value = result->get_intx();
   285   return true;
   286 }
   288 bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, FlagValueOrigin origin) {
   289   Flag* result = Flag::find_flag(name, len);
   290   if (result == NULL) return false;
   291   if (!result->is_intx()) return false;
   292   intx old_value = result->get_intx();
   293   result->set_intx(*value);
   294   *value = old_value;
   295   result->origin = origin;
   296   return true;
   297 }
   299 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, FlagValueOrigin origin) {
   300   Flag* faddr = address_of_flag(flag);
   301   guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
   302   faddr->set_intx(value);
   303   faddr->origin = origin;
   304 }
   306 bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) {
   307   Flag* result = Flag::find_flag(name, len);
   308   if (result == NULL) return false;
   309   if (!result->is_uintx()) return false;
   310   *value = result->get_uintx();
   311   return true;
   312 }
   314 bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, FlagValueOrigin origin) {
   315   Flag* result = Flag::find_flag(name, len);
   316   if (result == NULL) return false;
   317   if (!result->is_uintx()) return false;
   318   uintx old_value = result->get_uintx();
   319   result->set_uintx(*value);
   320   *value = old_value;
   321   result->origin = origin;
   322   return true;
   323 }
   325 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, FlagValueOrigin origin) {
   326   Flag* faddr = address_of_flag(flag);
   327   guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
   328   faddr->set_uintx(value);
   329   faddr->origin = origin;
   330 }
   332 bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) {
   333   Flag* result = Flag::find_flag(name, len);
   334   if (result == NULL) return false;
   335   if (!result->is_uint64_t()) return false;
   336   *value = result->get_uint64_t();
   337   return true;
   338 }
   340 bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, FlagValueOrigin origin) {
   341   Flag* result = Flag::find_flag(name, len);
   342   if (result == NULL) return false;
   343   if (!result->is_uint64_t()) return false;
   344   uint64_t old_value = result->get_uint64_t();
   345   result->set_uint64_t(*value);
   346   *value = old_value;
   347   result->origin = origin;
   348   return true;
   349 }
   351 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, FlagValueOrigin origin) {
   352   Flag* faddr = address_of_flag(flag);
   353   guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
   354   faddr->set_uint64_t(value);
   355   faddr->origin = origin;
   356 }
   358 bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) {
   359   Flag* result = Flag::find_flag(name, len);
   360   if (result == NULL) return false;
   361   if (!result->is_double()) return false;
   362   *value = result->get_double();
   363   return true;
   364 }
   366 bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, FlagValueOrigin origin) {
   367   Flag* result = Flag::find_flag(name, len);
   368   if (result == NULL) return false;
   369   if (!result->is_double()) return false;
   370   double old_value = result->get_double();
   371   result->set_double(*value);
   372   *value = old_value;
   373   result->origin = origin;
   374   return true;
   375 }
   377 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, FlagValueOrigin origin) {
   378   Flag* faddr = address_of_flag(flag);
   379   guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
   380   faddr->set_double(value);
   381   faddr->origin = origin;
   382 }
   384 bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) {
   385   Flag* result = Flag::find_flag(name, len);
   386   if (result == NULL) return false;
   387   if (!result->is_ccstr()) return false;
   388   *value = result->get_ccstr();
   389   return true;
   390 }
   392 // Contract:  Flag will make private copy of the incoming value.
   393 // Outgoing value is always malloc-ed, and caller MUST call free.
   394 bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, FlagValueOrigin origin) {
   395   Flag* result = Flag::find_flag(name, len);
   396   if (result == NULL) return false;
   397   if (!result->is_ccstr()) return false;
   398   ccstr old_value = result->get_ccstr();
   399   char* new_value = NULL;
   400   if (*value != NULL) {
   401     new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1);
   402     strcpy(new_value, *value);
   403   }
   404   result->set_ccstr(new_value);
   405   if (result->origin == DEFAULT && old_value != NULL) {
   406     // Prior value is NOT heap allocated, but was a literal constant.
   407     char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1);
   408     strcpy(old_value_to_free, old_value);
   409     old_value = old_value_to_free;
   410   }
   411   *value = old_value;
   412   result->origin = origin;
   413   return true;
   414 }
   416 // Contract:  Flag will make private copy of the incoming value.
   417 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) {
   418   Flag* faddr = address_of_flag(flag);
   419   guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
   420   ccstr old_value = faddr->get_ccstr();
   421   char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1);
   422   strcpy(new_value, value);
   423   faddr->set_ccstr(new_value);
   424   if (faddr->origin != DEFAULT && old_value != NULL) {
   425     // Prior value is heap allocated so free it.
   426     FREE_C_HEAP_ARRAY(char, old_value);
   427   }
   428   faddr->origin = origin;
   429 }
   431 extern "C" {
   432   static int compare_flags(const void* void_a, const void* void_b) {
   433     return strcmp((*((Flag**) void_a))->name, (*((Flag**) void_b))->name);
   434   }
   435 }
   437 void CommandLineFlags::printSetFlags() {
   438   // Print which flags were set on the command line
   439   // note: this method is called before the thread structure is in place
   440   //       which means resource allocation cannot be used.
   442   // Compute size
   443   int length= 0;
   444   while (flagTable[length].name != NULL) length++;
   446   // Sort
   447   Flag** array = NEW_C_HEAP_ARRAY(Flag*, length);
   448   for (int index = 0; index < length; index++) {
   449     array[index] = &flagTable[index];
   450   }
   451   qsort(array, length, sizeof(Flag*), compare_flags);
   453   // Print
   454   for (int i = 0; i < length; i++) {
   455     if (array[i]->origin /* naked field! */) {
   456       array[i]->print_as_flag(tty);
   457       tty->print(" ");
   458     }
   459   }
   460   tty->cr();
   461   FREE_C_HEAP_ARRAY(Flag*, array);
   462 }
   464 #ifndef PRODUCT
   467 void CommandLineFlags::verify() {
   468   assert(Arguments::check_vm_args_consistency(), "Some flag settings conflict");
   469 }
   471 #endif // PRODUCT
   473 void CommandLineFlags::printFlags() {
   474   // Print the flags sorted by name
   475   // note: this method is called before the thread structure is in place
   476   //       which means resource allocation cannot be used.
   478   // Compute size
   479   int length= 0;
   480   while (flagTable[length].name != NULL) length++;
   482   // Sort
   483   Flag** array = NEW_C_HEAP_ARRAY(Flag*, length);
   484   for (int index = 0; index < length; index++) {
   485     array[index] = &flagTable[index];
   486   }
   487   qsort(array, length, sizeof(Flag*), compare_flags);
   489   // Print
   490   tty->print_cr("[Global flags]");
   491   for (int i = 0; i < length; i++) {
   492     if (array[i]->is_unlocked()) {
   493       array[i]->print_on(tty);
   494     }
   495   }
   496   FREE_C_HEAP_ARRAY(Flag*, array);
   497 }

mercurial