Mercurial > hg > graal-jvmci-8
comparison src/share/vm/jvmci/jvmci_globals.cpp @ 24147:67afd64bc794
set jvmci.Compiler from <java.home>/jre/lib/jvmci/compiler-name before using its existence to change the default for UseJVMCICompiler
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 16 Jun 2017 13:55:05 +0200 |
parents | 2f2299c68571 |
children |
comparison
equal
deleted
inserted
replaced
24146:a63c0eedf71e | 24147:67afd64bc794 |
---|---|
42 #ifdef TARGET_OS_FAMILY_bsd | 42 #ifdef TARGET_OS_FAMILY_bsd |
43 # include "os_bsd.inline.hpp" | 43 # include "os_bsd.inline.hpp" |
44 #endif | 44 #endif |
45 | 45 |
46 JVMCI_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_NOTPRODUCT_FLAG) | 46 JVMCI_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_NOTPRODUCT_FLAG) |
47 | |
48 // Gets the value of the jvmci.Compiler system property, initializing it | |
49 // from <java.home>/lib/jvmci/compiler-name if the property is not | |
50 // already defined and the compiler-name file exists. | |
51 static const char* get_jvmci_compiler_name(bool* error) { | |
52 *error = false; | |
53 const char* compiler_name = Arguments::get_property("jvmci.Compiler"); | |
54 if (compiler_name == NULL) { | |
55 char filename[JVM_MAXPATHLEN]; | |
56 const char* fileSep = os::file_separator(); | |
57 jio_snprintf(filename, sizeof(filename), "%s%slib%sjvmci%scompiler-name", Arguments::get_java_home(), fileSep, fileSep, fileSep); | |
58 struct stat statbuf; | |
59 if (os::stat(filename, &statbuf) == 0) { | |
60 char line[256]; | |
61 if ((size_t) statbuf.st_size > sizeof(line)) { | |
62 jio_fprintf(defaultStream::error_stream(), "Size of %s is greater than %d\n", filename, sizeof(line)); | |
63 *error = true; | |
64 return NULL; | |
65 } | |
66 | |
67 FILE* stream = fopen(filename, "r"); | |
68 if (stream != NULL) { | |
69 char line[256]; | |
70 if (fgets(line, sizeof(line), stream) != NULL) { | |
71 // Strip newline from end of the line | |
72 char* p = line + strlen(line) - 1; | |
73 while (p >= line && (*p == '\r' || *p == '\n')) { | |
74 *p-- = 0; | |
75 } | |
76 SystemProperty* last_prop = NULL; | |
77 for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) { | |
78 last_prop = p; | |
79 } | |
80 guarantee(last_prop != NULL, "Cannot set jvmci.Compiler property before system properties have been created"); | |
81 SystemProperty* new_p = new SystemProperty("jvmci.Compiler", line, true); | |
82 last_prop->set_next(new_p); | |
83 compiler_name = new_p->value(); | |
84 } else { | |
85 jio_fprintf(defaultStream::error_stream(), | |
86 "Failed to read from %s (errno = %d)\n", filename, errno); | |
87 fclose(stream); | |
88 *error = true; | |
89 return NULL; | |
90 } | |
91 fclose(stream); | |
92 } else { | |
93 jio_fprintf(defaultStream::error_stream(), | |
94 "Failed to open %s (errno = %d)\n", filename, errno); | |
95 *error = true; | |
96 return NULL; | |
97 } | |
98 } | |
99 } | |
100 return compiler_name; | |
101 } | |
47 | 102 |
48 bool JVMCIGlobals::check_jvmci_flags_are_consistent() { | 103 bool JVMCIGlobals::check_jvmci_flags_are_consistent() { |
49 #ifndef PRODUCT | 104 #ifndef PRODUCT |
50 #define APPLY_JVMCI_FLAGS(params3, params4) \ | 105 #define APPLY_JVMCI_FLAGS(params3, params4) \ |
51 JVMCI_FLAGS(params4, params3, params4, params3, params4) | 106 JVMCI_FLAGS(params4, params3, params4, params3, params4) |
64 jio_fprintf(defaultStream::error_stream(), \ | 119 jio_fprintf(defaultStream::error_stream(), \ |
65 "Improperly specified VM option '%s': '%s' must be enabled\n", #FLAG, #GUARD); \ | 120 "Improperly specified VM option '%s': '%s' must be enabled\n", #FLAG, #GUARD); \ |
66 return false; \ | 121 return false; \ |
67 } | 122 } |
68 | 123 |
124 bool error; | |
125 const char* compiler_name = get_jvmci_compiler_name(&error); | |
126 if (error) { | |
127 return false; | |
128 } | |
129 | |
69 if (FLAG_IS_DEFAULT(UseJVMCICompiler) && !UseJVMCICompiler) { | 130 if (FLAG_IS_DEFAULT(UseJVMCICompiler) && !UseJVMCICompiler) { |
70 const char* compiler_name = Arguments::get_property("jvmci.Compiler"); | |
71 if (compiler_name != NULL) { | 131 if (compiler_name != NULL) { |
132 // If a JVMCI compiler has been explicitly specified, then | |
133 // we enable the JVMCI compiler by default. | |
72 FLAG_SET_DEFAULT(UseJVMCICompiler, true); | 134 FLAG_SET_DEFAULT(UseJVMCICompiler, true); |
73 } else { | |
74 char filename[JVM_MAXPATHLEN]; | |
75 const char* fileSep = os::file_separator(); | |
76 jio_snprintf(filename, sizeof(filename), "%s%slib%sjvmci%scompiler-name", Arguments::get_java_home(), fileSep, fileSep, fileSep); | |
77 struct stat statbuf; | |
78 if (os::stat(filename, &statbuf) == 0) { | |
79 char line[256]; | |
80 if ((size_t) statbuf.st_size > sizeof(line)) { | |
81 jio_fprintf(defaultStream::error_stream(), "Size of %s is greater than %d\n", filename, sizeof(line)); | |
82 return false; | |
83 } | |
84 | |
85 FILE* stream = fopen(filename, "r"); | |
86 if (stream != NULL) { | |
87 char line[256]; | |
88 if (fgets(line, sizeof(line), stream) != NULL) { | |
89 // Strip newline from end of the line | |
90 char* p = line + strlen(line) - 1; | |
91 while (p >= line && (*p == '\r' || *p == '\n')) { | |
92 *p-- = 0; | |
93 } | |
94 SystemProperty* props = Arguments::system_properties(); | |
95 if (props != NULL) { | |
96 while (props->next() != NULL) { | |
97 props = props->next(); | |
98 } | |
99 SystemProperty* new_p = new SystemProperty("jvmci.Compiler", line, true); | |
100 props->set_next(new_p); | |
101 FLAG_SET_DEFAULT(UseJVMCICompiler, true); | |
102 } | |
103 } else { | |
104 jio_fprintf(defaultStream::error_stream(), | |
105 "Failed to read from %s (errno = %d)\n", filename, errno); | |
106 fclose(stream); | |
107 return false; | |
108 } | |
109 fclose(stream); | |
110 } else { | |
111 jio_fprintf(defaultStream::error_stream(), | |
112 "Failed to open %s (errno = %d)\n", filename, errno); | |
113 return false; | |
114 } | |
115 } | |
116 } | 135 } |
117 } | 136 } |
118 | 137 |
119 JVMCI_FLAG_CHECKED(UseJVMCICompiler) | 138 JVMCI_FLAG_CHECKED(UseJVMCICompiler) |
120 JVMCI_FLAG_CHECKED(EnableJVMCI) | 139 JVMCI_FLAG_CHECKED(EnableJVMCI) |