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/bitMap.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);
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 constexpr size_t length = (sizeof(flagTable) / sizeof(JVMFlag)) - 1;
697
698 // Print
699 if (!printRanges) {
700 out->print_cr("[Global flags]");
701 } else {
702 out->print_cr("[Global flags ranges]");
703 }
704
705 BitMap::bm_word_t iteratorArray[BitMap::calc_size_in_words(length)];
706 BitMapView iteratorMarkers(iteratorArray, length);
707 iteratorMarkers.clear_range(0, length);
708 // Print the flag with best sort value, then mark it.
709 for (size_t j = 0; j < length; j++) {
710 JVMFlag* bestFlag = nullptr;
711 size_t bestFlagIndex = 0;
712 for (size_t i = 0; i < length; i++) {
713 const bool skip = (skipDefaults && flagTable[i].is_default());
714 const bool visited = iteratorMarkers.at(i);
715 if (!visited && flagTable[i].is_unlocked() && !skip) {
716 if ((bestFlag == nullptr) || (strcmp(bestFlag->name(), flagTable[i].name()) > 0)) {
717 bestFlag = &flagTable[i];
718 bestFlagIndex = i;
719 }
720 }
721 }
722 if (bestFlag != nullptr) {
723 bestFlag->print_on(out, withComments, printRanges);
724 iteratorMarkers.at_put(bestFlagIndex, true);
725 }
726 }
727 }
728
729 void JVMFlag::printError(bool verbose, const char* msg, ...) {
730 if (verbose) {
731 va_list listPointer;
732 va_start(listPointer, msg);
733 jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
734 va_end(listPointer);
735 }
736 }
|
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/bitMap.hpp"
36 #include "utilities/defaultStream.hpp"
37 #include "utilities/stringUtils.hpp"
38
39 static bool is_product_build() {
40 #ifdef PRODUCT
41 return true;
42 #else
43 return false;
44 #endif
45 }
46
47 void JVMFlag::set_origin(JVMFlagOrigin new_origin) {
48 int old_flags = _flags;
49 int origin = static_cast<int>(new_origin);
679 "%s can be declared with at most one of "
680 "DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL", current->_name);
681 assert((flags & KIND_DEVELOP) == 0,
682 "%s has an optional DIAGNOSTIC, MANAGEABLE or EXPERIMENTAL "
683 "attribute; it must be declared as a product flag", current->_name);
684 }
685 }
686 }
687
688 #endif // ASSERT
689
690 void JVMFlag::printFlags(outputStream* out, bool withComments, bool printRanges, bool skipDefaults) {
691 // Print the flags sorted by name
692 // Note: This method may be called before the thread structure is in place
693 // which means resource allocation cannot be used. Also, it may be
694 // called as part of error reporting, so handle native OOMs gracefully.
695
696 // The last entry is the null entry.
697 constexpr size_t length = (sizeof(flagTable) / sizeof(JVMFlag)) - 1;
698
699 const char* tag = 0;
700 if (xtty_owns(out))
701 xtty->head("%s", tag = !Universe::is_fully_initialized()
702 ? "vm_flags_initial" : "vm_flags_final");
703
704 // Print
705 if (!printRanges) {
706 out->print_cr("[Global flags]");
707 } else {
708 out->print_cr("[Global flags ranges]");
709 }
710
711 BitMap::bm_word_t iteratorArray[BitMap::calc_size_in_words(length)];
712 BitMapView iteratorMarkers(iteratorArray, length);
713 iteratorMarkers.clear_range(0, length);
714 // Print the flag with best sort value, then mark it.
715 for (size_t j = 0; j < length; j++) {
716 JVMFlag* bestFlag = nullptr;
717 size_t bestFlagIndex = 0;
718 for (size_t i = 0; i < length; i++) {
719 const bool skip = (skipDefaults && flagTable[i].is_default());
720 const bool visited = iteratorMarkers.at(i);
721 if (!visited && flagTable[i].is_unlocked() && !skip) {
722 if ((bestFlag == nullptr) || (strcmp(bestFlag->name(), flagTable[i].name()) > 0)) {
723 bestFlag = &flagTable[i];
724 bestFlagIndex = i;
725 }
726 }
727 }
728 if (bestFlag != nullptr) {
729 bestFlag->print_on(out, withComments, printRanges);
730 iteratorMarkers.at_put(bestFlagIndex, true);
731 }
732 }
733 if (xtty_owns(out))
734 xtty->tail(tag);
735 }
736
737 void JVMFlag::printError(bool verbose, const char* msg, ...) {
738 if (verbose) {
739 va_list listPointer;
740 va_start(listPointer, msg);
741 jio_vfprintf(defaultStream::error_stream(), msg, listPointer);
742 va_end(listPointer);
743 }
744 }
|