src/share/vm/oops/klass.inline.hpp

Mon, 16 Dec 2013 08:24:33 -0500

author
hseigel
date
Mon, 16 Dec 2013 08:24:33 -0500
changeset 6195
5832cdaf89c6
parent 5528
740e263c80c6
child 6680
78bbf4d43a14
permissions
-rw-r--r--

8027804: JCK resolveMethod test fails expecting AbstractMethodError
Summary: Create AME overpass methods and fix method search logic
Reviewed-by: kamg, acorn, lfoltan, coleenp

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

mercurial