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

Tue, 25 Feb 2014 18:16:24 +0100

author
roland
date
Tue, 25 Feb 2014 18:16:24 +0100
changeset 6377
b8413a9cbb84
parent 5528
740e263c80c6
child 6680
78bbf4d43a14
permissions
-rw-r--r--

8031752: Failed speculative optimizations should be reattempted when root of compilation is different
Summary: support for speculative traps that keep track of the root of the compilation in which a trap occurs.
Reviewed-by: kvn, twisti

     1 /*
     2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     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  */
    25 #ifndef SHARE_VM_OOPS_KLASS_INLINE_HPP
    26 #define SHARE_VM_OOPS_KLASS_INLINE_HPP
    28 #include "memory/universe.hpp"
    29 #include "oops/klass.hpp"
    30 #include "oops/markOop.hpp"
    32 inline void Klass::set_prototype_header(markOop header) {
    33   assert(!header->has_bias_pattern() || oop_is_instance(), "biased locking currently only supported for Java instances");
    34   _prototype_header = header;
    35 }
    37 inline bool Klass::is_null(Klass* obj)  { return obj == NULL; }
    38 inline bool Klass::is_null(narrowKlass obj) { return obj == 0; }
    40 // Encoding and decoding for klass field.
    42 inline bool check_klass_alignment(Klass* obj) {
    43   return (intptr_t)obj % KlassAlignmentInBytes == 0;
    44 }
    46 inline narrowKlass Klass::encode_klass_not_null(Klass* v) {
    47   assert(!is_null(v), "klass value can never be zero");
    48   assert(check_klass_alignment(v), "Address not aligned");
    49   int    shift = Universe::narrow_klass_shift();
    50   uint64_t pd = (uint64_t)(pointer_delta((void*)v, Universe::narrow_klass_base(), 1));
    51   assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding");
    52   uint64_t result = pd >> shift;
    53   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow");
    54   assert(decode_klass(result) == v, "reversibility");
    55   return (narrowKlass)result;
    56 }
    58 inline narrowKlass Klass::encode_klass(Klass* v) {
    59   return is_null(v) ? (narrowKlass)0 : encode_klass_not_null(v);
    60 }
    62 inline Klass* Klass::decode_klass_not_null(narrowKlass v) {
    63   assert(!is_null(v), "narrow klass value can never be zero");
    64   int    shift = Universe::narrow_klass_shift();
    65   Klass* result = (Klass*)(void*)((uintptr_t)Universe::narrow_klass_base() + ((uintptr_t)v << shift));
    66   assert(check_klass_alignment(result), err_msg("address not aligned: " PTR_FORMAT, (void*) result));
    67   return result;
    68 }
    70 inline Klass* Klass::decode_klass(narrowKlass v) {
    71   return is_null(v) ? (Klass*)NULL : decode_klass_not_null(v);
    72 }
    74 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP

mercurial