< prev index next >

src/hotspot/cpu/x86/jniFastGetField_x86_64.cpp

Print this page

 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.hpp"
 27 #include "code/codeBlob.hpp"
 28 #include "gc/shared/barrierSet.hpp"
 29 #include "gc/shared/barrierSetAssembler.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "prims/jniFastGetField.hpp"
 32 #include "prims/jvm_misc.hpp"

 33 #include "prims/jvmtiExport.hpp"
 34 #include "runtime/safepoint.hpp"
 35 
 36 #define __ masm->
 37 
 38 #define BUFFER_SIZE 30*wordSize
 39 
 40 // Common register usage:
 41 // rax/xmm0: result
 42 // c_rarg0:    jni env
 43 // c_rarg1:    obj
 44 // c_rarg2:    jfield id
 45 
 46 static const Register rtmp     = rax; // r8 == c_rarg2 on Windows
 47 static const Register robj     = r9;
 48 static const Register roffset  = r10;
 49 static const Register rcounter = r11;
 50 
 51 // Warning: do not use rip relative addressing after the first counter load
 52 // since that may scratch r10!

 68   MacroAssembler* masm = new MacroAssembler(&cbuf);
 69   address fast_entry = __ pc();
 70 
 71   Label slow;
 72 
 73   ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
 74   __ mov32 (rcounter, counter);
 75   __ mov   (robj, c_rarg1);
 76   __ testb (rcounter, 1);
 77   __ jcc (Assembler::notZero, slow);
 78 
 79   if (JvmtiExport::can_post_field_access()) {
 80     // Check to see if a field access watch has been set before we
 81     // take the fast path.
 82     assert_different_registers(rscratch1, robj, rcounter); // cmp32 clobbers rscratch1!
 83     __ cmp32(ExternalAddress((address) JvmtiExport::get_field_access_count_addr()), 0);
 84     __ jcc(Assembler::notZero, slow);
 85   }
 86 
 87   __ mov   (roffset, c_rarg2);
 88   __ shrptr(roffset, 2);                         // offset
 89 
 90   // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
 91   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
 92   bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
 93   DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
 94 
 95   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
 96   speculative_load_pclist[count] = __ pc();
 97   switch (type) {
 98     case T_BOOLEAN: __ movzbl (rax, Address(robj, roffset, Address::times_1)); break;
 99     case T_BYTE:    __ movsbl (rax, Address(robj, roffset, Address::times_1)); break;
100     case T_CHAR:    __ movzwl (rax, Address(robj, roffset, Address::times_1)); break;
101     case T_SHORT:   __ movswl (rax, Address(robj, roffset, Address::times_1)); break;
102     case T_INT:     __ movl   (rax, Address(robj, roffset, Address::times_1)); break;
103     case T_LONG:    __ movq   (rax, Address(robj, roffset, Address::times_1)); break;
104     default:        ShouldNotReachHere();
105   }
106 
107   __ cmp32 (rcounter, counter);
108   __ jcc (Assembler::notEqual, slow);

