< prev index next >

src/share/vm/runtime/globals.cpp

Print this page




 458 // All flags except "manageable" are assumed to be internal flags.
 459 // Long term, we need to define a mechanism to specify which flags
 460 // are external/stable and change this function accordingly.
 461 bool Flag::is_external() const {
 462   return is_manageable() || is_external_ext();
 463 }
 464 
 465 void Flag::print_on(outputStream* st, bool withComments, bool printRanges) {
 466   // Don't print notproduct and develop flags in a product build.
 467   if (is_constant_in_binary()) {
 468     return;
 469   }
 470 
 471   if (!printRanges) {
 472     // The print below assumes that the flag name is 40 characters or less.
 473     // This works for most flags, but there are exceptions. Our longest flag
 474     // name right now is UseAdaptiveGenerationSizePolicyAtMajorCollection and
 475     // its minor collection buddy. These are 48 characters. We use a buffer of
 476     // 10 spaces below to adjust the space between the flag value and the
 477     // column of flag type and origin that is printed in the end of the line.
 478     char spaces[10 + 1] = "          ";
 479     st->print("%9s %-40s = ", _type, _name);





 480 
 481     if (is_bool()) {
 482       st->print("%-20s", get_bool() ? "true" : "false");
 483     } else if (is_int()) {
 484       st->print("%-20d", get_int());
 485     } else if (is_uint()) {
 486       st->print("%-20u", get_uint());
 487     } else if (is_intx()) {
 488       st->print(INTX_FORMAT_W(-20), get_intx());
 489     } else if (is_uintx()) {
 490       st->print(UINTX_FORMAT_W(-20), get_uintx());
 491     } else if (is_uint64_t()) {
 492       st->print(UINT64_FORMAT_W(-20), get_uint64_t());
 493     } else if (is_size_t()) {
 494       st->print(SIZE_FORMAT_W(-20), get_size_t());
 495     } else if (is_double()) {
 496       st->print("%-20f", get_double());
 497     } else if (is_ccstr()) {
 498       const char* cp = get_ccstr();
 499       if (cp != NULL) {
 500         const char* eol;
 501         while ((eol = strchr(cp, '\n')) != NULL) {
 502           size_t llen = pointer_delta(eol, cp, sizeof(char));
 503           st->print("%.*s", (int)llen, cp);
 504           st->cr();
 505           cp = eol+1;
 506           st->print("%5s %-35s += ", "", _name);
 507         }
 508         st->print("%-20s", cp);
 509       }
 510       else st->print("%-20s", "");
 511     }
 512     assert(strlen(_name) < 50, "Flag name is longer than expected");
 513     spaces[50 - MAX2((size_t)40, strlen(_name))] = '\0';


 514     st->print("%s", spaces);

 515     print_kind_and_origin(st);
 516 
 517 #ifndef PRODUCT
 518     if (withComments) {
 519       st->print("%s", _doc);
 520     }
 521 #endif
 522 
 523     st->cr();
 524 
 525   } else if (!is_bool() && !is_ccstr()) {
 526     st->print("%9s %-50s ", _type, _name);
 527 
 528     RangeStrFunc func = NULL;
 529     if (is_int()) {
 530       func = Flag::get_int_default_range_str;
 531     } else if (is_uint()) {
 532       func = Flag::get_uint_default_range_str;
 533     } else if (is_intx()) {
 534       func = Flag::get_intx_default_range_str;




 458 // All flags except "manageable" are assumed to be internal flags.
 459 // Long term, we need to define a mechanism to specify which flags
 460 // are external/stable and change this function accordingly.
 461 bool Flag::is_external() const {
 462   return is_manageable() || is_external_ext();
 463 }
 464 
 465 void Flag::print_on(outputStream* st, bool withComments, bool printRanges) {
 466   // Don't print notproduct and develop flags in a product build.
 467   if (is_constant_in_binary()) {
 468     return;
 469   }
 470 
 471   if (!printRanges) {
 472     // The print below assumes that the flag name is 40 characters or less.
 473     // This works for most flags, but there are exceptions. Our longest flag
 474     // name right now is UseAdaptiveGenerationSizePolicyAtMajorCollection and
 475     // its minor collection buddy. These are 48 characters. We use a buffer of
 476     // 10 spaces below to adjust the space between the flag value and the
 477     // column of flag type and origin that is printed in the end of the line.
 478 
 479     // Use some named constants to make code more readable.
 480     char spaces[] = "          ";  // 10 spaces plus NUL
 481     const unsigned int maxFlagLen = 50;
 482     const unsigned int nSpaces = strlen(spaces);
 483 
 484     st->print("%9s %-*s = ", _type, maxFlagLen-nSpaces, _name);
 485 
 486     if (is_bool()) {
 487       st->print("%-20s", get_bool() ? "true" : "false");
 488     } else if (is_int()) {
 489       st->print("%-20d", get_int());
 490     } else if (is_uint()) {
 491       st->print("%-20u", get_uint());
 492     } else if (is_intx()) {
 493       st->print(INTX_FORMAT_W(-20), get_intx());
 494     } else if (is_uintx()) {
 495       st->print(UINTX_FORMAT_W(-20), get_uintx());
 496     } else if (is_uint64_t()) {
 497       st->print(UINT64_FORMAT_W(-20), get_uint64_t());
 498     } else if (is_size_t()) {
 499       st->print(SIZE_FORMAT_W(-20), get_size_t());
 500     } else if (is_double()) {
 501       st->print("%-20f", get_double());
 502     } else if (is_ccstr()) {
 503       const char* cp = get_ccstr();
 504       if (cp != NULL) {
 505         const char* eol;
 506         while ((eol = strchr(cp, '\n')) != NULL) {
 507           size_t llen = pointer_delta(eol, cp, sizeof(char));
 508           st->print("%.*s", (int)llen, cp);
 509           st->cr();
 510           cp = eol+1;
 511           st->print("%5s %-35s += ", "", _name);
 512         }
 513         st->print("%-20s", cp);
 514       }
 515       else st->print("%-20s", "");
 516     }
 517     // Make sure we do not punch a '\0' at a negative char array index.
 518     unsigned int nameLen = strlen(_name);
 519     if (nameLen <= maxFlagLen) {
 520       spaces[maxFlagLen - MAX2(maxFlagLen-nSpaces, nameLen)] = '\0';
 521       st->print("%s", spaces);
 522     }
 523     print_kind_and_origin(st);
 524 
 525 #ifndef PRODUCT
 526     if (withComments) {
 527       st->print("%s", _doc);
 528     }
 529 #endif
 530 
 531     st->cr();
 532 
 533   } else if (!is_bool() && !is_ccstr()) {
 534     st->print("%9s %-50s ", _type, _name);
 535 
 536     RangeStrFunc func = NULL;
 537     if (is_int()) {
 538       func = Flag::get_int_default_range_str;
 539     } else if (is_uint()) {
 540       func = Flag::get_uint_default_range_str;
 541     } else if (is_intx()) {
 542       func = Flag::get_intx_default_range_str;


< prev index next >