hotspot/src/share/vm/compiler/compilerOracle.cpp
author coleenp
Tue, 06 Nov 2012 15:09:37 -0500
changeset 14391 df0a1573d5bd
parent 14147 7e2ece489a84
child 14828 bb9dffedf46c
permissions -rw-r--r--
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass Summary: Change types of above methods and field to InstanceKlass and remove unneeded casts from the source files. Reviewed-by: dholmes, coleenp, zgu Contributed-by: harold.seigel@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
     2
 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4584
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4584
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4584
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "compiler/compilerOracle.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/oopFactory.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "oops/klass.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13202
diff changeset
    31
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "oops/oop.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    33
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "runtime/jniHandles.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    37
class MethodMatcher : public CHeapObj<mtCompiler> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  enum Mode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    Exact,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    Prefix = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    Suffix = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    Substring = Prefix | Suffix,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    Any,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    Unknown = -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 protected:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    49
  Symbol*        _class_name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    50
  Symbol*        _method_name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    51
  Symbol*        _signature;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  Mode           _class_mode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  Mode           _method_mode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  MethodMatcher* _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    56
  static bool match(Symbol* candidate, Symbol* match, Mode match_mode);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    58
  Symbol* class_name() const { return _class_name; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    59
  Symbol* method_name() const { return _method_name; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    60
  Symbol* signature() const { return _signature; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    63
  MethodMatcher(Symbol* class_name, Mode class_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    64
                Symbol* method_name, Mode method_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    65
                Symbol* signature, MethodMatcher* next);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    66
  MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // utility method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  MethodMatcher* find(methodHandle method) {
14391
df0a1573d5bd 8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents: 14147
diff changeset
    70
    Symbol* class_name  = method->method_holder()->name();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    71
    Symbol* method_name = method->name();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    for (MethodMatcher* current = this; current != NULL; current = current->_next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
      if (match(class_name, current->class_name(), current->_class_mode) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
          match(method_name, current->method_name(), current->_method_mode) &&
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    75
          (current->signature() == NULL || current->signature() == method->signature())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        return current;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool match(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    return find(method) != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  MethodMatcher* next() const { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    88
  static void print_symbol(Symbol* h, Mode mode) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    if (mode == Suffix || mode == Substring || mode == Any) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      tty->print("*");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    if (mode != Any) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    95
      h->print_symbol_on(tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    if (mode == Prefix || mode == Substring) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      tty->print("*");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  void print_base() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    print_symbol(class_name(), _class_mode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    tty->print(".");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    print_symbol(method_name(), _method_mode);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   106
    if (signature() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      tty->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      signature()->print_symbol_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  virtual void print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    print_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   118
MethodMatcher::MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   119
  _class_name  = class_name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   120
  _method_name = method_name;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  _next        = next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  _class_mode  = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  _method_mode = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  _signature   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   128
MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   129
                             Symbol* method_name, Mode method_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   130
                             Symbol* signature, MethodMatcher* next):
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    _class_mode(class_mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  , _method_mode(method_mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  , _next(next)
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   134
  , _class_name(class_name)
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   135
  , _method_name(method_name)
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   136
  , _signature(signature) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   139
bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  if (match_mode == Any) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  if (match_mode == Exact) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   145
    return candidate == match;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  const char * candidate_string = candidate->as_C_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  const char * match_string = match->as_C_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  switch (match_mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  case Prefix:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    return strstr(candidate_string, match_string) == candidate_string;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  case Suffix: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    size_t clen = strlen(candidate_string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    size_t mlen = strlen(match_string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    return clen >= mlen && strcmp(candidate_string + clen - mlen, match_string) == 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  case Substring:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    return strstr(candidate_string, match_string) != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
class MethodOptionMatcher: public MethodMatcher {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  const char * option;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   174
  MethodOptionMatcher(Symbol* class_name, Mode class_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   175
                             Symbol* method_name, Mode method_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   176
                             Symbol* signature, const char * opt, MethodMatcher* next):
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    option = opt;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  bool match(methodHandle method, const char* opt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    MethodOptionMatcher* current = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    while (current != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
      current = (MethodOptionMatcher*)current->find(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      if (current == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
      if (strcmp(current->option, opt) == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      current = current->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  MethodOptionMatcher* next() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    return (MethodOptionMatcher*)_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  virtual void print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    print_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    tty->print(" %s", option);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
// this must parallel the command_names below
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
enum OracleCommand {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  UnknownCommand = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  OracleFirstCommand = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  BreakCommand = OracleFirstCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  PrintCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  ExcludeCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  InlineCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  DontInlineCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  CompileOnlyCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  LogCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  OptionCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  QuietCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  HelpCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  OracleCommandCount
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
// this must parallel the enum OracleCommand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
static const char * command_names[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  "break",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  "print",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  "exclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  "inline",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  "dontinline",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  "compileonly",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  "log",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  "option",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  "quiet",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  "help"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
static const char * command_name(OracleCommand command) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  if (command < OracleFirstCommand || command >= OracleCommandCount) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    return "unknown command";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  return command_names[command];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
class MethodMatcher;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
static MethodMatcher* lists[OracleCommandCount] = { 0, };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
static bool check_predicate(OracleCommand command, methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  return ((lists[command] != NULL) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
          !method.is_null() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
          lists[command]->match(method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
static MethodMatcher* add_predicate(OracleCommand command,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   259
                                    Symbol* class_name, MethodMatcher::Mode c_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   260
                                    Symbol* method_name, MethodMatcher::Mode m_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   261
                                    Symbol* signature) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  assert(command != OptionCommand, "must use add_option_string");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    tty->print_cr("Warning:  +LogCompilation must be enabled in order for individual methods to be logged.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  return lists[command];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   271
static MethodMatcher* add_option_string(Symbol* class_name, MethodMatcher::Mode c_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   272
                                        Symbol* method_name, MethodMatcher::Mode m_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   273
                                        Symbol* signature,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
                                        const char* option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  lists[OptionCommand] = new MethodOptionMatcher(class_name, c_mode, method_name, m_mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
                                                 signature, option, lists[OptionCommand]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  return lists[OptionCommand];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
bool CompilerOracle::has_option_string(methodHandle method, const char* option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  return lists[OptionCommand] != NULL &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    ((MethodOptionMatcher*)lists[OptionCommand])->match(method, option);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  quietly = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  if (lists[ExcludeCommand] != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    if (lists[ExcludeCommand]->match(method)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
      quietly = _quiet;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  if (lists[CompileOnlyCommand] != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    return !lists[CompileOnlyCommand]->match(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
bool CompilerOracle::should_inline(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  return (check_predicate(InlineCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
bool CompilerOracle::should_not_inline(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  return (check_predicate(DontInlineCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
bool CompilerOracle::should_print(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  return (check_predicate(PrintCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
bool CompilerOracle::should_log(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  if (!LogCompilation)            return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  if (lists[LogCommand] == NULL)  return true;  // by default, log all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  return (check_predicate(LogCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
bool CompilerOracle::should_break_at(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  return check_predicate(BreakCommand, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
static OracleCommand parse_command_name(const char * line, int* bytes_read) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  assert(ARRAY_SIZE(command_names) == OracleCommandCount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
         "command_names size mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  *bytes_read = 0;
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   335
  char command[33];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  int result = sscanf(line, "%32[a-z]%n", command, bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  for (uint i = 0; i < ARRAY_SIZE(command_names); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    if (strcmp(command, command_names[i]) == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      return (OracleCommand)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  return UnknownCommand;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
static void usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  tty->print_cr("  CompileCommand and the CompilerOracle allows simple control over");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  tty->print_cr("  what's allowed to be compiled.  The standard supported directives");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  tty->print_cr("  are exclude and compileonly.  The exclude directive stops a method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  tty->print_cr("  from being compiled and compileonly excludes all methods except for");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  tty->print_cr("  the ones mentioned by compileonly directives.  The basic form of");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  tty->print_cr("  all commands is a command name followed by the name of the method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  tty->print_cr("  in one of two forms: the standard class file format as in");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  tty->print_cr("  class/name.methodName or the PrintCompilation format");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  tty->print_cr("  class.name::methodName.  The method name can optionally be followed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  tty->print_cr("  by a space then the signature of the method in the class file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  tty->print_cr("  format.  Otherwise the directive applies to all methods with the");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  tty->print_cr("  same name and class regardless of signature.  Leading and trailing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  tty->print_cr("  *'s in the class and/or method name allows a small amount of");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  tty->print_cr("  wildcarding.  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  tty->print_cr("  Examples:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  tty->print_cr("  exclude java/lang/StringBuffer.append");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  tty->print_cr("  compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  tty->print_cr("  exclude java/lang/String*.*");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  tty->print_cr("  exclude *.toString");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
// The characters allowed in a class or method name.  All characters > 0x7f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
// are allowed in order to handle obfuscated class files (e.g. Volano)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
#define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
        "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
        "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
        "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
        "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
        "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
#define RANGE0 "[*" RANGEBASE "]"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
#define RANGEDOT "[*" RANGEBASE ".]"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
#define RANGESLASH "[*" RANGEBASE "/]"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
// Accept several syntaxes for these patterns
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
//  original syntax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
//   cmd  java.lang.String foo
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
//  PrintCompilation syntax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
//   cmd  java.lang.String::foo
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
//  VM syntax
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
//   cmd  java/lang/String[. ]foo
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
static const char* patterns[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  "%*[ \t]%255" RANGEDOT    " "     "%255"  RANGE0 "%n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  "%*[ \t]%255" RANGEDOT   "::"     "%255"  RANGE0 "%n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  "%*[ \t]%255" RANGESLASH "%*[ .]" "%255"  RANGE0 "%n",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  int match = MethodMatcher::Exact;
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   405
  while (name[0] == '*') {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    match |= MethodMatcher::Suffix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    strcpy(name, name + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   410
  if (strcmp(name, "*") == 0) return MethodMatcher::Any;
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   411
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  size_t len = strlen(name);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   413
  while (len > 0 && name[len - 1] == '*') {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    match |= MethodMatcher::Prefix;
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   415
    name[--len] = '\0';
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  if (strstr(name, "*") != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    error_msg = "  Embedded * not allowed";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    return MethodMatcher::Unknown;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  return (MethodMatcher::Mode)match;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
static bool scan_line(const char * line,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
                      char class_name[],  MethodMatcher::Mode* c_mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
                      char method_name[], MethodMatcher::Mode* m_mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
                      int* bytes_read, const char*& error_msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  *bytes_read = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  error_msg = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  for (uint i = 0; i < ARRAY_SIZE(patterns); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    if (2 == sscanf(line, patterns[i], class_name, method_name, bytes_read)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      *c_mode = check_mode(class_name, error_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      *m_mode = check_mode(method_name, error_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
      return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
void CompilerOracle::parse_from_line(char* line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  if (line[0] == '\0') return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  if (line[0] == '#')  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  bool have_colon = (strstr(line, "::") != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  for (char* lp = line; *lp != '\0'; lp++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    // Allow '.' to separate the class name from the method name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    // This is the preferred spelling of methods:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    //      exclude java/lang/String.indexOf(I)I
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    // Allow ',' for spaces (eases command line quoting).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    //      exclude,java/lang/String.indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    // For backward compatibility, allow space as separator also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    //      exclude java/lang/String indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    //      exclude,java/lang/String,indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    // For easy cut-and-paste of method names, allow VM output format
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13202
diff changeset
   458
    // as produced by Method::print_short_name:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    //      exclude java.lang.String::indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    // For simple implementation convenience here, convert them all to space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    if (have_colon) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
      if (*lp == '.')  *lp = '/';   // dots build the package prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
      if (*lp == ':')  *lp = ' ';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    if (*lp == ',' || *lp == '.')  *lp = ' ';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  char* original_line = line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  int bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  OracleCommand command = parse_command_name(line, &bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  line += bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   473
  if (command == UnknownCommand) {
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   474
    tty->print_cr("CompilerOracle: unrecognized line");
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   475
    tty->print_cr("  \"%s\"", original_line);
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   476
    return;
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   477
  }
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   478
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  if (command == QuietCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    _quiet = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  if (command == HelpCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  MethodMatcher::Mode c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  MethodMatcher::Mode m_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  char class_name[256];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  char method_name[256];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  char sig[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  char errorbuf[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  const char* error_msg = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  MethodMatcher* match = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    EXCEPTION_MARK;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   500
    Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   501
    Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   502
    Symbol* signature = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    line += bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    // there might be a signature following the method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    // signatures always begin with ( so match that by hand
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   507
    if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      sig[0] = '(';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
      line += bytes_read;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   510
      signature = SymbolTable::new_symbol(sig, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    if (command == OptionCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
      // Look for trailing options to support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
      // ciMethod::has_option("string") to control features in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
      // compiler.  Multiple options may follow the method name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      char option[256];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
        if (match != NULL && !_quiet) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
          // Print out the last match added
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
          tty->print("CompilerOracle: %s ", command_names[command]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
          match->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
        match = add_option_string(c_name, c_match, m_name, m_match, signature, strdup(option));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
        line += bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      bytes_read = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
      sscanf(line, "%*[ \t]%n", &bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
      if (line[bytes_read] != '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
        jio_snprintf(errorbuf, sizeof(errorbuf), "  Unrecognized text after command: %s", line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
        error_msg = errorbuf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
        match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  if (match != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    if (!_quiet) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
      tty->print("CompilerOracle: %s ", command_names[command]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
      match->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    tty->print_cr("CompilerOracle: unrecognized line");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    tty->print_cr("  \"%s\"", original_line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    if (error_msg != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
      tty->print_cr(error_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
13194
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   553
static const char* default_cc_file = ".hotspot_compiler";
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   554
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
static const char* cc_file() {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   556
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  if (CompileCommandFile == NULL)
13194
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   558
    return default_cc_file;
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   559
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  return CompileCommandFile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
}
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   562
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   563
bool CompilerOracle::has_command_file() {
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   564
  return cc_file() != NULL;
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   565
}
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   566
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
bool CompilerOracle::_quiet = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
void CompilerOracle::parse_from_file() {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   570
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  FILE* stream = fopen(cc_file(), "rt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  if (stream == NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  char token[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  int  pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  int  c = getc(stream);
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents: 14138
diff changeset
   577
  while(c != EOF && pos < (int)(sizeof(token)-1)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    if (c == '\n') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
      token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      parse_from_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      token[pos++] = c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    c = getc(stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  parse_from_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  fclose(stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  char token[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  int  pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  const char* sp = str;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  int  c = *sp++;
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents: 14138
diff changeset
   598
  while (c != '\0' && pos < (int)(sizeof(token)-1)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    if (c == '\n') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
      token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
      parse_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      token[pos++] = c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    c = *sp++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  parse_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
void CompilerOracle::append_comment_to_file(const char* message) {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   613
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  fileStream stream(fopen(cc_file(), "at"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  stream.print("# ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  for (int index = 0; message[index] != '\0'; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    stream.put(message[index]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    if (message[index] == '\n') stream.print("# ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
void CompilerOracle::append_exclude_to_file(methodHandle method) {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   624
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  fileStream stream(fopen(cc_file(), "at"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  stream.print("exclude ");
14391
df0a1573d5bd 8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents: 14147
diff changeset
   627
  method->method_holder()->name()->print_symbol_on(&stream);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  stream.print(".");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  method->name()->print_symbol_on(&stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  method->signature()->print_symbol_on(&stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
void compilerOracle_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only);
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   639
  if (CompilerOracle::has_command_file()) {
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   640
    CompilerOracle::parse_from_file();
13194
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   641
  } else {
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   642
    struct stat buf;
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   643
    if (os::stat(default_cc_file, &buf) == 0) {
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   644
      warning("%s file is present but has been ignored.  "
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   645
              "Run with -XX:CompileCommandFile=%s to load the file.",
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   646
              default_cc_file, default_cc_file);
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   647
    }
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   648
  }
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   649
  if (lists[PrintCommand] != NULL) {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   650
    if (PrintAssembly) {
13194
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   651
      warning("CompileCommand and/or %s file contains 'print' commands, but PrintAssembly is also enabled", default_cc_file);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   652
    } else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   653
      warning("printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output");
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   654
      DebugNonSafepoints = true;
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   655
    }
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   656
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
void CompilerOracle::parse_compile_only(char * line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  char name[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  const char* className = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  const char* methodName = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  bool have_colon = (strstr(line, "::") != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  char method_sep = have_colon ? ':' : '.';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  if (Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
    tty->print_cr(line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  while (*line != '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    MethodMatcher::Mode c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    MethodMatcher::Mode m_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
    for (i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
         i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
         line++, i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
      name[i] = *line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      if (name[i] == '.')  name[i] = '/';  // package prefix uses '/'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
    if (i > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
      char* newName = NEW_RESOURCE_ARRAY( char, i + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
      if (newName == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
      strncpy(newName, name, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
      newName[i] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
        className = newName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
        c_match = MethodMatcher::Prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
        methodName = newName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    if (*line == method_sep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
        className = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
        c_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
        // foo/bar.blah is an exact match on foo/bar, bar.blah is a suffix match on bar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
        if (strchr(className, '/') != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
          c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
          c_match = MethodMatcher::Suffix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
      // got foo or foo/bar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
        // got foo or foo/bar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
        if (strchr(className, '/') != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
          c_match = MethodMatcher::Prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
        } else if (className[0] == '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
          c_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
          c_match = MethodMatcher::Substring;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
    // each directive is terminated by , or NUL or . followed by NUL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
    if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      if (methodName == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
        methodName = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
        if (*line != method_sep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
          m_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
      EXCEPTION_MARK;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   738
      Symbol* c_name = SymbolTable::new_symbol(className, CHECK);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   739
      Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   740
      Symbol* signature = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
      add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
      if (PrintVMOptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
        tty->print("CompileOnly: compileonly ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
        lists[CompileOnlyCommand]->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
      className = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
      methodName = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
    line = *line == '\0' ? line : line + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
}