< prev index next >

src/hotspot/share/runtime/flags/jvmFlag.cpp

Print this page

  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 "jvm_io.h"
 28 #include "memory/allocation.inline.hpp"

 29 #include "runtime/arguments.hpp"
 30 #include "runtime/flags/jvmFlag.hpp"
 31 #include "runtime/flags/jvmFlagAccess.hpp"
 32 #include "runtime/flags/jvmFlagLookup.hpp"
 33 #include "runtime/globals_extension.hpp"
 34 #include "utilities/defaultStream.hpp"
 35 #include "utilities/stringUtils.hpp"
 36 
 37 static bool is_product_build() {
 38 #ifdef PRODUCT
 39   return true;
 40 #else
 41   return false;
 42 #endif
 43 }
 44 
 45 void JVMFlag::set_origin(JVMFlagOrigin new_origin) {
 46   int old_flags = _flags;
 47   int origin = static_cast<int>(new_origin);
 48   assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");

677              "%s can be declared with at most one of "
678              "DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL", current->_name);
679       assert((flags & KIND_DEVELOP) == 0,
680              "%s has an optional DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL "
681              "attribute; it must be declared as a product flag", current->_name);
682     }
683   }
684 }
685 
686 #endif // ASSERT
687 
688 void JVMFlag::printFlags(outputStream* out, bool withComments, bool printRanges, bool skipDefaults) {
689   // Print the flags sorted by name
690   // Note: This method may be called before the thread structure is in place
691   //       which means resource allocation cannot be used. Also, it may be
692   //       called as part of error reporting, so handle native OOMs gracefully.
693 
694   // The last entry is the null entry.
695   const size_t length = JVMFlag::numFlags - 1;
696 





697   // Print
698   if (!printRanges) {
699     out->print_cr("[Global flags]");
700   } else {
701     out->print_cr("[Global flags ranges]");
702   }
703 
704   // Sort
705   JVMFlag** array = NEW_C_HEAP_ARRAY_RETURN_NULL(JVMFlag*, length, mtArguments);
706   if (array != nullptr) {
707     for (size_t i = 0; i < length; i++) {
708       array[i] = &flagTable[i];
709     }
710     qsort(array, length, sizeof(JVMFlag*), compare_flags);
711 
712     for (size_t i = 0; i < length; i++) {
713       if (array[i]->is_unlocked() && !(skipDefaults && array[i]->is_default())) {
714         array[i]->print_on(out, withComments, printRanges);
715       }
716     }
717     FREE_C_HEAP_ARRAY(JVMFlag*, array);
718   } else {
719     // OOM? Print unsorted.
720     for (size_t i = 0; i < length; i++) {
721       if (flagTable[i].is_unlocked() && !(skipDefaults && flagTable[i].is_default())) {
722         flagTable[i].print_on(out, withComments, printRanges);
723       }
724     }
725   }


726 }
727 
728 void JVMFlag::printError(bool verbose, const char* msg, ...) {
729   if (verbose) {
730     va_list listPointer;
731     va_start(listPointer, msg);
732     jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
733     va_end(listPointer);
734   }
735 }

  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 "jvm_io.h"
 28 #include "memory/allocation.inline.hpp"
 29 #include "memory/universe.hpp"
 30 #include "runtime/arguments.hpp"
 31 #include "runtime/flags/jvmFlag.hpp"
 32 #include "runtime/flags/jvmFlagAccess.hpp"
 33 #include "runtime/flags/jvmFlagLookup.hpp"
 34 #include "runtime/globals_extension.hpp"
 35 #include "utilities/defaultStream.hpp"
 36 #include "utilities/stringUtils.hpp"
 37 
 38 static bool is_product_build() {
 39 #ifdef PRODUCT
 40   return true;
 41 #else
 42   return false;
 43 #endif
 44 }
 45 
 46 void JVMFlag::set_origin(JVMFlagOrigin new_origin) {
 47   int old_flags = _flags;
 48   int origin = static_cast<int>(new_origin);
 49   assert((origin & VALUE_ORIGIN_MASK) == origin, "sanity");

678              "%s can be declared with at most one of "
679              "DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL", current->_name);
680       assert((flags & KIND_DEVELOP) == 0,
681              "%s has an optional DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL "
682              "attribute; it must be declared as a product flag", current->_name);
683     }
684   }
685 }
686 
687 #endif // ASSERT
688 
689 void JVMFlag::printFlags(outputStream* out, bool withComments, bool printRanges, bool skipDefaults) {
690   // Print the flags sorted by name
691   // Note: This method may be called before the thread structure is in place
692   //       which means resource allocation cannot be used. Also, it may be
693   //       called as part of error reporting, so handle native OOMs gracefully.
694 
695   // The last entry is the null entry.
696   const size_t length = JVMFlag::numFlags - 1;
697 
698   const char* tag = 0;
699   if (xtty_owns(out))
700     xtty->head("%s", tag = !Universe::is_fully_initialized()
701                ? "vm_flags_initial" : "vm_flags_final");
702 
703   // Print
704   if (!printRanges) {
705     out->print_cr("[Global flags]");
706   } else {
707     out->print_cr("[Global flags ranges]");
708   }
709 
710   // Sort
711   JVMFlag** array = NEW_C_HEAP_ARRAY_RETURN_NULL(JVMFlag*, length, mtArguments);
712   if (array != nullptr) {
713     for (size_t i = 0; i < length; i++) {
714       array[i] = &flagTable[i];
715     }
716     qsort(array, length, sizeof(JVMFlag*), compare_flags);
717 
718     for (size_t i = 0; i < length; i++) {
719       if (array[i]->is_unlocked() && !(skipDefaults && array[i]->is_default())) {
720         array[i]->print_on(out, withComments, printRanges);
721       }
722     }
723     FREE_C_HEAP_ARRAY(JVMFlag*, array);
724   } else {
725     // OOM? Print unsorted.
726     for (size_t i = 0; i < length; i++) {
727       if (flagTable[i].is_unlocked() && !(skipDefaults && flagTable[i].is_default())) {
728         flagTable[i].print_on(out, withComments, printRanges);
729       }
730     }
731   }
732   if (xtty_owns(out))
733     xtty->tail(tag);
734 }
735 
736 void JVMFlag::printError(bool verbose, const char* msg, ...) {
737   if (verbose) {
738     va_list listPointer;
739     va_start(listPointer, msg);
740     jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
741     va_end(listPointer);
742   }
743 }
< prev index next >