170 
171   ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
172   __ mov32 (rcounter, counter);
173   __ mov   (robj, c_rarg1);
174   __ testb (rcounter, 1);
175   __ jcc (Assembler::notZero, slow);
176 
177   if (JvmtiExport::can_post_field_access()) {
178     // Check to see if a field access watch has been set before we
179     // take the fast path.
180     __ cmp32(ExternalAddress((address) JvmtiExport::get_field_access_count_addr()), 0);
181     __ jcc(Assembler::notZero, slow);
182   }
183 
184   // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
185   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
186   bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
187   DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
188 
189   __ mov   (roffset, c_rarg2);
190   __ shrptr(roffset, 2);                         // offset
191 
192   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
193   speculative_load_pclist[count] = __ pc();
194   switch (type) {
195     case T_FLOAT:  __ movflt (xmm0, Address(robj, roffset, Address::times_1)); break;
196     case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break;
197     default:        ShouldNotReachHere();
198   }
199   __ cmp32 (rcounter, counter);
200   __ jcc (Assembler::notEqual, slow);
201 
202   __ ret (0);
203 
204   slowcase_entry_pclist[count++] = __ pc();
205   __ bind (slow);
206   address slow_case_addr = NULL;
207   switch (type) {
208     case T_FLOAT:     slow_case_addr = jni_GetFloatField_addr();  break;
209     case T_DOUBLE:    slow_case_addr = jni_GetDoubleField_addr(); break;
210     default:                                                      break;

 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.hpp"
 27 #include "code/codeBlob.hpp"
 28 #include "gc/shared/barrierSet.hpp"
 29 #include "gc/shared/barrierSetAssembler.hpp"
 30 #include "memory/resourceArea.hpp"
 31 #include "prims/jniFastGetField.hpp"
 32 #include "prims/jvm_misc.hpp"
 33 #include "runtime/jfieldIDWorkaround.hpp"
 34 #include "prims/jvmtiExport.hpp"
 35 #include "runtime/safepoint.hpp"
 36 
 37 #define __ masm->
 38 
 39 #define BUFFER_SIZE 30*wordSize
 40 
 41 // Common register usage:
 42 // rax/xmm0: result
 43 // c_rarg0:    jni env
 44 // c_rarg1:    obj
 45 // c_rarg2:    jfield id
 46 
 47 static const Register rtmp     = rax; // r8 == c_rarg2 on Windows
 48 static const Register robj     = r9;
 49 static const Register roffset  = r10;
 50 static const Register rcounter = r11;
 51 
 52 // Warning: do not use rip relative addressing after the first counter load
 53 // since that may scratch r10!

 69   MacroAssembler* masm = new MacroAssembler(&cbuf);
 70   address fast_entry = __ pc();
 71 
 72   Label slow;
 73 
 74   ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
 75   __ mov32 (rcounter, counter);
 76   __ mov   (robj, c_rarg1);
 77   __ testb (rcounter, 1);
 78   __ jcc (Assembler::notZero, slow);
 79 
 80   if (JvmtiExport::can_post_field_access()) {
 81     // Check to see if a field access watch has been set before we
 82     // take the fast path.
 83     assert_different_registers(rscratch1, robj, rcounter); // cmp32 clobbers rscratch1!
 84     __ cmp32(ExternalAddress((address) JvmtiExport::get_field_access_count_addr()), 0);
 85     __ jcc(Assembler::notZero, slow);
 86   }
 87 
 88   __ mov   (roffset, c_rarg2);
 89   __ shrptr(roffset, jfieldIDWorkaround::offset_shift);                         // offset
 90 
 91   // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
 92   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
 93   bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
 94   DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
 95 
 96   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
 97   speculative_load_pclist[count] = __ pc();
 98   switch (type) {
 99     case T_BOOLEAN: __ movzbl (rax, Address(robj, roffset, Address::times_1)); break;
100     case T_BYTE:    __ movsbl (rax, Address(robj, roffset, Address::times_1)); break;
101     case T_CHAR:    __ movzwl (rax, Address(robj, roffset, Address::times_1)); break;
102     case T_SHORT:   __ movswl (rax, Address(robj, roffset, Address::times_1)); break;
103     case T_INT:     __ movl   (rax, Address(robj, roffset, Address::times_1)); break;
104     case T_LONG:    __ movq   (rax, Address(robj, roffset, Address::times_1)); break;
105     default:        ShouldNotReachHere();
106   }
107 
108   __ cmp32 (rcounter, counter);
109   __ jcc (Assembler::notEqual, slow);

171 
172   ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
173   __ mov32 (rcounter, counter);
174   __ mov   (robj, c_rarg1);
175   __ testb (rcounter, 1);
176   __ jcc (Assembler::notZero, slow);
177 
178   if (JvmtiExport::can_post_field_access()) {
179     // Check to see if a field access watch has been set before we
180     // take the fast path.
181     __ cmp32(ExternalAddress((address) JvmtiExport::get_field_access_count_addr()), 0);
182     __ jcc(Assembler::notZero, slow);
183   }
184 
185   // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
186   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
187   bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
188   DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
189 
190   __ mov   (roffset, c_rarg2);
191   __ shrptr(roffset, jfieldIDWorkaround::offset_shift);                         // offset
192 
193   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
194   speculative_load_pclist[count] = __ pc();
195   switch (type) {
196     case T_FLOAT:  __ movflt (xmm0, Address(robj, roffset, Address::times_1)); break;
197     case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break;
198     default:        ShouldNotReachHere();
199   }
200   __ cmp32 (rcounter, counter);
201   __ jcc (Assembler::notEqual, slow);
202 
203   __ ret (0);
204 
205   slowcase_entry_pclist[count++] = __ pc();
206   __ bind (slow);
207   address slow_case_addr = NULL;
208   switch (type) {
209     case T_FLOAT:     slow_case_addr = jni_GetFloatField_addr();  break;
210     case T_DOUBLE:    slow_case_addr = jni_GetDoubleField_addr(); break;
211     default:                                                      break;
< prev index next >