Mercurial > hg > graal-compiler
comparison src/share/vm/compiler/abstractCompiler.hpp @ 12880:469216acdb28
8023014: CodeSweeperSweepNoFlushTest.java fails with HS crash
Summary: Ensure ensure correct initialization of compiler runtime
Reviewed-by: kvn, twisti
author | anoll |
---|---|
date | Thu, 10 Oct 2013 15:44:12 +0200 |
parents | 606eada1bf86 |
children | 096c224171c4 de6a9e811145 |
comparison
equal
deleted
inserted
replaced
12876:8b80b262e501 | 12880:469216acdb28 |
---|---|
25 #ifndef SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP | 25 #ifndef SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP |
26 #define SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP | 26 #define SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP |
27 | 27 |
28 #include "ci/compilerInterface.hpp" | 28 #include "ci/compilerInterface.hpp" |
29 | 29 |
30 typedef void (*initializer)(void); | |
31 | |
32 class AbstractCompiler : public CHeapObj<mtCompiler> { | 30 class AbstractCompiler : public CHeapObj<mtCompiler> { |
33 private: | 31 private: |
34 bool _is_initialized; // Mark whether compiler object is initialized | 32 volatile int _num_compiler_threads; |
35 | 33 |
36 protected: | 34 protected: |
35 volatile int _compiler_state; | |
37 // Used for tracking global state of compiler runtime initialization | 36 // Used for tracking global state of compiler runtime initialization |
38 enum { uninitialized, initializing, initialized }; | 37 enum { uninitialized, initializing, initialized, failed, shut_down }; |
39 | 38 |
40 // This method will call the initialization method "f" once (per compiler class/subclass) | 39 // This method returns true for the first compiler thread that reaches that methods. |
41 // and do so without holding any locks | 40 // This thread will initialize the compiler runtime. |
42 void initialize_runtimes(initializer f, volatile int* state); | 41 bool should_perform_init(); |
43 | 42 |
44 public: | 43 public: |
45 AbstractCompiler() : _is_initialized(false) {} | 44 AbstractCompiler() : _compiler_state(uninitialized), _num_compiler_threads(0) {} |
45 | |
46 // This function determines the compiler thread that will perform the | |
47 // shutdown of the corresponding compiler runtime. | |
48 bool should_perform_shutdown(); | |
46 | 49 |
47 // Name of this compiler | 50 // Name of this compiler |
48 virtual const char* name() = 0; | 51 virtual const char* name() = 0; |
49 | 52 |
50 // Missing feature tests | 53 // Missing feature tests |
72 bool is_shark() { return true; } | 75 bool is_shark() { return true; } |
73 #endif // SHARK | 76 #endif // SHARK |
74 #endif // TIERED | 77 #endif // TIERED |
75 | 78 |
76 // Customization | 79 // Customization |
77 virtual bool needs_stubs () = 0; | 80 virtual void initialize () = 0; |
78 | 81 |
79 void mark_initialized() { _is_initialized = true; } | 82 void set_num_compiler_threads(int num) { _num_compiler_threads = num; } |
80 bool is_initialized() { return _is_initialized; } | 83 int num_compiler_threads() { return _num_compiler_threads; } |
81 | 84 |
82 virtual void initialize() = 0; | 85 // Get/set state of compiler objects |
83 | 86 bool is_initialized() { return _compiler_state == initialized; } |
87 bool is_failed () { return _compiler_state == failed;} | |
88 void set_state (int state); | |
89 void set_shut_down () { set_state(shut_down); } | |
84 // Compilation entry point for methods | 90 // Compilation entry point for methods |
85 virtual void compile_method(ciEnv* env, | 91 virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
86 ciMethod* target, | |
87 int entry_bci) { | |
88 ShouldNotReachHere(); | 92 ShouldNotReachHere(); |
89 } | 93 } |
90 | 94 |
91 | 95 |
92 // Print compilation timers and statistics | 96 // Print compilation timers and statistics |