annotate src/share/vm/oops/klass.inline.hpp @ 7745:6dc8db7164d2

Added tag jdk9-b49 for changeset 360cd1fc42f1
author katleman
date Thu, 05 Feb 2015 11:43:29 -0800
parents 740e263c80c6
children dc9930a04ab0
rev   line source
duke@0 1 /*
drchase@6412 2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_OOPS_KLASS_INLINE_HPP
stefank@1879 26 #define SHARE_VM_OOPS_KLASS_INLINE_HPP
stefank@1879 27
hseigel@5093 28 #include "memory/universe.hpp"
stefank@1879 29 #include "oops/klass.hpp"
stefank@1879 30 #include "oops/markOop.hpp"
stefank@1879 31
duke@0 32 inline void Klass::set_prototype_header(markOop header) {
duke@0 33 assert(!header->has_bias_pattern() || oop_is_instance(), "biased locking currently only supported for Java instances");
duke@0 34 _prototype_header = header;
duke@0 35 }
stefank@1879 36
hseigel@5093 37 inline bool Klass::is_null(Klass* obj) { return obj == NULL; }
hseigel@5093 38 inline bool Klass::is_null(narrowKlass obj) { return obj == 0; }
hseigel@5093 39
hseigel@5093 40 // Encoding and decoding for klass field.
hseigel@5093 41
hseigel@5093 42 inline bool check_klass_alignment(Klass* obj) {
hseigel@5093 43 return (intptr_t)obj % KlassAlignmentInBytes == 0;
hseigel@5093 44 }
hseigel@5093 45
hseigel@5093 46 inline narrowKlass Klass::encode_klass_not_null(Klass* v) {
hseigel@5093 47 assert(!is_null(v), "klass value can never be zero");
hseigel@5093 48 assert(check_klass_alignment(v), "Address not aligned");
hseigel@5093 49 int shift = Universe::narrow_klass_shift();
hseigel@5093 50 uint64_t pd = (uint64_t)(pointer_delta((void*)v, Universe::narrow_klass_base(), 1));
hseigel@5093 51 assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding");
hseigel@5093 52 uint64_t result = pd >> shift;
hseigel@5093 53 assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow");
hseigel@5093 54 assert(decode_klass(result) == v, "reversibility");
hseigel@5093 55 return (narrowKlass)result;
hseigel@5093 56 }
hseigel@5093 57
hseigel@5093 58 inline narrowKlass Klass::encode_klass(Klass* v) {
hseigel@5093 59 return is_null(v) ? (narrowKlass)0 : encode_klass_not_null(v);
hseigel@5093 60 }
hseigel@5093 61
hseigel@5093 62 inline Klass* Klass::decode_klass_not_null(narrowKlass v) {
hseigel@5093 63 assert(!is_null(v), "narrow klass value can never be zero");
hseigel@5093 64 int shift = Universe::narrow_klass_shift();
hseigel@5093 65 Klass* result = (Klass*)(void*)((uintptr_t)Universe::narrow_klass_base() + ((uintptr_t)v << shift));
drchase@6412 66 assert(check_klass_alignment(result), err_msg("address not aligned: " INTPTR_FORMAT, p2i((void*) result)));
hseigel@5093 67 return result;
hseigel@5093 68 }
hseigel@5093 69
hseigel@5093 70 inline Klass* Klass::decode_klass(narrowKlass v) {
hseigel@5093 71 return is_null(v) ? (Klass*)NULL : decode_klass_not_null(v);
hseigel@5093 72 }
hseigel@5093 73
stefank@1879 74 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP