src/cpu/sparc/vm/jniTypes_sparc.hpp

Thu, 07 Apr 2011 09:53:20 -0700

author
johnc
date
Thu, 07 Apr 2011 09:53:20 -0700
changeset 2781
e1162778c1c8
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
Summary: A referent object that is only weakly reachable at the start of concurrent marking but is re-attached to the strongly reachable object graph during marking may not be marked as live. This can cause the reference object to be processed prematurely and leave dangling pointers to the referent object. Implement a read barrier for the java.lang.ref.Reference::referent field by intrinsifying the Reference.get() method, and intercepting accesses though JNI, reflection, and Unsafe, so that when a non-null referent object is read it is also logged in an SATB buffer.
Reviewed-by: kvn, iveresov, never, tonyp, dholmes

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1998, 2010, 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 CPU_SPARC_VM_JNITYPES_SPARC_HPP
stefank@2314 26 #define CPU_SPARC_VM_JNITYPES_SPARC_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "oops/oop.hpp"
stefank@2314 30 #include "prims/jni.h"
stefank@2314 31
duke@435 32 // This file holds platform-dependent routines used to write primitive jni
duke@435 33 // types to the array of arguments passed into JavaCalls::call
duke@435 34
duke@435 35 class JNITypes : AllStatic {
duke@435 36 // These functions write a java primitive type (in native format)
duke@435 37 // to a java stack slot array to be passed as an argument to JavaCalls:calls.
duke@435 38 // I.e., they are functionally 'push' operations if they have a 'pos'
duke@435 39 // formal parameter. Note that jlong's and jdouble's are written
duke@435 40 // _in reverse_ of the order in which they appear in the interpreter
duke@435 41 // stack. This is because call stubs (see stubGenerator_sparc.cpp)
duke@435 42 // reverse the argument list constructed by JavaCallArguments (see
duke@435 43 // javaCalls.hpp).
duke@435 44
duke@435 45 private:
duke@435 46 // Helper routines.
duke@435 47 static inline void put_int2 (jint *from, jint *to) { to[0] = from[0]; to[1] = from[1]; }
duke@435 48 static inline void put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; }
duke@435 49 static inline void put_int2r(jint *from, jint *to) { to[0] = from[1]; to[1] = from[0]; }
duke@435 50 static inline void put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; }
duke@435 51
duke@435 52 public:
duke@435 53 // Ints are stored in native format in one JavaCallArgument slot at *to.
duke@435 54 static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; }
duke@435 55 static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; }
duke@435 56 static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; }
duke@435 57
duke@435 58 #ifdef _LP64
duke@435 59 // Longs are stored in native format in one JavaCallArgument slot at *(to+1).
duke@435 60 static inline void put_long(jlong from, intptr_t *to) { *(jlong *)(to + 1 + 0) = from; }
duke@435 61 static inline void put_long(jlong from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = from; pos += 2; }
duke@435 62 static inline void put_long(jlong *from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = *from; pos += 2; }
duke@435 63 #else
duke@435 64 // Longs are stored in reversed native word format in two JavaCallArgument slots at *to.
duke@435 65 // The high half is in *(to+1) and the low half in *to.
duke@435 66 static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
duke@435 67 static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
duke@435 68 static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
duke@435 69 #endif
duke@435 70
duke@435 71 // Oops are stored in native format in one JavaCallArgument slot at *to.
duke@435 72 static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; }
duke@435 73 static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; }
duke@435 74 static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; }
duke@435 75
duke@435 76 // Floats are stored in native format in one JavaCallArgument slot at *to.
duke@435 77 static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; }
duke@435 78 static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; }
duke@435 79 static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; }
duke@435 80
duke@435 81 #ifdef _LP64
duke@435 82 // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1).
duke@435 83 static inline void put_double(jdouble from, intptr_t *to) { *(jdouble *)(to + 1 + 0) = from; }
duke@435 84 static inline void put_double(jdouble from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = from; pos += 2; }
duke@435 85 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; }
duke@435 86 #else
duke@435 87 // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to.
duke@435 88 static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); }
duke@435 89 static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); }
duke@435 90 static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); }
duke@435 91 #endif
duke@435 92
duke@435 93 // The get_xxx routines, on the other hand, actually _do_ fetch
duke@435 94 // java primitive types from the interpreter stack.
duke@435 95 static inline jint get_int(intptr_t *from) { return *(jint *)from; }
duke@435 96
duke@435 97 #ifdef _LP64
duke@435 98 static inline jlong get_long(intptr_t *from) { return *(jlong *)from; }
duke@435 99 #else
duke@435 100 static inline jlong get_long(intptr_t *from) { return ((jlong)(*( signed int *)((jint *)from )) << 32) |
duke@435 101 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); }
duke@435 102 #endif
duke@435 103
duke@435 104 static inline oop get_obj(intptr_t *from) { return *(oop *)from; }
duke@435 105 static inline jfloat get_float(intptr_t *from) { return *(jfloat *)from; }
duke@435 106
duke@435 107 #ifdef _LP64
duke@435 108 static inline jdouble get_double(intptr_t *from) { return *(jdouble *)from; }
duke@435 109 #else
duke@435 110 static inline jdouble get_double(intptr_t *from) { jlong jl = ((jlong)(*( signed int *)((jint *)from )) << 32) |
duke@435 111 ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0);
duke@435 112 return *(jdouble *)&jl; }
duke@435 113 #endif
duke@435 114
duke@435 115 };
stefank@2314 116
stefank@2314 117 #endif // CPU_SPARC_VM_JNITYPES_SPARC_HPP

mercurial