comparison src/share/vm/opto/c2compiler.cpp @ 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 6f3fd5150b67
children de6a9e811145 2b8e28fdf503
comparison
equal deleted inserted replaced
12876:8b80b262e501 12880:469216acdb28
42 #endif 42 #endif
43 #ifdef TARGET_ARCH_MODEL_ppc 43 #ifdef TARGET_ARCH_MODEL_ppc
44 # include "adfiles/ad_ppc.hpp" 44 # include "adfiles/ad_ppc.hpp"
45 #endif 45 #endif
46 46
47
48 volatile int C2Compiler::_runtimes = uninitialized;
49
50 // register information defined by ADLC 47 // register information defined by ADLC
51 extern const char register_save_policy[]; 48 extern const char register_save_policy[];
52 extern const int register_save_type[]; 49 extern const int register_save_type[];
53 50
54 const char* C2Compiler::retry_no_subsuming_loads() { 51 const char* C2Compiler::retry_no_subsuming_loads() {
55 return "retry without subsuming loads"; 52 return "retry without subsuming loads";
56 } 53 }
57 const char* C2Compiler::retry_no_escape_analysis() { 54 const char* C2Compiler::retry_no_escape_analysis() {
58 return "retry without escape analysis"; 55 return "retry without escape analysis";
59 } 56 }
60 void C2Compiler::initialize_runtime() { 57 bool C2Compiler::init_c2_runtime() {
61 58
62 // Check assumptions used while running ADLC 59 // Check assumptions used while running ADLC
63 Compile::adlc_verification(); 60 Compile::adlc_verification();
64 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts"); 61 assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
65 62
88 85
89 Compile::pd_compiler2_init(); 86 Compile::pd_compiler2_init();
90 87
91 CompilerThread* thread = CompilerThread::current(); 88 CompilerThread* thread = CompilerThread::current();
92 89
93 HandleMark handle_mark(thread); 90 HandleMark handle_mark(thread);
94 91 return OptoRuntime::generate(thread->env());
95 OptoRuntime::generate(thread->env());
96
97 } 92 }
98 93
99 94
100 void C2Compiler::initialize() { 95 void C2Compiler::initialize() {
101
102 // This method can only be called once per C2Compiler object
103 // The first compiler thread that gets here will initialize the 96 // The first compiler thread that gets here will initialize the
104 // small amount of global state (and runtime stubs) that c2 needs. 97 // small amount of global state (and runtime stubs) that C2 needs.
105 98
106 // There is a race possible once at startup and then we're fine 99 // There is a race possible once at startup and then we're fine
107 100
108 // Note that this is being called from a compiler thread not the 101 // Note that this is being called from a compiler thread not the
109 // main startup thread. 102 // main startup thread.
110 103 if (should_perform_init()) {
111 if (_runtimes != initialized) { 104 bool successful = C2Compiler::init_c2_runtime();
112 initialize_runtimes( initialize_runtime, &_runtimes); 105 int new_state = (successful) ? initialized : failed;
106 set_state(new_state);
113 } 107 }
114
115 // Mark this compiler object as ready to roll
116 mark_initialized();
117 } 108 }
118 109
119 void C2Compiler::compile_method(ciEnv* env, 110 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
120 ciMethod* target, 111 assert(is_initialized(), "Compiler thread must be initialized");
121 int entry_bci) { 112
122 if (!is_initialized()) {
123 initialize();
124 }
125 bool subsume_loads = SubsumeLoads; 113 bool subsume_loads = SubsumeLoads;
126 bool do_escape_analysis = DoEscapeAnalysis && 114 bool do_escape_analysis = DoEscapeAnalysis && !env->jvmti_can_access_local_variables();
127 !env->jvmti_can_access_local_variables();
128 bool eliminate_boxing = EliminateAutoBox; 115 bool eliminate_boxing = EliminateAutoBox;
129 while (!env->failing()) { 116 while (!env->failing()) {
130 // Attempt to compile while subsuming loads into machine instructions. 117 // Attempt to compile while subsuming loads into machine instructions.
131 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing); 118 Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis, eliminate_boxing);
132 119