< 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");

687              "DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL", current->_name);
688       assert((flags & KIND_NOT_PRODUCT) == 0 &&
689              (flags & KIND_DEVELOP) == 0,
690              "%s has an optional DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL "
691              "attribute; it must be declared as a product flag", current->_name);
692     }
693   }
694 }
695 
696 #endif // ASSERT
697 
698 void JVMFlag::printFlags(outputStream* out, bool withComments, bool printRanges, bool skipDefaults) {
699   // Print the flags sorted by name
700   // Note: This method may be called before the thread structure is in place
701   //       which means resource allocation cannot be used. Also, it may be
702   //       called as part of error reporting, so handle native OOMs gracefully.
703 
704   // The last entry is the null entry.
705   const size_t length = JVMFlag::numFlags - 1;
706 





707   // Print
708   if (!printRanges) {
709     out->print_cr("[Global flags]");
710   } else {
711     out->print_cr("[Global flags ranges]");
712   }
713 
714   // Sort
715   JVMFlag** array = NEW_C_HEAP_ARRAY_RETURN_NULL(JVMFlag*, length, mtArguments);
716   if (array != nullptr) {
717     for (size_t i = 0; i < length; i++) {
718       array[i] = &flagTable[i];
719     }
720     qsort(array, length, sizeof(JVMFlag*), compare_flags);
721 
722     for (size_t i = 0; i < length; i++) {
723       if (array[i]->is_unlocked() && !(skipDefaults && array[i]->is_default())) {
724         array[i]->print_on(out, withComments, printRanges);
725       }
726     }
727     FREE_C_HEAP_ARRAY(JVMFlag*, array);
728   } else {
729     // OOM? Print unsorted.
730     for (size_t i = 0; i < length; i++) {
731       if (flagTable[i].is_unlocked() && !(skipDefaults && flagTable[i].is_default())) {
732         flagTable[i].print_on(out, withComments, printRanges);
733       }
734     }
735   }


736 }
737 
738 void JVMFlag::printError(bool verbose, const char* msg, ...) {
739   if (verbose) {
740     va_list listPointer;
741     va_start(listPointer, msg);
742     jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
743     va_end(listPointer);
744   }
745 }

  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");

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