< prev index next >
src/share/vm/jvmci/jvmciRuntime.cpp
Print this page
@@ -50,10 +50,12 @@
bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
bool JVMCIRuntime::_well_known_classes_initialized = false;
const char* JVMCIRuntime::_compiler = NULL;
int JVMCIRuntime::_options_count = 0;
SystemProperty** JVMCIRuntime::_options = NULL;
+int JVMCIRuntime::_trivial_prefixes_count = 0;
+char** JVMCIRuntime::_trivial_prefixes = NULL;
bool JVMCIRuntime::_shutdown_called = false;
static const char* OPTION_PREFIX = "jvmci.option.";
static const size_t OPTION_PREFIX_LEN = strlen(OPTION_PREFIX);
@@ -431,16 +433,17 @@
TRACE_jvmci_3("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock));
tty->flush();
}
JRT_END
-JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, jint flags))
- bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING);
- bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS);
- bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE);
- if (!string) {
- if (!addr && obj->is_oop_or_null(true)) {
+JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
+ ttyLocker ttyl;
+
+ if (obj == NULL) {
+ tty->print("NULL");
+ } else if (obj->is_oop_or_null(true) && (!as_string || !java_lang_String::is_instance(obj))) {
+ if (obj->is_oop_or_null(true)) {
char buf[O_BUFLEN];
tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj));
} else {
tty->print(INTPTR_FORMAT, p2i(obj));
}
@@ -626,14 +629,14 @@
return Handle((oop)result.get_jobject());
}
static bool jvmci_options_file_exists() {
const char* home = Arguments::get_java_home();
- size_t path_len = strlen(home) + strlen("/lib/jvmci/options") + 1;
+ size_t path_len = strlen(home) + strlen("/lib/jvmci.options") + 1;
char path[JVM_MAXPATHLEN];
char sep = os::file_separator()[0];
- jio_snprintf(path, JVM_MAXPATHLEN, "%s%clib%cjvmci%coptions", home, sep, sep, sep);
+ jio_snprintf(path, JVM_MAXPATHLEN, "%s%clib%cjvmci.options", home, sep, sep);
struct stat st;
return os::stat(path, &st) == 0;
}
void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
@@ -654,11 +657,12 @@
if (_options != NULL) {
options = oopFactory::new_objArray(SystemDictionary::String_klass(), _options_count * 2, CHECK);
for (int i = 0; i < _options_count; i++) {
SystemProperty* prop = _options[i];
oop name = java_lang_String::create_oop_from_str(prop->key() + OPTION_PREFIX_LEN, CHECK);
- oop value = java_lang_String::create_oop_from_str(prop->value(), CHECK);
+ const char* prop_value = prop->value() != NULL ? prop->value() : "";
+ oop value = java_lang_String::create_oop_from_str(prop_value, CHECK);
options->obj_at_put(i * 2, name);
options->obj_at_put((i * 2) + 1, value);
}
} else {
options = NULL;
@@ -680,10 +684,24 @@
}
Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
"runtime",
"()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
+ objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
+ if (trivial_prefixes != NULL) {
+ char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
+ for (int i = 0; i < trivial_prefixes->length(); i++) {
+ oop str = trivial_prefixes->obj_at(i);
+ if (str == NULL) {
+ THROW(vmSymbols::java_lang_NullPointerException());
+ } else {
+ prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
+ }
+ }
+ _trivial_prefixes = prefixes;
+ _trivial_prefixes_count = trivial_prefixes->length();
+ }
_HotSpotJVMCIRuntime_initialized = true;
_HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
}
}
@@ -875,19 +893,31 @@
assert(compiler != NULL, "npe");
assert(_compiler == NULL, "cannot reassign JVMCI compiler");
_compiler = compiler;
}
-jint JVMCIRuntime::save_options(SystemProperty* props) {
+void JVMCIRuntime::maybe_print_flags(TRAPS) {
+ if (_options != NULL) {
+ for (int i = 0; i < _options_count; i++) {
+ SystemProperty* p = _options[i];
+ const char* name = p->key() + OPTION_PREFIX_LEN;
+ if (strcmp(name, "PrintFlags") == 0 || strcmp(name, "ShowFlags") == 0) {
+ JVMCIRuntime::initialize_well_known_classes(CHECK);
+ HandleMark hm;
+ ResourceMark rm;
+ JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
+ return;
+ }
+ }
+ }
+}
+
+void JVMCIRuntime::save_options(SystemProperty* props) {
int count = 0;
SystemProperty* first = NULL;
for (SystemProperty* p = props; p != NULL; p = p->next()) {
if (strncmp(p->key(), OPTION_PREFIX, OPTION_PREFIX_LEN) == 0) {
- if (p->value() == NULL || strlen(p->value()) == 0) {
- jio_fprintf(defaultStream::output_stream(), "JVMCI option %s must have non-zero length value\n", p->key());
- return JNI_ERR;
- }
if (first == NULL) {
first = p;
}
count++;
}
@@ -903,11 +933,10 @@
insert_pos++;
}
}
assert (insert_pos - _options == count, "must be");
}
- return JNI_OK;
}
void JVMCIRuntime::shutdown() {
if (_HotSpotJVMCIRuntime_instance != NULL) {
_shutdown_called = true;
@@ -919,10 +948,24 @@
args.push_oop(receiver);
JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT);
}
}
+bool JVMCIRuntime::treat_as_trivial(Method* method) {
+ if (_HotSpotJVMCIRuntime_initialized) {
+ oop loader = method->method_holder()->class_loader();
+ if (loader == NULL) {
+ for (int i = 0; i < _trivial_prefixes_count; i++) {
+ if (method->method_holder()->name()->starts_with(_trivial_prefixes[i])) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
void JVMCIRuntime::call_printStackTrace(Handle exception, Thread* thread) {
assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
JavaValue result(T_VOID);
JavaCalls::call_virtual(&result,
exception,
@@ -947,22 +990,22 @@
vm_abort(dump_core);
}
void JVMCIRuntime::parse_lines(char* path, ParseClosure* closure, bool warnStatFailure) {
struct stat st;
- if (os::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
- int file_handle = os::open(path, 0, 0);
+ if (::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
+ int file_handle = ::open(path, os::default_file_open_flags(), 0);
if (file_handle != -1) {
char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal);
int num_read;
- num_read = (int) os::read(file_handle, (char*) buffer, st.st_size);
+ num_read = (int) ::read(file_handle, (char*) buffer, st.st_size);
if (num_read == -1) {
warning("Error reading file %s due to %s", path, strerror(errno));
} else if (num_read != st.st_size) {
warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path);
}
- os::close(file_handle);
+ ::close(file_handle);
closure->set_filename(path);
if (num_read == st.st_size) {
buffer[num_read] = '\0';
char* line = buffer;
< prev index next >