changeset 6517:2dfab5607b3d

fix hashCode changes: port to x64
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 05 Oct 2012 13:44:26 +0200
parents 174805dea3fc
children ea845fd3c820
files src/cpu/x86/vm/sharedRuntime_x86_32.cpp src/cpu/x86/vm/sharedRuntime_x86_64.cpp
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Fri Oct 05 10:54:06 2012 +0200
+++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Fri Oct 05 13:44:26 2012 +0200
@@ -1746,7 +1746,7 @@
     __ ret(0);
     __ bind (slowCase);
   }
-#endif // COMPILER1
+#endif // COMPILER1 || GRAAL
 
   // The instruction at the verified entry point must be 5 bytes or longer
   // because it can be patched on the fly by make_non_entrant. The stack bang
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Fri Oct 05 10:54:06 2012 +0200
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Fri Oct 05 13:44:26 2012 +0200
@@ -1969,6 +1969,38 @@
 
   int vep_offset = ((intptr_t)__ pc()) - start;
 
+#ifdef GRAAL
+  if (InlineObjectHash && method->intrinsic_id() == vmIntrinsics::_hashCode) {
+    // Object.hashCode can pull the hashCode from the header word
+    // instead of doing a full VM transition once it's been computed.
+    // Since hashCode is usually polymorphic at call sites we can't do
+    // this optimization at the call site without a lot of work.
+    Label slowCase;
+    Register result = rax;
+
+    __ movptr(result, Address(receiver, oopDesc::mark_offset_in_bytes()));
+
+    // check if locked
+    __ testptr(result, markOopDesc::unlocked_value);
+    __ jcc (Assembler::zero, slowCase);
+
+    if (UseBiasedLocking) {
+      // Check if biased and fall through to runtime if so
+      __ testptr(result, markOopDesc::biased_lock_bit_in_place);
+      __ jcc (Assembler::notZero, slowCase);
+    }
+
+    // get hash
+    __ shrptr(result, markOopDesc::hash_shift);
+    __ andptr(result, markOopDesc::hash_mask);
+    // test if hashCode exists
+    __ jcc  (Assembler::zero, slowCase);
+    __ ret(0);
+
+    __ bind (slowCase);
+  }
+#endif // GRAAL
+
   // The instruction at the verified entry point must be 5 bytes or longer
   // because it can be patched on the fly by make_non_entrant. The stack bang
   // instruction fits that requirement.