Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/globals.cpp @ 14518:d8041d695d19
Merged with jdk9/dev/hotspot changeset 3812c088b945
author | twisti |
---|---|
date | Tue, 11 Mar 2014 18:45:59 -0700 |
parents | 02f27ecb4f3a 20e2bd0e84bf |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14141:f97c5ec83832 | 14518:d8041d695d19 |
---|---|
29 #include "runtime/globals.hpp" | 29 #include "runtime/globals.hpp" |
30 #include "runtime/globals_extension.hpp" | 30 #include "runtime/globals_extension.hpp" |
31 #include "utilities/ostream.hpp" | 31 #include "utilities/ostream.hpp" |
32 #include "utilities/macros.hpp" | 32 #include "utilities/macros.hpp" |
33 #include "utilities/top.hpp" | 33 #include "utilities/top.hpp" |
34 #include "trace/tracing.hpp" | |
34 #if INCLUDE_ALL_GCS | 35 #if INCLUDE_ALL_GCS |
35 #include "gc_implementation/g1/g1_globals.hpp" | 36 #include "gc_implementation/g1/g1_globals.hpp" |
36 #endif // INCLUDE_ALL_GCS | 37 #endif // INCLUDE_ALL_GCS |
37 #ifdef COMPILER1 | 38 #ifdef COMPILER1 |
38 #include "c1/c1_globals.hpp" | 39 #include "c1/c1_globals.hpp" |
62 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \ | 63 MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \ |
63 MATERIALIZE_NOTPRODUCT_FLAG) | 64 MATERIALIZE_NOTPRODUCT_FLAG) |
64 | 65 |
65 MATERIALIZE_FLAGS_EXT | 66 MATERIALIZE_FLAGS_EXT |
66 | 67 |
68 | |
69 static bool is_product_build() { | |
70 #ifdef PRODUCT | |
71 return true; | |
72 #else | |
73 return false; | |
74 #endif | |
75 } | |
67 | 76 |
68 void Flag::check_writable() { | 77 void Flag::check_writable() { |
69 if (is_constant_in_binary()) { | 78 if (is_constant_in_binary()) { |
70 fatal(err_msg("flag is constant: %s", _name)); | 79 fatal(err_msg("flag is constant: %s", _name)); |
71 } | 80 } |
236 } | 245 } |
237 | 246 |
238 // Get custom message for this locked flag, or return NULL if | 247 // Get custom message for this locked flag, or return NULL if |
239 // none is available. | 248 // none is available. |
240 void Flag::get_locked_message(char* buf, int buflen) const { | 249 void Flag::get_locked_message(char* buf, int buflen) const { |
250 buf[0] = '\0'; | |
251 if (is_diagnostic() && !is_unlocked()) { | |
252 jio_snprintf(buf, buflen, "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n", | |
253 _name); | |
254 return; | |
255 } | |
256 if (is_experimental() && !is_unlocked()) { | |
257 jio_snprintf(buf, buflen, "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n", | |
258 _name); | |
259 return; | |
260 } | |
261 if (is_develop() && is_product_build()) { | |
262 jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n", | |
263 _name); | |
264 return; | |
265 } | |
266 if (is_notproduct() && is_product_build()) { | |
267 jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n", | |
268 _name); | |
269 return; | |
270 } | |
241 get_locked_message_ext(buf, buflen); | 271 get_locked_message_ext(buf, buflen); |
242 } | 272 } |
243 | 273 |
244 bool Flag::is_writeable() const { | 274 bool Flag::is_writeable() const { |
245 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); | 275 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); |
296 st->print("%-16s", cp); | 326 st->print("%-16s", cp); |
297 } | 327 } |
298 else st->print("%-16s", ""); | 328 else st->print("%-16s", ""); |
299 } | 329 } |
300 | 330 |
301 st->print("%-20"); | 331 st->print("%-20s", " "); |
302 print_kind(st); | 332 print_kind(st); |
303 | 333 |
304 if (withComments) { | 334 if (withComments) { |
305 #ifndef PRODUCT | 335 #ifndef PRODUCT |
306 st->print("%s", _doc); | 336 st->print("%s", _doc); |
475 if (strlen(s) != (unsigned int) len) return false; | 505 if (strlen(s) != (unsigned int) len) return false; |
476 return strncmp(s, q, len) == 0; | 506 return strncmp(s, q, len) == 0; |
477 } | 507 } |
478 | 508 |
479 // Search the flag table for a named flag | 509 // Search the flag table for a named flag |
480 Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) { | 510 Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) { |
481 for (Flag* current = &flagTable[0]; current->_name != NULL; current++) { | 511 for (Flag* current = &flagTable[0]; current->_name != NULL; current++) { |
482 if (str_equal(current->_name, name, length)) { | 512 if (str_equal(current->_name, name, length)) { |
483 // Found a matching entry. | 513 // Found a matching entry. |
484 // Don't report notproduct and develop flags in product builds. | 514 // Don't report notproduct and develop flags in product builds. |
485 if (current->is_constant_in_binary()) { | 515 if (current->is_constant_in_binary()) { |
486 return NULL; | 516 return (return_flag == true ? current : NULL); |
487 } | 517 } |
488 // Report locked flags only if allowed. | 518 // Report locked flags only if allowed. |
489 if (!(current->is_unlocked() || current->is_unlocker())) { | 519 if (!(current->is_unlocked() || current->is_unlocker())) { |
490 if (!allow_locked) { | 520 if (!allow_locked) { |
491 // disable use of locked flags, e.g. diagnostic, experimental, | 521 // disable use of locked flags, e.g. diagnostic, experimental, |
575 if (result == NULL) return false; | 605 if (result == NULL) return false; |
576 *value = result->is_command_line(); | 606 *value = result->is_command_line(); |
577 return true; | 607 return true; |
578 } | 608 } |
579 | 609 |
610 template<class E, class T> | |
611 static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin) | |
612 { | |
613 E e; | |
614 e.set_name(name); | |
615 e.set_old_value(old_value); | |
616 e.set_new_value(new_value); | |
617 e.set_origin(origin); | |
618 e.commit(); | |
619 } | |
620 | |
580 bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { | 621 bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { |
581 Flag* result = Flag::find_flag(name, len); | 622 Flag* result = Flag::find_flag(name, len); |
582 if (result == NULL) return false; | 623 if (result == NULL) return false; |
583 if (!result->is_bool()) return false; | 624 if (!result->is_bool()) return false; |
584 *value = result->get_bool(); | 625 *value = result->get_bool(); |
588 bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) { | 629 bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) { |
589 Flag* result = Flag::find_flag(name, len); | 630 Flag* result = Flag::find_flag(name, len); |
590 if (result == NULL) return false; | 631 if (result == NULL) return false; |
591 if (!result->is_bool()) return false; | 632 if (!result->is_bool()) return false; |
592 bool old_value = result->get_bool(); | 633 bool old_value = result->get_bool(); |
634 trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin); | |
593 result->set_bool(*value); | 635 result->set_bool(*value); |
594 *value = old_value; | 636 *value = old_value; |
595 result->set_origin(origin); | 637 result->set_origin(origin); |
596 return true; | 638 return true; |
597 } | 639 } |
598 | 640 |
599 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) { | 641 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) { |
600 Flag* faddr = address_of_flag(flag); | 642 Flag* faddr = address_of_flag(flag); |
601 guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); | 643 guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type"); |
644 trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin); | |
602 faddr->set_bool(value); | 645 faddr->set_bool(value); |
603 faddr->set_origin(origin); | 646 faddr->set_origin(origin); |
604 } | 647 } |
605 | 648 |
606 bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { | 649 bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { |
614 bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) { | 657 bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) { |
615 Flag* result = Flag::find_flag(name, len); | 658 Flag* result = Flag::find_flag(name, len); |
616 if (result == NULL) return false; | 659 if (result == NULL) return false; |
617 if (!result->is_intx()) return false; | 660 if (!result->is_intx()) return false; |
618 intx old_value = result->get_intx(); | 661 intx old_value = result->get_intx(); |
662 trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin); | |
619 result->set_intx(*value); | 663 result->set_intx(*value); |
620 *value = old_value; | 664 *value = old_value; |
621 result->set_origin(origin); | 665 result->set_origin(origin); |
622 return true; | 666 return true; |
623 } | 667 } |
624 | 668 |
625 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) { | 669 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) { |
626 Flag* faddr = address_of_flag(flag); | 670 Flag* faddr = address_of_flag(flag); |
627 guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); | 671 guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type"); |
672 trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin); | |
628 faddr->set_intx(value); | 673 faddr->set_intx(value); |
629 faddr->set_origin(origin); | 674 faddr->set_origin(origin); |
630 } | 675 } |
631 | 676 |
632 bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { | 677 bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { |
640 bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) { | 685 bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) { |
641 Flag* result = Flag::find_flag(name, len); | 686 Flag* result = Flag::find_flag(name, len); |
642 if (result == NULL) return false; | 687 if (result == NULL) return false; |
643 if (!result->is_uintx()) return false; | 688 if (!result->is_uintx()) return false; |
644 uintx old_value = result->get_uintx(); | 689 uintx old_value = result->get_uintx(); |
690 trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); | |
645 result->set_uintx(*value); | 691 result->set_uintx(*value); |
646 *value = old_value; | 692 *value = old_value; |
647 result->set_origin(origin); | 693 result->set_origin(origin); |
648 return true; | 694 return true; |
649 } | 695 } |
650 | 696 |
651 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) { | 697 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) { |
652 Flag* faddr = address_of_flag(flag); | 698 Flag* faddr = address_of_flag(flag); |
653 guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); | 699 guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type"); |
700 trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin); | |
654 faddr->set_uintx(value); | 701 faddr->set_uintx(value); |
655 faddr->set_origin(origin); | 702 faddr->set_origin(origin); |
656 } | 703 } |
657 | 704 |
658 bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { | 705 bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { |
666 bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) { | 713 bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) { |
667 Flag* result = Flag::find_flag(name, len); | 714 Flag* result = Flag::find_flag(name, len); |
668 if (result == NULL) return false; | 715 if (result == NULL) return false; |
669 if (!result->is_uint64_t()) return false; | 716 if (!result->is_uint64_t()) return false; |
670 uint64_t old_value = result->get_uint64_t(); | 717 uint64_t old_value = result->get_uint64_t(); |
718 trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin); | |
671 result->set_uint64_t(*value); | 719 result->set_uint64_t(*value); |
672 *value = old_value; | 720 *value = old_value; |
673 result->set_origin(origin); | 721 result->set_origin(origin); |
674 return true; | 722 return true; |
675 } | 723 } |
676 | 724 |
677 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) { | 725 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) { |
678 Flag* faddr = address_of_flag(flag); | 726 Flag* faddr = address_of_flag(flag); |
679 guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); | 727 guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type"); |
728 trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin); | |
680 faddr->set_uint64_t(value); | 729 faddr->set_uint64_t(value); |
681 faddr->set_origin(origin); | 730 faddr->set_origin(origin); |
682 } | 731 } |
683 | 732 |
684 bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { | 733 bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { |
692 bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) { | 741 bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) { |
693 Flag* result = Flag::find_flag(name, len); | 742 Flag* result = Flag::find_flag(name, len); |
694 if (result == NULL) return false; | 743 if (result == NULL) return false; |
695 if (!result->is_double()) return false; | 744 if (!result->is_double()) return false; |
696 double old_value = result->get_double(); | 745 double old_value = result->get_double(); |
746 trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin); | |
697 result->set_double(*value); | 747 result->set_double(*value); |
698 *value = old_value; | 748 *value = old_value; |
699 result->set_origin(origin); | 749 result->set_origin(origin); |
700 return true; | 750 return true; |
701 } | 751 } |
702 | 752 |
703 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) { | 753 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) { |
704 Flag* faddr = address_of_flag(flag); | 754 Flag* faddr = address_of_flag(flag); |
705 guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); | 755 guarantee(faddr != NULL && faddr->is_double(), "wrong flag type"); |
756 trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin); | |
706 faddr->set_double(value); | 757 faddr->set_double(value); |
707 faddr->set_origin(origin); | 758 faddr->set_origin(origin); |
708 } | 759 } |
709 | 760 |
710 bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { | 761 bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { |
713 if (!result->is_ccstr()) return false; | 764 if (!result->is_ccstr()) return false; |
714 *value = result->get_ccstr(); | 765 *value = result->get_ccstr(); |
715 return true; | 766 return true; |
716 } | 767 } |
717 | 768 |
718 // Contract: Flag will make private copy of the incoming value. | |
719 // Outgoing value is always malloc-ed, and caller MUST call free. | |
720 bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) { | 769 bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) { |
721 Flag* result = Flag::find_flag(name, len); | 770 Flag* result = Flag::find_flag(name, len); |
722 if (result == NULL) return false; | 771 if (result == NULL) return false; |
723 if (!result->is_ccstr()) return false; | 772 if (!result->is_ccstr()) return false; |
724 ccstr old_value = result->get_ccstr(); | 773 ccstr old_value = result->get_ccstr(); |
774 trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin); | |
725 char* new_value = NULL; | 775 char* new_value = NULL; |
726 if (*value != NULL) { | 776 if (*value != NULL) { |
727 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal); | 777 new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal); |
728 strcpy(new_value, *value); | 778 strcpy(new_value, *value); |
729 } | 779 } |
737 *value = old_value; | 787 *value = old_value; |
738 result->set_origin(origin); | 788 result->set_origin(origin); |
739 return true; | 789 return true; |
740 } | 790 } |
741 | 791 |
742 // Contract: Flag will make private copy of the incoming value. | |
743 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) { | 792 void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) { |
744 Flag* faddr = address_of_flag(flag); | 793 Flag* faddr = address_of_flag(flag); |
745 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); | 794 guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); |
746 ccstr old_value = faddr->get_ccstr(); | 795 ccstr old_value = faddr->get_ccstr(); |
796 trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin); | |
747 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal); | 797 char* new_value = NEW_C_HEAP_ARRAY(char, strlen(value)+1, mtInternal); |
748 strcpy(new_value, value); | 798 strcpy(new_value, value); |
749 faddr->set_ccstr(new_value); | 799 faddr->set_ccstr(new_value); |
750 if (!faddr->is_default() && old_value != NULL) { | 800 if (!faddr->is_default() && old_value != NULL) { |
751 // Prior value is heap allocated so free it. | 801 // Prior value is heap allocated so free it. |