comparison src/share/vm/runtime/globals.cpp @ 6197:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents f47478089efc
children a5dd6e3ef9f3
comparison
equal deleted inserted replaced
6174:74533f63b116 6197:d2a62e0f25eb
463 if (result == NULL) return false; 463 if (result == NULL) return false;
464 if (!result->is_ccstr()) return false; 464 if (!result->is_ccstr()) return false;
465 ccstr old_value = result->get_ccstr(); 465 ccstr old_value = result->get_ccstr();
466 char* new_value = NULL; 466 char* new_value = NULL;
467 if (*value != NULL) { 467 if (*value != NULL) {
468 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1); 468 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
469 strcpy(new_value, *value); 469 strcpy(new_value, *value);
470 } 470 }
471 result->set_ccstr(new_value); 471 result->set_ccstr(new_value);
472 if (result->origin == DEFAULT && old_value != NULL) { 472 if (result->origin == DEFAULT && old_value != NULL) {
473 // Prior value is NOT heap allocated, but was a literal constant. 473 // Prior value is NOT heap allocated, but was a literal constant.
474 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);
475 strcpy(old_value_to_free, old_value); 475 strcpy(old_value_to_free, old_value);
476 old_value = old_value_to_free; 476 old_value = old_value_to_free;
477 } 477 }
478 *value = old_value; 478 *value = old_value;
479 result->origin = origin; 479 result->origin = origin;
483 // Contract: Flag will make private copy of the incoming value. 483 // Contract: Flag will make private copy of the incoming value.
484 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) { 484 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, FlagValueOrigin origin) {
485 Flag* faddr = address_of_flag(flag); 485 Flag* faddr = address_of_flag(flag);
486 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); 486 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
487 ccstr old_value = faddr->get_ccstr(); 487 ccstr old_value = faddr->get_ccstr();
488 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1); 488 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal);
489 strcpy(new_value, value); 489 strcpy(new_value, value);
490 faddr->set_ccstr(new_value); 490 faddr->set_ccstr(new_value);
491 if (faddr->origin != DEFAULT && old_value != NULL) { 491 if (faddr->origin != DEFAULT && old_value != NULL) {
492 // Prior value is heap allocated so free it. 492 // Prior value is heap allocated so free it.
493 FREE_C_HEAP_ARRAY(char, old_value); 493 FREE_C_HEAP_ARRAY(char, old_value, mtInternal);
494 } 494 }
495 faddr->origin = origin; 495 faddr->origin = origin;
496 } 496 }
497 497
498 extern "C" { 498 extern "C" {
509 // Compute size 509 // Compute size
510 int length= 0; 510 int length= 0;
511 while (flagTable[length].name != NULL) length++; 511 while (flagTable[length].name != NULL) length++;
512 512
513 // Sort 513 // Sort
514 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); 514 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
515 for (int index = 0; index < length; index++) { 515 for (int index = 0; index < length; index++) {
516 array[index] = &flagTable[index]; 516 array[index] = &flagTable[index];
517 } 517 }
518 qsort(array, length, sizeof(Flag*), compare_flags); 518 qsort(array, length, sizeof(Flag*), compare_flags);
519 519
523 array[i]->print_as_flag(out); 523 array[i]->print_as_flag(out);
524 out->print(" "); 524 out->print(" ");
525 } 525 }
526 } 526 }
527 out->cr(); 527 out->cr();
528 FREE_C_HEAP_ARRAY(Flag*, array); 528 FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
529 } 529 }
530 530
531 #ifndef PRODUCT 531 #ifndef PRODUCT
532 532
533 533
545 // Compute size 545 // Compute size
546 int length= 0; 546 int length= 0;
547 while (flagTable[length].name != NULL) length++; 547 while (flagTable[length].name != NULL) length++;
548 548
549 // Sort 549 // Sort
550 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length); 550 Flag** array = NEW_C_HEAP_ARRAY(Flag*, length, mtInternal);
551 for (int index = 0; index < length; index++) { 551 for (int index = 0; index < length; index++) {
552 array[index] = &flagTable[index]; 552 array[index] = &flagTable[index];
553 } 553 }
554 qsort(array, length, sizeof(Flag*), compare_flags); 554 qsort(array, length, sizeof(Flag*), compare_flags);
555 555
558 for (int i = 0; i < length; i++) { 558 for (int i = 0; i < length; i++) {
559 if (array[i]->is_unlocked()) { 559 if (array[i]->is_unlocked()) {
560 array[i]->print_on(out, withComments); 560 array[i]->print_on(out, withComments);
561 } 561 }
562 } 562 }
563 FREE_C_HEAP_ARRAY(Flag*, array); 563 FREE_C_HEAP_ARRAY(Flag*, array, mtInternal);
564 } 564 }