comparison src/share/vm/jvmci/jvmciRuntime.cpp @ 21956:35affb9c707a

add properties from <jdk>/jre/lib/jvmci/*.properties files to system properties
author Doug Simon <doug.simon@oracle.com>
date Sat, 13 Jun 2015 00:22:48 +0200
parents d358434dd6b7
children 9a73e6176063
comparison
equal deleted inserted replaced
21955:3ce35131bff2 21956:35affb9c707a
32 #include "jvmci/jvmciEnv.hpp" 32 #include "jvmci/jvmciEnv.hpp"
33 #include "memory/oopFactory.hpp" 33 #include "memory/oopFactory.hpp"
34 #include "prims/jvm.h" 34 #include "prims/jvm.h"
35 #include "runtime/biasedLocking.hpp" 35 #include "runtime/biasedLocking.hpp"
36 #include "runtime/interfaceSupport.hpp" 36 #include "runtime/interfaceSupport.hpp"
37 #include "runtime/arguments.hpp"
38 #include "runtime/reflection.hpp" 37 #include "runtime/reflection.hpp"
39 #include "utilities/debug.hpp" 38 #include "utilities/debug.hpp"
40 #include "utilities/defaultStream.hpp" 39 #include "utilities/defaultStream.hpp"
41 40
42 #if defined(_MSC_VER) 41 #if defined(_MSC_VER)
724 address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields()); 723 address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields());
725 *((jboolean *) addr) = (jboolean) UseJVMCIClassLoader; 724 *((jboolean *) addr) = (jboolean) UseJVMCIClassLoader;
726 klass->initialize(CHECK_ABORT); 725 klass->initialize(CHECK_ABORT);
727 _FactoryKlass = klass(); 726 _FactoryKlass = klass();
728 assert(!UseJVMCIClassLoader || SystemDictionary::jvmci_loader() != NULL, "JVMCI classloader should have been initialized"); 727 assert(!UseJVMCIClassLoader || SystemDictionary::jvmci_loader() != NULL, "JVMCI classloader should have been initialized");
728 }
729 }
730
731 /**
732 * Closure for parsing a line from a *.properties file in jre/lib/jvmci/properties.
733 * The line must match the regular expression "[^=]+=.*". That is one or more
734 * characters other than '=' followed by '=' followed by zero or more characters.
735 * Everything before the '=' is the property name and everything after '=' is the value.
736 * No special processing of whitespace or any escape characters is performed.
737 * Also, no check is made whether an existing property is overridden.
738 */
739 class JVMCIPropertiesFileClosure : public ParseClosure {
740 SystemProperty** _plist;
741 public:
742 JVMCIPropertiesFileClosure(SystemProperty** plist) : _plist(plist) {}
743 void do_line(char* line) {
744 size_t len = strlen(line);
745 char* sep = strchr(line, '=');
746 if (sep == NULL) {
747 warn_and_abort("invalid format: could not find '=' character");
748 return;
749 }
750 if (sep == line) {
751 warn_and_abort("invalid format: name cannot be empty");
752 return;
753 }
754 *sep = '\0';
755 const char* name = line;
756 char* value = sep + 1;
757 Arguments::PropertyList_add(_plist, name, value);
758 }
759 };
760
761 void JVMCIRuntime::parse_properties(SystemProperty** plist) {
762 char jvmciDir[JVM_MAXPATHLEN];
763 const char* fileSep = os::file_separator();
764 jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci",
765 Arguments::get_java_home(), fileSep, fileSep, fileSep);
766 DIR* dir = os::opendir(jvmciDir);
767 if (dir != NULL) {
768 struct dirent *entry;
769 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal);
770 JVMCIPropertiesFileClosure closure(plist);
771 const int suffix_len = strlen(".properties");
772 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL && !closure.is_aborted()) {
773 const char* name = entry->d_name;
774 if (strlen(name) > suffix_len && strcmp(name + strlen(name) - suffix_len, ".properties") == 0) {
775 char propertiesFilePath[JVM_MAXPATHLEN];
776 jio_snprintf(propertiesFilePath, sizeof(propertiesFilePath), "%s%s%s",jvmciDir, fileSep, name);
777 JVMCIRuntime::parse_lines(propertiesFilePath, &closure, false);
778 }
779 }
780 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
781 os::closedir(dir);
729 } 782 }
730 } 783 }
731 784
732 OptionValuesTable* JVMCIRuntime::parse_arguments() { 785 OptionValuesTable* JVMCIRuntime::parse_arguments() {
733 OptionDescsTable* table = OptionDescsTable::load_options(); 786 OptionDescsTable* table = OptionDescsTable::load_options();