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 "jfr/jfrEvents.hpp"
26 #include "jvm_io.h"
27 #include "memory/allocation.inline.hpp"
28 #include "runtime/arguments.hpp"
29 #include "runtime/flags/jvmFlag.hpp"
30 #include "runtime/flags/jvmFlagAccess.hpp"
31 #include "runtime/flags/jvmFlagLookup.hpp"
32 #include "runtime/globals_extension.hpp"
33 #include "utilities/bitMap.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);
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 constexpr size_t length = (sizeof(flagTable) / sizeof(JVMFlag)) - 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 BitMap::bm_word_t iteratorArray[BitMap::calc_size_in_words(length)];
705 BitMapView iteratorMarkers(iteratorArray, length);
706 iteratorMarkers.clear_range(0, length);
707 // Print the flag with best sort value, then mark it.
708 for (size_t j = 0; j < length; j++) {
709 JVMFlag* bestFlag = nullptr;
710 size_t bestFlagIndex = 0;
711 for (size_t i = 0; i < length; i++) {
712 const bool skip = (skipDefaults && flagTable[i].is_default());
713 const bool visited = iteratorMarkers.at(i);
714 if (!visited && flagTable[i].is_unlocked() && !skip) {
715 if ((bestFlag == nullptr) || (strcmp(bestFlag->name(), flagTable[i].name()) > 0)) {
716 bestFlag = &flagTable[i];
717 bestFlagIndex = i;
718 }
719 }
720 }
721 if (bestFlag != nullptr) {
722 bestFlag->print_on(out, withComments, printRanges);
723 iteratorMarkers.at_put(bestFlagIndex, true);
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 }
|
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 "jfr/jfrEvents.hpp"
26 #include "jvm_io.h"
27 #include "memory/allocation.inline.hpp"
28 #include "memory/universe.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 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 BitMap::bm_word_t iteratorArray[BitMap::calc_size_in_words(length)];
711 BitMapView iteratorMarkers(iteratorArray, length);
712 iteratorMarkers.clear_range(0, length);
713 // Print the flag with best sort value, then mark it.
714 for (size_t j = 0; j < length; j++) {
715 JVMFlag* bestFlag = nullptr;
716 size_t bestFlagIndex = 0;
717 for (size_t i = 0; i < length; i++) {
718 const bool skip = (skipDefaults && flagTable[i].is_default());
719 const bool visited = iteratorMarkers.at(i);
720 if (!visited && flagTable[i].is_unlocked() && !skip) {
721 if ((bestFlag == nullptr) || (strcmp(bestFlag->name(), flagTable[i].name()) > 0)) {
722 bestFlag = &flagTable[i];
723 bestFlagIndex = i;
724 }
725 }
726 }
727 if (bestFlag != nullptr) {
728 bestFlag->print_on(out, withComments, printRanges);
729 iteratorMarkers.at_put(bestFlagIndex, true);
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 }
|