hotspot/src/share/vm/compiler/compilerDirectives.cpp
author zmajo
Thu, 29 Oct 2015 09:24:00 +0100
changeset 33480 e4cef6796874
parent 33479 2f62e0833ea2
child 34191 8287a25df277
permissions -rw-r--r--
8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly Summary: Improve parsing of DisableIntrinsic flag. Reviewed-by: kvn, shade, neliasso
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
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    89
void CompilerDirectives::finalize() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    90
  if (_c1_store != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    91
    _c1_store->finalize();
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) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    94
    _c2_store->finalize();
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
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    98
void DirectiveSet::finalize() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
    99
  // if any flag has been modified - set directive as enabled
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   100
  // unless it already has been explicitly set.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   101
  if (!_modified[EnableIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   102
    if (_inlinematchers != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   103
      EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   104
      return;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   105
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   106
    int i;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   107
    for (i = 0; i < number_of_flags; i++) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   108
      if (_modified[i]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   109
        EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   110
        return;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   111
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   112
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   113
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   114
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   115
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   116
CompilerDirectives* CompilerDirectives::next() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   117
  return _next;
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
bool CompilerDirectives::match(methodHandle method) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   121
  if (is_default_directive()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   122
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   123
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   124
  if (method == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   125
    return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   126
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   127
  if (_match->match(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   128
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   129
  }
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
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   133
bool CompilerDirectives::add_match(char* str, const char*& error_msg) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   134
  BasicMatcher* bm = BasicMatcher::parse_method_pattern(str, error_msg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   135
  if (bm == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   136
    assert(error_msg != NULL, "Must have error message");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   137
    return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   138
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   139
    bm->set_next(_match);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   140
    _match = bm;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   141
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   142
  }
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
void CompilerDirectives::inc_refcount() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   146
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   147
  _ref_count++;
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::dec_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
int CompilerDirectives::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
  return _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
DirectiveSet* CompilerDirectives::get_for(AbstractCompiler *comp) {
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
  inc_refcount(); // The compiling thread is responsible to decrement this when finished.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   163
  if (comp == NULL) { // Xint
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   164
    return _c1_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   165
  } else if (comp->is_c2()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   166
    return _c2_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   167
  } else if (comp->is_c1()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   168
    return _c1_store;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   169
  } else if (comp->is_shark()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   170
    return NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   171
  } else if (comp->is_jvmci()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   172
    return NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   173
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   174
  ShouldNotReachHere();
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
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   177
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   178
// 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
   179
// - 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
   180
// - 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
   181
// - 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
   182
//
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   183
// To simplify the processing of the list, the canonicalize_disableintrinsic() method
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   184
// 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
   185
ccstrlist DirectiveSet::canonicalize_disableintrinsic(ccstrlist option_value) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   186
  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
   187
  int i = 0;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   188
  char current;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   189
  while ((current = option_value[i]) != '\0') {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   190
    if (current == '\n' || current == ' ') {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   191
      canonicalized_list[i] = ',';
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   192
    } else {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   193
      canonicalized_list[i] = current;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   194
    }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   195
    i++;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   196
  }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   197
  canonicalized_list[i] = '\0';
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   198
  return canonicalized_list;
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
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   201
DirectiveSet::DirectiveSet(CompilerDirectives* d) :_inlinematchers(NULL), _directive(d) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   202
#define init_defaults_definition(name, type, dvalue, compiler) this->name##Option = dvalue;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   203
  compilerdirectives_common_flags(init_defaults_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   204
  compilerdirectives_c2_flags(init_defaults_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   205
  compilerdirectives_c1_flags(init_defaults_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   206
  memset(_modified, 0, sizeof _modified);
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   207
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   208
  // Canonicalize DisableIntrinsic to contain only ',' as a separator.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   209
  this->DisableIntrinsicOption = canonicalize_disableintrinsic(DisableIntrinsic);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   210
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   211
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   212
DirectiveSet::~DirectiveSet() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   213
  // remove all linked methodmatchers
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   214
  InlineMatcher* tmp = _inlinematchers;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   215
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   216
    InlineMatcher* next = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   217
    delete tmp;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   218
    tmp = next;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   219
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   220
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   221
  // When constructed, DirectiveSet canonicalizes the DisableIntrinsic flag
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   222
  // into a new string. Therefore, that string is deallocated when
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   223
  // the DirectiveSet is destroyed.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   224
  assert(this->DisableIntrinsicOption != NULL, "");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   225
  FREE_C_HEAP_ARRAY(char, (void *)this->DisableIntrinsicOption);
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   226
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   227
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   228
// Backward compatibility for CompileCommands
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   229
// Breaks the abstraction and causes lots of extra complexity
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   230
// - 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
   231
// - Need to free copy after use
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   232
// - 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
   233
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   234
DirectiveSet* DirectiveSet::compilecommand_compatibility_init(methodHandle method) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   235
  // 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
   236
  // Only set a flag if it has not been modified and value changes.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   237
  // Only copy set if a flag needs to be set
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   238
  if (!CompilerDirectivesIgnoreCompileCommandsOption && CompilerOracle::has_any_option()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   239
    DirectiveSet* set = DirectiveSet::clone(this);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   240
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   241
    bool changed = false; // Track if we actually change anything
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   242
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   243
    // All CompileCommands are not equal so this gets a bit verbose
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   244
    // When CompileCommands have been refactored less clutter will remain.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   245
    if (CompilerOracle::should_break_at(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   246
      if (!_modified[BreakAtCompileIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   247
        set->BreakAtCompileOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   248
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   249
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   250
      if (!_modified[BreakAtExecuteIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   251
        set->BreakAtExecuteOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   252
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   253
      }
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 (CompilerOracle::should_log(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   256
      if (!_modified[LogIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   257
        set->LogOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   258
        changed = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   259
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   260
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   261
    if (CompilerOracle::should_print(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   262
      if (!_modified[PrintAssemblyIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   263
        set->PrintAssemblyOption = true;
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
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   267
    // Exclude as in should not compile == Enabled
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   268
    if (CompilerOracle::should_exclude(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   269
      if (!_modified[ExcludeIndex]) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   270
        set->ExcludeOption = 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
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   275
    // inline and dontinline (including exclude) are implemented in the directiveset accessors
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   276
#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
   277
    compilerdirectives_common_flags(init_default_cc)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   278
    compilerdirectives_c2_flags(init_default_cc)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   279
    compilerdirectives_c1_flags(init_default_cc)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   280
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   281
    // Canonicalize DisableIntrinsic to contain only ',' as a separator.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   282
    ccstrlist option_value;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   283
    if (!_modified[DisableIntrinsicIndex] &&
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   284
        CompilerOracle::has_option_value(method, "DisableIntrinsic", option_value)) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   285
      set->DisableIntrinsicOption = canonicalize_disableintrinsic(option_value);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   286
    }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   287
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   288
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   289
    if (!changed) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   290
      // We didn't actually update anything, discard.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   291
      delete set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   292
    } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   293
      // 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
   294
      DirectivesStack::release(this);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   295
      return set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   296
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   297
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   298
  // Nothing changed
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   299
  return this;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   300
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   301
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   302
CompilerDirectives* DirectiveSet::directive() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   303
  assert(_directive != NULL, "Must have been initialized");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   304
  return _directive;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   305
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   306
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   307
bool DirectiveSet::matches_inline(methodHandle method, int inline_action) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   308
  if (_inlinematchers != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   309
    if (_inlinematchers->match(method, InlineMatcher::force_inline)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   310
      return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   311
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   312
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   313
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   314
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   315
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   316
bool DirectiveSet::should_inline(ciMethod* inlinee) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   317
  inlinee->check_is_loaded();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   318
  VM_ENTRY_MARK;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   319
  methodHandle mh(THREAD, inlinee->get_Method());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   320
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   321
  if (matches_inline(mh, InlineMatcher::force_inline)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   322
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   323
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   324
  if (!CompilerDirectivesIgnoreCompileCommandsOption && CompilerOracle::should_inline(mh)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   325
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   326
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   327
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   328
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   329
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   330
bool DirectiveSet::should_not_inline(ciMethod* inlinee) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   331
  inlinee->check_is_loaded();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   332
  VM_ENTRY_MARK;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   333
  methodHandle mh(THREAD, inlinee->get_Method());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   334
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   335
  if (matches_inline(mh, InlineMatcher::dont_inline)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   336
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   337
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   338
  if (!CompilerDirectivesIgnoreCompileCommandsOption && CompilerOracle::should_not_inline(mh)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   339
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   340
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   341
  return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   342
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   343
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   344
bool DirectiveSet::parse_and_add_inline(char* str, const char*& error_msg) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   345
  InlineMatcher* m = InlineMatcher::parse_inline_pattern(str, error_msg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   346
  if (m != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   347
    // add matcher last in chain - the order is significant
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   348
    append_inline(m);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   349
    return true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   350
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   351
    assert(error_msg != NULL, "Error message must be set");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   352
    return false;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   353
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   354
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   355
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   356
void DirectiveSet::append_inline(InlineMatcher* m) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   357
  if (_inlinematchers == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   358
    _inlinematchers = m;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   359
    return;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   360
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   361
  InlineMatcher* tmp = _inlinematchers;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   362
  while (tmp->next() != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   363
    tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   364
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   365
  tmp->set_next(m);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   366
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   367
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   368
void DirectiveSet::print_inline(outputStream* st) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   369
  if (_inlinematchers == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   370
    st->print_cr("  inline: -");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   371
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   372
    st->print("  inline: ");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   373
    _inlinematchers->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   374
    InlineMatcher* tmp = _inlinematchers->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   375
    while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   376
      st->print(", ");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   377
      tmp->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   378
      tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   379
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   380
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   381
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   382
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   383
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   384
bool DirectiveSet::is_intrinsic_disabled(methodHandle method) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   385
  vmIntrinsics::ID id = method->intrinsic_id();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   386
  assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   387
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   388
  ResourceMark rm;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   389
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   390
  // 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
   391
  // intrinsics. The copy is created because the string
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   392
  // will be modified by strtok(). Then, the list is tokenized with
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   393
  // ',' as a separator.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   394
  size_t length = strlen(DisableIntrinsicOption);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   395
  char* local_list = NEW_RESOURCE_ARRAY(char, length + 1);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   396
  strncpy(local_list, DisableIntrinsicOption, length + 1);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   397
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   398
  char* token = strtok(local_list, ",");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   399
  while (token != NULL) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   400
    if (strcmp(token, vmIntrinsics::name_at(id)) == 0) {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   401
      return true;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   402
    } else {
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   403
      token = strtok(NULL, ",");
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
  }
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   406
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   407
  return false;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   408
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   409
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   410
DirectiveSet* DirectiveSet::clone(DirectiveSet const* src) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   411
  DirectiveSet* set = new DirectiveSet(NULL);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   412
  memcpy(set->_modified, src->_modified, sizeof(src->_modified));
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   413
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   414
  InlineMatcher* tmp = src->_inlinematchers;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   415
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   416
    set->append_inline(tmp->clone());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   417
    tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   418
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   419
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   420
  #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
   421
    compilerdirectives_common_flags(copy_members_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   422
    compilerdirectives_c2_flags(copy_members_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   423
    compilerdirectives_c1_flags(copy_members_definition)
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   424
33480
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   425
  // Create a local copy of the DisableIntrinsicOption.
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   426
  assert(src->DisableIntrinsicOption != NULL, "");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   427
  size_t len = strlen(src->DisableIntrinsicOption) + 1;
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   428
  char* s = NEW_C_HEAP_ARRAY(char, len, mtCompiler);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   429
  strncpy(s, src->DisableIntrinsicOption, len);
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   430
  assert(s[len-1] == '\0', "");
e4cef6796874 8138651: -XX:DisableIntrinsic matches intrinsics overly eagerly
zmajo
parents: 33479
diff changeset
   431
  set->DisableIntrinsicOption = s;
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   432
  return set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   433
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   434
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   435
// Create a new dirstack and push a default directive
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   436
void DirectivesStack::init() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   437
  CompilerDirectives* _default_directives = new CompilerDirectives();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   438
  char str[] = "*.*";
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   439
  const char* error_msg = NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   440
  _default_directives->add_match(str, error_msg);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   441
#ifdef COMPILER1
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   442
  _default_directives->_c1_store->EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   443
#endif
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   444
#ifdef COMPILER2
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   445
  _default_directives->_c2_store->EnableOption = true;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   446
#endif
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   447
  assert(error_msg == NULL, "Must succeed.");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   448
  push(_default_directives);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   449
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   450
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   451
DirectiveSet* DirectivesStack::getDefaultDirective(AbstractCompiler* comp) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   452
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   453
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   454
  assert(_bottom != NULL, "Must never be empty");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   455
  return _bottom->get_for(comp);
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
void DirectivesStack::push(CompilerDirectives* directive) {
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
  directive->inc_refcount();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   462
  if (_top == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   463
    assert(_bottom == NULL, "There can only be one default directive");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   464
    _bottom = directive; // default directive, can never be removed.
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   465
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   466
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   467
  directive->set_next(_top);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   468
  _top = directive;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   469
  _depth++;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   470
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   471
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   472
void DirectivesStack::pop() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   473
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   474
  pop_inner();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   475
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   476
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   477
void DirectivesStack::pop_inner() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   478
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   479
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   480
  if (_top->next() == NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   481
    return; // Do nothing - don't allow an empty stack
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   482
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   483
  CompilerDirectives* tmp = _top;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   484
  _top = _top->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   485
  _depth--;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   486
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   487
  DirectivesStack::release(tmp);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   488
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   489
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   490
void DirectivesStack::clear() {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   491
  // holding the lock during the whole operation ensuring consistent result
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   492
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   493
  while (_top->next() != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   494
    pop_inner();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   495
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   496
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   497
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   498
void DirectivesStack::print(outputStream* st) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   499
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   500
  CompilerDirectives* tmp = _top;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   501
  while (tmp != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   502
    tmp->print(st);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   503
    tmp = tmp->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   504
    st->cr();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   505
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   506
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   507
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   508
void DirectivesStack::release(DirectiveSet* set) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   509
  MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   510
  if (set->is_exclusive_copy()) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   511
    // Old CompilecCmmands forced us to create an exclusive copy
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   512
    delete set;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   513
  } else {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   514
    assert(set->directive() != NULL, "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   515
    release(set->directive());
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   516
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   517
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   518
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   519
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   520
void DirectivesStack::release(CompilerDirectives* dir) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   521
  assert(DirectivesStack_lock->owned_by_self(), "");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   522
  dir->dec_refcount();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   523
  if (dir->refcount() == 0) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   524
    delete dir;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   525
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   526
}
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   527
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   528
DirectiveSet* DirectivesStack::getMatchingDirective(methodHandle method, AbstractCompiler *comp) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   529
  assert(_depth > 0, "Must never be empty");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   530
  CompilerDirectives* dir = _top;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   531
  assert(dir != NULL, "Must be initialized");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   532
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   533
  DirectiveSet* match = NULL;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   534
  {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   535
    MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   536
    while (dir != NULL) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   537
      if (dir->is_default_directive() || dir->match(method)) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   538
        match = dir->get_for(comp);
33479
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   539
        if (match == NULL) {
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   540
          // temporary workaround for compilers without directives.
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   541
          if (dir->is_default_directive()) {
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   542
            // default dir is always enabled
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   543
            // match c1 store - it contains all common flags even if C1 is unavailable
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   544
            match = dir->_c1_store;
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   545
            break;
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   546
          }
2f62e0833ea2 8140343: SEGV in DirectivesStack::getMatchingDirective
neliasso
parents: 33451
diff changeset
   547
        }
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   548
        if (match->EnableOption) {
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   549
          // The directiveSet for this compile is also enabled -> success
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   550
          break;
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   551
        }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   552
      }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   553
      dir = dir->next();
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   554
    }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   555
  }
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   556
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   557
  guarantee(match != NULL, "There should always be a default directive that matches");
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   558
  // Check for legacy compile commands update, without DirectivesStack_lock
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   559
  return match->compilecommand_compatibility_init(method);
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
diff changeset
   560
}