< prev index next >

src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp

Print this page

  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  */
 24 
 25 #include "precompiled.hpp"

 26 #include "classfile/classLoaderData.hpp"
 27 #include "gc/shared/barrierSet.hpp"
 28 #include "gc/shared/barrierSetAssembler.hpp"
 29 #include "gc/shared/barrierSetNMethod.hpp"

 30 #include "gc/shared/collectedHeap.hpp"
 31 #include "interpreter/interp_masm.hpp"
 32 #include "memory/universe.hpp"
 33 #include "runtime/jniHandles.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "runtime/stubRoutines.hpp"
 36 #include "runtime/thread.hpp"
 37 
 38 #define __ masm->
 39 
 40 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
 41                                   Register dst, Address src, Register tmp1, Register tmp_thread) {
 42   bool in_heap = (decorators & IN_HEAP) != 0;
 43   bool in_native = (decorators & IN_NATIVE) != 0;
 44   bool is_not_null = (decorators & IS_NOT_NULL) != 0;
 45   bool atomic = (decorators & MO_RELAXED) != 0;
 46 

 47   switch (type) {
 48   case T_OBJECT:
 49   case T_ARRAY: {
 50     if (in_heap) {
 51 #ifdef _LP64
 52       if (UseCompressedOops) {
 53         __ movl(dst, src);
 54         if (is_not_null) {
 55           __ decode_heap_oop_not_null(dst);
 56         } else {
 57           __ decode_heap_oop(dst);
 58         }
 59       } else
 60 #endif
 61       {
 62         __ movptr(dst, src);
 63       }
 64     } else {
 65       assert(in_native, "why else?");
 66       __ movptr(dst, src);

 86 #ifdef _LP64
 87     __ movq(rax, src);
 88 #else
 89     if (atomic) {
 90       __ fild_d(src);               // Must load atomically
 91       __ subptr(rsp,2*wordSize);    // Make space for store
 92       __ fistp_d(Address(rsp,0));
 93       __ pop(rax);
 94       __ pop(rdx);
 95     } else {
 96       __ movl(rax, src);
 97       __ movl(rdx, src.plus_disp(wordSize));
 98     }
 99 #endif
100     break;
101   default: Unimplemented();
102   }
103 }
104 
105 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
106                                    Address dst, Register val, Register tmp1, Register tmp2) {
107   bool in_heap = (decorators & IN_HEAP) != 0;
108   bool in_native = (decorators & IN_NATIVE) != 0;
109   bool is_not_null = (decorators & IS_NOT_NULL) != 0;
110   bool atomic = (decorators & MO_RELAXED) != 0;
111 

112   switch (type) {
113   case T_OBJECT:
114   case T_ARRAY: {
115     if (in_heap) {
116       if (val == noreg) {
117         assert(!is_not_null, "inconsistent access");
118 #ifdef _LP64
119         if (UseCompressedOops) {
120           __ movl(dst, (int32_t)NULL_WORD);
121         } else {
122           __ movslq(dst, (int32_t)NULL_WORD);
123         }
124 #else
125         __ movl(dst, (int32_t)NULL_WORD);
126 #endif
127       } else {
128 #ifdef _LP64
129         if (UseCompressedOops) {
130           assert(!dst.uses(val), "not enough registers");
131           if (is_not_null) {

178       __ movptr(dst, rax);
179       __ movptr(dst.plus_disp(wordSize), rdx);
180     }
181 #endif
182     break;
183   case T_FLOAT:
184     assert(val == noreg, "only tos");
185     __ store_float(dst);
186     break;
187   case T_DOUBLE:
188     assert(val == noreg, "only tos");
189     __ store_double(dst);
190     break;
191   case T_ADDRESS:
192     __ movptr(dst, val);
193     break;
194   default: Unimplemented();
195   }
196 }
197 













198 void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
199                                                         Register obj, Register tmp, Label& slowpath) {
200   __ clear_jweak_tag(obj);
201   __ movptr(obj, Address(obj, 0));
202 }
203 
204 void BarrierSetAssembler::tlab_allocate(MacroAssembler* masm,
205                                         Register thread, Register obj,
206                                         Register var_size_in_bytes,
207                                         int con_size_in_bytes,
208                                         Register t1,
209                                         Register t2,
210                                         Label& slow_case) {
211   assert_different_registers(obj, t1, t2);
212   assert_different_registers(obj, var_size_in_bytes, t1);
213   Register end = t2;
214   if (!thread->is_valid()) {
215 #ifdef _LP64
216     thread = r15_thread;
217 #else

  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  */
 24 
 25 #include "precompiled.hpp"
 26 #include "asm/macroAssembler.inline.hpp"
 27 #include "classfile/classLoaderData.hpp"
 28 #include "gc/shared/barrierSet.hpp"
 29 #include "gc/shared/barrierSetAssembler.hpp"
 30 #include "gc/shared/barrierSetNMethod.hpp"
 31 #include "gc/shared/barrierSetRuntime.hpp"
 32 #include "gc/shared/collectedHeap.hpp"
 33 #include "interpreter/interp_masm.hpp"
 34 #include "memory/universe.hpp"
 35 #include "runtime/jniHandles.hpp"
 36 #include "runtime/sharedRuntime.hpp"
 37 #include "runtime/stubRoutines.hpp"
 38 #include "runtime/thread.hpp"
 39 
 40 #define __ masm->
 41 
 42 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
 43                                   Register dst, Address src, Register tmp1, Register tmp_thread) {
 44   bool in_heap = (decorators & IN_HEAP) != 0;
 45   bool in_native = (decorators & IN_NATIVE) != 0;
 46   bool is_not_null = (decorators & IS_NOT_NULL) != 0;
 47   bool atomic = (decorators & MO_RELAXED) != 0;
 48 
 49   assert(type != T_INLINE_TYPE, "Not supported yet");
 50   switch (type) {
 51   case T_OBJECT:
 52   case T_ARRAY: {
 53     if (in_heap) {
 54 #ifdef _LP64
 55       if (UseCompressedOops) {
 56         __ movl(dst, src);
 57         if (is_not_null) {
 58           __ decode_heap_oop_not_null(dst);
 59         } else {
 60           __ decode_heap_oop(dst);
 61         }
 62       } else
 63 #endif
 64       {
 65         __ movptr(dst, src);
 66       }
 67     } else {
 68       assert(in_native, "why else?");
 69       __ movptr(dst, src);

 89 #ifdef _LP64
 90     __ movq(rax, src);
 91 #else
 92     if (atomic) {
 93       __ fild_d(src);               // Must load atomically
 94       __ subptr(rsp,2*wordSize);    // Make space for store
 95       __ fistp_d(Address(rsp,0));
 96       __ pop(rax);
 97       __ pop(rdx);
 98     } else {
 99       __ movl(rax, src);
100       __ movl(rdx, src.plus_disp(wordSize));
101     }
102 #endif
103     break;
104   default: Unimplemented();
105   }
106 }
107 
108 void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
109                                    Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
110   bool in_heap = (decorators & IN_HEAP) != 0;
111   bool in_native = (decorators & IN_NATIVE) != 0;
112   bool is_not_null = (decorators & IS_NOT_NULL) != 0;
113   bool atomic = (decorators & MO_RELAXED) != 0;
114 
115   assert(type != T_INLINE_TYPE, "Not supported yet");
116   switch (type) {
117   case T_OBJECT:
118   case T_ARRAY: {
119     if (in_heap) {
120       if (val == noreg) {
121         assert(!is_not_null, "inconsistent access");
122 #ifdef _LP64
123         if (UseCompressedOops) {
124           __ movl(dst, (int32_t)NULL_WORD);
125         } else {
126           __ movslq(dst, (int32_t)NULL_WORD);
127         }
128 #else
129         __ movl(dst, (int32_t)NULL_WORD);
130 #endif
131       } else {
132 #ifdef _LP64
133         if (UseCompressedOops) {
134           assert(!dst.uses(val), "not enough registers");
135           if (is_not_null) {

182       __ movptr(dst, rax);
183       __ movptr(dst.plus_disp(wordSize), rdx);
184     }
185 #endif
186     break;
187   case T_FLOAT:
188     assert(val == noreg, "only tos");
189     __ store_float(dst);
190     break;
191   case T_DOUBLE:
192     assert(val == noreg, "only tos");
193     __ store_double(dst);
194     break;
195   case T_ADDRESS:
196     __ movptr(dst, val);
197     break;
198   default: Unimplemented();
199   }
200 }
201 
202 void BarrierSetAssembler::value_copy(MacroAssembler* masm, DecoratorSet decorators,
203                                      Register src, Register dst, Register value_klass) {
204   // value_copy implementation is fairly complex, and there are not any
205   // "short-cuts" to be made from asm. What there is, appears to have the same
206   // cost in C++, so just "call_VM_leaf" for now rather than maintain hundreds
207   // of hand-rolled instructions...
208   if (decorators & IS_DEST_UNINITIALIZED) {
209     __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy_is_dest_uninitialized), src, dst, value_klass);
210   } else {
211     __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy), src, dst, value_klass);
212   }
213 }
214 
215 void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
216                                                         Register obj, Register tmp, Label& slowpath) {
217   __ clear_jweak_tag(obj);
218   __ movptr(obj, Address(obj, 0));
219 }
220 
221 void BarrierSetAssembler::tlab_allocate(MacroAssembler* masm,
222                                         Register thread, Register obj,
223                                         Register var_size_in_bytes,
224                                         int con_size_in_bytes,
225                                         Register t1,
226                                         Register t2,
227                                         Label& slow_case) {
228   assert_different_registers(obj, t1, t2);
229   assert_different_registers(obj, var_size_in_bytes, t1);
230   Register end = t2;
231   if (!thread->is_valid()) {
232 #ifdef _LP64
233     thread = r15_thread;
234 #else
< prev index next >