< prev index next >

src/share/vm/services/nmtCommon.hpp

Print this page
rev 12329 : 8167650: NMT should check for invalid MEMFLAGS
Reviewed-by: dholmes, mockner, cjplummer

*** 1,7 **** /* ! * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 53,72 **** // A few common utilities for native memory tracking class NMTUtil : AllStatic { public: // Map memory type to index static inline int flag_to_index(MEMFLAGS flag) { ! return (flag & 0xff); } // Map memory type to human readable name static const char* flag_to_name(MEMFLAGS flag) { return _memory_type_names[flag_to_index(flag)]; } // Map an index to memory type static MEMFLAGS index_to_flag(int index) { return (MEMFLAGS)index; } // Memory size scale static const char* scale_name(size_t scale); --- 53,75 ---- // A few common utilities for native memory tracking class NMTUtil : AllStatic { public: // Map memory type to index static inline int flag_to_index(MEMFLAGS flag) { ! const int index = flag & 0xff; ! assert(index >= 0 && index < (int)mt_number_of_types, "Index out of bounds"); ! return index; } // Map memory type to human readable name static const char* flag_to_name(MEMFLAGS flag) { return _memory_type_names[flag_to_index(flag)]; } // Map an index to memory type static MEMFLAGS index_to_flag(int index) { + assert(index >= 0 && index < (int) mt_number_of_types, "Index out of bounds"); return (MEMFLAGS)index; } // Memory size scale static const char* scale_name(size_t scale);
< prev index next >