8186837: Memory ordering nmethod, _state and _stack_traversal_mark
authorrehn
Thu, 31 Aug 2017 08:18:47 +0200
changeset 47099 49f5fa3fc2ae
parent 47098 e704f55561c3
child 47101 f5ec4aa2309d
8186837: Memory ordering nmethod, _state and _stack_traversal_mark Reviewed-by: dholmes, rkennke
hotspot/src/share/vm/code/nmethod.cpp
hotspot/src/share/vm/code/nmethod.hpp
hotspot/src/share/vm/runtime/sweeper.cpp
hotspot/src/share/vm/runtime/vmStructs.cpp
--- a/hotspot/src/share/vm/code/nmethod.cpp	Wed Aug 30 19:18:22 2017 -0400
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Thu Aug 31 08:18:47 2017 +0200
@@ -1220,7 +1220,7 @@
     // for stack scanning.
     if (state == not_entrant) {
       mark_as_seen_on_stack();
-      OrderAccess::storestore();
+      OrderAccess::storestore(); // _stack_traversal_mark and _state
     }
 
     // Change state
--- a/hotspot/src/share/vm/code/nmethod.hpp	Wed Aug 30 19:18:22 2017 -0400
+++ b/hotspot/src/share/vm/code/nmethod.hpp	Thu Aug 31 08:18:47 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -136,7 +136,7 @@
   // stack.  An not_entrant method can be removed when there are no
   // more activations, i.e., when the _stack_traversal_mark is less than
   // current sweep traversal index.
-  volatile jlong _stack_traversal_mark;
+  volatile long _stack_traversal_mark;
 
   // The _hotness_counter indicates the hotness of a method. The higher
   // the value the hotter the method. The hotness counter of a nmethod is
@@ -396,8 +396,8 @@
  public:
 
   // Sweeper support
-  jlong  stack_traversal_mark()                    { return OrderAccess::load_acquire(&_stack_traversal_mark); }
-  void  set_stack_traversal_mark(jlong l)          { OrderAccess::release_store(&_stack_traversal_mark, l); }
+  long  stack_traversal_mark()                    { return _stack_traversal_mark; }
+  void  set_stack_traversal_mark(long l)          { _stack_traversal_mark = l; }
 
   // implicit exceptions support
   address continuation_for_implicit_exception(address pc);
--- a/hotspot/src/share/vm/runtime/sweeper.cpp	Wed Aug 30 19:18:22 2017 -0400
+++ b/hotspot/src/share/vm/runtime/sweeper.cpp	Thu Aug 31 08:18:47 2017 +0200
@@ -53,7 +53,7 @@
  public:
   int traversal;
   int compile_id;
-  jlong traversal_mark;
+  long traversal_mark;
   int state;
   const char* kind;
   address vep;
@@ -62,7 +62,7 @@
 
   void print() {
       tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = "
-                    PTR_FORMAT " state = %d traversal_mark "JLONG_FORMAT" line = %d",
+                    PTR_FORMAT " state = %d traversal_mark %ld line = %d",
                     traversal,
                     compile_id,
                     kind == NULL ? "" : kind,
@@ -629,6 +629,7 @@
   } else if (cm->is_not_entrant()) {
     // If there are no current activations of this method on the
     // stack we can safely convert it to a zombie method
+    OrderAccess::loadload(); // _stack_traversal_mark and _state
     if (cm->can_convert_to_zombie()) {
       // Clear ICStubs to prevent back patching stubs of zombie or flushed
       // nmethods during the next safepoint (see ICStub::finalize).
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Aug 30 19:18:22 2017 -0400
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Aug 31 08:18:47 2017 +0200
@@ -841,7 +841,7 @@
   nonstatic_field(nmethod,                     _verified_entry_point,                         address)                               \
   nonstatic_field(nmethod,                     _osr_entry_point,                              address)                               \
   volatile_nonstatic_field(nmethod,            _lock_count,                                   jint)                                  \
-  volatile_nonstatic_field(nmethod,            _stack_traversal_mark,                         jlong)                                 \
+  volatile_nonstatic_field(nmethod,            _stack_traversal_mark,                         long)                                  \
   nonstatic_field(nmethod,                     _compile_id,                                   int)                                   \
   nonstatic_field(nmethod,                     _comp_level,                                   int)                                   \
                                                                                                                                      \