comparison src/share/vm/graal/graalRuntime.cpp @ 15589:ddb3ef30fcd2

fixed livelock issue introduced by 063ec2920d21
author Doug Simon <doug.simon@oracle.com>
date Sun, 11 May 2014 13:43:19 +0200
parents 063ec2920d21
children b7fb36e57da8
comparison
equal deleted inserted replaced
15588:9a63ccd66007 15589:ddb3ef30fcd2
35 #include "runtime/arguments.hpp" 35 #include "runtime/arguments.hpp"
36 #include "runtime/reflection.hpp" 36 #include "runtime/reflection.hpp"
37 #include "utilities/debug.hpp" 37 #include "utilities/debug.hpp"
38 38
39 address GraalRuntime::_external_deopt_i2c_entry = NULL; 39 address GraalRuntime::_external_deopt_i2c_entry = NULL;
40 volatile int GraalRuntime::_state = uninitialized; 40 volatile GraalRuntime::State GraalRuntime::_state = uninitialized;
41 41 Thread* GraalRuntime::_initializingThread = NULL;
42 void GraalRuntime::initialize() { 42
43 { 43 bool GraalRuntime::should_perform_init() {
44 JavaThread* THREAD = JavaThread::current();
45 if (_state != initialized) {
46 if (THREAD == _initializingThread) {
47 return false;
48 }
44 MutexLocker locker(GraalInitialization_lock); 49 MutexLocker locker(GraalInitialization_lock);
45 if (_state == uninitialized) { 50 if (_state == uninitialized) {
46 _state = initializing; 51 _state = initializing;
52 _initializingThread = THREAD;
53 return true;
47 } else { 54 } else {
48 while (_state == initializing) { 55 while (_state == initializing) {
49 GraalInitialization_lock->wait(); 56 GraalInitialization_lock->wait();
50 } 57 }
51 return; 58 }
52 } 59 }
60 return false;
61 }
62
63 void GraalRuntime::initialize() {
64 if (!should_perform_init()) {
65 return;
53 } 66 }
54 67
55 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); 68 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
56 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; 69 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024;
57 AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)")); 70 AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)"));
58 NOT_LP64(error("check TLAB allocation code for address space conflicts")); 71 NOT_LP64(error("check TLAB allocation code for address space conflicts"));
59 72
60 ThreadToNativeFromVM trans(JavaThread::current());
61 JavaThread* THREAD = JavaThread::current(); 73 JavaThread* THREAD = JavaThread::current();
74 ThreadToNativeFromVM trans(THREAD);
62 TRACE_graal_1("GraalRuntime::initialize"); 75 TRACE_graal_1("GraalRuntime::initialize");
63 76
64 JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment(); 77 JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment();
65 jclass klass = env->FindClass("com/oracle/graal/hotspot/bridge/CompilerToVMImpl"); 78 jclass klass = env->FindClass("com/oracle/graal/hotspot/bridge/CompilerToVMImpl");
66 if (klass == NULL) { 79 if (klass == NULL) {
101 VMToCompiler::startRuntime(); 114 VMToCompiler::startRuntime();
102 115
103 { 116 {
104 MutexLocker locker(GraalInitialization_lock); 117 MutexLocker locker(GraalInitialization_lock);
105 _state = initialized; 118 _state = initialized;
119 _initializingThread = NULL;
106 } 120 }
107 121
108 #if !defined(PRODUCT) && !defined(COMPILERGRAAL) 122 #if !defined(PRODUCT) && !defined(COMPILERGRAAL)
109 // In COMPILERGRAAL, we want to allow GraalBootstrap 123 // In COMPILERGRAAL, we want to allow GraalBootstrap
110 // to happen first so GraalCompiler::initialize() 124 // to happen first so GraalCompiler::initialize()