src/hotspot/share/compiler/directivesParser.hpp
author iklam
Mon, 20 Aug 2018 13:58:23 -0700
changeset 51467 12997ebbc0d8
parent 47216 71c04702a3d5
child 52290 db83eceba962
permissions -rw-r--r--
8209647: constantPoolHandle::constantPoolHandle(ConstantPool*) when precompiled header is disabled Summary: Added fieldDescriptor.inline.hpp Reviewed-by: coleenp, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     1
/*
36597
ee256e343585 8150646: Add support for blocking compiles though whitebox API
simonis
parents: 35529
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     4
 *
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     8
 *
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    13
 * accompanied this code).
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    14
 *
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    18
 *
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    21
 * questions.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    22
 *
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    23
 */
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    24
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    25
#ifndef SHARE_VM_COMPILER_DIRECTIVESPARSER_HPP
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    26
#define SHARE_VM_COMPILER_DIRECTIVESPARSER_HPP
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    27
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    28
#include "utilities/json.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    29
#include "compiler/compilerDirectives.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    30
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    31
enum FlagType {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    32
  boolFlag,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    33
  intxFlag,
42617
9ac2fe949f27 8170416: CompilerControl: VectorizeDebug option type is incorrect
kvn
parents: 38113
diff changeset
    34
  uintxFlag,
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    35
  doubleFlag,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    36
  ccstrFlag,
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33451
diff changeset
    37
  ccstrlistFlag,
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    38
  UnknownFlagType
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    39
};
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    40
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    41
static const char* flag_type_names[] = {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    42
    "bool",
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    43
    "int",
42617
9ac2fe949f27 8170416: CompilerControl: VectorizeDebug option type is incorrect
kvn
parents: 38113
diff changeset
    44
    "uint",
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    45
    "double",
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    46
    "string",
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33451
diff changeset
    47
    "string list",
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    48
    "unknown"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    49
};
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    50
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    51
class DirectivesParser : public JSON {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    52
public:
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    53
  static bool has_file();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    54
  static bool parse_from_flag();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    55
  static bool parse_from_file(const char* filename, outputStream* st);
36597
ee256e343585 8150646: Add support for blocking compiles though whitebox API
simonis
parents: 35529
diff changeset
    56
  static int  parse_string(const char* string, outputStream* st);
ee256e343585 8150646: Add support for blocking compiles though whitebox API
simonis
parents: 35529
diff changeset
    57
  int install_directives();
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    58
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    59
private:
38113
0df3b8f87cca 8155206: Internal VM test DirectiveParser_test is too verbose
stefank
parents: 36597
diff changeset
    60
  DirectivesParser(const char* text, outputStream* st, bool silent);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    61
  ~DirectivesParser();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    62
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    63
  bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    64
  static bool parse_from_file_inner(const char* filename, outputStream* st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    65
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    66
  // types of "keys". i.e recognized <key>:<value> pairs in our JSON syntax
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    67
  typedef enum {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    68
     type_c1,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    69
     type_c2,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    70
     type_enable,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    71
     type_preset,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    72
     type_match,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    73
     type_inline,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    74
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    75
     // After here, there is no correlation between
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    76
     // keytype and keys array
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    77
     //type_strategy,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    78
     type_flag,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    79
     //type_dir,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    80
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    81
     // Synthetic.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    82
     type_dir_array,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    83
     type_directives,
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    84
     type_value_array
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    85
  } keytype;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    86
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    87
  // name, type, dtd info and maybe a setter
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    88
  // this is how we map key-values
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    89
  typedef struct {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    90
     const char *name;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    91
     keytype     type;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    92
     uint    allow_array_value : 1;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    93
     uint    allowedmask;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    94
     void (DirectiveSet::*set)(void* arg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    95
     FlagType flag_type;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    96
  } key;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    97
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    98
  // Array with valid keys for the directive file
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    99
  static const key keys[];
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   100
  // Marker for outermost moosewings/array
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   101
  static const key dir_array_key;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   102
  // Marker for a directives set (these are "implicit" objects, as in not named)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   103
  static const key dir_key;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   104
  // Marker for a multi value
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   105
  static const key value_array_key;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   106
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   107
  // A compiler directive shouldn't be able to use more than 5 stack slots.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   108
  // Example of max stack usage:
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   109
  // depth 1: type_dir_array  [
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   110
  // depth 2: type_directives   {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   111
  // depth 3: type_c1             c1: {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   112
  // depth 4: type_inline           inline:
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   113
  // depth 5: type_value_array      [ ...
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   114
  static const uint MAX_DEPTH = 5;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   115
  const key* stack[MAX_DEPTH];
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   116
  uint depth;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   117
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   118
  bool push_key(const char* str, size_t len);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   119
  bool push_key(const key* k);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   120
  const key* current_key();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   121
  const key* pop_key();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   122
  static const key* lookup_key(const char* s, size_t len);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   123
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   124
  bool set_option(JSON_TYPE t, JSON_VAL* v);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   125
  bool set_option_flag(JSON_TYPE t, JSON_VAL* v, const key* option_key, DirectiveSet* set);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   126
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   127
  CompilerDirectives* current_directive;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   128
  DirectiveSet*       current_directiveset;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   129
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   130
  void push_tmp(CompilerDirectives* dir);
35129
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 33480
diff changeset
   131
  void clean_tmp();
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   132
  CompilerDirectives* pop_tmp();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   133
  CompilerDirectives* _tmp_top; // temporary storage for dirs while parsing
35129
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 33480
diff changeset
   134
  int _tmp_depth;               // Number of directives that has been parsed but not installed.
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   135
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   136
  static uint mask(keytype kt);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   137
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   138
#ifndef PRODUCT
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   139
  static void test(const char* json, bool valid);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   140
public:
35529
39376b4613b5 8147012: Fix includes in internalVMTests.cpp
ehelin
parents: 35129
diff changeset
   141
  static void test();
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   142
#endif
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   143
};
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   144
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   145
#endif // SHARE_VM_COMPILER_DIRECTIVESPARSER_HPP