diff src/share/vm/compiler/abstractCompiler.hpp @ 13086:096c224171c4

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 20 Nov 2013 00:10:38 +0100
parents f6c511451e4a 469216acdb28
children d8041d695d19
line wrap: on
line diff
--- a/src/share/vm/compiler/abstractCompiler.hpp	Tue Nov 19 17:44:26 2013 +0100
+++ b/src/share/vm/compiler/abstractCompiler.hpp	Wed Nov 20 00:10:38 2013 +0100
@@ -67,21 +67,22 @@
 
 class AbstractCompiler : public CHeapObj<mtCompiler> {
  private:
-  bool _is_initialized; // Mark whether compiler object is initialized
+  volatile int _num_compiler_threads;
 
  protected:
+  volatile int _compiler_state;
   // Used for tracking global state of compiler runtime initialization
-  enum { uninitialized, initializing, initialized };
+  enum { uninitialized, initializing, initialized, failed, shut_down };
+
+  // This method returns true for the first compiler thread that reaches that methods.
+  // This thread will initialize the compiler runtime.
+  bool should_perform_init();
 
   // The (closed set) of concrete compiler classes. Using an tag like this
   // avoids a confusing use of macros around the definition of the
   // 'is_<compiler type>' methods.
   enum Type { c1, c2, shark, graal };
 
-  // This method will call the initialization method "f" once (per compiler class/subclass)
-  // and do so without holding any locks
-  void initialize_runtimes(initializer f, volatile int* state);
-
  private:
   Type _type;
 
@@ -90,7 +91,11 @@
 #endif
 
  public:
-  AbstractCompiler(Type type) : _is_initialized(false), _type(type)    {}
+  AbstractCompiler(Type type) : _type(type), _compiler_state(uninitialized), _num_compiler_threads(0) {}
+
+  // This function determines the compiler thread that will perform the
+  // shutdown of the corresponding compiler runtime.
+  bool should_perform_shutdown();
 
   // Name of this compiler
   virtual const char* name() = 0;
@@ -107,17 +112,18 @@
   bool is_graal()                                { return _type == graal; }
 
   // Customization
-  virtual bool needs_stubs            ()         = 0;
+  virtual void initialize () = 0;
 
-  void mark_initialized()                        { _is_initialized = true; }
-  bool is_initialized()                          { return _is_initialized; }
+  void set_num_compiler_threads(int num) { _num_compiler_threads = num;  }
+  int num_compiler_threads()             { return _num_compiler_threads; }
 
-  virtual void initialize()                      = 0;
-
+  // Get/set state of compiler objects
+  bool is_initialized()           { return _compiler_state == initialized; }
+  bool is_failed     ()           { return _compiler_state == failed;}
+  void set_state     (int state);
+  void set_shut_down ()           { set_state(shut_down); }
   // Compilation entry point for methods
-  virtual void compile_method(ciEnv* env,
-                              ciMethod* target,
-                              int entry_bci) {
+  virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
     ShouldNotReachHere();
   }