changeset 8103:2206bbeb3185

8075967: Zero interpreter asserts for SafeFetch<32,N> calls in ObjectMonitor Summary: Implement SafeFetchX unsafely and make CanUseSafeFetchX false for Zero Reviewed-by: sgehwolf, dholmes
author coleenp
date Wed, 25 Mar 2015 22:27:51 -0400
parents 0b0b09a60061
children 7a5a0939880f
files src/cpu/zero/vm/frame_zero.cpp src/cpu/zero/vm/methodHandles_zero.cpp src/cpu/zero/vm/stubGenerator_zero.cpp src/share/vm/runtime/stubRoutines.hpp
diffstat 4 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/zero/vm/frame_zero.cpp	Wed Mar 25 15:18:37 2015 -0700
+++ b/src/cpu/zero/vm/frame_zero.cpp	Wed Mar 25 22:27:51 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -213,7 +213,7 @@
     valuebuf[buflen - 1] = '\0';
 
     // Print the result
-    st->print_cr(" " PTR_FORMAT ": %-21s = %s", addr, fieldbuf, valuebuf);
+    st->print_cr(" " PTR_FORMAT ": %-21s = %s", p2i(addr), fieldbuf, valuebuf);
   }
 }
 
--- a/src/cpu/zero/vm/methodHandles_zero.cpp	Wed Mar 25 15:18:37 2015 -0700
+++ b/src/cpu/zero/vm/methodHandles_zero.cpp	Wed Mar 25 22:27:51 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -144,6 +144,7 @@
   oop recv = STACK_OBJECT(-numArgs);
   Klass* clazz = recv->klass();
   Klass* klass_part = InstanceKlass::cast(clazz);
+  ResourceMark rm(THREAD);
   klassVtable* vtable = klass_part->vtable();
   Method* vmtarget = vtable->method_at(vmindex);
 
--- a/src/cpu/zero/vm/stubGenerator_zero.cpp	Wed Mar 25 15:18:37 2015 -0700
+++ b/src/cpu/zero/vm/stubGenerator_zero.cpp	Wed Mar 25 22:27:51 2015 -0400
@@ -176,6 +176,19 @@
       StubRoutines::_oop_arraycopy;
   }
 
+  // NYI: SafeFetch for Zero isn't actually safe.
+  static int SafeFetch32(int *adr, int errValue) {
+    int value = errValue;
+    value = *adr;
+    return value;
+  }
+
+  static intptr_t SafeFetchN(intptr_t *adr, intptr_t errValue) {
+    intptr_t value = errValue;
+    value = *adr;
+    return value;
+  }
+
   void generate_initial() {
     // Generates all stubs and initializes the entry points
 
@@ -228,11 +241,11 @@
     generate_arraycopy_stubs();
 
     // Safefetch stubs.
-    StubRoutines::_safefetch32_entry = NULL;
+    StubRoutines::_safefetch32_entry = CAST_FROM_FN_PTR(address, StubGenerator::SafeFetch32);
     StubRoutines::_safefetch32_fault_pc = NULL;
     StubRoutines::_safefetch32_continuation_pc = NULL;
 
-    StubRoutines::_safefetchN_entry = NULL;
+    StubRoutines::_safefetchN_entry = CAST_FROM_FN_PTR(address, StubGenerator::SafeFetchN);
     StubRoutines::_safefetchN_fault_pc = NULL;
     StubRoutines::_safefetchN_continuation_pc = NULL;
   }
--- a/src/share/vm/runtime/stubRoutines.hpp	Wed Mar 25 15:18:37 2015 -0700
+++ b/src/share/vm/runtime/stubRoutines.hpp	Wed Mar 25 22:27:51 2015 -0400
@@ -450,7 +450,15 @@
 
 
 // returns true if SafeFetch32 and SafeFetchN can be used safely (stubroutines are already generated)
-inline bool CanUseSafeFetch32() { return StubRoutines::SafeFetch32_stub() ? true : false; }
-inline bool CanUseSafeFetchN()  { return StubRoutines::SafeFetchN_stub() ? true : false; }
+inline bool CanUseSafeFetch32() {
+  // All platforms have the stub but ZERO isn't safe.
+  assert(StubRoutines::SafeFetch32_stub() != NULL, "should have generated stub");
+  return NOT_ZERO(true) ZERO_ONLY(false);
+}
 
+inline bool CanUseSafeFetchN()  {
+  // All platforms have the stub but ZERO isn't safe.
+  assert(StubRoutines::SafeFetchN_stub() != NULL, "should have generated stub");
+  return NOT_ZERO(true) ZERO_ONLY(false);
+}
 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP