src/hotspot/share/compiler/compilerOracle.cpp
author coleenp
Tue, 14 May 2019 11:29:18 -0400
changeset 54847 59ea39bb2809
parent 54786 ebf733a324d4
permissions -rw-r--r--
8223657: Remove unused THREAD argument from SymbolTable functions Summary: also made lookup and lookup_only functions private to SymbolTable. External callers use new_symbol or probe. Reviewed-by: dholmes, gziemski
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
54374
22eb1f7416f1 8221541: clean up functions in CompilerOracle
mbaesken
parents: 47765
diff changeset
     2
 * Copyright (c) 1998, 2019, 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"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    26
#include "jvm.h"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54374
diff changeset
    27
#include "classfile/symbolTable.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "compiler/compilerOracle.hpp"
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
    29
#include "compiler/methodMatcher.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "memory/oopFactory.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/klass.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13202
diff changeset
    34
#include "oops/method.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
    35
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "runtime/jniHandles.hpp"
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 24658
diff changeset
    38
#include "runtime/os.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    40
enum OptionType {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    41
  IntxType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    42
  UintxType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    43
  BoolType,
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    44
  CcstrType,
27143
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
    45
  DoubleType,
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    46
  UnknownType
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    47
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    49
/* Methods to map real type names to OptionType */
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    50
template<typename T>
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    51
static OptionType get_type_for() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    52
  return UnknownType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    53
};
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    54
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    55
template<> OptionType get_type_for<intx>() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    56
  return IntxType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    57
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    58
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    59
template<> OptionType get_type_for<uintx>() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    60
  return UintxType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    61
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    62
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    63
template<> OptionType get_type_for<bool>() {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    64
  return BoolType;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    65
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
    66
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
    67
template<> OptionType get_type_for<ccstr>() {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
    68
  return CcstrType;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
    69
}
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
    70
27143
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
    71
template<> OptionType get_type_for<double>() {
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
    72
  return DoubleType;
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
    73
}
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
    74
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// this must parallel the command_names below
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
enum OracleCommand {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  UnknownCommand = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  OracleFirstCommand = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  BreakCommand = OracleFirstCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  PrintCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  ExcludeCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  InlineCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  DontInlineCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  CompileOnlyCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  LogCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  OptionCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  QuietCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  HelpCommand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  OracleCommandCount
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// this must parallel the enum OracleCommand
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
static const char * command_names[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  "break",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  "print",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  "exclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  "inline",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  "dontinline",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  "compileonly",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  "log",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  "option",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  "quiet",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  "help"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
class MethodMatcher;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   107
class TypedMethodOptionMatcher;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   108
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   109
static BasicMatcher* lists[OracleCommandCount] = { 0, };
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   110
static TypedMethodOptionMatcher* option_list = NULL;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   111
static bool any_set = false;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   112
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   113
class TypedMethodOptionMatcher : public MethodMatcher {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   114
 private:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   115
  TypedMethodOptionMatcher* _next;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   116
  const char*   _option;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   117
  OptionType    _type;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   118
 public:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   119
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   120
  union {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   121
    bool bool_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   122
    intx intx_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   123
    uintx uintx_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   124
    double double_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   125
    ccstr ccstr_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   126
  } _u;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   127
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   128
  TypedMethodOptionMatcher() : MethodMatcher(),
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   129
    _next(NULL),
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   130
    _type(UnknownType) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   131
      _option = NULL;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   132
      memset(&_u, 0, sizeof(_u));
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   133
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   134
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   135
  static TypedMethodOptionMatcher* parse_method_pattern(char*& line, const char*& error_msg);
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46560
diff changeset
   136
  TypedMethodOptionMatcher* match(const methodHandle& method, const char* opt, OptionType type);
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   137
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   138
  void init(const char* opt, OptionType type, TypedMethodOptionMatcher* next) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   139
    _next = next;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   140
    _type = type;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   141
    _option = os::strdup_check_oom(opt);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   142
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   143
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   144
  void set_next(TypedMethodOptionMatcher* next) {_next = next; }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   145
  TypedMethodOptionMatcher* next() { return _next; }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   146
  OptionType type() { return _type; }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   147
  template<typename T> T value();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   148
  template<typename T> void set_value(T value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   149
  void print();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   150
  void print_all();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   151
  TypedMethodOptionMatcher* clone();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   152
  ~TypedMethodOptionMatcher();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   153
};
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   154
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   155
// A few templated accessors instead of a full template class.
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   156
template<> intx TypedMethodOptionMatcher::value<intx>() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   157
  return _u.intx_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   158
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   159
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   160
template<> uintx TypedMethodOptionMatcher::value<uintx>() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   161
  return _u.uintx_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   162
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   163
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   164
template<> bool TypedMethodOptionMatcher::value<bool>() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   165
  return _u.bool_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   166
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   167
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   168
template<> double TypedMethodOptionMatcher::value<double>() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   169
  return _u.double_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   170
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   171
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   172
template<> ccstr TypedMethodOptionMatcher::value<ccstr>() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   173
  return _u.ccstr_value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   174
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   175
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   176
template<> void TypedMethodOptionMatcher::set_value(intx value) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   177
  _u.intx_value = value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   178
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   179
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   180
template<> void TypedMethodOptionMatcher::set_value(uintx value) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   181
  _u.uintx_value = value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   182
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   183
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   184
template<> void TypedMethodOptionMatcher::set_value(double value) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   185
  _u.double_value = value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   186
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   187
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   188
template<> void TypedMethodOptionMatcher::set_value(bool value) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   189
  _u.bool_value = value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   190
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   191
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   192
template<> void TypedMethodOptionMatcher::set_value(ccstr value) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   193
  _u.ccstr_value = (const ccstr)os::strdup_check_oom(value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   194
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   196
void TypedMethodOptionMatcher::print() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   197
  ttyLocker ttyl;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   198
  print_base(tty);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   199
  switch (_type) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   200
  case IntxType:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   201
    tty->print_cr(" intx %s = " INTX_FORMAT, _option, value<intx>());
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   202
    break;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   203
  case UintxType:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   204
    tty->print_cr(" uintx %s = " UINTX_FORMAT, _option, value<uintx>());
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   205
    break;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   206
  case BoolType:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   207
    tty->print_cr(" bool %s = %s", _option, value<bool>() ? "true" : "false");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   208
    break;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   209
  case DoubleType:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   210
    tty->print_cr(" double %s = %f", _option, value<double>());
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   211
    break;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   212
  case CcstrType:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   213
    tty->print_cr(" const char* %s = '%s'", _option, value<ccstr>());
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   214
    break;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   215
  default:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   216
    ShouldNotReachHere();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   217
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   218
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   219
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   220
void TypedMethodOptionMatcher::print_all() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   221
   print();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   222
   if (_next != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   223
     tty->print(" ");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   224
     _next->print_all();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   225
   }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   226
 }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   227
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   228
TypedMethodOptionMatcher* TypedMethodOptionMatcher::clone() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   229
  TypedMethodOptionMatcher* m = new TypedMethodOptionMatcher();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   230
  m->_class_mode = _class_mode;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   231
  m->_class_name = _class_name;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   232
  m->_method_mode = _method_mode;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   233
  m->_method_name = _method_name;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   234
  m->_signature = _signature;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   235
  // Need to ref count the symbols
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   236
  if (_class_name != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   237
    _class_name->increment_refcount();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   238
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   239
  if (_method_name != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   240
    _method_name->increment_refcount();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   241
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   242
  if (_signature != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   243
    _signature->increment_refcount();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   244
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   245
  return m;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   246
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   247
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   248
TypedMethodOptionMatcher::~TypedMethodOptionMatcher() {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   249
  if (_option != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   250
    os::free((void*)_option);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   251
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   252
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   253
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   254
TypedMethodOptionMatcher* TypedMethodOptionMatcher::parse_method_pattern(char*& line, const char*& error_msg) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   255
  assert(error_msg == NULL, "Dont call here with error_msg already set");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   256
  TypedMethodOptionMatcher* tom = new TypedMethodOptionMatcher();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   257
  MethodMatcher::parse_method_pattern(line, error_msg, tom);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   258
  if (error_msg != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   259
    delete tom;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   260
    return NULL;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   261
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   262
  return tom;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   263
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   264
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46560
diff changeset
   265
TypedMethodOptionMatcher* TypedMethodOptionMatcher::match(const methodHandle& method, const char* opt, OptionType type) {
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   266
  TypedMethodOptionMatcher* current = this;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   267
  while (current != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   268
    // Fastest compare first.
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   269
    if (current->type() == type) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   270
      if (strcmp(current->_option, opt) == 0) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   271
        if (current->matches(method)) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   272
          return current;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   273
        }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   274
      }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   275
    }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   276
    current = current->next();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   277
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   278
  return NULL;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   279
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   280
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   281
template<typename T>
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   282
static void add_option_string(TypedMethodOptionMatcher* matcher,
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   283
                                        const char* option,
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   284
                                        T value) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   285
  assert(matcher != option_list, "No circular lists please");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   286
  matcher->init(option, get_type_for<T>(), option_list);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   287
  matcher->set_value<T>(value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   288
  option_list = matcher;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   289
  any_set = true;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   290
  return;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   291
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46560
diff changeset
   293
static bool check_predicate(OracleCommand command, const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  return ((lists[command] != NULL) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
          !method.is_null() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
          lists[command]->match(method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   299
static void add_predicate(OracleCommand command, BasicMatcher* bm) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  assert(command != OptionCommand, "must use add_option_string");
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   301
  if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    tty->print_cr("Warning:  +LogCompilation must be enabled in order for individual methods to be logged.");
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   303
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   304
  bm->set_next(lists[command]);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   305
  lists[command] = bm;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   306
  if ((command != DontInlineCommand) && (command != InlineCommand)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   307
    any_set = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   308
  }
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   309
  return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   312
template<typename T>
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   313
bool CompilerOracle::has_option_value(const methodHandle& method, const char* option, T& value) {
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   314
  if (option_list != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   315
    TypedMethodOptionMatcher* m = option_list->match(method, option, get_type_for<T>());
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   316
    if (m != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   317
      value = m->value<T>();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   318
      return true;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   319
    }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   320
  }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   321
  return false;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   322
}
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   323
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   324
bool CompilerOracle::has_any_option() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   325
  return any_set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   326
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   327
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   328
// Explicit instantiation for all OptionTypes supported.
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   329
template bool CompilerOracle::has_option_value<intx>(const methodHandle& method, const char* option, intx& value);
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   330
template bool CompilerOracle::has_option_value<uintx>(const methodHandle& method, const char* option, uintx& value);
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   331
template bool CompilerOracle::has_option_value<bool>(const methodHandle& method, const char* option, bool& value);
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   332
template bool CompilerOracle::has_option_value<ccstr>(const methodHandle& method, const char* option, ccstr& value);
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   333
template bool CompilerOracle::has_option_value<double>(const methodHandle& method, const char* option, double& value);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   335
bool CompilerOracle::has_option_string(const methodHandle& method, const char* option) {
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   336
  bool value = false;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   337
  has_option_value(method, option, value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   338
  return value;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   339
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   340
33626
jwilhelm
parents: 33593 33451
diff changeset
   341
bool CompilerOracle::should_exclude(const methodHandle& method) {
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   342
  if (check_predicate(ExcludeCommand, method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33069
diff changeset
   343
    return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  if (lists[CompileOnlyCommand] != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    return !lists[CompileOnlyCommand]->match(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   351
bool CompilerOracle::should_inline(const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  return (check_predicate(InlineCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   355
bool CompilerOracle::should_not_inline(const methodHandle& method) {
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   356
  return check_predicate(DontInlineCommand, method) || check_predicate(ExcludeCommand, method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   359
bool CompilerOracle::should_print(const methodHandle& method) {
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   360
  return check_predicate(PrintCommand, method);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
24658
e41df2fc6e87 8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents: 24424
diff changeset
   363
bool CompilerOracle::should_print_methods() {
e41df2fc6e87 8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents: 24424
diff changeset
   364
  return lists[PrintCommand] != NULL;
e41df2fc6e87 8042727: nsk/jdb/unwatch/unwatch001 crash in InstanceKlass::methods_do(void (*)(Method*))
coleenp
parents: 24424
diff changeset
   365
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   367
bool CompilerOracle::should_log(const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  if (!LogCompilation)            return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  if (lists[LogCommand] == NULL)  return true;  // by default, log all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  return (check_predicate(LogCommand, method));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33069
diff changeset
   373
bool CompilerOracle::should_break_at(const methodHandle& method) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  return check_predicate(BreakCommand, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
static OracleCommand parse_command_name(const char * line, int* bytes_read) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  assert(ARRAY_SIZE(command_names) == OracleCommandCount,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
         "command_names size mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  *bytes_read = 0;
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   382
  char command[33];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  int result = sscanf(line, "%32[a-z]%n", command, bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  for (uint i = 0; i < ARRAY_SIZE(command_names); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    if (strcmp(command, command_names[i]) == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      return (OracleCommand)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  return UnknownCommand;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
static void usage() {
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   393
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   394
  tty->print_cr("The CompileCommand option enables the user of the JVM to control specific");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   395
  tty->print_cr("behavior of the dynamic compilers. Many commands require a pattern that defines");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   396
  tty->print_cr("the set of methods the command shall be applied to. The CompileCommand");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   397
  tty->print_cr("option provides the following commands:");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  tty->cr();
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   399
  tty->print_cr("  break,<pattern>       - debug breakpoint in compiler and in generated code");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   400
  tty->print_cr("  print,<pattern>       - print assembly");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   401
  tty->print_cr("  exclude,<pattern>     - don't compile or inline");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   402
  tty->print_cr("  inline,<pattern>      - always inline");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   403
  tty->print_cr("  dontinline,<pattern>  - don't inline");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   404
  tty->print_cr("  compileonly,<pattern> - compile only");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   405
  tty->print_cr("  log,<pattern>         - log compilation");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   406
  tty->print_cr("  option,<pattern>,<option type>,<option name>,<value>");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   407
  tty->print_cr("                        - set value of custom option");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   408
  tty->print_cr("  option,<pattern>,<bool option name>");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   409
  tty->print_cr("                        - shorthand for setting boolean flag");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   410
  tty->print_cr("  quiet                 - silence the compile command output");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   411
  tty->print_cr("  help                  - print this text");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   412
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   413
  tty->print_cr("The preferred format for the method matching pattern is:");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   414
  tty->print_cr("  package/Class.method()");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   415
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   416
  tty->print_cr("For backward compatibility this form is also allowed:");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   417
  tty->print_cr("  package.Class::method()");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   418
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   419
  tty->print_cr("The signature can be separated by an optional whitespace or comma:");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   420
  tty->print_cr("  package/Class.method ()");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   421
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   422
  tty->print_cr("The class and method identifier can be used together with leading or");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   423
  tty->print_cr("trailing *'s for a small amount of wildcarding:");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   424
  tty->print_cr("  *ackage/Clas*.*etho*()");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   425
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   426
  tty->print_cr("It is possible to use more than one CompileCommand on the command line:");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   427
  tty->print_cr("  -XX:CompileCommand=exclude,java/*.* -XX:CompileCommand=log,java*.*");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  tty->cr();
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   429
  tty->print_cr("The CompileCommands can be loaded from a file with the flag");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   430
  tty->print_cr("-XX:CompileCommandFile=<file> or be added to the file '.hotspot_compiler'");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   431
  tty->print_cr("Use the same format in the file as the argument to the CompileCommand flag.");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   432
  tty->print_cr("Add one command on each line.");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   433
  tty->print_cr("  exclude java/*.*");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   434
  tty->print_cr("  option java/*.* ReplayInline");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   435
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   436
  tty->print_cr("The following commands have conflicting behavior: 'exclude', 'inline', 'dontinline',");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   437
  tty->print_cr("and 'compileonly'. There is no priority of commands. Applying (a subset of) these");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   438
  tty->print_cr("commands to the same method results in undefined behavior.");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   439
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   440
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   442
// 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
   443
// On failure, error_msg contains description for the first error.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   444
// For future extensions: set error_msg on first error.
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   445
static void scan_flag_and_value(const char* type, const char* line, int& total_bytes_read,
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   446
                                            TypedMethodOptionMatcher* matcher,
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   447
                                            char* errorbuf, const int buf_size) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   448
  total_bytes_read = 0;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   449
  int bytes_read = 0;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   450
  char flag[256];
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   451
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   452
  // Read flag name.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   453
  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
   454
    line += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   455
    total_bytes_read += bytes_read;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   456
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   457
    // Read value.
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   458
    if (strcmp(type, "intx") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   459
      intx value;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   460
      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
   461
        total_bytes_read += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   462
        add_option_string(matcher, flag, value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   463
        return;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   464
      } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   465
        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
   466
      }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   467
    } else if (strcmp(type, "uintx") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   468
      uintx value;
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   469
      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
   470
        total_bytes_read += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   471
        add_option_string(matcher, flag, value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   472
        return;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   473
      } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   474
        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
   475
      }
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   476
    } else if (strcmp(type, "ccstr") == 0) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   477
      ResourceMark rm;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   478
      char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   479
      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
   480
        total_bytes_read += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   481
        add_option_string(matcher, flag, (ccstr)value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   482
        return;
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   483
      } else {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   484
        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
   485
      }
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   486
    } else if (strcmp(type, "ccstrlist") == 0) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   487
      // Accumulates several strings into one. The internal type is ccstr.
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   488
      ResourceMark rm;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   489
      char* value = NEW_RESOURCE_ARRAY(char, strlen(line) + 1);
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   490
      char* next_value = value;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   491
      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
   492
        total_bytes_read += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   493
        line += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   494
        next_value += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   495
        char* end_value = next_value-1;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   496
        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
   497
          total_bytes_read += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   498
          line += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   499
          *end_value = ' '; // override '\0'
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   500
          next_value += bytes_read;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   501
          end_value = next_value-1;
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   502
        }
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   503
        add_option_string(matcher, flag, (ccstr)value);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   504
        return;
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   505
      } else {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   506
        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
   507
      }
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   508
    } else if (strcmp(type, "bool") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   509
      char value[256];
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   510
      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
   511
        if (strcmp(value, "true") == 0) {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   512
          total_bytes_read += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   513
          add_option_string(matcher, flag, true);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   514
          return;
26433
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   515
        } else if (strcmp(value, "false") == 0) {
27020fde2dbf 8056964: JDK-8055286 changes are incomplete.
kvn
parents: 26430
diff changeset
   516
          total_bytes_read += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   517
          add_option_string(matcher, flag, false);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   518
          return;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   519
        } else {
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   520
          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
   521
        }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   522
      } else {
31615
e48d94b97b6c 8130036: Fix problems with imprecise C++ coding.
goetz
parents: 30281
diff changeset
   523
        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   524
      }
27143
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   525
    } else if (strcmp(type, "double") == 0) {
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   526
      char buffer[2][256];
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   527
      // Decimal separator '.' has been replaced with ' ' or '/' earlier,
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   528
      // so read integer and fraction part of double value separately.
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   529
      if (sscanf(line, "%*[ \t]%255[0-9]%*[ /\t]%255[0-9]%n", buffer[0], buffer[1], &bytes_read) == 2) {
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   530
        char value[512] = "";
30281
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 28721
diff changeset
   531
        jio_snprintf(value, sizeof(value), "%s.%s", buffer[0], buffer[1]);
27143
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   532
        total_bytes_read += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   533
        add_option_string(matcher, flag, atof(value));
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   534
        return;
27143
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   535
      } else {
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   536
        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
feee4a6106bc 8059847: complement JDK-8055286 and JDK-8056964 changes
anoll
parents: 26441
diff changeset
   537
      }
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   538
    } else {
31615
e48d94b97b6c 8130036: Fix problems with imprecise C++ coding.
goetz
parents: 30281
diff changeset
   539
      jio_snprintf(errorbuf, buf_size, "  Type %s not supported ", type);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   540
    }
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   541
  } else {
31615
e48d94b97b6c 8130036: Fix problems with imprecise C++ coding.
goetz
parents: 30281
diff changeset
   542
    jio_snprintf(errorbuf, buf_size, "  Flag name for type %s should be alphanumeric ", type);
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   543
  }
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   544
  return;
26430
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
28721
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   547
int skip_whitespace(char* line) {
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   548
  // Skip any leading spaces
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   549
  int whitespace_read = 0;
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   550
  sscanf(line, "%*[ \t]%n", &whitespace_read);
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   551
  return whitespace_read;
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   552
}
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   553
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   554
void CompilerOracle::print_parse_error(const char*&  error_msg, char* original_line) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   555
  assert(error_msg != NULL, "Must have error_message");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   556
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   557
  ttyLocker ttyl;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   558
  tty->print_cr("CompileCommand: An error occurred during parsing");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   559
  tty->print_cr("Line: %s", original_line);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   560
  tty->print_cr("Error: %s", error_msg);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   561
  CompilerOracle::print_tip();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   562
}
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   563
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
void CompilerOracle::parse_from_line(char* line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  if (line[0] == '\0') return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  if (line[0] == '#')  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  char* original_line = line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  int bytes_read;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  OracleCommand command = parse_command_name(line, &bytes_read);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  line += bytes_read;
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   572
  ResourceMark rm;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   574
  if (command == UnknownCommand) {
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   575
    ttyLocker ttyl;
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   576
    tty->print_cr("CompileCommand: unrecognized command");
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   577
    tty->print_cr("  \"%s\"", original_line);
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   578
    CompilerOracle::print_tip();
7701
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   579
    return;
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   580
  }
766eb9258574 6765546: Wrong sscanf used to parse CompilerOracle command >= 32 characters could lead to crash
never
parents: 7397
diff changeset
   581
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  if (command == QuietCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    _quiet = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  if (command == HelpCommand) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   592
  const char* error_msg = NULL;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   593
  if (command == OptionCommand) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   594
    // Look for trailing options.
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   595
    //
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   596
    // Two types of trailing options are
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   597
    // supported:
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   598
    //
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   599
    // (1) CompileCommand=option,Klass::method,flag
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   600
    // (2) CompileCommand=option,Klass::method,type,flag,value
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   601
    //
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   602
    // Type (1) is used to enable a boolean flag for a method.
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   603
    //
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   604
    // Type (2) is used to support options with a value. Values can have the
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   605
    // the following types: intx, uintx, bool, ccstr, ccstrlist, and double.
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   606
    //
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   607
    // For future extensions: extend scan_flag_and_value()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   609
    char option[256]; // stores flag for Type (1) and type of Type (2)
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   610
    line++; // skip the ','
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   611
    TypedMethodOptionMatcher* archetype = TypedMethodOptionMatcher::parse_method_pattern(line, error_msg);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   612
    if (archetype == NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   613
      assert(error_msg != NULL, "Must have error_message");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   614
      print_parse_error(error_msg, original_line);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   615
      return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   618
    line += skip_whitespace(line);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   619
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   620
    // This is unnecessarily complex. Should retire multi-option lines and skip while loop
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   621
    while (sscanf(line, "%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   622
      line += bytes_read;
28721
b9655115bf4e 8069035: compiler/oracle/CheckCompileCommandOption.java nightly failure
neliasso
parents: 28720
diff changeset
   623
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   624
      // typed_matcher is used as a blueprint for each option, deleted at the end
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   625
      TypedMethodOptionMatcher* typed_matcher = archetype->clone();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   626
      if (strcmp(option, "intx") == 0
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   627
          || strcmp(option, "uintx") == 0
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   628
          || strcmp(option, "bool") == 0
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   629
          || strcmp(option, "ccstr") == 0
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   630
          || strcmp(option, "ccstrlist") == 0
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   631
          || strcmp(option, "double") == 0
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   632
          ) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   633
        char errorbuf[1024] = {0};
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   634
        // Type (2) option: parse flag name and value.
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   635
        scan_flag_and_value(option, line, bytes_read, typed_matcher, errorbuf, sizeof(errorbuf));
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   636
        if (*errorbuf != '\0') {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   637
          error_msg = errorbuf;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   638
          print_parse_error(error_msg, original_line);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   639
          return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
        line += bytes_read;
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   642
      } else {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   643
        // Type (1) option
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   644
        add_option_string(typed_matcher, option, true);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   645
      }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   646
      if (typed_matcher != NULL && !_quiet) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   647
        // Print out the last match added
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   648
        assert(error_msg == NULL, "No error here");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   649
        ttyLocker ttyl;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   650
        tty->print("CompileCommand: %s ", command_names[command]);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   651
        typed_matcher->print();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   652
      }
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   653
      line += skip_whitespace(line);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   654
    } // while(
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   655
    delete archetype;
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   656
  } else {  // not an OptionCommand)
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   657
    assert(error_msg == NULL, "Don't call here with error_msg already set");
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   658
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   659
    BasicMatcher* matcher = BasicMatcher::parse_method_pattern(line, error_msg);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   660
    if (error_msg != NULL) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   661
      assert(matcher == NULL, "consistency");
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   662
      print_parse_error(error_msg, original_line);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   663
      return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   666
    add_predicate(command, matcher);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   667
    if (!_quiet) {
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   668
      ttyLocker ttyl;
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   669
      tty->print("CompileCommand: %s ", command_names[command]);
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   670
      matcher->print(tty);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   671
      tty->cr();
26430
7f20c536cd5b 8055286: Extend CompileCommand=option to handle numeric parameters
zmajo
parents: 25949
diff changeset
   672
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
28496
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   676
void CompilerOracle::print_tip() {
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   677
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   678
  tty->print_cr("Usage: '-XX:CompileCommand=command,\"package/Class.method()\"'");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   679
  tty->print_cr("Use:   '-XX:CompileCommand=help' for more information.");
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   680
  tty->cr();
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   681
}
f9753412d4f5 8027829: CompileCommand does not accept all JLS-conformant class/method names
neliasso
parents: 27143
diff changeset
   682
13194
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   683
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
   684
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
static const char* cc_file() {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   686
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  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
   688
    return default_cc_file;
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   689
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  return CompileCommandFile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
}
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   692
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   693
bool CompilerOracle::has_command_file() {
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   694
  return cc_file() != NULL;
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   695
}
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   696
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
bool CompilerOracle::_quiet = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
void CompilerOracle::parse_from_file() {
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   700
  assert(has_command_file(), "command file must be specified");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  FILE* stream = fopen(cc_file(), "rt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  if (stream == NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  char token[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  int  pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
  int  c = getc(stream);
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents: 14138
diff changeset
   707
  while(c != EOF && pos < (int)(sizeof(token)-1)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    if (c == '\n') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
      token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
      parse_from_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
      pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
      token[pos++] = c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
    c = getc(stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  parse_from_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  fclose(stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  char token[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  int  pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  const char* sp = str;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  int  c = *sp++;
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents: 14138
diff changeset
   728
  while (c != '\0' && pos < (int)(sizeof(token)-1)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
    if (c == '\n') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
      token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
      parse_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
      pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
      token[pos++] = c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    c = *sp++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  token[pos++] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  parse_line(token);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
void compilerOracle_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  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
   745
  if (CompilerOracle::has_command_file()) {
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   746
    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
   747
  } else {
603ef19adcb8 7167142: Consider a warning when finding a .hotspotrc or .hotspot_compiler file that isn't used
kamg
parents: 12981
diff changeset
   748
    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
   749
    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
   750
      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
   751
              "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
   752
              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
   753
    }
12981
b557c10f5444 7110720: Issue with vm config file loadingIssue with vm config file loading
kamg
parents: 8921
diff changeset
   754
  }
4584
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   755
  if (lists[PrintCommand] != NULL) {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   756
    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
   757
      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
   758
    } else if (FLAG_IS_DEFAULT(DebugNonSafepoints)) {
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   759
      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
   760
      DebugNonSafepoints = true;
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   761
    }
e2a449e8cc6f 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 1
diff changeset
   762
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
void CompilerOracle::parse_compile_only(char * line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  char name[1024];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  const char* className = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  const char* methodName = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  bool have_colon = (strstr(line, "::") != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  char method_sep = have_colon ? ':' : '.';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  if (Verbose) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23185
diff changeset
   776
    tty->print_cr("%s", line);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  while (*line != '\0') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
    MethodMatcher::Mode c_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
    MethodMatcher::Mode m_match = MethodMatcher::Exact;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    for (i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
         i < 1024 && *line != '\0' && *line != method_sep && *line != ',' && !isspace(*line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
         line++, i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
      name[i] = *line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
      if (name[i] == '.')  name[i] = '/';  // package prefix uses '/'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    if (i > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
      char* newName = NEW_RESOURCE_ARRAY( char, i + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
      if (newName == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
        return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
      strncpy(newName, name, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
      newName[i] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
        className = newName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
        methodName = newName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    if (*line == method_sep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
        className = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
        c_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
      // got foo or foo/bar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
      if (className == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
      } else {
40079
40d48ddc12bc 8071652: -XX:CompileOnly does not behave as documented
dpochepk
parents: 35138
diff changeset
   815
        // missing class name handled as "Any" class match
40d48ddc12bc 8071652: -XX:CompileOnly does not behave as documented
dpochepk
parents: 35138
diff changeset
   816
        if (className[0] == '\0') {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
          c_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
    // each directive is terminated by , or NUL or . followed by NUL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    if (*line == ',' || *line == '\0' || (line[0] == '.' && line[1] == '\0')) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
      if (methodName == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
        methodName = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
        if (*line != method_sep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
          m_match = MethodMatcher::Any;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
      EXCEPTION_MARK;
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   832
      Symbol* c_name = SymbolTable::new_symbol(className);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   833
      Symbol* m_name = SymbolTable::new_symbol(methodName);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7701
diff changeset
   834
      Symbol* signature = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   836
      BasicMatcher* bm = new BasicMatcher();
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   837
      bm->init(c_name, c_match, m_name, m_match, signature);
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   838
      add_predicate(CompileOnlyCommand, bm);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
      if (PrintVMOptions) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
        tty->print("CompileOnly: compileonly ");
33069
d8eed614f298 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 31615
diff changeset
   841
        lists[CompileOnlyCommand]->print_all(tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
      className = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
      methodName = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
    line = *line == '\0' ? line : line + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
}