提交 9b22e5ef 编写于 作者: K kamg

7110720: Issue with vm config file loadingIssue with vm config file loading

Summary: disabling default config files if -XX:-ReadDefaultConfigFiles
Reviewed-by: phh, jrose, dcubed, dholmes
上级 ffaddb49
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -551,13 +551,21 @@ void CompilerOracle::parse_from_line(char* line) { ...@@ -551,13 +551,21 @@ void CompilerOracle::parse_from_line(char* line) {
} }
static const char* cc_file() { static const char* cc_file() {
#ifdef ASSERT
if (CompileCommandFile == NULL) if (CompileCommandFile == NULL)
return ".hotspot_compiler"; return ".hotspot_compiler";
#endif
return CompileCommandFile; return CompileCommandFile;
} }
bool CompilerOracle::has_command_file() {
return cc_file() != NULL;
}
bool CompilerOracle::_quiet = false; bool CompilerOracle::_quiet = false;
void CompilerOracle::parse_from_file() { void CompilerOracle::parse_from_file() {
assert(has_command_file(), "command file must be specified");
FILE* stream = fopen(cc_file(), "rt"); FILE* stream = fopen(cc_file(), "rt");
if (stream == NULL) return; if (stream == NULL) return;
...@@ -600,6 +608,7 @@ void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char* ...@@ -600,6 +608,7 @@ void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*
} }
void CompilerOracle::append_comment_to_file(const char* message) { void CompilerOracle::append_comment_to_file(const char* message) {
assert(has_command_file(), "command file must be specified");
fileStream stream(fopen(cc_file(), "at")); fileStream stream(fopen(cc_file(), "at"));
stream.print("# "); stream.print("# ");
for (int index = 0; message[index] != '\0'; index++) { for (int index = 0; message[index] != '\0'; index++) {
...@@ -610,6 +619,7 @@ void CompilerOracle::append_comment_to_file(const char* message) { ...@@ -610,6 +619,7 @@ void CompilerOracle::append_comment_to_file(const char* message) {
} }
void CompilerOracle::append_exclude_to_file(methodHandle method) { void CompilerOracle::append_exclude_to_file(methodHandle method) {
assert(has_command_file(), "command file must be specified");
fileStream stream(fopen(cc_file(), "at")); fileStream stream(fopen(cc_file(), "at"));
stream.print("exclude "); stream.print("exclude ");
Klass::cast(method->method_holder())->name()->print_symbol_on(&stream); Klass::cast(method->method_holder())->name()->print_symbol_on(&stream);
...@@ -624,7 +634,9 @@ void CompilerOracle::append_exclude_to_file(methodHandle method) { ...@@ -624,7 +634,9 @@ void CompilerOracle::append_exclude_to_file(methodHandle method) {
void compilerOracle_init() { void compilerOracle_init() {
CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line); CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only); CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only);
if (CompilerOracle::has_command_file()) {
CompilerOracle::parse_from_file(); CompilerOracle::parse_from_file();
}
if (lists[PrintCommand] != NULL) { if (lists[PrintCommand] != NULL) {
if (PrintAssembly) { if (PrintAssembly) {
warning("CompileCommand and/or .hotspot_compiler file contains 'print' commands, but PrintAssembly is also enabled"); warning("CompileCommand and/or .hotspot_compiler file contains 'print' commands, but PrintAssembly is also enabled");
......
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -36,6 +36,10 @@ class CompilerOracle : AllStatic { ...@@ -36,6 +36,10 @@ class CompilerOracle : AllStatic {
static bool _quiet; static bool _quiet;
public: public:
// True if the command file has been specified or is implicit
static bool has_command_file();
// Reads from file and adds to lists // Reads from file and adds to lists
static void parse_from_file(); static void parse_from_file();
......
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -896,7 +896,8 @@ static void report_null_exception_in_code_cache(address exception_pc) { ...@@ -896,7 +896,8 @@ static void report_null_exception_in_code_cache(address exception_pc) {
methodOop method = ((nmethod*)n)->method(); methodOop method = ((nmethod*)n)->method();
tty->print_cr("# Method where it happened %s.%s ", Klass::cast(method->method_holder())->name()->as_C_string(), method->name()->as_C_string()); tty->print_cr("# Method where it happened %s.%s ", Klass::cast(method->method_holder())->name()->as_C_string(), method->name()->as_C_string());
tty->print_cr("#"); tty->print_cr("#");
if (ShowMessageBoxOnError && UpdateHotSpotCompilerFileOnError) { if (ShowMessageBoxOnError && UpdateHotSpotCompilerFileOnError &&
CompilerOracle::has_command_file()) {
const char* title = "HotSpot Runtime Error"; const char* title = "HotSpot Runtime Error";
const char* question = "Do you want to exclude compilation of this method in future runs?"; const char* question = "Do you want to exclude compilation of this method in future runs?";
if (os::message_box(title, question)) { if (os::message_box(title, question)) {
......
...@@ -3002,12 +3002,14 @@ jint Arguments::parse(const JavaVMInitArgs* args) { ...@@ -3002,12 +3002,14 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
} }
} }
#ifdef ASSERT
// Parse default .hotspotrc settings file // Parse default .hotspotrc settings file
if (!settings_file_specified) { if (!settings_file_specified) {
if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) { if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) {
return JNI_EINVAL; return JNI_EINVAL;
} }
} }
#endif
if (PrintVMOptions) { if (PrintVMOptions) {
for (index = 0; index < args->nOptions; index++) { for (index = 0; index < args->nOptions; index++) {
......
#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# @test Test7110720.sh
# @bug 7110720
# @summary improve VM configuration file loading
# @run shell Test7110720.sh
#
if [ "${TESTSRC}" = "" ]
then TESTSRC=.
fi
if [ "${TESTJAVA}" = "" ]
then
PARENT=`dirname \`which java\``
TESTJAVA=`dirname ${PARENT}`
echo "TESTJAVA not set, selecting " ${TESTJAVA}
echo "If this is incorrect, try setting the variable manually."
fi
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
# Jtreg sets TESTVMOPTS which may include -d64 which is
# required to test a 64-bit JVM on some platforms.
# If another test harness still creates HOME/JDK64BIT,
# we can recognise that.
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux )
FS="/"
RM=/bin/rm
CP=/bin/cp
MV=/bin/mv
## for solaris, linux it's HOME
FILE_LOCATION=$HOME
if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
then
TESTVMOPTS=`cat ${FILE_LOCATION}${FS}JDK64BIT`
fi
;;
Windows_* )
FS="\\"
RM=rm
CP=cp
MV=mv
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
JAVA=${TESTJAVA}${FS}bin${FS}java
# Don't test debug builds, they do read the config files:
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "debug" >/dev/null
if [ "$?" = "0" ]; then
echo Skipping test for debug build.
exit 0
fi
ok=yes
$RM -f .hotspot_compiler .hotspotrc
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "garbage in" >/dev/null
if [ "$?" = "0" ]; then
echo "FAILED: base case failure"
exit 1
fi
echo "garbage in, garbage out" > .hotspot_compiler
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "garbage in" >/dev/null
if [ "$?" = "0" ]; then
echo "FAILED: .hotspot_compiler was read"
ok=no
fi
$MV .hotspot_compiler hs_comp.txt
${JAVA} ${TESTVMOPTS} -XX:CompileCommandFile=hs_comp.txt -version 2>&1 | grep "garbage in" >/dev/null
if [ "$?" = "1" ]; then
echo "FAILED: explicit compiler command file not read"
ok=no
fi
$RM -f .hotspot_compiler hs_comp.txt
echo "garbage" > .hotspotrc
${JAVA} ${TESTVMOPTS} -version 2>&1 | grep "garbage" >/dev/null
if [ "$?" = "0" ]; then
echo "FAILED: .hotspotrc was read"
ok=no
fi
$MV .hotspotrc hs_flags.txt
${JAVA} ${TESTVMOPTS} -XX:Flags=hs_flags.txt -version 2>&1 | grep "garbage" >/dev/null
if [ "$?" = "1" ]; then
echo "FAILED: explicit flags file not read"
ok=no
fi
if [ "${ok}" = "no" ]; then
echo "Some tests failed."
exit 1
else
echo "Passed"
exit 0
fi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册