Mercurial > hg > truffle
comparison src/share/vm/runtime/arguments.cpp @ 20375:6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
Summary: Cleaned up CDS to be more configurable, maintainable and extensible
Reviewed-by: dholmes, coleenp, acorn, mchung
author | iklam |
---|---|
date | Thu, 21 Aug 2014 13:57:51 -0700 |
parents | 833b0f92429a |
children | 7430aa5718a5 |
comparison
equal
deleted
inserted
replaced
20374:999824269b71 | 20375:6e0cb14ce59b |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "classfile/classLoader.hpp" | |
26 #include "classfile/javaAssertions.hpp" | 27 #include "classfile/javaAssertions.hpp" |
27 #include "classfile/symbolTable.hpp" | 28 #include "classfile/symbolTable.hpp" |
28 #include "compiler/compilerOracle.hpp" | 29 #include "compiler/compilerOracle.hpp" |
29 #include "memory/allocation.inline.hpp" | 30 #include "memory/allocation.inline.hpp" |
30 #include "memory/cardTableRS.hpp" | 31 #include "memory/cardTableRS.hpp" |
38 #include "runtime/java.hpp" | 39 #include "runtime/java.hpp" |
39 #include "services/management.hpp" | 40 #include "services/management.hpp" |
40 #include "services/memTracker.hpp" | 41 #include "services/memTracker.hpp" |
41 #include "utilities/defaultStream.hpp" | 42 #include "utilities/defaultStream.hpp" |
42 #include "utilities/macros.hpp" | 43 #include "utilities/macros.hpp" |
44 #include "utilities/stringUtils.hpp" | |
43 #include "utilities/taskqueue.hpp" | 45 #include "utilities/taskqueue.hpp" |
44 #ifdef TARGET_OS_FAMILY_linux | 46 #ifdef TARGET_OS_FAMILY_linux |
45 # include "os_linux.inline.hpp" | 47 # include "os_linux.inline.hpp" |
46 #endif | 48 #endif |
47 #ifdef TARGET_OS_FAMILY_solaris | 49 #ifdef TARGET_OS_FAMILY_solaris |
1107 | 1109 |
1108 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS | 1110 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS |
1109 // Conflict: required to use shared spaces (-Xshare:on), but | 1111 // Conflict: required to use shared spaces (-Xshare:on), but |
1110 // incompatible command line options were chosen. | 1112 // incompatible command line options were chosen. |
1111 | 1113 |
1112 static void no_shared_spaces() { | 1114 static void no_shared_spaces(const char* message) { |
1113 if (RequireSharedSpaces) { | 1115 if (RequireSharedSpaces) { |
1114 jio_fprintf(defaultStream::error_stream(), | 1116 jio_fprintf(defaultStream::error_stream(), |
1115 "Class data sharing is inconsistent with other specified options.\n"); | 1117 "Class data sharing is inconsistent with other specified options.\n"); |
1116 vm_exit_during_initialization("Unable to use shared archive.", NULL); | 1118 vm_exit_during_initialization("Unable to use shared archive.", message); |
1117 } else { | 1119 } else { |
1118 FLAG_SET_DEFAULT(UseSharedSpaces, false); | 1120 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
1119 } | 1121 } |
1120 } | 1122 } |
1121 #endif | 1123 #endif |
1552 // server performance. When -server is specified, keep the default off | 1554 // server performance. When -server is specified, keep the default off |
1553 // unless it is asked for. Future work: either add bytecode rewriting | 1555 // unless it is asked for. Future work: either add bytecode rewriting |
1554 // at link time, or rewrite bytecodes in non-shared methods. | 1556 // at link time, or rewrite bytecodes in non-shared methods. |
1555 if (!DumpSharedSpaces && !RequireSharedSpaces && | 1557 if (!DumpSharedSpaces && !RequireSharedSpaces && |
1556 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { | 1558 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { |
1557 no_shared_spaces(); | 1559 no_shared_spaces("COMPILER2 default: -Xshare:auto | off, have to manually setup to on."); |
1558 } | 1560 } |
1559 #endif | 1561 #endif |
1560 | 1562 |
1561 set_conservative_max_heap_alignment(); | 1563 set_conservative_max_heap_alignment(); |
1562 | 1564 |
3241 } else if (is_bad_option(option, args->ignoreUnrecognized)) { | 3243 } else if (is_bad_option(option, args->ignoreUnrecognized)) { |
3242 return JNI_ERR; | 3244 return JNI_ERR; |
3243 } | 3245 } |
3244 } | 3246 } |
3245 | 3247 |
3248 // PrintSharedArchiveAndExit will turn on | |
3249 // -Xshare:on | |
3250 // -XX:+TraceClassPaths | |
3251 if (PrintSharedArchiveAndExit) { | |
3252 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); | |
3253 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); | |
3254 FLAG_SET_CMDLINE(bool, TraceClassPaths, true); | |
3255 } | |
3256 | |
3246 // Change the default value for flags which have different default values | 3257 // Change the default value for flags which have different default values |
3247 // when working with older JDKs. | 3258 // when working with older JDKs. |
3248 #ifdef LINUX | 3259 #ifdef LINUX |
3249 if (JDK_Version::current().compare_major(6) <= 0 && | 3260 if (JDK_Version::current().compare_major(6) <= 0 && |
3250 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { | 3261 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) { |
3251 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); | 3262 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false); |
3252 } | 3263 } |
3253 #endif // LINUX | 3264 #endif // LINUX |
3265 fix_appclasspath(); | |
3254 return JNI_OK; | 3266 return JNI_OK; |
3267 } | |
3268 | |
3269 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled) | |
3270 // | |
3271 // This is necessary because some apps like to specify classpath like -cp foo.jar:${XYZ}:bar.jar | |
3272 // in their start-up scripts. If XYZ is empty, the classpath will look like "-cp foo.jar::bar.jar". | |
3273 // Java treats such empty paths as if the user specified "-cp foo.jar:.:bar.jar". I.e., an empty | |
3274 // path is treated as the current directory. | |
3275 // | |
3276 // This causes problems with CDS, which requires that all directories specified in the classpath | |
3277 // must be empty. In most cases, applications do NOT want to load classes from the current | |
3278 // directory anyway. Adding -XX:+IgnoreEmptyClassPaths will make these applications' start-up | |
3279 // scripts compatible with CDS. | |
3280 void Arguments::fix_appclasspath() { | |
3281 if (IgnoreEmptyClassPaths) { | |
3282 const char separator = *os::path_separator(); | |
3283 const char* src = _java_class_path->value(); | |
3284 | |
3285 // skip over all the leading empty paths | |
3286 while (*src == separator) { | |
3287 src ++; | |
3288 } | |
3289 | |
3290 char* copy = AllocateHeap(strlen(src) + 1, mtInternal); | |
3291 strncpy(copy, src, strlen(src) + 1); | |
3292 | |
3293 // trim all trailing empty paths | |
3294 for (char* tail = copy + strlen(copy) - 1; tail >= copy && *tail == separator; tail--) { | |
3295 *tail = '\0'; | |
3296 } | |
3297 | |
3298 char from[3] = {separator, separator, '\0'}; | |
3299 char to [2] = {separator, '\0'}; | |
3300 while (StringUtils::replace_no_expand(copy, from, to) > 0) { | |
3301 // Keep replacing "::" -> ":" until we have no more "::" (non-windows) | |
3302 // Keep replacing ";;" -> ";" until we have no more ";;" (windows) | |
3303 } | |
3304 | |
3305 _java_class_path->set_value(copy); | |
3306 FreeHeap(copy); // a copy was made by set_value, so don't need this anymore | |
3307 } | |
3308 | |
3309 if (!PrintSharedArchiveAndExit) { | |
3310 ClassLoader::trace_class_path("[classpath: ", _java_class_path->value()); | |
3311 } | |
3255 } | 3312 } |
3256 | 3313 |
3257 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { | 3314 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) { |
3258 // This must be done after all -D arguments have been processed. | 3315 // This must be done after all -D arguments have been processed. |
3259 scp_p->expand_endorsed(); | 3316 scp_p->expand_endorsed(); |
3422 if (!UseCompressedOops || !UseCompressedClassPointers) { | 3479 if (!UseCompressedOops || !UseCompressedClassPointers) { |
3423 vm_exit_during_initialization( | 3480 vm_exit_during_initialization( |
3424 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); | 3481 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL); |
3425 } | 3482 } |
3426 } else { | 3483 } else { |
3427 // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces. | |
3428 if (!UseCompressedOops || !UseCompressedClassPointers) { | 3484 if (!UseCompressedOops || !UseCompressedClassPointers) { |
3429 no_shared_spaces(); | 3485 no_shared_spaces("UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces."); |
3430 } | 3486 } |
3431 #endif | 3487 #endif |
3432 } | 3488 } |
3433 } | 3489 } |
3434 | 3490 |
3682 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) { | 3738 if ((UseSharedSpaces && FLAG_IS_CMDLINE(UseSharedSpaces)) || PrintSharedSpaces) { |
3683 warning("Shared spaces are not supported in this VM"); | 3739 warning("Shared spaces are not supported in this VM"); |
3684 FLAG_SET_DEFAULT(UseSharedSpaces, false); | 3740 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
3685 FLAG_SET_DEFAULT(PrintSharedSpaces, false); | 3741 FLAG_SET_DEFAULT(PrintSharedSpaces, false); |
3686 } | 3742 } |
3687 no_shared_spaces(); | 3743 no_shared_spaces("CDS Disabled"); |
3688 #endif // INCLUDE_CDS | 3744 #endif // INCLUDE_CDS |
3689 | 3745 |
3690 return JNI_OK; | 3746 return JNI_OK; |
3691 } | 3747 } |
3692 | 3748 |