comparison src/share/vm/runtime/globals.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents d2a62e0f25eb
children a5dd6e3ef9f3
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
79 } else { 79 } else {
80 return is_unlocked_ext(); 80 return is_unlocked_ext();
81 } 81 }
82 } 82 }
83 83
84 // Get custom message for this locked flag, or return NULL if
85 // none is available.
86 void Flag::get_locked_message(char* buf, int buflen) const {
87 get_locked_message_ext(buf, buflen);
88 }
89
84 bool Flag::is_writeable() const { 90 bool Flag::is_writeable() const {
85 return strcmp(kind, "{manageable}") == 0 || 91 return strcmp(kind, "{manageable}") == 0 ||
86 strcmp(kind, "{product rw}") == 0 || 92 strcmp(kind, "{product rw}") == 0 ||
87 is_writeable_ext(); 93 is_writeable_ext();
88 } 94 }
140 st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); 146 st->print("-XX:%s=" INTX_FORMAT, name, get_intx());
141 } else if (is_uintx()) { 147 } else if (is_uintx()) {
142 st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); 148 st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
143 } else if (is_uint64_t()) { 149 } else if (is_uint64_t()) {
144 st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t()); 150 st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t());
151 } else if (is_double()) {
152 st->print("-XX:%s=%f", name, get_double());
145 } else if (is_ccstr()) { 153 } else if (is_ccstr()) {
146 st->print("-XX:%s=", name); 154 st->print("-XX:%s=", name);
147 const char* cp = get_ccstr(); 155 const char* cp = get_ccstr();
148 if (cp != NULL) { 156 if (cp != NULL) {
149 // Need to turn embedded '\n's back into separate arguments 157 // Need to turn embedded '\n's back into separate arguments
258 // s is null terminated, q is not! 266 // s is null terminated, q is not!
259 if (strlen(s) != (unsigned int) len) return false; 267 if (strlen(s) != (unsigned int) len) return false;
260 return strncmp(s, q, len) == 0; 268 return strncmp(s, q, len) == 0;
261 } 269 }
262 270
263 Flag* Flag::find_flag(char* name, size_t length) { 271 // Search the flag table for a named flag
264 for (Flag* current = &flagTable[0]; current->name; current++) { 272 Flag* Flag::find_flag(char* name, size_t length, bool allow_locked) {
273 for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
265 if (str_equal(current->name, name, length)) { 274 if (str_equal(current->name, name, length)) {
275 // Found a matching entry. Report locked flags only if allowed.
266 if (!(current->is_unlocked() || current->is_unlocker())) { 276 if (!(current->is_unlocked() || current->is_unlocker())) {
267 // disable use of diagnostic or experimental flags until they 277 if (!allow_locked) {
268 // are explicitly unlocked 278 // disable use of locked flags, e.g. diagnostic, experimental,
269 return NULL; 279 // commercial... until they are explicitly unlocked
280 return NULL;
281 }
270 } 282 }
271 return current; 283 return current;
272 } 284 }
273 } 285 }
286 // Flag name is not in the flag table
274 return NULL; 287 return NULL;
275 } 288 }
276 289
277 // Returns the address of the index'th element 290 // Returns the address of the index'th element
278 static Flag* address_of_flag(CommandLineFlagWithType flag) { 291 static Flag* address_of_flag(CommandLineFlagWithType flag) {
450 if (result == NULL) return false; 463 if (result == NULL) return false;
451 if (!result->is_ccstr()) return false; 464 if (!result->is_ccstr()) return false;
452 ccstr old_value = result->get_ccstr(); 465 ccstr old_value = result->get_ccstr();
453 char* new_value = NULL; 466 char* new_value = NULL;
454 if (*value != NULL) { 467 if (*value != NULL) {
455 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1); 468 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
456 strcpy(new_value, *value); 469 strcpy(new_value, *value);
457 } 470 }
458 result->set_ccstr(new_value); 471 result->set_ccstr(new_value);
459 if (result->origin == DEFAULT && old_value != NULL) { 472 if (result->origin == DEFAULT && old_value != NULL) {
460 // Prior value is NOT heap allocated, but was a literal constant. 473 // Prior value is NOT heap allocated, but was a literal constant.
461 char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1); 474 char* old_value_to_free = NEW_C_HEAP_ARRAY(char, strlen(old_value)+1, mtInternal);
462 strcpy(old_value_to_free, old_value); 475 strcpy(old_value_to_free, old_value);
463 old_value = old_value_to_free; 476 old_value = old_value_to_free;
464 } 477 }
465 *value = old_value; 478 *value = old_value;
466 result->origin = origin; 479 result->origin = origin;
470 // Contract: Flag will make private copy of the incoming value. 483 // Contract: Flag will make private copy of the incoming value.
471 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) { 484 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) {
472 Flag* faddr = address_of_flag(flag); 485 Flag* faddr = address_of_flag(flag);
473 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); 486 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
474 ccstr old_value = faddr->get_ccstr(); 487 ccstr old_value = faddr->get_ccstr();
475 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1); 488 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
476 strcpy(new_value, value); 489 strcpy(new_value, value);
477 faddr->set_ccstr(new_value); 490 faddr->set_ccstr(new_value);
478 if (faddr->origin != DEFAULT && old_value != NULL) { 491 if (faddr->origin != DEFAULT && old_value != NULL) {
479 // Prior value is heap allocated so free it. 492 // Prior value is heap allocated so free it.
480 FREE_C_HEAP_ARRAY(char, old_value); 493 FREE_C_HEAP_ARRAY(char, old_value, mtInternal);
481 } 494 }
482 faddr->origin = origin; 495 faddr->origin = origin;
483 } 496 }
484 497
485 extern "C" { 498 extern "C" {
496 // Compute size 509 // Compute size
497 int length= 0; 510 int length= 0;
498 while (flagTable[length].name != NULL) length++; 511 while (flagTable[length].name != NULL) length++;
499 512
500 // Sort 513 // Sort
501 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); 514 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
502 for (int index = 0; index < length; index++) { 515 for (int index = 0; index < length; index++) {
503 array[index] = &flagTable[index]; 516 array[index] = &flagTable[index];
504 } 517 }
505 qsort(array, length, sizeof(Flag*), compare_flags); 518 qsort(array, length, sizeof(Flag*), compare_flags);
506 519
510 array[i]->print_as_flag(out); 523 array[i]->print_as_flag(out);
511 out->print(" "); 524 out->print(" ");
512 } 525 }
513 } 526 }
514 out->cr(); 527 out->cr();
515 FREE_C_HEAP_ARRAY(Flag*, array); 528 FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
516 } 529 }
517 530
518 #ifndef PRODUCT 531 #ifndef PRODUCT
519 532
520 533
532 // Compute size 545 // Compute size
533 int length= 0; 546 int length= 0;
534 while (flagTable[length].name != NULL) length++; 547 while (flagTable[length].name != NULL) length++;
535 548
536 // Sort 549 // Sort
537 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); 550 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
538 for (int index = 0; index < length; index++) { 551 for (int index = 0; index < length; index++) {
539 array[index] = &flagTable[index]; 552 array[index] = &flagTable[index];
540 } 553 }
541 qsort(array, length, sizeof(Flag*), compare_flags); 554 qsort(array, length, sizeof(Flag*), compare_flags);
542 555
545 for (int i = 0; i < length; i++) { 558 for (int i = 0; i < length; i++) {
546 if (array[i]->is_unlocked()) { 559 if (array[i]->is_unlocked()) {
547 array[i]->print_on(out, withComments); 560 array[i]->print_on(out, withComments);
548 } 561 }
549 } 562 }
550 FREE_C_HEAP_ARRAY(Flag*, array); 563 FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
551 } 564 }