2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2014-05-09 16:50:54 -04:00
|
|
|
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "compiler/compilerOracle.hpp"
|
|
|
|
#include "memory/allocation.inline.hpp"
|
|
|
|
#include "memory/oopFactory.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "oops/klass.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "oops/method.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
2011-01-27 16:11:27 -08:00
|
|
|
#include "oops/symbol.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "runtime/jniHandles.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-06-28 17:03:16 -04:00
|
|
|
class MethodMatcher : public CHeapObj<mtCompiler> {
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
Exact,
|
|
|
|
Prefix = 1,
|
|
|
|
Suffix = 2,
|
|
|
|
Substring = Prefix | Suffix,
|
|
|
|
Any,
|
|
|
|
Unknown = -1
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* _class_name;
|
|
|
|
Symbol* _method_name;
|
|
|
|
Symbol* _signature;
|
2007-12-01 00:00:00 +00:00
|
|
|
Mode _class_mode;
|
|
|
|
Mode _method_mode;
|
|
|
|
MethodMatcher* _next;
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
static bool match(Symbol* candidate, Symbol* match, Mode match_mode);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* class_name() const { return _class_name; }
|
|
|
|
Symbol* method_name() const { return _method_name; }
|
|
|
|
Symbol* signature() const { return _signature; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
public:
|
2011-01-27 16:11:27 -08:00
|
|
|
MethodMatcher(Symbol* class_name, Mode class_mode,
|
|
|
|
Symbol* method_name, Mode method_mode,
|
|
|
|
Symbol* signature, MethodMatcher* next);
|
|
|
|
MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// utility method
|
|
|
|
MethodMatcher* find(methodHandle method) {
|
2012-11-06 15:09:37 -05:00
|
|
|
Symbol* class_name = method->method_holder()->name();
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* method_name = method->name();
|
2007-12-01 00:00:00 +00:00
|
|
|
for (MethodMatcher* current = this; current != NULL; current = current->_next) {
|
|
|
|
if (match(class_name, current->class_name(), current->_class_mode) &&
|
|
|
|
match(method_name, current->method_name(), current->_method_mode) &&
|
2011-01-27 16:11:27 -08:00
|
|
|
(current->signature() == NULL || current->signature() == method->signature())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool match(methodHandle method) {
|
|
|
|
return find(method) != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodMatcher* next() const { return _next; }
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
static void print_symbol(Symbol* h, Mode mode) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm;
|
|
|
|
|
|
|
|
if (mode == Suffix || mode == Substring || mode == Any) {
|
|
|
|
tty->print("*");
|
|
|
|
}
|
|
|
|
if (mode != Any) {
|
2011-01-27 16:11:27 -08:00
|
|
|
h->print_symbol_on(tty);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
if (mode == Prefix || mode == Substring) {
|
|
|
|
tty->print("*");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void print_base() {
|
|
|
|
print_symbol(class_name(), _class_mode);
|
|
|
|
tty->print(".");
|
|
|
|
print_symbol(method_name(), _method_mode);
|
2011-01-27 16:11:27 -08:00
|
|
|
if (signature() != NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print(" ");
|
|
|
|
signature()->print_symbol_on(tty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void print() {
|
|
|
|
print_base();
|
|
|
|
tty->cr();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
MethodMatcher::MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next) {
|
|
|
|
_class_name = class_name;
|
|
|
|
_method_name = method_name;
|
2007-12-01 00:00:00 +00:00
|
|
|
_next = next;
|
|
|
|
_class_mode = MethodMatcher::Exact;
|
|
|
|
_method_mode = MethodMatcher::Exact;
|
|
|
|
_signature = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode,
|
|
|
|
Symbol* method_name, Mode method_mode,
|
|
|
|
Symbol* signature, MethodMatcher* next):
|
2007-12-01 00:00:00 +00:00
|
|
|
_class_mode(class_mode)
|
|
|
|
, _method_mode(method_mode)
|
|
|
|
, _next(next)
|
2011-01-27 16:11:27 -08:00
|
|
|
, _class_name(class_name)
|
|
|
|
, _method_name(method_name)
|
|
|
|
, _signature(signature) {
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (match_mode == Any) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match_mode == Exact) {
|
2011-01-27 16:11:27 -08:00
|
|
|
return candidate == match;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ResourceMark rm;
|
|
|
|
const char * candidate_string = candidate->as_C_string();
|
|
|
|
const char * match_string = match->as_C_string();
|
|
|
|
|
|
|
|
switch (match_mode) {
|
|
|
|
case Prefix:
|
|
|
|
return strstr(candidate_string, match_string) == candidate_string;
|
|
|
|
|
|
|
|
case Suffix: {
|
|
|
|
size_t clen = strlen(candidate_string);
|
|
|
|
size_t mlen = strlen(match_string);
|
|
|
|
return clen >= mlen && strcmp(candidate_string + clen - mlen, match_string) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Substring:
|
|
|
|
return strstr(candidate_string, match_string) != NULL;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MethodOptionMatcher: public MethodMatcher {
|
|
|
|
const char * option;
|
|
|
|
public:
|
2011-01-27 16:11:27 -08:00
|
|
|
MethodOptionMatcher(Symbol* class_name, Mode class_mode,
|
|
|
|
Symbol* method_name, Mode method_mode,
|
|
|
|
Symbol* signature, const char * opt, MethodMatcher* next):
|
2007-12-01 00:00:00 +00:00
|
|
|
MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next) {
|
|
|
|
option = opt;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool match(methodHandle method, const char* opt) {
|
|
|
|
MethodOptionMatcher* current = this;
|
|
|
|
while (current != NULL) {
|
|
|
|
current = (MethodOptionMatcher*)current->find(method);
|
|
|
|
if (current == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (strcmp(current->option, opt) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
current = current->next();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodOptionMatcher* next() {
|
|
|
|
return (MethodOptionMatcher*)_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void print() {
|
|
|
|
print_base();
|
|
|
|
tty->print(" %s", option);
|
|
|
|
tty->cr();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this must parallel the command_names below
|
|
|
|
enum OracleCommand {
|
|
|
|
UnknownCommand = -1,
|
|
|
|
OracleFirstCommand = 0,
|
|
|
|
BreakCommand = OracleFirstCommand,
|
|
|
|
PrintCommand,
|
|
|
|
ExcludeCommand,
|
|
|
|
InlineCommand,
|
|
|
|
DontInlineCommand,
|
|
|
|
CompileOnlyCommand,
|
|
|
|
LogCommand,
|
|
|
|
OptionCommand,
|
|
|
|
QuietCommand,
|
|
|
|
HelpCommand,
|
|
|
|
OracleCommandCount
|
|
|
|
};
|
|
|
|
|
|
|
|
// this must parallel the enum OracleCommand
|
|
|
|
static const char * command_names[] = {
|
|
|
|
"break",
|
|
|
|
"print",
|
|
|
|
"exclude",
|
|
|
|
"inline",
|
|
|
|
"dontinline",
|
|
|
|
"compileonly",
|
|
|
|
"log",
|
|
|
|
"option",
|
|
|
|
"quiet",
|
|
|
|
"help"
|
|
|
|
};
|
|
|
|
|
|
|
|
class MethodMatcher;
|
|
|
|
static MethodMatcher* lists[OracleCommandCount] = { 0, };
|
|
|
|
|
|
|
|
|
|
|
|
static bool check_predicate(OracleCommand command, methodHandle method) {
|
|
|
|
return ((lists[command] != NULL) &&
|
|
|
|
!method.is_null() &&
|
|
|
|
lists[command]->match(method));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static MethodMatcher* add_predicate(OracleCommand command,
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* class_name, MethodMatcher::Mode c_mode,
|
|
|
|
Symbol* method_name, MethodMatcher::Mode m_mode,
|
|
|
|
Symbol* signature) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(command != OptionCommand, "must use add_option_string");
|
|
|
|
if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL)
|
|
|
|
tty->print_cr("Warning: +LogCompilation must be enabled in order for individual methods to be logged.");
|
|
|
|
lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]);
|
|
|
|
return lists[command];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
static MethodMatcher* add_option_string(Symbol* class_name, MethodMatcher::Mode c_mode,
|
|
|
|
Symbol* method_name, MethodMatcher::Mode m_mode,
|
|
|
|
Symbol* signature,
|
2007-12-01 00:00:00 +00:00
|
|
|
const char* option) {
|
|
|
|
lists[OptionCommand] = new MethodOptionMatcher(class_name, c_mode, method_name, m_mode,
|
|
|
|
signature, option, lists[OptionCommand]);
|
|
|
|
return lists[OptionCommand];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CompilerOracle::has_option_string(methodHandle method, const char* option) {
|
|
|
|
return lists[OptionCommand] != NULL &&
|
|
|
|
((MethodOptionMatcher*)lists[OptionCommand])->match(method, option);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) {
|
|
|
|
quietly = true;
|
|
|
|
if (lists[ExcludeCommand] != NULL) {
|
|
|
|
if (lists[ExcludeCommand]->match(method)) {
|
|
|
|
quietly = _quiet;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lists[CompileOnlyCommand] != NULL) {
|
|
|
|
return !lists[CompileOnlyCommand]->match(method);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CompilerOracle::should_inline(methodHandle method) {
|
|
|
|
return (check_predicate(InlineCommand, method));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CompilerOracle::should_not_inline(methodHandle method) {
|
|
|
|
return (check_predicate(DontInlineCommand, method));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CompilerOracle::should_print(methodHandle method) {
|
|
|
|
return (check_predicate(PrintCommand, method));
|
|
|
|
}
|
|
|
|
|
2014-05-21 14:36:18 -04:00
|
|
|
bool CompilerOracle::should_print_methods() {
|
|
|
|
return lists[PrintCommand] != NULL;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
bool CompilerOracle::should_log(methodHandle method) {
|
|
|
|
if (!LogCompilation) return false;
|
|
|
|
if (lists[LogCommand] == NULL) return true; // by default, log all
|
|
|
|
return (check_predicate(LogCommand, method));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CompilerOracle::should_break_at(methodHandle method) {
|
|
|
|
return check_predicate(BreakCommand, method);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static OracleCommand parse_command_name(const char * line, int* bytes_read) {
|
|
|
|
assert(ARRAY_SIZE(command_names) == OracleCommandCount,
|
|
|
|
"command_names size mismatch");
|
|
|
|
|
|
|
|
*bytes_read = 0;
|
2010-12-14 23:17:00 -08:00
|
|
|
char command[33];
|
2007-12-01 00:00:00 +00:00
|
|
|
int result = sscanf(line, "%32[a-z]%n", command, bytes_read);
|
|
|
|
for (uint i = 0; i < ARRAY_SIZE(command_names); i++) {
|
|
|
|
if (strcmp(command, command_names[i]) == 0) {
|
|
|
|
return (OracleCommand)i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return UnknownCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void usage() {
|
|
|
|
tty->print_cr(" CompileCommand and the CompilerOracle allows simple control over");
|
|
|
|
tty->print_cr(" what's allowed to be compiled. The standard supported directives");
|
|
|
|
tty->print_cr(" are exclude and compileonly. The exclude directive stops a method");
|
|
|
|
tty->print_cr(" from being compiled and compileonly excludes all methods except for");
|
|
|
|
tty->print_cr(" the ones mentioned by compileonly directives. The basic form of");
|
|
|
|
tty->print_cr(" all commands is a command name followed by the name of the method");
|
|
|
|
tty->print_cr(" in one of two forms: the standard class file format as in");
|
|
|
|
tty->print_cr(" class/name.methodName or the PrintCompilation format");
|
|
|
|
tty->print_cr(" class.name::methodName. The method name can optionally be followed");
|
|
|
|
tty->print_cr(" by a space then the signature of the method in the class file");
|
|
|
|
tty->print_cr(" format. Otherwise the directive applies to all methods with the");
|
|
|
|
tty->print_cr(" same name and class regardless of signature. Leading and trailing");
|
|
|
|
tty->print_cr(" *'s in the class and/or method name allows a small amount of");
|
|
|
|
tty->print_cr(" wildcarding. ");
|
|
|
|
tty->cr();
|
|
|
|
tty->print_cr(" Examples:");
|
|
|
|
tty->cr();
|
|
|
|
tty->print_cr(" exclude java/lang/StringBuffer.append");
|
|
|
|
tty->print_cr(" compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
|
|
|
|
tty->print_cr(" exclude java/lang/String*.*");
|
|
|
|
tty->print_cr(" exclude *.toString");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The characters allowed in a class or method name. All characters > 0x7f
|
|
|
|
// are allowed in order to handle obfuscated class files (e.g. Volano)
|
|
|
|
#define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
|
|
|
|
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
|
|
|
|
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
|
|
|
|
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
|
|
|
|
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
|
|
|
|
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
|
|
|
|
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
|
|
|
|
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
|
|
|
|
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
|
|
|
|
|
|
|
|
#define RANGE0 "[*" RANGEBASE "]"
|
|
|
|
#define RANGESLASH "[*" RANGEBASE "/]"
|
|
|
|
|
|
|
|
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
|
|
|
|
int match = MethodMatcher::Exact;
|
2010-01-08 13:47:01 -08:00
|
|
|
while (name[0] == '*') {
|
2007-12-01 00:00:00 +00:00
|
|
|
match |= MethodMatcher::Suffix;
|
|
|
|
strcpy(name, name + 1);
|
|
|
|
}
|
|
|
|
|
2010-01-08 13:47:01 -08:00
|
|
|
if (strcmp(name, "*") == 0) return MethodMatcher::Any;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t len = strlen(name);
|
2010-01-08 13:47:01 -08:00
|
|
|
while (len > 0 && name[len - 1] == '*') {
|
2007-12-01 00:00:00 +00:00
|
|
|
match |= MethodMatcher::Prefix;
|
2010-01-08 13:47:01 -08:00
|
|
|
name[--len] = '\0';
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (strstr(name, "*") != NULL) {
|
|
|
|
error_msg = " Embedded * not allowed";
|
|
|
|
return MethodMatcher::Unknown;
|
|
|
|
}
|
|
|
|
return (MethodMatcher::Mode)match;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool scan_line(const char * line,
|
|
|
|
char class_name[], MethodMatcher::Mode* c_mode,
|
|
|
|
char method_name[], MethodMatcher::Mode* m_mode,
|
|
|
|
int* bytes_read, const char*& error_msg) {
|
|
|
|
*bytes_read = 0;
|
|
|
|
error_msg = NULL;
|
2014-03-03 11:54:35 +01:00
|
|
|
if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255" RANGE0 "%n", class_name, method_name, bytes_read)) {
|
|
|
|
*c_mode = check_mode(class_name, error_msg);
|
|
|
|
*m_mode = check_mode(method_name, error_msg);
|
|
|
|
return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerOracle::parse_from_line(char* line) {
|
|
|
|
if (line[0] == '\0') return;
|
|
|
|
if (line[0] == '#') return;
|
|
|
|
|
|
|
|
bool have_colon = (strstr(line, "::") != NULL);
|
|
|
|
for (char* lp = line; *lp != '\0'; lp++) {
|
|
|
|
// Allow '.' to separate the class name from the method name.
|
|
|
|
// This is the preferred spelling of methods:
|
|
|
|
// exclude java/lang/String.indexOf(I)I
|
|
|
|
// Allow ',' for spaces (eases command line quoting).
|
|
|
|
// exclude,java/lang/String.indexOf
|
|
|
|
// For backward compatibility, allow space as separator also.
|
|
|
|
// exclude java/lang/String indexOf
|
|
|
|
// exclude,java/lang/String,indexOf
|
|
|
|
// For easy cut-and-paste of method names, allow VM output format
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// as produced by Method::print_short_name:
|
2007-12-01 00:00:00 +00:00
|
|
|
// exclude java.lang.String::indexOf
|
|
|
|
// For simple implementation convenience here, convert them all to space.
|
|
|
|
if (have_colon) {
|
|
|
|
if (*lp == '.') *lp = '/'; // dots build the package prefix
|
|
|
|
if (*lp == ':') *lp = ' ';
|
|
|
|
}
|
|
|
|
if (*lp == ',' || *lp == '.') *lp = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
char* original_line = line;
|
|
|
|
int bytes_read;
|
|
|
|
OracleCommand command = parse_command_name(line, &bytes_read);
|
|
|
|
line += bytes_read;
|
|
|
|
|
2010-12-14 23:17:00 -08:00
|
|
|
if (command == UnknownCommand) {
|
|
|
|
tty->print_cr("CompilerOracle: unrecognized line");
|
|
|
|
tty->print_cr(" \"%s\"", original_line);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (command == QuietCommand) {
|
|
|
|
_quiet = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command == HelpCommand) {
|
|
|
|
usage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodMatcher::Mode c_match = MethodMatcher::Exact;
|
|
|
|
MethodMatcher::Mode m_match = MethodMatcher::Exact;
|
|
|
|
char class_name[256];
|
|
|
|
char method_name[256];
|
|
|
|
char sig[1024];
|
|
|
|
char errorbuf[1024];
|
|
|
|
const char* error_msg = NULL;
|
|
|
|
MethodMatcher* match = NULL;
|
|
|
|
|
|
|
|
if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
|
|
|
|
EXCEPTION_MARK;
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
|
|
|
|
Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
|
|
|
|
Symbol* signature = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
line += bytes_read;
|
|
|
|
// there might be a signature following the method.
|
|
|
|
// signatures always begin with ( so match that by hand
|
2010-12-14 23:17:00 -08:00
|
|
|
if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
sig[0] = '(';
|
|
|
|
line += bytes_read;
|
2011-01-27 16:11:27 -08:00
|
|
|
signature = SymbolTable::new_symbol(sig, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (command == OptionCommand) {
|
|
|
|
// Look for trailing options to support
|
|
|
|
// ciMethod::has_option("string") to control features in the
|
|
|
|
// compiler. Multiple options may follow the method name.
|
|
|
|
char option[256];
|
|
|
|
while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
|
|
|
|
if (match != NULL && !_quiet) {
|
|
|
|
// Print out the last match added
|
|
|
|
tty->print("CompilerOracle: %s ", command_names[command]);
|
|
|
|
match->print();
|
|
|
|
}
|
|
|
|
match = add_option_string(c_name, c_match, m_name, m_match, signature, strdup(option));
|
|
|
|
line += bytes_read;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bytes_read = 0;
|
|
|
|
sscanf(line, "%*[ \t]%n", &bytes_read);
|
|
|
|
if (line[bytes_read] != '\0') {
|
|
|
|
jio_snprintf(errorbuf, sizeof(errorbuf), " Unrecognized text after command: %s", line);
|
|
|
|
error_msg = errorbuf;
|
|
|
|
} else {
|
|
|
|
match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match != NULL) {
|
|
|
|
if (!_quiet) {
|
2012-12-18 14:55:25 +01:00
|
|
|
ResourceMark rm;
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print("CompilerOracle: %s ", command_names[command]);
|
|
|
|
match->print();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tty->print_cr("CompilerOracle: unrecognized line");
|
|
|
|
tty->print_cr(" \"%s\"", original_line);
|
|
|
|
if (error_msg != NULL) {
|
2014-05-09 16:50:54 -04:00
|
|
|
tty->print_cr("%s", error_msg);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-02 10:54:17 -04:00
|
|
|
static const char* default_cc_file = ".hotspot_compiler";
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
static const char* cc_file() {
|
2012-03-29 18:55:32 -04:00
|
|
|
#ifdef ASSERT
|
2007-12-01 00:00:00 +00:00
|
|
|
if (CompileCommandFile == NULL)
|
2012-07-02 10:54:17 -04:00
|
|
|
return default_cc_file;
|
2012-03-29 18:55:32 -04:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
return CompileCommandFile;
|
|
|
|
}
|
2012-03-29 18:55:32 -04:00
|
|
|
|
|
|
|
bool CompilerOracle::has_command_file() {
|
|
|
|
return cc_file() != NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool CompilerOracle::_quiet = false;
|
|
|
|
|
|
|
|
void CompilerOracle::parse_from_file() {
|
2012-03-29 18:55:32 -04:00
|
|
|
assert(has_command_file(), "command file must be specified");
|
2007-12-01 00:00:00 +00:00
|
|
|
FILE* stream = fopen(cc_file(), "rt");
|
|
|
|
if (stream == NULL) return;
|
|
|
|
|
|
|
|
char token[1024];
|
|
|
|
int pos = 0;
|
|
|
|
int c = getc(stream);
|
2012-06-08 12:49:12 -04:00
|
|
|
while(c != EOF && pos < (int)(sizeof(token)-1)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (c == '\n') {
|
|
|
|
token[pos++] = '\0';
|
|
|
|
parse_from_line(token);
|
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
token[pos++] = c;
|
|
|
|
}
|
|
|
|
c = getc(stream);
|
|
|
|
}
|
|
|
|
token[pos++] = '\0';
|
|
|
|
parse_from_line(token);
|
|
|
|
|
|
|
|
fclose(stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) {
|
|
|
|
char token[1024];
|
|
|
|
int pos = 0;
|
|
|
|
const char* sp = str;
|
|
|
|
int c = *sp++;
|
2012-06-08 12:49:12 -04:00
|
|
|
while (c != '\0' && pos < (int)(sizeof(token)-1)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (c == '\n') {
|
|
|
|
token[pos++] = '\0';
|
|
|
|
parse_line(token);
|
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
token[pos++] = c;
|
|
|
|
}
|
|
|
|
c = *sp++;
|
|
|
|
}
|
|
|
|
token[pos++] = '\0';
|
|
|
|
parse_line(token);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerOracle::append_comment_to_file(const char* message) {
|
2012-03-29 18:55:32 -04:00
|
|
|
assert(has_command_file(), "command file must be specified");
|
2007-12-01 00:00:00 +00:00
|
|
|
fileStream stream(fopen(cc_file(), "at"));
|
|
|
|
stream.print("# ");
|
|
|
|
for (int index = 0; message[index] != '\0'; index++) {
|
|
|
|
stream.put(message[index]);
|
|
|
|
if (message[index] == '\n') stream.print("# ");
|
|
|
|
}
|
|
|
|
stream.cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerOracle::append_exclude_to_file(methodHandle method) {
|
2012-03-29 18:55:32 -04:00
|
|
|
assert(has_command_file(), "command file must be specified");
|
2007-12-01 00:00:00 +00:00
|
|
|
fileStream stream(fopen(cc_file(), "at"));
|
|
|
|
stream.print("exclude ");
|
2012-11-06 15:09:37 -05:00
|
|
|
method->method_holder()->name()->print_symbol_on(&stream);
|
2007-12-01 00:00:00 +00:00
|
|
|
stream.print(".");
|
|
|
|
method->name()->print_symbol_on(&stream);
|
|
|
|
method->signature()->print_symbol_on(&stream);
|
|
|
|
stream.cr();
|
|
|
|
stream.cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void compilerOracle_init() {
|
|
|
|
CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
|
|
|
|
CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only);
|
2012-03-29 18:55:32 -04:00
|
|
|
if (CompilerOracle::has_command_file()) {
|
|
|
|
CompilerOracle::parse_from_file();
|
2012-07-02 10:54:17 -04:00
|
|
|
} else {
|
|
|
|
struct stat buf;
|
|
|
|
if (os::stat(default_cc_file, &buf) == 0) {
|
|
|
|
warning("%s file is present but has been ignored. "
|
|
|
|
"Run with -XX:CompileCommandFile=%s to load the file.",
|
|
|
|
default_cc_file, default_cc_file);
|
|
|
|
}
|
2012-03-29 18:55:32 -04:00
|
|
|
}
|
2010-01-08 13:47:01 -08:00
|
|
|
if (lists[PrintCommand] != NULL) {
|
|
|
|
if (PrintAssembly) {
|
2012-07-02 10:54:17 -04:00
|
|
|
warning("CompileCommand and/or %s file contains 'print' commands, but PrintAssembly is also enabled", default_cc_file);
|
2010-01-08 13:47:01 -08:00
|
|
|
} else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) {
|
|
|
|
warning("printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output");
|
|
|
|
DebugNonSafepoints = true;
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerOracle::parse_compile_only(char * line) {
|
|
|
|
int i;
|
|
|
|
char name[1024];
|
|
|
|
const char* className = NULL;
|
|
|
|
const char* methodName = NULL;
|
|
|
|
|
|
|
|
bool have_colon = (strstr(line, "::") != NULL);
|
|
|
|
char method_sep = have_colon ? ':' : '.';
|
|
|
|
|
|
|
|
if (Verbose) {
|
2014-05-09 16:50:54 -04:00
|
|
|
tty->print_cr("%s", line);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ResourceMark rm;
|
|
|
|
while (*line != '\0') {
|
|
|
|
MethodMatcher::Mode c_match = MethodMatcher::Exact;
|
|
|
|
MethodMatcher::Mode m_match = MethodMatcher::Exact;
|
|
|
|
|
|
|
|
for (i = 0;
|
|
|
|
i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line);
|
|
|
|
line++, i++) {
|
|
|
|
name[i] = *line;
|
|
|
|
if (name[i] == '.') name[i] = '/'; // package prefix uses '/'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i > 0) {
|
|
|
|
char* newName = NEW_RESOURCE_ARRAY( char, i + 1);
|
|
|
|
if (newName == NULL)
|
|
|
|
return;
|
|
|
|
strncpy(newName, name, i);
|
|
|
|
newName[i] = '\0';
|
|
|
|
|
|
|
|
if (className == NULL) {
|
|
|
|
className = newName;
|
|
|
|
c_match = MethodMatcher::Prefix;
|
|
|
|
} else {
|
|
|
|
methodName = newName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*line == method_sep) {
|
|
|
|
if (className == NULL) {
|
|
|
|
className = "";
|
|
|
|
c_match = MethodMatcher::Any;
|
|
|
|
} else {
|
|
|
|
// foo/bar.blah is an exact match on foo/bar, bar.blah is a suffix match on bar
|
|
|
|
if (strchr(className, '/') != NULL) {
|
|
|
|
c_match = MethodMatcher::Exact;
|
|
|
|
} else {
|
|
|
|
c_match = MethodMatcher::Suffix;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// got foo or foo/bar
|
|
|
|
if (className == NULL) {
|
|
|
|
ShouldNotReachHere();
|
|
|
|
} else {
|
|
|
|
// got foo or foo/bar
|
|
|
|
if (strchr(className, '/') != NULL) {
|
|
|
|
c_match = MethodMatcher::Prefix;
|
|
|
|
} else if (className[0] == '\0') {
|
|
|
|
c_match = MethodMatcher::Any;
|
|
|
|
} else {
|
|
|
|
c_match = MethodMatcher::Substring;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// each directive is terminated by , or NUL or . followed by NUL
|
|
|
|
if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) {
|
|
|
|
if (methodName == NULL) {
|
|
|
|
methodName = "";
|
|
|
|
if (*line != method_sep) {
|
|
|
|
m_match = MethodMatcher::Any;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EXCEPTION_MARK;
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* c_name = SymbolTable::new_symbol(className, CHECK);
|
|
|
|
Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK);
|
|
|
|
Symbol* signature = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature);
|
|
|
|
if (PrintVMOptions) {
|
|
|
|
tty->print("CompileOnly: compileonly ");
|
|
|
|
lists[CompileOnlyCommand]->print();
|
|
|
|
}
|
|
|
|
|
|
|
|
className = NULL;
|
|
|
|
methodName = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
line = *line == '\0' ? line : line + 1;
|
|
|
|
}
|
|
|
|
}
|