src/cpu/sparc/vm/bytes_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) 1997, 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_BYTES_SPARC_HPP
stefank@2314 26 #define CPU_SPARC_VM_BYTES_SPARC_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29
duke@435 30 class Bytes: AllStatic {
duke@435 31 public:
duke@435 32 // Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering
duke@435 33 // Sparc needs to check for alignment.
duke@435 34
duke@435 35 // can I count on address always being a pointer to an unsigned char? Yes
duke@435 36
duke@435 37 // Returns true, if the byte ordering used by Java is different from the nativ byte ordering
duke@435 38 // of the underlying machine. For example, true for Intel x86, False, for Solaris on Sparc.
duke@435 39 static inline bool is_Java_byte_ordering_different() { return false; }
duke@435 40
duke@435 41 // Thus, a swap between native and Java ordering is always a no-op:
duke@435 42 static inline u2 swap_u2(u2 x) { return x; }
duke@435 43 static inline u4 swap_u4(u4 x) { return x; }
duke@435 44 static inline u8 swap_u8(u8 x) { return x; }
duke@435 45
duke@435 46 static inline u2 get_native_u2(address p){
duke@435 47 return (intptr_t(p) & 1) == 0
duke@435 48 ? *(u2*)p
duke@435 49 : ( u2(p[0]) << 8 )
duke@435 50 | ( u2(p[1]) );
duke@435 51 }
duke@435 52
duke@435 53 static inline u4 get_native_u4(address p) {
duke@435 54 switch (intptr_t(p) & 3) {
duke@435 55 case 0: return *(u4*)p;
duke@435 56
duke@435 57 case 2: return ( u4( ((u2*)p)[0] ) << 16 )
duke@435 58 | ( u4( ((u2*)p)[1] ) );
duke@435 59
duke@435 60 default: return ( u4(p[0]) << 24 )
duke@435 61 | ( u4(p[1]) << 16 )
duke@435 62 | ( u4(p[2]) << 8 )
duke@435 63 | u4(p[3]);
duke@435 64 }
duke@435 65 }
duke@435 66
duke@435 67 static inline u8 get_native_u8(address p) {
duke@435 68 switch (intptr_t(p) & 7) {
duke@435 69 case 0: return *(u8*)p;
duke@435 70
duke@435 71 case 4: return ( u8( ((u4*)p)[0] ) << 32 )
duke@435 72 | ( u8( ((u4*)p)[1] ) );
duke@435 73
duke@435 74 case 2: return ( u8( ((u2*)p)[0] ) << 48 )
duke@435 75 | ( u8( ((u2*)p)[1] ) << 32 )
duke@435 76 | ( u8( ((u2*)p)[2] ) << 16 )
duke@435 77 | ( u8( ((u2*)p)[3] ) );
duke@435 78
duke@435 79 default: return ( u8(p[0]) << 56 )
duke@435 80 | ( u8(p[1]) << 48 )
duke@435 81 | ( u8(p[2]) << 40 )
duke@435 82 | ( u8(p[3]) << 32 )
duke@435 83 | ( u8(p[4]) << 24 )
duke@435 84 | ( u8(p[5]) << 16 )
duke@435 85 | ( u8(p[6]) << 8 )
duke@435 86 | u8(p[7]);
duke@435 87 }
duke@435 88 }
duke@435 89
duke@435 90
duke@435 91
duke@435 92 static inline void put_native_u2(address p, u2 x) {
duke@435 93 if ( (intptr_t(p) & 1) == 0 ) *(u2*)p = x;
duke@435 94 else {
duke@435 95 p[0] = x >> 8;
duke@435 96 p[1] = x;
duke@435 97 }
duke@435 98 }
duke@435 99
duke@435 100 static inline void put_native_u4(address p, u4 x) {
duke@435 101 switch ( intptr_t(p) & 3 ) {
duke@435 102 case 0: *(u4*)p = x;
duke@435 103 break;
duke@435 104
duke@435 105 case 2: ((u2*)p)[0] = x >> 16;
duke@435 106 ((u2*)p)[1] = x;
duke@435 107 break;
duke@435 108
duke@435 109 default: ((u1*)p)[0] = x >> 24;
duke@435 110 ((u1*)p)[1] = x >> 16;
duke@435 111 ((u1*)p)[2] = x >> 8;
duke@435 112 ((u1*)p)[3] = x;
duke@435 113 break;
duke@435 114 }
duke@435 115 }
duke@435 116
duke@435 117 static inline void put_native_u8(address p, u8 x) {
duke@435 118 switch ( intptr_t(p) & 7 ) {
duke@435 119 case 0: *(u8*)p = x;
duke@435 120 break;
duke@435 121
duke@435 122 case 4: ((u4*)p)[0] = x >> 32;
duke@435 123 ((u4*)p)[1] = x;
duke@435 124 break;
duke@435 125
duke@435 126 case 2: ((u2*)p)[0] = x >> 48;
duke@435 127 ((u2*)p)[1] = x >> 32;
duke@435 128 ((u2*)p)[2] = x >> 16;
duke@435 129 ((u2*)p)[3] = x;
duke@435 130 break;
duke@435 131
duke@435 132 default: ((u1*)p)[0] = x >> 56;
duke@435 133 ((u1*)p)[1] = x >> 48;
duke@435 134 ((u1*)p)[2] = x >> 40;
duke@435 135 ((u1*)p)[3] = x >> 32;
duke@435 136 ((u1*)p)[4] = x >> 24;
duke@435 137 ((u1*)p)[5] = x >> 16;
duke@435 138 ((u1*)p)[6] = x >> 8;
duke@435 139 ((u1*)p)[7] = x;
duke@435 140 }
duke@435 141 }
duke@435 142
duke@435 143
duke@435 144 // Efficient reading and writing of unaligned unsigned data in Java byte ordering (i.e. big-endian ordering)
duke@435 145 // (no byte-order reversal is needed since SPARC CPUs are big-endian oriented)
duke@435 146 static inline u2 get_Java_u2(address p) { return get_native_u2(p); }
duke@435 147 static inline u4 get_Java_u4(address p) { return get_native_u4(p); }
duke@435 148 static inline u8 get_Java_u8(address p) { return get_native_u8(p); }
duke@435 149
duke@435 150 static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, x); }
duke@435 151 static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, x); }
duke@435 152 static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, x); }
duke@435 153 };
duke@435 154
duke@435 155 //Reconciliation History
duke@435 156 // 1.7 98/02/24 10:18:41 bytes_i486.hpp
duke@435 157 // 1.10 98/04/08 18:47:57 bytes_i486.hpp
duke@435 158 // 1.13 98/07/15 17:10:03 bytes_i486.hpp
duke@435 159 // 1.14 98/08/13 10:38:23 bytes_i486.hpp
duke@435 160 // 1.15 98/10/05 16:30:21 bytes_i486.hpp
duke@435 161 // 1.17 99/06/22 16:37:35 bytes_i486.hpp
duke@435 162 //End
stefank@2314 163
stefank@2314 164 #endif // CPU_SPARC_VM_BYTES_SPARC_HPP

mercurial