< prev index next >

src/share/vm/runtime/globals.cpp

Print this page




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"

  26 #include "memory/allocation.inline.hpp"
  27 #include "oops/oop.inline.hpp"
  28 #include "runtime/arguments.hpp"
  29 #include "runtime/globals.hpp"
  30 #include "runtime/globals_extension.hpp"
  31 #include "utilities/ostream.hpp"
  32 #include "utilities/macros.hpp"
  33 #include "utilities/top.hpp"
  34 #include "trace/tracing.hpp"
  35 #if INCLUDE_ALL_GCS
  36 #include "gc_implementation/g1/g1_globals.hpp"
  37 #endif // INCLUDE_ALL_GCS
  38 #ifdef COMPILER1
  39 #include "c1/c1_globals.hpp"
  40 #endif
  41 #ifdef COMPILER2
  42 #include "opto/c2_globals.hpp"
  43 #endif
  44 #ifdef SHARK
  45 #include "shark/shark_globals.hpp"
  46 #endif
  47 
  48 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  49 
  50 RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
  51               MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
  52               MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
  53               MATERIALIZE_NOTPRODUCT_FLAG, \
  54               MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \


 593 }
 594 
 595 bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
 596   assert((size_t)flag < Flag::numFlags, "bad command line flag index");
 597   Flag* f = &Flag::flags[flag];
 598   return f->is_command_line();
 599 }
 600 
 601 bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
 602   Flag* result = Flag::find_flag((char*)name, strlen(name));
 603   if (result == NULL) return false;
 604   *value = result->is_command_line();
 605   return true;
 606 }
 607 
 608 template<class E, class T>
 609 static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin)
 610 {
 611   E e;
 612   e.set_name(name);
 613   e.set_old_value(old_value);
 614   e.set_new_value(new_value);
 615   e.set_origin(origin);
 616   e.commit();
 617 }
 618 
 619 bool CommandLineFlags::boolAt(const char* name, size_t len, bool* value) {
 620   Flag* result = Flag::find_flag(name, len);
 621   if (result == NULL) return false;
 622   if (!result->is_bool()) return false;
 623   *value = result->get_bool();
 624   return true;
 625 }
 626 
 627 bool CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) {
 628   Flag* result = Flag::find_flag(name, len);
 629   if (result == NULL) return false;
 630   if (!result->is_bool()) return false;
 631   bool old_value = result->get_bool();
 632   trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
 633   result->set_bool(*value);
 634   *value = old_value;
 635   result->set_origin(origin);
 636   return true;
 637 }
 638 
 639 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
 640   Flag* faddr = address_of_flag(flag);
 641   guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
 642   trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
 643   faddr->set_bool(value);
 644   faddr->set_origin(origin);
 645 }
 646 
 647 bool CommandLineFlags::intxAt(const char* name, size_t len, intx* value) {
 648   Flag* result = Flag::find_flag(name, len);
 649   if (result == NULL) return false;
 650   if (!result->is_intx()) return false;
 651   *value = result->get_intx();
 652   return true;
 653 }
 654 
 655 bool CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
 656   Flag* result = Flag::find_flag(name, len);
 657   if (result == NULL) return false;
 658   if (!result->is_intx()) return false;
 659   intx old_value = result->get_intx();
 660   trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
 661   result->set_intx(*value);
 662   *value = old_value;
 663   result->set_origin(origin);
 664   return true;
 665 }
 666 
 667 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
 668   Flag* faddr = address_of_flag(flag);
 669   guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
 670   trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin);
 671   faddr->set_intx(value);
 672   faddr->set_origin(origin);
 673 }
 674 
 675 bool CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value) {
 676   Flag* result = Flag::find_flag(name, len);
 677   if (result == NULL) return false;
 678   if (!result->is_uintx()) return false;
 679   *value = result->get_uintx();
 680   return true;
 681 }
 682 
 683 bool CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
 684   Flag* result = Flag::find_flag(name, len);
 685   if (result == NULL) return false;
 686   if (!result->is_uintx()) return false;
 687   uintx old_value = result->get_uintx();
 688   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
 689   result->set_uintx(*value);
 690   *value = old_value;
 691   result->set_origin(origin);
 692   return true;
 693 }
 694 
 695 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
 696   Flag* faddr = address_of_flag(flag);
 697   guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
 698   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
 699   faddr->set_uintx(value);
 700   faddr->set_origin(origin);
 701 }
 702 
 703 bool CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t* value) {
 704   Flag* result = Flag::find_flag(name, len);
 705   if (result == NULL) return false;
 706   if (!result->is_uint64_t()) return false;
 707   *value = result->get_uint64_t();
 708   return true;
 709 }
 710 
 711 bool CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
 712   Flag* result = Flag::find_flag(name, len);
 713   if (result == NULL) return false;
 714   if (!result->is_uint64_t()) return false;
 715   uint64_t old_value = result->get_uint64_t();
 716   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
 717   result->set_uint64_t(*value);
 718   *value = old_value;
 719   result->set_origin(origin);
 720   return true;
 721 }
 722 
 723 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
 724   Flag* faddr = address_of_flag(flag);
 725   guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
 726   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
 727   faddr->set_uint64_t(value);
 728   faddr->set_origin(origin);
 729 }
 730 
 731 bool CommandLineFlags::doubleAt(const char* name, size_t len, double* value) {
 732   Flag* result = Flag::find_flag(name, len);
 733   if (result == NULL) return false;
 734   if (!result->is_double()) return false;
 735   *value = result->get_double();
 736   return true;
 737 }
 738 
 739 bool CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
 740   Flag* result = Flag::find_flag(name, len);
 741   if (result == NULL) return false;
 742   if (!result->is_double()) return false;
 743   double old_value = result->get_double();
 744   trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
 745   result->set_double(*value);
 746   *value = old_value;
 747   result->set_origin(origin);
 748   return true;
 749 }
 750 
 751 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
 752   Flag* faddr = address_of_flag(flag);
 753   guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
 754   trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
 755   faddr->set_double(value);
 756   faddr->set_origin(origin);
 757 }
 758 
 759 bool CommandLineFlags::ccstrAt(const char* name, size_t len, ccstr* value) {
 760   Flag* result = Flag::find_flag(name, len);
 761   if (result == NULL) return false;
 762   if (!result->is_ccstr()) return false;
 763   *value = result->get_ccstr();
 764   return true;
 765 }
 766 
 767 bool CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin) {
 768   Flag* result = Flag::find_flag(name, len);
 769   if (result == NULL) return false;
 770   if (!result->is_ccstr()) return false;
 771   ccstr old_value = result->get_ccstr();
 772   trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
 773   char* new_value = NULL;
 774   if (*value != NULL) {
 775     new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
 776     strcpy(new_value, *value);
 777   }
 778   result->set_ccstr(new_value);
 779   if (result->is_default() && old_value != NULL) {
 780     // Prior value is NOT heap allocated, but was a literal constant.




   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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jfr/jfrEvents.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "runtime/arguments.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 #include "utilities/ostream.hpp"
  33 #include "utilities/macros.hpp"
  34 #include "utilities/top.hpp"

  35 #if INCLUDE_ALL_GCS
  36 #include "gc_implementation/g1/g1_globals.hpp"
  37 #endif // INCLUDE_ALL_GCS
  38 #ifdef COMPILER1
  39 #include "c1/c1_globals.hpp"
  40 #endif
  41 #ifdef COMPILER2
  42 #include "opto/c2_globals.hpp"
  43 #endif
  44 #ifdef SHARK
  45 #include "shark/shark_globals.hpp"
  46 #endif
  47 
  48 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  49 
  50 RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, \
  51               MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, \
  52               MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_EXPERIMENTAL_FLAG, \
  53               MATERIALIZE_NOTPRODUCT_FLAG, \
  54               MATERIALIZE_MANAGEABLE_FLAG, MATERIALIZE_PRODUCT_RW_FLAG, \


 593 }
 594 
 595 bool CommandLineFlagsEx::is_cmdline(CommandLineFlag flag) {
 596   assert((size_t)flag < Flag::numFlags, "bad command line flag index");
 597   Flag* f = &Flag::flags[flag];
 598   return f->is_command_line();
 599 }
 600 
 601 bool CommandLineFlags::wasSetOnCmdline(const char* name, bool* value) {
 602   Flag* result = Flag::find_flag((char*)name, strlen(name));
 603   if (result == NULL) return false;
 604   *value = result->is_command_line();
 605   return true;
 606 }
 607 
 608 template<class E, class T>
 609 static void trace_flag_changed(const char* name, const T old_value, const T new_value, const Flag::Flags origin)
 610 {
 611   E e;
 612   e.set_name(name);
 613   e.set_oldValue(old_value);
 614   e.set_newValue(new_value);
 615   e.set_origin(origin);
 616   e.commit();
 617 }
 618 
 619 bool CommandLineFlags::boolAt(const char* name, size_t len, bool* value, bool allow_locked, bool return_flag) {
 620   Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
 621   if (result == NULL) return false;
 622   if (!result->is_bool()) return false;
 623   *value = result->get_bool();
 624   return true;
 625 }
 626 
 627 bool CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) {
 628   Flag* result = Flag::find_flag(name, len);
 629   if (result == NULL) return false;
 630   if (!result->is_bool()) return false;
 631   bool old_value = result->get_bool();
 632   trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
 633   result->set_bool(*value);
 634   *value = old_value;
 635   result->set_origin(origin);
 636   return true;
 637 }
 638 
 639 void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin) {
 640   Flag* faddr = address_of_flag(flag);
 641   guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
 642   trace_flag_changed<EventBooleanFlagChanged, bool>(faddr->_name, faddr->get_bool(), value, origin);
 643   faddr->set_bool(value);
 644   faddr->set_origin(origin);
 645 }
 646 
 647 bool CommandLineFlags::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) {
 648   Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
 649   if (result == NULL) return false;
 650   if (!result->is_intx()) return false;
 651   *value = result->get_intx();
 652   return true;
 653 }
 654 
 655 bool CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) {
 656   Flag* result = Flag::find_flag(name, len);
 657   if (result == NULL) return false;
 658   if (!result->is_intx()) return false;
 659   intx old_value = result->get_intx();
 660   trace_flag_changed<EventLongFlagChanged, s8>(name, old_value, *value, origin);
 661   result->set_intx(*value);
 662   *value = old_value;
 663   result->set_origin(origin);
 664   return true;
 665 }
 666 
 667 void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin) {
 668   Flag* faddr = address_of_flag(flag);
 669   guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
 670   trace_flag_changed<EventLongFlagChanged, s8>(faddr->_name, faddr->get_intx(), value, origin);
 671   faddr->set_intx(value);
 672   faddr->set_origin(origin);
 673 }
 674 
 675 bool CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) {
 676   Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
 677   if (result == NULL) return false;
 678   if (!result->is_uintx()) return false;
 679   *value = result->get_uintx();
 680   return true;
 681 }
 682 
 683 bool CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) {
 684   Flag* result = Flag::find_flag(name, len);
 685   if (result == NULL) return false;
 686   if (!result->is_uintx()) return false;
 687   uintx old_value = result->get_uintx();
 688   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
 689   result->set_uintx(*value);
 690   *value = old_value;
 691   result->set_origin(origin);
 692   return true;
 693 }
 694 
 695 void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin) {
 696   Flag* faddr = address_of_flag(flag);
 697   guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
 698   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uintx(), value, origin);
 699   faddr->set_uintx(value);
 700   faddr->set_origin(origin);
 701 }
 702 
 703 bool CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked, bool return_flag) {
 704   Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
 705   if (result == NULL) return false;
 706   if (!result->is_uint64_t()) return false;
 707   *value = result->get_uint64_t();
 708   return true;
 709 }
 710 
 711 bool CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) {
 712   Flag* result = Flag::find_flag(name, len);
 713   if (result == NULL) return false;
 714   if (!result->is_uint64_t()) return false;
 715   uint64_t old_value = result->get_uint64_t();
 716   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
 717   result->set_uint64_t(*value);
 718   *value = old_value;
 719   result->set_origin(origin);
 720   return true;
 721 }
 722 
 723 void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin) {
 724   Flag* faddr = address_of_flag(flag);
 725   guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
 726   trace_flag_changed<EventUnsignedLongFlagChanged, u8>(faddr->_name, faddr->get_uint64_t(), value, origin);
 727   faddr->set_uint64_t(value);
 728   faddr->set_origin(origin);
 729 }
 730 
 731 bool CommandLineFlags::doubleAt(const char* name, size_t len, double* value, bool allow_locked, bool return_flag) {
 732   Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
 733   if (result == NULL) return false;
 734   if (!result->is_double()) return false;
 735   *value = result->get_double();
 736   return true;
 737 }
 738 
 739 bool CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {
 740   Flag* result = Flag::find_flag(name, len);
 741   if (result == NULL) return false;
 742   if (!result->is_double()) return false;
 743   double old_value = result->get_double();
 744   trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
 745   result->set_double(*value);
 746   *value = old_value;
 747   result->set_origin(origin);
 748   return true;
 749 }
 750 
 751 void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin) {
 752   Flag* faddr = address_of_flag(flag);
 753   guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
 754   trace_flag_changed<EventDoubleFlagChanged, double>(faddr->_name, faddr->get_double(), value, origin);
 755   faddr->set_double(value);
 756   faddr->set_origin(origin);
 757 }
 758 
 759 bool CommandLineFlags::ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked, bool return_flag) {
 760   Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
 761   if (result == NULL) return false;
 762   if (!result->is_ccstr()) return false;
 763   *value = result->get_ccstr();
 764   return true;
 765 }
 766 
 767 bool CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin) {
 768   Flag* result = Flag::find_flag(name, len);
 769   if (result == NULL) return false;
 770   if (!result->is_ccstr()) return false;
 771   ccstr old_value = result->get_ccstr();
 772   trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
 773   char* new_value = NULL;
 774   if (*value != NULL) {
 775     new_value = NEW_C_HEAP_ARRAY(char, strlen(*value)+1, mtInternal);
 776     strcpy(new_value, *value);
 777   }
 778   result->set_ccstr(new_value);
 779   if (result->is_default() && old_value != NULL) {
 780     // Prior value is NOT heap allocated, but was a literal constant.


< prev index next >