hotspot/src/share/vm/compiler/compilerDirectives.cpp
author neliasso
Wed, 09 Dec 2015 13:37:59 +0100
changeset 35131 d231aa9f57ba
parent 35130 223598d44a8b
child 35141 3cddc2b46986
permissions -rw-r--r--
8144091: CompilerControl: directive file doesn't override inlining rules Summary: Fix correct overrides Reviewed-by: roland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     1
/*
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
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
#include "precompiled.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    26
#include "ci/ciMethod.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    27
#include "ci/ciUtilities.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    28
#include "compiler/abstractCompiler.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
#include "compiler/compilerOracle.hpp"
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    31
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    32
CompilerDirectives::CompilerDirectives() :_match(NULL), _next(NULL), _ref_count(0) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    33
  _c1_store = new DirectiveSet(this);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    34
  _c2_store = new DirectiveSet(this);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    35
};
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    36
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    37
CompilerDirectives::~CompilerDirectives() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    38
  if (_c1_store != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    39
    delete _c1_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    40
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    41
  if (_c2_store != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    42
    delete _c2_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    43
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    44
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    45
  // remove all linked method matchers
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    46
  BasicMatcher* tmp = _match;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    47
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    48
    BasicMatcher* next = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    49
    delete tmp;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    50
    tmp = next;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    51
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    52
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    53
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    54
void CompilerDirectives::print(outputStream* st) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    55
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    56
  if (_match != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    57
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    58
    st->print("Directive:");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    59
    if (is_default_directive()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    60
      st->print_cr(" (default)");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    61
    } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    62
      st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    63
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    64
    st->print(" matching: ");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    65
    _match->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    66
    BasicMatcher* tmp = _match->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    67
    while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    68
      st->print(", ");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    69
      tmp->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    70
      tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    71
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    72
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    73
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    74
    assert(0, "There should always be a match");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    75
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    76
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    77
  if (_c1_store != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    78
    st->print_cr(" c1 directives:");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    79
    _c1_store->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    80
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    81
  if (_c2_store != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    82
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    83
    st->print_cr(" c2 directives:");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    84
    _c2_store->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    85
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    86
  //---
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    87
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    88
35130
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
    89
void CompilerDirectives::finalize(outputStream* st) {
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    90
  if (_c1_store != NULL) {
35130
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
    91
    _c1_store->finalize(st);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    92
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    93
  if (_c2_store != NULL) {
35130
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
    94
    _c2_store->finalize(st);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    95
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    96
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    97
35130
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
    98
void DirectiveSet::finalize(outputStream* st) {
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
    99
  // Check LogOption and warn
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   100
  if (LogOption && !LogCompilation) {
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   101
    st->print_cr("Warning:  +LogCompilation must be set to enable compilation logging from directives");
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   102
  }
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   103
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   104
  // if any flag has been modified - set directive as enabled
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   105
  // unless it already has been explicitly set.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   106
  if (!_modified[EnableIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   107
    if (_inlinematchers != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   108
      EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   109
      return;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   110
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   111
    int i;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   112
    for (i = 0; i < number_of_flags; i++) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   113
      if (_modified[i]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   114
        EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   115
        return;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   116
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   117
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   118
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   119
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   120
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   121
CompilerDirectives* CompilerDirectives::next() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   122
  return _next;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   123
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   124
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   125
bool CompilerDirectives::match(methodHandle method) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   126
  if (is_default_directive()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   127
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   128
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   129
  if (method == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   130
    return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   131
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   132
  if (_match->match(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   133
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   134
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   135
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   136
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   137
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   138
bool CompilerDirectives::add_match(char* str, const char*& error_msg) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   139
  BasicMatcher* bm = BasicMatcher::parse_method_pattern(str, error_msg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   140
  if (bm == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   141
    assert(error_msg != NULL, "Must have error message");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   142
    return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   143
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   144
    bm->set_next(_match);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   145
    _match = bm;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   146
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   147
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   148
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   149
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   150
void CompilerDirectives::inc_refcount() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   151
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   152
  _ref_count++;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   153
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   154
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   155
void CompilerDirectives::dec_refcount() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   156
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   157
  _ref_count--;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   158
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   159
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   160
int CompilerDirectives::refcount() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   161
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   162
  return _ref_count;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   163
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   164
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   165
DirectiveSet* CompilerDirectives::get_for(AbstractCompiler *comp) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   166
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   167
  inc_refcount(); // The compiling thread is responsible to decrement this when finished.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   168
  if (comp == NULL) { // Xint
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   169
    return _c1_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   170
  } else if (comp->is_c2()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   171
    return _c2_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   172
  } else if (comp->is_c1()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   173
    return _c1_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   174
  } else if (comp->is_shark()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   175
    return NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   176
  } else if (comp->is_jvmci()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   177
    return NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   178
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   179
  ShouldNotReachHere();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   180
  return NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   181
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   182
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   183
// In the list of disabled intrinsics, the ID of the disabled intrinsics can separated:
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   184
// - by ',' (if -XX:DisableIntrinsic is used once when invoking the VM) or
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   185
// - by '\n' (if -XX:DisableIntrinsic is used multiple times when invoking the VM) or
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   186
// - by ' ' (if DisableIntrinsic is used on a per-method level, e.g., with CompileCommand).
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   187
//
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   188
// To simplify the processing of the list, the canonicalize_disableintrinsic() method
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   189
// returns a new copy of the list in which '\n' and ' ' is replaced with ','.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   190
ccstrlist DirectiveSet::canonicalize_disableintrinsic(ccstrlist option_value) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   191
  char* canonicalized_list = NEW_C_HEAP_ARRAY(char, strlen(option_value) + 1, mtCompiler);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   192
  int i = 0;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   193
  char current;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   194
  while ((current = option_value[i]) != '\0') {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   195
    if (current == '\n' || current == ' ') {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   196
      canonicalized_list[i] = ',';
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   197
    } else {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   198
      canonicalized_list[i] = current;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   199
    }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   200
    i++;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   201
  }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   202
  canonicalized_list[i] = '\0';
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   203
  return canonicalized_list;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   204
}
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   205
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   206
DirectiveSet::DirectiveSet(CompilerDirectives* d) :_inlinematchers(NULL), _directive(d) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   207
#define init_defaults_definition(name, type, dvalue, compiler) this->name##Option = dvalue;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   208
  compilerdirectives_common_flags(init_defaults_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   209
  compilerdirectives_c2_flags(init_defaults_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   210
  compilerdirectives_c1_flags(init_defaults_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   211
  memset(_modified, 0, sizeof _modified);
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   212
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   213
  // Canonicalize DisableIntrinsic to contain only ',' as a separator.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   214
  this->DisableIntrinsicOption = canonicalize_disableintrinsic(DisableIntrinsic);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   215
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   216
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   217
DirectiveSet::~DirectiveSet() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   218
  // remove all linked methodmatchers
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   219
  InlineMatcher* tmp = _inlinematchers;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   220
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   221
    InlineMatcher* next = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   222
    delete tmp;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   223
    tmp = next;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   224
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   225
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   226
  // When constructed, DirectiveSet canonicalizes the DisableIntrinsic flag
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   227
  // into a new string. Therefore, that string is deallocated when
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   228
  // the DirectiveSet is destroyed.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   229
  assert(this->DisableIntrinsicOption != NULL, "");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   230
  FREE_C_HEAP_ARRAY(char, (void *)this->DisableIntrinsicOption);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   231
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   232
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   233
// Backward compatibility for CompileCommands
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   234
// Breaks the abstraction and causes lots of extra complexity
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   235
// - if some option is changed we need to copy directiveset since it no longer can be shared
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   236
// - Need to free copy after use
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   237
// - Requires a modified bit so we don't overwrite options that is set by directives
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   238
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   239
DirectiveSet* DirectiveSet::compilecommand_compatibility_init(methodHandle method) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   240
  // Early bail out - checking all options is expensive - we rely on them not being used
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   241
  // Only set a flag if it has not been modified and value changes.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   242
  // Only copy set if a flag needs to be set
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   243
  if (!CompilerDirectivesIgnoreCompileCommandsOption && CompilerOracle::has_any_option()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   244
    DirectiveSet* set = DirectiveSet::clone(this);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   245
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   246
    bool changed = false; // Track if we actually change anything
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   247
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   248
    // All CompileCommands are not equal so this gets a bit verbose
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   249
    // When CompileCommands have been refactored less clutter will remain.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   250
    if (CompilerOracle::should_break_at(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   251
      if (!_modified[BreakAtCompileIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   252
        set->BreakAtCompileOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   253
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   254
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   255
      if (!_modified[BreakAtExecuteIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   256
        set->BreakAtExecuteOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   257
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   258
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   259
    }
35130
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   260
    if (!_modified[LogIndex]) {
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   261
      bool log = CompilerOracle::should_log(method);
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   262
      if (log != set->LogOption) {
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   263
        set->LogOption = log;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   264
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   265
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   266
    }
35130
223598d44a8b 8145345: LogCompilation output is empty after JEP165: Compiler Control
neliasso
parents: 35129
diff changeset
   267
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   268
    if (CompilerOracle::should_print(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   269
      if (!_modified[PrintAssemblyIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   270
        set->PrintAssemblyOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   271
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   272
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   273
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   274
    // Exclude as in should not compile == Enabled
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   275
    if (CompilerOracle::should_exclude(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   276
      if (!_modified[ExcludeIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   277
        set->ExcludeOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   278
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   279
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   280
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   281
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   282
    // inline and dontinline (including exclude) are implemented in the directiveset accessors
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   283
#define init_default_cc(name, type, dvalue, cc_flag) { type v; if (!_modified[name##Index] && CompilerOracle::has_option_value(method, #cc_flag, v) && v != this->name##Option) { set->name##Option = v; changed = true;} }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   284
    compilerdirectives_common_flags(init_default_cc)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   285
    compilerdirectives_c2_flags(init_default_cc)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   286
    compilerdirectives_c1_flags(init_default_cc)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   287
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   288
    // Canonicalize DisableIntrinsic to contain only ',' as a separator.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   289
    ccstrlist option_value;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   290
    if (!_modified[DisableIntrinsicIndex] &&
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   291
        CompilerOracle::has_option_value(method, "DisableIntrinsic", option_value)) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   292
      set->DisableIntrinsicOption = canonicalize_disableintrinsic(option_value);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   293
    }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   294
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   295
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   296
    if (!changed) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   297
      // We didn't actually update anything, discard.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   298
      delete set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   299
    } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   300
      // We are returning a (parentless) copy. The originals parent don't need to account for this.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   301
      DirectivesStack::release(this);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   302
      return set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   303
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   304
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   305
  // Nothing changed
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   306
  return this;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   307
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   308
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   309
CompilerDirectives* DirectiveSet::directive() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   310
  assert(_directive != NULL, "Must have been initialized");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   311
  return _directive;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   312
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   313
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   314
bool DirectiveSet::matches_inline(methodHandle method, int inline_action) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   315
  if (_inlinematchers != NULL) {
35131
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   316
    if (_inlinematchers->match(method, inline_action)) {
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   317
      return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   318
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   319
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   320
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   321
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   322
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   323
bool DirectiveSet::should_inline(ciMethod* inlinee) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   324
  inlinee->check_is_loaded();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   325
  VM_ENTRY_MARK;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   326
  methodHandle mh(THREAD, inlinee->get_Method());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   327
35131
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   328
  if (_inlinematchers != NULL) {
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   329
    return matches_inline(mh, InlineMatcher::force_inline);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   330
  }
35131
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   331
  if (!CompilerDirectivesIgnoreCompileCommandsOption) {
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   332
    return CompilerOracle::should_inline(mh);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   333
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   334
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   335
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   336
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   337
bool DirectiveSet::should_not_inline(ciMethod* inlinee) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   338
  inlinee->check_is_loaded();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   339
  VM_ENTRY_MARK;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   340
  methodHandle mh(THREAD, inlinee->get_Method());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   341
35131
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   342
  if (_inlinematchers != NULL) {
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   343
    return matches_inline(mh, InlineMatcher::dont_inline);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   344
  }
35131
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   345
  if (!CompilerDirectivesIgnoreCompileCommandsOption) {
d231aa9f57ba 8144091: CompilerControl: directive file doesn't override inlining rules
neliasso
parents: 35130
diff changeset
   346
    return CompilerOracle::should_not_inline(mh);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   347
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   348
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   349
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   350
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   351
bool DirectiveSet::parse_and_add_inline(char* str, const char*& error_msg) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   352
  InlineMatcher* m = InlineMatcher::parse_inline_pattern(str, error_msg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   353
  if (m != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   354
    // add matcher last in chain - the order is significant
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   355
    append_inline(m);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   356
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   357
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   358
    assert(error_msg != NULL, "Error message must be set");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   359
    return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   360
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   361
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   362
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   363
void DirectiveSet::append_inline(InlineMatcher* m) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   364
  if (_inlinematchers == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   365
    _inlinematchers = m;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   366
    return;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   367
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   368
  InlineMatcher* tmp = _inlinematchers;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   369
  while (tmp->next() != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   370
    tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   371
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   372
  tmp->set_next(m);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   373
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   374
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   375
void DirectiveSet::print_inline(outputStream* st) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   376
  if (_inlinematchers == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   377
    st->print_cr("  inline: -");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   378
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   379
    st->print("  inline: ");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   380
    _inlinematchers->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   381
    InlineMatcher* tmp = _inlinematchers->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   382
    while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   383
      st->print(", ");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   384
      tmp->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   385
      tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   386
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   387
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   388
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   389
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   390
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   391
bool DirectiveSet::is_intrinsic_disabled(methodHandle method) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   392
  vmIntrinsics::ID id = method->intrinsic_id();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   393
  assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   394
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   395
  ResourceMark rm;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   396
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   397
  // Create a copy of the string that contains the list of disabled
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   398
  // intrinsics. The copy is created because the string
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   399
  // will be modified by strtok(). Then, the list is tokenized with
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   400
  // ',' as a separator.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   401
  size_t length = strlen(DisableIntrinsicOption);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   402
  char* local_list = NEW_RESOURCE_ARRAY(char, length + 1);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   403
  strncpy(local_list, DisableIntrinsicOption, length + 1);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   404
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   405
  char* token = strtok(local_list, ",");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   406
  while (token != NULL) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   407
    if (strcmp(token, vmIntrinsics::name_at(id)) == 0) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   408
      return true;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   409
    } else {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   410
      token = strtok(NULL, ",");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   411
    }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   412
  }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   413
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   414
  return false;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   415
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   416
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   417
DirectiveSet* DirectiveSet::clone(DirectiveSet const* src) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   418
  DirectiveSet* set = new DirectiveSet(NULL);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   419
  memcpy(set->_modified, src->_modified, sizeof(src->_modified));
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   420
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   421
  InlineMatcher* tmp = src->_inlinematchers;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   422
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   423
    set->append_inline(tmp->clone());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   424
    tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   425
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   426
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   427
  #define copy_members_definition(name, type, dvalue, cc_flag) set->name##Option = src->name##Option;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   428
    compilerdirectives_common_flags(copy_members_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   429
    compilerdirectives_c2_flags(copy_members_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   430
    compilerdirectives_c1_flags(copy_members_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   431
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   432
  // Create a local copy of the DisableIntrinsicOption.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   433
  assert(src->DisableIntrinsicOption != NULL, "");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   434
  size_t len = strlen(src->DisableIntrinsicOption) + 1;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   435
  char* s = NEW_C_HEAP_ARRAY(char, len, mtCompiler);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   436
  strncpy(s, src->DisableIntrinsicOption, len);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   437
  assert(s[len-1] == '\0', "");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   438
  set->DisableIntrinsicOption = s;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   439
  return set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   440
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   441
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   442
// Create a new dirstack and push a default directive
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   443
void DirectivesStack::init() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   444
  CompilerDirectives* _default_directives = new CompilerDirectives();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   445
  char str[] = "*.*";
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   446
  const char* error_msg = NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   447
  _default_directives->add_match(str, error_msg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   448
#ifdef COMPILER1
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   449
  _default_directives->_c1_store->EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   450
#endif
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   451
#ifdef COMPILER2
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   452
  _default_directives->_c2_store->EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   453
#endif
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   454
  assert(error_msg == NULL, "Must succeed.");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   455
  push(_default_directives);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   456
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   457
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   458
DirectiveSet* DirectivesStack::getDefaultDirective(AbstractCompiler* comp) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   459
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   460
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   461
  assert(_bottom != NULL, "Must never be empty");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   462
  return _bottom->get_for(comp);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   463
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   464
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   465
void DirectivesStack::push(CompilerDirectives* directive) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   466
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   467
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   468
  directive->inc_refcount();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   469
  if (_top == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   470
    assert(_bottom == NULL, "There can only be one default directive");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   471
    _bottom = directive; // default directive, can never be removed.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   472
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   473
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   474
  directive->set_next(_top);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   475
  _top = directive;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   476
  _depth++;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   477
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   478
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   479
void DirectivesStack::pop() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   480
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   481
  pop_inner();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   482
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   483
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   484
void DirectivesStack::pop_inner() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   485
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   486
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   487
  if (_top->next() == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   488
    return; // Do nothing - don't allow an empty stack
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   489
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   490
  CompilerDirectives* tmp = _top;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   491
  _top = _top->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   492
  _depth--;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   493
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   494
  DirectivesStack::release(tmp);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   495
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   496
35129
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   497
bool DirectivesStack::check_capacity(int request_size, outputStream* st) {
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   498
  if ((request_size + _depth) > CompilerDirectivesLimit) {
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   499
    st->print_cr("Could not add %i more directives. Currently %i/%i directives.", request_size, _depth, CompilerDirectivesLimit);
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   500
    return false;
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   501
  }
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   502
  return true;
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   503
}
8b93709bf4e5 8144246: adding lots of directives via jcmd may produce OOM crash
neliasso
parents: 34191
diff changeset
   504
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   505
void DirectivesStack::clear() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   506
  // holding the lock during the whole operation ensuring consistent result
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   507
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   508
  while (_top->next() != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   509
    pop_inner();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   510
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   511
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   512
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   513
void DirectivesStack::print(outputStream* st) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   514
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   515
  CompilerDirectives* tmp = _top;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   516
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   517
    tmp->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   518
    tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   519
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   520
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   521
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   522
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   523
void DirectivesStack::release(DirectiveSet* set) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   524
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   525
  if (set->is_exclusive_copy()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   526
    // Old CompilecCmmands forced us to create an exclusive copy
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   527
    delete set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   528
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   529
    assert(set->directive() != NULL, "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   530
    release(set->directive());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   531
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   532
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   533
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   534
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   535
void DirectivesStack::release(CompilerDirectives* dir) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   536
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   537
  dir->dec_refcount();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   538
  if (dir->refcount() == 0) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   539
    delete dir;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   540
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   541
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   542
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   543
DirectiveSet* DirectivesStack::getMatchingDirective(methodHandle method, AbstractCompiler *comp) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   544
  assert(_depth > 0, "Must never be empty");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   545
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   546
  DirectiveSet* match = NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   547
  {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   548
    MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
34191
8287a25df277 8141585: CompilerDirectivesDCMDTest intermittently SEGVs in MethodMatcher::matcher
neliasso
parents: 33480
diff changeset
   549
8287a25df277 8141585: CompilerDirectivesDCMDTest intermittently SEGVs in MethodMatcher::matcher
neliasso
parents: 33480
diff changeset
   550
    CompilerDirectives* dir = _top;
8287a25df277 8141585: CompilerDirectivesDCMDTest intermittently SEGVs in MethodMatcher::matcher
neliasso
parents: 33480
diff changeset
   551
    assert(dir != NULL, "Must be initialized");
8287a25df277 8141585: CompilerDirectivesDCMDTest intermittently SEGVs in MethodMatcher::matcher
neliasso
parents: 33480
diff changeset
   552
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   553
    while (dir != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   554
      if (dir->is_default_directive() || dir->match(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   555
        match = dir->get_for(comp);
33479
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   556
        if (match == NULL) {
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   557
          // temporary workaround for compilers without directives.
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   558
          if (dir->is_default_directive()) {
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   559
            // default dir is always enabled
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   560
            // match c1 store - it contains all common flags even if C1 is unavailable
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   561
            match = dir->_c1_store;
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   562
            break;
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   563
          }
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   564
        }
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   565
        if (match->EnableOption) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   566
          // The directiveSet for this compile is also enabled -> success
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   567
          break;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   568
        }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   569
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   570
      dir = dir->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   571
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   572
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   573
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   574
  guarantee(match != NULL, "There should always be a default directive that matches");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   575
  // Check for legacy compile commands update, without DirectivesStack_lock
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   576
  return match->compilecommand_compatibility_init(method);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   577
}