hotspot/src/share/vm/compiler/compilerOracle.cpp
author kvn
Tue, 02 Sep 2014 10:26:48 -0700
changeset 26433 27020fde2dbf
parent 26430 7f20c536cd5b
child 26441 fb92944bb02d
permissions -rw-r--r--
8056964: JDK-8055286 changes are incomplete. Summary: added ccstr and ccstrlist types to compilerOracle 'option' command Reviewed-by: roland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23185
diff changeset
     2
 * Copyright (c) 1998, 2014, 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"
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24658
diff changeset
    36
#include "runtime/os.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    38
class MethodMatcher : public CHeapObj<mtCompiler> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  enum Mode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    Exact,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    Prefix = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    Suffix = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    Substring = Prefix | Suffix,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    Any,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    Unknown = -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
 protected:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    50
  Symbol*        _class_name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    51
  Symbol*        _method_name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    52
  Symbol*        _signature;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  Mode           _class_mode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  Mode           _method_mode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  MethodMatcher* _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    57
  static bool match(Symbol* candidate, Symbol* match, Mode match_mode);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    59
  Symbol* class_name() const { return _class_name; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    60
  Symbol* method_name() const { return _method_name; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    61
  Symbol* signature() const { return _signature; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    64
  MethodMatcher(Symbol* class_name, Mode class_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    65
                Symbol* method_name, Mode method_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    66
                Symbol* signature, MethodMatcher* next);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    67
  MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // utility method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  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
    71
    Symbol* class_name  = method->method_holder()->name();
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    72
    Symbol* method_name = method->name();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    for (MethodMatcher* current = this; current != NULL; current = current->_next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      if (match(class_name, current->class_name(), current->_class_mode) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
          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
    76
          (current->signature() == NULL || current->signature() == method->signature())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        return current;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  bool match(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    return find(method) != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  MethodMatcher* next() const { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    89
  static void print_symbol(Symbol* h, Mode mode) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    if (mode == Suffix || mode == Substring || mode == Any) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      tty->print("*");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    if (mode != Any) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    96
      h->print_symbol_on(tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    if (mode == Prefix || mode == Substring) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      tty->print("*");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void print_base() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    print_symbol(class_name(), _class_mode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    tty->print(".");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    print_symbol(method_name(), _method_mode);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   107
    if (signature() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      tty->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      signature()->print_symbol_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  virtual void print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    print_base();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   119
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
   120
  _class_name  = class_name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   121
  _method_name = method_name;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  _next        = next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  _class_mode  = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  _method_mode = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  _signature   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   129
MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   130
                             Symbol* method_name, Mode method_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   131
                             Symbol* signature, MethodMatcher* next):
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    _class_mode(class_mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  , _method_mode(method_mode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  , _next(next)
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   135
  , _class_name(class_name)
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   136
  , _method_name(method_name)
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   137
  , _signature(signature) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   140
bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  if (match_mode == Any) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  if (match_mode == Exact) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   146
    return candidate == match;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  const char * candidate_string = candidate->as_C_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  const char * match_string = match->as_C_string();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  switch (match_mode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  case Prefix:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    return strstr(candidate_string, match_string) == candidate_string;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  case Suffix: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    size_t clen = strlen(candidate_string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    size_t mlen = strlen(match_string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    return clen >= mlen && strcmp(candidate_string + clen - mlen, match_string) == 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  case Substring:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    return strstr(candidate_string, match_string) != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   171
enum OptionType {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   172
  IntxType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   173
  UintxType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   174
  BoolType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   175
  CcstrType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   176
  UnknownType
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   177
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   179
/* Methods to map real type names to OptionType */
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   180
template<typename T>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   181
static OptionType get_type_for() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   182
  return UnknownType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   183
};
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   184
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   185
template<> OptionType get_type_for<intx>() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   186
  return IntxType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   187
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   188
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   189
template<> OptionType get_type_for<uintx>() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   190
  return UintxType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   191
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   192
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   193
template<> OptionType get_type_for<bool>() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   194
  return BoolType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   195
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   196
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   197
template<> OptionType get_type_for<ccstr>() {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   198
  return CcstrType;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   199
}
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   200
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   201
template<typename T>
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   202
static const T copy_value(const T value) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   203
  return value;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   204
}
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   205
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   206
template<> const ccstr copy_value<ccstr>(const ccstr value) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   207
  return (const ccstr)os::strdup_check_oom(value);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   208
}
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   209
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   210
template <typename T>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   211
class TypedMethodOptionMatcher : public MethodMatcher {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   212
  const char* _option;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   213
  OptionType _type;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   214
  const T _value;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   215
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   216
public:
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   217
  TypedMethodOptionMatcher(Symbol* class_name, Mode class_mode,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   218
                           Symbol* method_name, Mode method_mode,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   219
                           Symbol* signature, const char* opt,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   220
                           const T value,  MethodMatcher* next) :
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   221
    MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next),
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   222
                  _type(get_type_for<T>()), _value(copy_value<T>(value)) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   223
    _option = os::strdup_check_oom(opt);
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24658
diff changeset
   224
  }
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24658
diff changeset
   225
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   226
  ~TypedMethodOptionMatcher() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   227
    os::free((void*)_option);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   230
  TypedMethodOptionMatcher* match(methodHandle method, const char* opt) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   231
    TypedMethodOptionMatcher* current = this;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    while (current != NULL) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   233
      current = (TypedMethodOptionMatcher*)current->find(method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      if (current == NULL) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   235
        return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      }
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   237
      if (strcmp(current->_option, opt) == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   238
        return current;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
      current = current->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    }
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   242
    return NULL;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   243
  }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   244
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   245
  TypedMethodOptionMatcher* next() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   246
    return (TypedMethodOptionMatcher*)_next;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   249
  OptionType get_type(void) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   250
      return _type;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   251
  };
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   252
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   253
  T value() { return _value; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   255
  void print() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   256
    ttyLocker ttyl;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    print_base();
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   258
    tty->print(" %s", _option);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   259
    tty->print(" <unknown option type>");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   264
template<>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   265
void TypedMethodOptionMatcher<intx>::print() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   266
  ttyLocker ttyl;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   267
  print_base();
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   268
  tty->print(" intx %s", _option);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   269
  tty->print(" = " INTX_FORMAT, _value);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   270
  tty->cr();
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   271
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   273
template<>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   274
void TypedMethodOptionMatcher<uintx>::print() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   275
  ttyLocker ttyl;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   276
  print_base();
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   277
  tty->print(" uintx %s", _option);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   278
  tty->print(" = " UINTX_FORMAT, _value);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   279
  tty->cr();
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   280
};
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   281
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   282
template<>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   283
void TypedMethodOptionMatcher<bool>::print() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   284
  ttyLocker ttyl;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   285
  print_base();
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   286
  tty->print(" bool %s", _option);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   287
  tty->print(" = %s", _value ? "true" : "false");
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   288
  tty->cr();
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   289
};
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   290
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   291
template<>
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   292
void TypedMethodOptionMatcher<ccstr>::print() {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   293
  ttyLocker ttyl;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   294
  print_base();
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   295
  tty->print(" const char* %s", _option);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   296
  tty->print(" = '%s'", _value);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   297
  tty->cr();
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   298
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
// this must parallel the command_names below
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
enum OracleCommand {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  UnknownCommand = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  OracleFirstCommand = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  BreakCommand = OracleFirstCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  PrintCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  ExcludeCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  InlineCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  DontInlineCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  CompileOnlyCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  LogCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  OptionCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  QuietCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  HelpCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  OracleCommandCount
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
// this must parallel the enum OracleCommand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
static const char * command_names[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  "break",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  "print",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  "exclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  "inline",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  "dontinline",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  "compileonly",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  "log",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  "option",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  "quiet",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  "help"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
class MethodMatcher;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
static MethodMatcher* lists[OracleCommandCount] = { 0, };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
static bool check_predicate(OracleCommand command, methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  return ((lists[command] != NULL) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
          !method.is_null() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
          lists[command]->match(method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
static MethodMatcher* add_predicate(OracleCommand command,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   343
                                    Symbol* class_name, MethodMatcher::Mode c_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   344
                                    Symbol* method_name, MethodMatcher::Mode m_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   345
                                    Symbol* signature) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  assert(command != OptionCommand, "must use add_option_string");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    tty->print_cr("Warning:  +LogCompilation must be enabled in order for individual methods to be logged.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  lists[command] = new MethodMatcher(class_name, c_mode, method_name, m_mode, signature, lists[command]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  return lists[command];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   353
template<typename T>
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   354
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
   355
                                        Symbol* method_name, MethodMatcher::Mode m_mode,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   356
                                        Symbol* signature,
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   357
                                        const char* option,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   358
                                        T value) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   359
  lists[OptionCommand] = new TypedMethodOptionMatcher<T>(class_name, c_mode, method_name, m_mode,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   360
                                                         signature, option, value, lists[OptionCommand]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  return lists[OptionCommand];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   364
template<typename T>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   365
static bool get_option_value(methodHandle method, const char* option, T& value) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   366
   TypedMethodOptionMatcher<T>* m;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   367
   if (lists[OptionCommand] != NULL
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   368
       && (m = ((TypedMethodOptionMatcher<T>*)lists[OptionCommand])->match(method, option)) != NULL
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   369
       && m->get_type() == get_type_for<T>()) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   370
       value = m->value();
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   371
       return true;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   372
   } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   373
     return false;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   374
   }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   375
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
bool CompilerOracle::has_option_string(methodHandle method, const char* option) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   378
  bool value = false;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   379
  get_option_value(method, option, value);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   380
  return value;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   383
template<typename T>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   384
bool CompilerOracle::has_option_value(methodHandle method, const char* option, T& value) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   385
  return get_option_value(method, option, value);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   386
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   387
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   388
// Explicit instantiation for all OptionTypes supported.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   389
template bool CompilerOracle::has_option_value<intx>(methodHandle method, const char* option, intx& value);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   390
template bool CompilerOracle::has_option_value<uintx>(methodHandle method, const char* option, uintx& value);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   391
template bool CompilerOracle::has_option_value<bool>(methodHandle method, const char* option, bool& value);
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   392
template bool CompilerOracle::has_option_value<ccstr>(methodHandle method, const char* option, ccstr& value);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
bool CompilerOracle::should_exclude(methodHandle method, bool& quietly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  quietly = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  if (lists[ExcludeCommand] != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    if (lists[ExcludeCommand]->match(method)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      quietly = _quiet;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  if (lists[CompileOnlyCommand] != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    return !lists[CompileOnlyCommand]->match(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
bool CompilerOracle::should_inline(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  return (check_predicate(InlineCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
bool CompilerOracle::should_not_inline(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  return (check_predicate(DontInlineCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
bool CompilerOracle::should_print(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  return (check_predicate(PrintCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
24658
e41df2fc6e87 8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents: 24424
diff changeset
   424
bool CompilerOracle::should_print_methods() {
e41df2fc6e87 8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents: 24424
diff changeset
   425
  return lists[PrintCommand] != NULL;
e41df2fc6e87 8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents: 24424
diff changeset
   426
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
bool CompilerOracle::should_log(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  if (!LogCompilation)            return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  if (lists[LogCommand] == NULL)  return true;  // by default, log all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  return (check_predicate(LogCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
bool CompilerOracle::should_break_at(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  return check_predicate(BreakCommand, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
static OracleCommand parse_command_name(const char * line, int* bytes_read) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  assert(ARRAY_SIZE(command_names) == OracleCommandCount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
         "command_names size mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  *bytes_read = 0;
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   445
  char command[33];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  int result = sscanf(line, "%32[a-z]%n", command, bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  for (uint i = 0; i < ARRAY_SIZE(command_names); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    if (strcmp(command, command_names[i]) == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      return (OracleCommand)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  return UnknownCommand;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
static void usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  tty->print_cr("  CompileCommand and the CompilerOracle allows simple control over");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  tty->print_cr("  what's allowed to be compiled.  The standard supported directives");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  tty->print_cr("  are exclude and compileonly.  The exclude directive stops a method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  tty->print_cr("  from being compiled and compileonly excludes all methods except for");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  tty->print_cr("  the ones mentioned by compileonly directives.  The basic form of");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  tty->print_cr("  all commands is a command name followed by the name of the method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  tty->print_cr("  in one of two forms: the standard class file format as in");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  tty->print_cr("  class/name.methodName or the PrintCompilation format");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  tty->print_cr("  class.name::methodName.  The method name can optionally be followed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  tty->print_cr("  by a space then the signature of the method in the class file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  tty->print_cr("  format.  Otherwise the directive applies to all methods with the");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  tty->print_cr("  same name and class regardless of signature.  Leading and trailing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  tty->print_cr("  *'s in the class and/or method name allows a small amount of");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  tty->print_cr("  wildcarding.  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  tty->print_cr("  Examples:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  tty->print_cr("  exclude java/lang/StringBuffer.append");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  tty->print_cr("  compileonly java/lang/StringBuffer.toString ()Ljava/lang/String;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  tty->print_cr("  exclude java/lang/String*.*");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  tty->print_cr("  exclude *.toString");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
// The characters allowed in a class or method name.  All characters > 0x7f
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
// are allowed in order to handle obfuscated class files (e.g. Volano)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
#define RANGEBASE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_<>" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
        "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
        "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
        "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
        "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
        "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
        "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
        "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
        "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
#define RANGE0 "[*" RANGEBASE "]"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
#define RANGESLASH "[*" RANGEBASE "/]"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  int match = MethodMatcher::Exact;
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   498
  while (name[0] == '*') {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    match |= MethodMatcher::Suffix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    strcpy(name, name + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   503
  if (strcmp(name, "*") == 0) return MethodMatcher::Any;
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   504
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  size_t len = strlen(name);
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   506
  while (len > 0 && name[len - 1] == '*') {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    match |= MethodMatcher::Prefix;
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   508
    name[--len] = '\0';
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  if (strstr(name, "*") != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    error_msg = "  Embedded * not allowed";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    return MethodMatcher::Unknown;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  return (MethodMatcher::Mode)match;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
static bool scan_line(const char * line,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
                      char class_name[],  MethodMatcher::Mode* c_mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
                      char method_name[], MethodMatcher::Mode* m_mode,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
                      int* bytes_read, const char*& error_msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  *bytes_read = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  error_msg = NULL;
23185
a2143156a0a0 8036122: Fix warning 'format not a string literal'
goetz
parents: 22234
diff changeset
   524
  if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255"  RANGE0 "%n", class_name, method_name, bytes_read)) {
a2143156a0a0 8036122: Fix warning 'format not a string literal'
goetz
parents: 22234
diff changeset
   525
    *c_mode = check_mode(class_name, error_msg);
a2143156a0a0 8036122: Fix warning 'format not a string literal'
goetz
parents: 22234
diff changeset
   526
    *m_mode = check_mode(method_name, error_msg);
a2143156a0a0 8036122: Fix warning 'format not a string literal'
goetz
parents: 22234
diff changeset
   527
    return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   534
// Scan next flag and value in line, return MethodMatcher object on success, NULL on failure.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   535
// On failure, error_msg contains description for the first error.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   536
// For future extensions: set error_msg on first error.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   537
static MethodMatcher* scan_flag_and_value(const char* type, const char* line, int& total_bytes_read,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   538
                                          Symbol* c_name, MethodMatcher::Mode c_match,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   539
                                          Symbol* m_name, MethodMatcher::Mode m_match,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   540
                                          Symbol* signature,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   541
                                          char* errorbuf, const int buf_size) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   542
  total_bytes_read = 0;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   543
  int bytes_read = 0;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   544
  char flag[256];
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   545
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   546
  // Read flag name.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   547
  if (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", flag, &bytes_read) == 1) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   548
    line += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   549
    total_bytes_read += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   550
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   551
    // Read value.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   552
    if (strcmp(type, "intx") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   553
      intx value;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   554
      if (sscanf(line, "%*[ \t]" INTX_FORMAT "%n", &value, &bytes_read) == 1) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   555
        total_bytes_read += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   556
        return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   557
      } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   558
        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s ", flag, type);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   559
      }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   560
    } else if (strcmp(type, "uintx") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   561
      uintx value;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   562
      if (sscanf(line, "%*[ \t]" UINTX_FORMAT "%n", &value, &bytes_read) == 1) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   563
        total_bytes_read += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   564
        return add_option_string(c_name, c_match, m_name, m_match, signature, flag, value);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   565
      } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   566
        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   567
      }
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   568
    } else if (strcmp(type, "ccstr") == 0) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   569
      ResourceMark rm;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   570
      char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   571
      if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", value, &bytes_read) == 1) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   572
        total_bytes_read += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   573
        return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   574
      } else {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   575
        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   576
      }
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   577
    } else if (strcmp(type, "ccstrlist") == 0) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   578
      // Accumulates several strings into one. The internal type is ccstr.
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   579
      ResourceMark rm;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   580
      char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   581
      char* next_value = value;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   582
      if (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   583
        total_bytes_read += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   584
        line += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   585
        next_value += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   586
        char* end_value = next_value-1;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   587
        while (sscanf(line, "%*[ \t]%255[_a-zA-Z0-9]%n", next_value, &bytes_read) == 1) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   588
          total_bytes_read += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   589
          line += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   590
          *end_value = ' '; // override '\0'
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   591
          next_value += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   592
          end_value = next_value-1;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   593
        }
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   594
        return add_option_string(c_name, c_match, m_name, m_match, signature, flag, (ccstr)value);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   595
      } else {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   596
        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   597
      }
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   598
    } else if (strcmp(type, "bool") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   599
      char value[256];
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   600
      if (sscanf(line, "%*[ \t]%255[a-zA-Z]%n", value, &bytes_read) == 1) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   601
        if (strcmp(value, "true") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   602
          total_bytes_read += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   603
          return add_option_string(c_name, c_match, m_name, m_match, signature, flag, true);
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   604
        } else if (strcmp(value, "false") == 0) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   605
          total_bytes_read += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   606
          return add_option_string(c_name, c_match, m_name, m_match, signature, flag, false);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   607
        } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   608
          jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   609
        }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   610
      } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   611
        jio_snprintf(errorbuf, sizeof(errorbuf), "  Value cannot be read for flag %s of type %s", flag, type);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   612
      }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   613
    } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   614
      jio_snprintf(errorbuf, sizeof(errorbuf), "  Type %s not supported ", type);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   615
    }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   616
  } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   617
    jio_snprintf(errorbuf, sizeof(errorbuf), "  Flag name for type %s should be alphanumeric ", type);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   618
  }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   619
  return NULL;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   620
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   621
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
void CompilerOracle::parse_from_line(char* line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  if (line[0] == '\0') return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  if (line[0] == '#')  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  bool have_colon = (strstr(line, "::") != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  for (char* lp = line; *lp != '\0'; lp++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
    // Allow '.' to separate the class name from the method name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    // This is the preferred spelling of methods:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    //      exclude java/lang/String.indexOf(I)I
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    // Allow ',' for spaces (eases command line quoting).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
    //      exclude,java/lang/String.indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    // For backward compatibility, allow space as separator also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
    //      exclude java/lang/String indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    //      exclude,java/lang/String,indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
    // 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
   637
    // as produced by Method::print_short_name:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    //      exclude java.lang.String::indexOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
    // For simple implementation convenience here, convert them all to space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    if (have_colon) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      if (*lp == '.')  *lp = '/';   // dots build the package prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
      if (*lp == ':')  *lp = ' ';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    if (*lp == ',' || *lp == '.')  *lp = ' ';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  char* original_line = line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  int bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  OracleCommand command = parse_command_name(line, &bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  line += bytes_read;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   651
  ResourceMark rm;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   653
  if (command == UnknownCommand) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   654
    ttyLocker ttyl;
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   655
    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
   656
    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
   657
    return;
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   658
  }
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   659
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  if (command == QuietCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    _quiet = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  if (command == HelpCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  MethodMatcher::Mode c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  MethodMatcher::Mode m_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  char class_name[256];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  char method_name[256];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  char sig[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  char errorbuf[1024];
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   676
  const char* error_msg = NULL; // description of first error that appears
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  MethodMatcher* match = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    EXCEPTION_MARK;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   681
    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
   682
    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
   683
    Symbol* signature = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
    line += bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    // there might be a signature following the method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    // 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
   688
    if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
      sig[0] = '(';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
      line += bytes_read;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   691
      signature = SymbolTable::new_symbol(sig, CHECK);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
    if (command == OptionCommand) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   695
      // Look for trailing options.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   696
      //
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   697
      // Two types of trailing options are
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   698
      // supported:
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   699
      //
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   700
      // (1) CompileCommand=option,Klass::method,flag
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   701
      // (2) CompileCommand=option,Klass::method,type,flag,value
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   702
      //
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   703
      // Type (1) is used to support ciMethod::has_option("someflag")
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   704
      // (i.e., to check if a flag "someflag" is enabled for a method).
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   705
      //
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   706
      // Type (2) is used to support options with a value. Values can have the
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   707
      // the following types: intx, uintx, bool, ccstr, and ccstrlist.
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   708
      //
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   709
      // For future extensions: extend scan_flag_and_value()
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   710
      char option[256]; // stores flag for Type (1) and type of Type (2)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
      while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
        if (match != NULL && !_quiet) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
          // Print out the last match added
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   714
          ttyLocker ttyl;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
          tty->print("CompilerOracle: %s ", command_names[command]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
          match->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
        line += bytes_read;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   719
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   720
        if (strcmp(option, "intx") == 0
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   721
            || strcmp(option, "uintx") == 0
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   722
            || strcmp(option, "bool") == 0
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   723
            || strcmp(option, "ccstr") == 0
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   724
            || strcmp(option, "ccstrlist") == 0
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   725
            ) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   726
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   727
          // Type (2) option: parse flag name and value.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   728
          match = scan_flag_and_value(option, line, bytes_read,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   729
                                      c_name, c_match, m_name, m_match, signature,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   730
                                      errorbuf, sizeof(errorbuf));
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   731
          if (match == NULL) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   732
            error_msg = errorbuf;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   733
            break;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   734
          }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   735
          line += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   736
        } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   737
          // Type (1) option
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   738
          match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   739
        }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   740
      } // while(
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
    } else {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   742
      match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   746
  ttyLocker ttyl;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   747
  if (error_msg != NULL) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   748
    // an error has happened
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
    tty->print_cr("CompilerOracle: unrecognized line");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
    tty->print_cr("  \"%s\"", original_line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    if (error_msg != NULL) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23185
diff changeset
   752
      tty->print_cr("%s", error_msg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    }
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   754
  } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   755
    // check for remaining characters
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   756
    bytes_read = 0;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   757
    sscanf(line, "%*[ \t]%n", &bytes_read);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   758
    if (line[bytes_read] != '\0') {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   759
      tty->print_cr("CompilerOracle: unrecognized line");
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   760
      tty->print_cr("  \"%s\"", original_line);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   761
      tty->print_cr("  Unrecognized text %s after command ", line);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   762
    } else if (match != NULL && !_quiet) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   763
      tty->print("CompilerOracle: %s ", command_names[command]);
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   764
      match->print();
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   765
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
13194
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   769
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
   770
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
static const char* cc_file() {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   772
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  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
   774
    return default_cc_file;
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   775
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  return CompileCommandFile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
}
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   778
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   779
bool CompilerOracle::has_command_file() {
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   780
  return cc_file() != NULL;
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   781
}
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   782
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
bool CompilerOracle::_quiet = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
void CompilerOracle::parse_from_file() {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   786
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  FILE* stream = fopen(cc_file(), "rt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
  if (stream == NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  char token[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  int  pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  int  c = getc(stream);
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents: 14138
diff changeset
   793
  while(c != EOF && pos < (int)(sizeof(token)-1)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
    if (c == '\n') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
      token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
      parse_from_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
      pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
      token[pos++] = c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    c = getc(stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
  parse_from_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  fclose(stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  char token[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  int  pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  const char* sp = str;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  int  c = *sp++;
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents: 14138
diff changeset
   814
  while (c != '\0' && pos < (int)(sizeof(token)-1)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
    if (c == '\n') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
      token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
      parse_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
      pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
      token[pos++] = c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    c = *sp++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  parse_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
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
   829
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  fileStream stream(fopen(cc_file(), "at"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  stream.print("# ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  for (int index = 0; message[index] != '\0'; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    stream.put(message[index]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
    if (message[index] == '\n') stream.print("# ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
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
   840
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  fileStream stream(fopen(cc_file(), "at"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  stream.print("exclude ");
14391
df0a1573d5bd 8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents: 14147
diff changeset
   843
  method->method_holder()->name()->print_symbol_on(&stream);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  stream.print(".");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  method->name()->print_symbol_on(&stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  method->signature()->print_symbol_on(&stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
void compilerOracle_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  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
   855
  if (CompilerOracle::has_command_file()) {
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   856
    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
   857
  } else {
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   858
    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
   859
    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
   860
      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
   861
              "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
   862
              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
   863
    }
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   864
  }
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   865
  if (lists[PrintCommand] != NULL) {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   866
    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
   867
      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
   868
    } else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   869
      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
   870
      DebugNonSafepoints = true;
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   871
    }
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   872
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
void CompilerOracle::parse_compile_only(char * line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  char name[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  const char* className = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  const char* methodName = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  bool have_colon = (strstr(line, "::") != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  char method_sep = have_colon ? ':' : '.';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
  if (Verbose) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23185
diff changeset
   886
    tty->print_cr("%s", line);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  while (*line != '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
    MethodMatcher::Mode c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
    MethodMatcher::Mode m_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    for (i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
         i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
         line++, i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
      name[i] = *line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
      if (name[i] == '.')  name[i] = '/';  // package prefix uses '/'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    if (i > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
      char* newName = NEW_RESOURCE_ARRAY( char, i + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
      if (newName == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
      strncpy(newName, name, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
      newName[i] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
        className = newName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
        c_match = MethodMatcher::Prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
        methodName = newName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
    if (*line == method_sep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
        className = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
        c_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
        // 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
   922
        if (strchr(className, '/') != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
          c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
          c_match = MethodMatcher::Suffix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
      // got foo or foo/bar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
        // got foo or foo/bar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
        if (strchr(className, '/') != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
          c_match = MethodMatcher::Prefix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
        } else if (className[0] == '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
          c_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
          c_match = MethodMatcher::Substring;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
    // each directive is terminated by , or NUL or . followed by NUL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
    if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
      if (methodName == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
        methodName = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
        if (*line != method_sep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
          m_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
      EXCEPTION_MARK;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   954
      Symbol* c_name = SymbolTable::new_symbol(className, CHECK);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   955
      Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   956
      Symbol* signature = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
      add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
      if (PrintVMOptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
        tty->print("CompileOnly: compileonly ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
        lists[CompileOnlyCommand]->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
      className = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      methodName = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
    line = *line == '\0' ? line : line + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
}