Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalRuntime.cpp @ 16876:9d4c73b0646e
graalRuntime: name_len shound be a size_t
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Mon, 18 Aug 2014 19:07:56 +0200 |
parents | 11b22ccafccd |
children | aa412e64808e |
comparison
equal
deleted
inserted
replaced
16875:73d994651fcd | 16876:9d4c73b0646e |
---|---|
726 | 726 |
727 // private static boolean HotSpotOptions.parseVMOptions() | 727 // private static boolean HotSpotOptions.parseVMOptions() |
728 JVM_ENTRY(jboolean, JVM_ParseGraalOptions(JNIEnv *env, jclass c)) | 728 JVM_ENTRY(jboolean, JVM_ParseGraalOptions(JNIEnv *env, jclass c)) |
729 HandleMark hm; | 729 HandleMark hm; |
730 KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); | 730 KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); |
731 return GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false); | 731 bool result = GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false); |
732 return result; | |
732 JVM_END | 733 JVM_END |
733 | 734 |
734 jint GraalRuntime::check_arguments(TRAPS) { | 735 jint GraalRuntime::check_arguments(TRAPS) { |
735 KlassHandle nullHandle; | 736 KlassHandle nullHandle; |
736 parse_arguments(nullHandle, THREAD); | 737 parse_arguments(nullHandle, THREAD); |
772 parse_argument(hotSpotOptionsClass, arg, CHECK_false); | 773 parse_argument(hotSpotOptionsClass, arg, CHECK_false); |
773 } | 774 } |
774 return CITime || CITimeEach; | 775 return CITime || CITimeEach; |
775 } | 776 } |
776 | 777 |
777 void GraalRuntime::check_required_value(const char* name, int name_len, const char* value, TRAPS) { | 778 void GraalRuntime::check_required_value(const char* name, size_t name_len, const char* value, TRAPS) { |
778 if (value == NULL) { | 779 if (value == NULL) { |
779 char buf[200]; | 780 char buf[200]; |
780 jio_snprintf(buf, sizeof(buf), "Must use '-G:%.*s=<value>' format for %.*s option", name_len, name, name_len, name); | 781 jio_snprintf(buf, sizeof(buf), "Must use '-G:%.*s=<value>' format for %.*s option", name_len, name, name_len, name); |
781 THROW_MSG(vmSymbols::java_lang_InternalError(), buf); | 782 THROW_MSG(vmSymbols::java_lang_InternalError(), buf); |
782 } | 783 } |
788 size_t name_len; | 789 size_t name_len; |
789 bool recognized = true; | 790 bool recognized = true; |
790 if (first == '+' || first == '-') { | 791 if (first == '+' || first == '-') { |
791 name = arg + 1; | 792 name = arg + 1; |
792 name_len = strlen(name); | 793 name_len = strlen(name); |
793 recognized = set_option_bool(hotSpotOptionsClass, name, (int)name_len, first, CHECK); | 794 recognized = set_option_bool(hotSpotOptionsClass, name, name_len, first, CHECK); |
794 } else { | 795 } else { |
795 char* sep = strchr(arg, '='); | 796 char* sep = strchr(arg, '='); |
796 name = arg; | 797 name = arg; |
797 char* value = NULL; | 798 char* value = NULL; |
798 if (sep != NULL) { | 799 if (sep != NULL) { |
799 name_len = sep - name; | 800 name_len = sep - name; |
800 value = sep + 1; | 801 value = sep + 1; |
801 } else { | 802 } else { |
802 name_len = strlen(name); | 803 name_len = strlen(name); |
803 } | 804 } |
804 recognized = set_option(hotSpotOptionsClass, name, (int)name_len, value, CHECK); | 805 recognized = set_option(hotSpotOptionsClass, name, name_len, value, CHECK); |
805 } | 806 } |
806 | 807 |
807 if (!recognized) { | 808 if (!recognized) { |
808 bool throw_err = hotSpotOptionsClass.is_null(); | 809 bool throw_err = hotSpotOptionsClass.is_null(); |
809 if (!hotSpotOptionsClass.is_null()) { | 810 if (!hotSpotOptionsClass.is_null()) { |
810 set_option_helper(hotSpotOptionsClass, name, (int)name_len, Handle(), ' ', Handle(), 0L); | 811 set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), ' ', Handle(), 0L); |
811 if (!HAS_PENDING_EXCEPTION) { | 812 if (!HAS_PENDING_EXCEPTION) { |
812 throw_err = true; | 813 throw_err = true; |
813 } | 814 } |
814 } | 815 } |
815 | 816 |
821 } | 822 } |
822 } | 823 } |
823 | 824 |
824 void GraalRuntime::parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS) { | 825 void GraalRuntime::parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS) { |
825 const char* home = Arguments::get_java_home(); | 826 const char* home = Arguments::get_java_home(); |
826 int path_len = (int)strlen(home) + (int)strlen("/lib/graal.options") + 1; | 827 size_t path_len = strlen(home) + strlen("/lib/graal.options") + 1; |
827 char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); | 828 char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); |
828 char sep = os::file_separator()[0]; | 829 char sep = os::file_separator()[0]; |
829 sprintf(path, "%s%clib%cgraal.options", home, sep, sep); | 830 sprintf(path, "%s%clib%cgraal.options", home, sep, sep); |
830 | 831 |
831 struct stat st; | 832 struct stat st; |
866 warning("Error opening file %s due to %s", path, strerror(errno)); | 867 warning("Error opening file %s due to %s", path, strerror(errno)); |
867 } | 868 } |
868 } | 869 } |
869 } | 870 } |
870 | 871 |
871 jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, int name_len, const char* value, TRAPS) { | 872 jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS) { |
872 check_required_value(name, name_len, value, CHECK_(0L)); | 873 check_required_value(name, name_len, value, CHECK_(0L)); |
873 union { | 874 union { |
874 jint i; | 875 jint i; |
875 jlong l; | 876 jlong l; |
876 double d; | 877 double d; |
903 jio_snprintf(buf, sizeof(buf), "Invalid %s value for Graal option %.*s: %s", (spec == 'i' ? "numeric" : "float/double"), name_len, name, value); | 904 jio_snprintf(buf, sizeof(buf), "Invalid %s value for Graal option %.*s: %s", (spec == 'i' ? "numeric" : "float/double"), name_len, name, value); |
904 } | 905 } |
905 THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L); | 906 THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L); |
906 } | 907 } |
907 | 908 |
908 void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, int name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { | 909 void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { |
909 Thread* THREAD = Thread::current(); | 910 Thread* THREAD = Thread::current(); |
910 Handle name_handle; | 911 Handle name_handle; |
911 if (name != NULL) { | 912 if (name != NULL) { |
912 if ((int) strlen(name) > name_len) { | 913 if (strlen(name) > name_len) { |
913 // Temporarily replace '=' with NULL to create the Java string for the option name | 914 // Temporarily replace '=' with NULL to create the Java string for the option name |
914 char save = name[name_len]; | 915 char save = name[name_len]; |
915 name[name_len] = '\0'; | 916 name[name_len] = '\0'; |
916 name_handle = java_lang_String::create_from_str(name, THREAD); | 917 name_handle = java_lang_String::create_from_str(name, THREAD); |
917 name[name_len] = '='; | 918 name[name_len] = '='; |
918 if (HAS_PENDING_EXCEPTION) { | 919 if (HAS_PENDING_EXCEPTION) { |
919 return; | 920 return; |
920 } | 921 } |
921 } else { | 922 } else { |
922 assert((int) strlen(name) == name_len, "must be"); | 923 assert(strlen(name) == name_len, "must be"); |
923 name_handle = java_lang_String::create_from_str(name, CHECK); | 924 name_handle = java_lang_String::create_from_str(name, CHECK); |
924 } | 925 } |
925 } | 926 } |
926 | 927 |
927 TempNewSymbol setOption = SymbolTable::new_symbol("setOption", CHECK); | 928 TempNewSymbol setOption = SymbolTable::new_symbol("setOption", CHECK); |