--- old/src/share/vm/compiler/compilerDirectives.cpp 2015-10-23 09:49:08.149321978 +0200 +++ new/src/share/vm/compiler/compilerDirectives.cpp 2015-10-23 09:49:08.037321974 +0200 @@ -352,8 +352,43 @@ vmIntrinsics::ID id = method->intrinsic_id(); assert(id != vmIntrinsics::_none, "must be a VM intrinsic"); - ccstr disable_intr = DisableIntrinsicOption; - return ((disable_intr != '\0') && strstr(disable_intr, vmIntrinsics::name_at(id)) != NULL); + ResourceMark rm; + + // Create a copy of the string that contains the list of disabled + // intrinsics. The copy is created because the string + // will be modified by this method as well as by a callee of + // this method, strtok(). + size_t length = strlen(DisableIntrinsicOption); + char* local_list = NEW_RESOURCE_ARRAY(char, length + 1); + strncpy(local_list, DisableIntrinsicOption, length + 1); + + // In the list of disabled intrinsics, the ID of the disabled intrinsics can separated: + // - by ',' (if -XX:DisableIntrinsic is used once when invoking the VM) or + // - by '\n' (if -XX:DisableIntrinsic is used multiple times when invoking the VM) or + // - by ' ' (if DisableIntrinsic is used on a per-method level, e.g., with CompileCommand). + // + // To simplify the processing of the list, in the local copy of the list '\n' and ' ' + // is replaced with ','. Then, the list is tokenized with ',' as a separator. + char* current = local_list; + while (*current != '\0') { + if (*current == '\n') { + *current = ','; + } else if (*current == ' ') { + *current = ','; + } + current++; + } + + char* token = strtok(local_list, ","); + while (token != NULL) { + if (strcmp(token, vmIntrinsics::name_at(id)) == 0) { + return true; + } else { + token = strtok(NULL, ","); + } + } + + return false; } DirectiveSet* DirectiveSet::clone(DirectiveSet const* src) {