hotspot/src/share/vm/opto/parseHelper.cpp
author iveresov
Thu, 22 Jan 2015 11:25:23 -0800
changeset 28723 0a36120cb225
parent 27637 cf68c0af6882
child 46630 75aa3e39d02c
permissions -rw-r--r--
8071302: assert(!_reg_node[reg_lo] || edge_from_to(_reg_node[reg_lo], def)) failed: after block local Summary: Add merge nodes to node to block mapping Reviewed-by: kvn, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
     2
 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4754
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4754
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4754
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    26
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    27
#include "compiler/compileLog.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    28
#include "oops/objArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    29
#include "opto/addnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    30
#include "opto/memnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    31
#include "opto/mulnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    32
#include "opto/parse.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    33
#include "opto/rootnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    34
#include "opto/runtime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6416
diff changeset
    35
#include "runtime/sharedRuntime.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//------------------------------make_dtrace_method_entry_exit ----------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// Dtrace -- record entry or exit of a method if compiled with dtrace support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  const TypeFunc *call_type    = OptoRuntime::dtrace_method_entry_exit_Type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  address         call_address = is_entry ? CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
                                            CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  const char     *call_name    = is_entry ? "dtrace_method_entry" : "dtrace_method_exit";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Get base of thread-local storage area
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
    46
  Node* thread = _gvn.transform( new ThreadLocalNode() );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Get method
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
    49
  const TypePtr* method_type = TypeMetadataPtr::make(method);
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
    50
  Node *method_node = _gvn.transform(ConNode::make(method_type));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  kill_dead_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // For some reason, this call reads only raw memory.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  make_runtime_call(RC_LEAF | RC_NARROW_MEM,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
                    call_type, call_address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
                    call_name, raw_adr_type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
                    thread, method_node);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//------------------------------do_checkcast-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
void Parse::do_checkcast() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  ciKlass* klass = iter().get_klass(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  Node *obj = peek();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Throw uncommon trap if class is not loaded or the value we are casting
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // _from_ is not loaded, and value is not null.  If the value _is_ NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // then the checkcast does nothing.
11570
25f3e9348905 7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents: 11439
diff changeset
    74
  const TypeOopPtr *tp = _gvn.type(obj)->isa_oopptr();
25f3e9348905 7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents: 11439
diff changeset
    75
  if (!will_link || (tp && tp->klass() && !tp->klass()->is_loaded())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    if (C->log() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        C->log()->elem("assert_null reason='checkcast' klass='%d'",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
                       C->log()->identify(klass));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      }
11570
25f3e9348905 7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents: 11439
diff changeset
    81
      if (tp && tp->klass() && !tp->klass()->is_loaded()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        // %%% Cannot happen?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        C->log()->elem("assert_null reason='checkcast source' klass='%d'",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
                       C->log()->identify(tp->klass()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    }
14621
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13952
diff changeset
    87
    null_assert(obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    if (!stopped()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      profile_null_checkcast();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  Node *res = gen_checkcast(obj, makecon(TypeKlassPtr::make(klass)) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // Pop from stack AFTER gen_checkcast because it can uncommon trap and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // the debug info has to be correct.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  push(res);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
//------------------------------do_instanceof----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
void Parse::do_instanceof() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  if (stopped())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // We would like to return false if class is not loaded, emitting a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // dependency, but Java requires instanceof to load its operand.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Throw uncommon trap if class is not loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  ciKlass* klass = iter().get_klass(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    if (C->log() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
      C->log()->elem("assert_null reason='instanceof' klass='%d'",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
                     C->log()->identify(klass));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    }
14621
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13952
diff changeset
   119
    null_assert(peek());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    if (!stopped()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      // The object is now known to be null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      // Shortcut the effect of gen_instanceof and return "false" directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      pop();                   // pop the null
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      push(_gvn.intcon(0));    // push false answer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Push the bool result back on stack
21099
46e6bbecd9e5 8024070: C2 needs some form of type speculation
roland
parents: 20695
diff changeset
   131
  Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass)), true);
6416
d49b65c9425a 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 5925
diff changeset
   132
d49b65c9425a 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 5925
diff changeset
   133
  // Pop from stack AFTER gen_instanceof because it can uncommon trap.
d49b65c9425a 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 5925
diff changeset
   134
  pop();
d49b65c9425a 6912064: type profiles need to be exploited more for dynamic language support
jrose
parents: 5925
diff changeset
   135
  push(res);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
//------------------------------array_store_check------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// pull array from stack and check that the store is valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
void Parse::array_store_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
14621
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13952
diff changeset
   142
  // Shorthand access to array store elements without popping them.
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13952
diff changeset
   143
  Node *obj = peek(0);
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13952
diff changeset
   144
  Node *idx = peek(1);
fd9265ab0f67 7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents: 13952
diff changeset
   145
  Node *ary = peek(2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  if (_gvn.type(obj) == TypePtr::NULL_PTR) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    // There's never a type check on null values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    // This cutout lets us avoid the uncommon_trap(Reason_array_check)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    // below, which turns into a performance liability if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    // gen_checkcast folds up completely.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Extract the array klass type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  int klass_offset = oopDesc::klass_offset_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  Node* p = basic_plus_adr( ary, ary, klass_offset );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // p's type is array-of-OOPS plus klass_offset
27637
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   159
  Node* array_klass = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeInstPtr::KLASS));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // Get the array klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
27637
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   163
  // The type of array_klass is usually INexact array-of-oop.  Heroically
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   164
  // cast array_klass to EXACT array and uncommon-trap if the cast fails.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   165
  // Make constant out of the inexact array klass, but use it only if the cast
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   166
  // succeeds.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  bool always_see_exact_class = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  if (MonomorphicArrayCheck
27637
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   169
      && !too_many_traps(Deoptimization::Reason_array_check)
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   170
      && !tak->klass_is_exact()
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   171
      && tak != TypeKlassPtr::OBJECT) {
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   172
      // Regarding the fourth condition in the if-statement from above:
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   173
      //
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   174
      // If the compiler has determined that the type of array 'ary' (represented
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   175
      // by 'array_klass') is java/lang/Object, the compiler must not assume that
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   176
      // the array 'ary' is monomorphic.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   177
      //
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   178
      // If 'ary' were of type java/lang/Object, this arraystore would have to fail,
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   179
      // because it is not possible to perform a arraystore into an object that is not
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   180
      // a "proper" array.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   181
      //
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   182
      // Therefore, let's obtain at runtime the type of 'ary' and check if we can still
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   183
      // successfully perform the store.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   184
      //
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   185
      // The implementation reasons for the condition are the following:
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   186
      //
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   187
      // java/lang/Object is the superclass of all arrays, but it is represented by the VM
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   188
      // as an InstanceKlass. The checks generated by gen_checkcast() (see below) expect
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   189
      // 'array_klass' to be ObjArrayKlass, which can result in invalid memory accesses.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   190
      //
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   191
      // See issue JDK-8057622 for details.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   192
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    always_see_exact_class = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    // (If no MDO at all, hope for the best, until a trap actually occurs.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    // Make a constant out of the inexact array klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    Node* con = makecon(extak);
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   199
    Node* cmp = _gvn.transform(new CmpPNode( array_klass, con ));
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   200
    Node* bol = _gvn.transform(new BoolNode( cmp, BoolTest::eq ));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    Node* ctrl= control();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    { BuildCutout unless(this, bol, PROB_MAX);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      uncommon_trap(Deoptimization::Reason_array_check,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
                    Deoptimization::Action_maybe_recompile,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
                    tak->klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    if (stopped()) {          // MUST uncommon-trap?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
      set_control(ctrl);      // Then Don't Do It, just fall into the normal checking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    } else {                  // Cast array klass to exactness:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
      // Use the exact constant value we know it is.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
      replace_in_map(array_klass,con);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      CompileLog* log = C->log();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      if (log != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
                  log->identify(tak->klass()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      array_klass = con;      // Use cast value moving forward
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Come here for polymorphic array klasses
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // Extract the array element class
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13895
diff changeset
   224
  int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset);
27637
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   226
  // We are allowed to use the constant type only if cast succeeded. If always_see_exact_class is true,
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   227
  // we must set a control edge from the IfTrue node created by the uncommon_trap above to the
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   228
  // LoadKlassNode.
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   229
  Node* a_e_klass = _gvn.transform(LoadKlassNode::make(_gvn, always_see_exact_class ? control() : NULL,
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   230
                                                       immutable_memory(), p2, tak));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // Check (the hard way) and throw if not a subklass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  // Result is ignored, we just need the CFG effects.
27637
cf68c0af6882 8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc)
zmajo
parents: 25930
diff changeset
   234
  gen_checkcast(obj, a_e_klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   238
void Parse::emit_guard_for_new(ciInstanceKlass* klass) {
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   239
  // Emit guarded new
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   240
  //   if (klass->_init_thread != current_thread ||
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   241
  //       klass->_init_state != being_initialized)
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   242
  //      uncommon_trap
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   243
  Node* cur_thread = _gvn.transform( new ThreadLocalNode() );
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   244
  Node* merge = new RegionNode(3);
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   245
  _gvn.set_type(merge, Type::CONTROL);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   246
  Node* kls = makecon(TypeKlassPtr::make(klass));
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   247
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   248
  Node* init_thread_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_thread_offset()));
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   249
  Node* adr_node = basic_plus_adr(kls, kls, init_thread_offset);
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   250
  Node* init_thread = make_load(NULL, adr_node, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   251
  Node *tst   = Bool( CmpP( init_thread, cur_thread), BoolTest::eq);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   252
  IfNode* iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   253
  set_control(IfTrue(iff));
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   254
  merge->set_req(1, IfFalse(iff));
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   255
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   256
  Node* init_state_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_state_offset()));
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   257
  adr_node = basic_plus_adr(kls, kls, init_state_offset);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   258
  // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler
11407
5399831730cd 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 7397
diff changeset
   259
  // can generate code to load it as unsigned byte.
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   260
  Node* init_state = make_load(NULL, adr_node, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   261
  Node* being_init = _gvn.intcon(InstanceKlass::being_initialized);
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   262
  tst   = Bool( CmpI( init_state, being_init), BoolTest::eq);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   263
  iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   264
  set_control(IfTrue(iff));
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   265
  merge->set_req(2, IfFalse(iff));
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   266
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   267
  PreserveJVMState pjvms(this);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   268
  record_for_igvn(merge);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   269
  set_control(merge);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   270
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   271
  uncommon_trap(Deoptimization::Reason_uninitialized,
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   272
                Deoptimization::Action_reinterpret,
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   273
                klass);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   274
}
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   275
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   276
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
//------------------------------do_new-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
void Parse::do_new() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  kill_dead_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  assert(will_link, "_new: typeflow responsibility");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  // Should initialize, or throw an InstantiationError?
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   286
  if (!klass->is_initialized() && !klass->is_being_initialized() ||
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
      klass->is_abstract() || klass->is_interface() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
      klass->name() == ciSymbol::java_lang_Class() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
      iter().is_unresolved_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    uncommon_trap(Deoptimization::Reason_uninitialized,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
                  Deoptimization::Action_reinterpret,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
                  klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  }
5925
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   295
  if (klass->is_being_initialized()) {
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   296
    emit_guard_for_new(klass);
a30fef61d0b7 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 5547
diff changeset
   297
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  Node* kls = makecon(TypeKlassPtr::make(klass));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  Node* obj = new_instance(kls);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // Push resultant oop onto stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  push(obj);
4450
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   304
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   305
  // Keep track of whether opportunities exist for StringBuilder
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   306
  // optimizations.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   307
  if (OptimizeStringConcat &&
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   308
      (klass == C->env()->StringBuilder_klass() ||
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   309
       klass == C->env()->StringBuffer_klass())) {
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   310
    C->set_has_stringbuilder(true);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 3261
diff changeset
   311
  }
17383
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 17000
diff changeset
   312
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 17000
diff changeset
   313
  // Keep track of boxed values for EliminateAutoBox optimizations.
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 17000
diff changeset
   314
  if (C->eliminate_boxing() && klass->is_box_klass()) {
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 17000
diff changeset
   315
    C->set_has_boxed_value(true);
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 17000
diff changeset
   316
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
//------------------------------dump_map_adr_mem-------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
// Debug dump of the mapping from address types to MergeMemNode indices.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
void Parse::dump_map_adr_mem() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  tty->print_cr("--- Mapping from address types to memory Nodes ---");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  MergeMemNode *mem = map() == NULL ? NULL : (map()->memory()->is_MergeMem() ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
                                      map()->memory()->as_MergeMem() : NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  for (uint i = 0; i < (uint)C->num_alias_types(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    C->alias_type(i)->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    tty->print("\t");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    // Node mapping, if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    if (mem && i < mem->req() && mem->in(i) && mem->in(i) != mem->empty_memory()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      mem->in(i)->dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
// parser methods for profiling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
//----------------------test_counter_against_threshold ------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
void Parse::test_counter_against_threshold(Node* cnt, int limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  // Test the counter against the limit and uncommon trap if greater.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  // This code is largely copied from the range check code in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  // array_addressing()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  // Test invocation count vs threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  Node *threshold = makecon(TypeInt::make(limit));
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   355
  Node *chk   = _gvn.transform( new CmpUNode( cnt, threshold) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  BoolTest::mask btest = BoolTest::lt;
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   357
  Node *tst   = _gvn.transform( new BoolNode( chk, btest) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  // Branch to failure if threshold exceeded
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  { BuildCutout unless(this, tst, PROB_ALWAYS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    uncommon_trap(Deoptimization::Reason_age,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
                  Deoptimization::Action_maybe_recompile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
//----------------------increment_and_test_invocation_counter-------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
void Parse::increment_and_test_invocation_counter(int limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  if (!count_invocations()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   369
  // Get the Method* node.
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 14621
diff changeset
   370
  ciMethod* m = method();
20695
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 17383
diff changeset
   371
  MethodCounters* counters_adr = m->ensure_method_counters();
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 17383
diff changeset
   372
  if (counters_adr == NULL) {
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 17383
diff changeset
   373
    C->record_failure("method counters allocation failed");
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 17383
diff changeset
   374
    return;
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 17383
diff changeset
   375
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 14621
diff changeset
   377
  Node* ctrl = control();
20695
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 17383
diff changeset
   378
  const TypePtr* adr_type = TypeRawPtr::make((address) counters_adr);
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 14621
diff changeset
   379
  Node *counters_node = makecon(adr_type);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 14621
diff changeset
   380
  Node* adr_iic_node = basic_plus_adr(counters_node, counters_node,
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 14621
diff changeset
   381
    MethodCounters::interpreter_invocation_counter_offset_in_bytes());
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   382
  Node* cnt = make_load(ctrl, adr_iic_node, TypeInt::INT, T_INT, adr_type, MemNode::unordered);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  test_counter_against_threshold(cnt, limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  // Add one to the counter and store
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   387
  Node* incr = _gvn.transform(new AddINode(cnt, _gvn.intcon(1)));
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   388
  store_to_memory(ctrl, adr_iic_node, incr, T_INT, adr_type, MemNode::unordered);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
//----------------------------method_data_addressing---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
Node* Parse::method_data_addressing(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, Node* idx, uint stride) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   393
  // Get offset within MethodData* of the data array
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   394
  ByteSize data_offset = MethodData::data_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  // Get cell offset of the ProfileData within data array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  int cell_offset = md->dp_to_di(data->dp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // Add in counter_offset, the # of bytes into the ProfileData of counter or flag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  int offset = in_bytes(data_offset) + cell_offset + in_bytes(counter_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 11570
diff changeset
   402
  const TypePtr* adr_type = TypeMetadataPtr::make(md);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  Node* mdo = makecon(adr_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  Node* ptr = basic_plus_adr(mdo, mdo, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  if (stride != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    Node* str = _gvn.MakeConX(stride);
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   408
    Node* scale = _gvn.transform( new MulXNode( idx, str ) );
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   409
    ptr   = _gvn.transform( new AddPNode( mdo, ptr, scale ) );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  return ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
//--------------------------increment_md_counter_at----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
void Parse::increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, Node* idx, uint stride) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  Node* adr_node = method_data_addressing(md, data, counter_offset, idx, stride);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   420
  Node* cnt  = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type, MemNode::unordered);
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   421
  Node* incr = _gvn.transform(new AddINode(cnt, _gvn.intcon(DataLayout::counter_increment)));
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   422
  store_to_memory(NULL, adr_node, incr, T_INT, adr_type, MemNode::unordered);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
//--------------------------test_for_osr_md_counter_at-------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
void Parse::test_for_osr_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, int limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  Node* adr_node = method_data_addressing(md, data, counter_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   430
  Node* cnt  = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type, MemNode::unordered);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  test_counter_against_threshold(cnt, limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
//-------------------------------set_md_flag_at--------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
void Parse::set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_constant) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  Node* adr_node = method_data_addressing(md, data, DataLayout::flags_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr();
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   440
  Node* flags = make_load(NULL, adr_node, TypeInt::BYTE, T_BYTE, adr_type, MemNode::unordered);
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 22845
diff changeset
   441
  Node* incr = _gvn.transform(new OrINode(flags, _gvn.intcon(flag_constant)));
22845
d8812d0ff387 8024921: PPC64 (part 113): Extend Load and Store nodes to know about memory ordering
goetz
parents: 21099
diff changeset
   442
  store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type, MemNode::unordered);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
//----------------------------profile_taken_branch-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
void Parse::profile_taken_branch(int target_bci, bool force_update) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // This is a potential osr_site if we have a backedge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  int cur_bci = bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  bool osr_site =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    (target_bci <= cur_bci) && count_invocations() && UseOnStackReplacement;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  // If we are going to OSR, restart at the target bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  set_bci(target_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // To do: factor out the the limit calculations below. These duplicate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  // the similar limit calculations in the interpreter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  if (method_data_update() || force_update) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    ciProfileData* data = md->bci_to_data(cur_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    assert(data->is_JumpData(), "need JumpData for taken branch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    increment_md_counter_at(md, data, JumpData::taken_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  // In the new tiered system this is all we need to do. In the old
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  // (c2 based) tiered sytem we must do the code below.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
#ifndef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  if (method_data_update()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
    if (osr_site) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
      ciProfileData* data = md->bci_to_data(cur_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
      int limit = (CompileThreshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
                   * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
      test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    // With method data update off, use the invocation counter to trigger an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    // OSR compilation, as done in the interpreter.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    if (osr_site) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
      int limit = (CompileThreshold * OnStackReplacePercentage) / 100;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
      increment_and_test_invocation_counter(limit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  // Restore the original bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  set_bci(cur_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
//--------------------------profile_not_taken_branch---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
void Parse::profile_not_taken_branch(bool force_update) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  if (method_data_update() || force_update) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    ciProfileData* data = md->bci_to_data(bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    assert(data->is_BranchData(), "need BranchData for not taken branch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    increment_md_counter_at(md, data, BranchData::not_taken_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
//---------------------------------profile_call--------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
void Parse::profile_call(Node* receiver) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  if (!method_data_update()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  switch (bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  case Bytecodes::_invokeinterface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    profile_receiver_type(receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  case Bytecodes::_invokestatic:
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 670
diff changeset
   514
  case Bytecodes::_invokedynamic:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  case Bytecodes::_invokespecial:
4754
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   516
    profile_generic_call();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  default: fatal("unexpected call bytecode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
//------------------------------profile_generic_call---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
void Parse::profile_generic_call() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  assert(method_data_update(), "must be generating profile code");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  ciProfileData* data = md->bci_to_data(bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  assert(data->is_CounterData(), "need CounterData for not taken branch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  increment_md_counter_at(md, data, CounterData::count_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
//-----------------------------profile_receiver_type---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
void Parse::profile_receiver_type(Node* receiver) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  assert(method_data_update(), "must be generating profile code");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  ciProfileData* data = md->bci_to_data(bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  assert(data->is_ReceiverTypeData(), "need ReceiverTypeData here");
4754
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   541
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   542
  // Skip if we aren't tracking receivers
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   543
  if (TypeProfileWidth < 1) {
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   544
    increment_md_counter_at(md, data, CounterData::count_offset());
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   545
    return;
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4450
diff changeset
   546
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  ciReceiverTypeData* rdata = (ciReceiverTypeData*)data->as_ReceiverTypeData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  Node* method_data = method_data_addressing(md, rdata, in_ByteSize(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  // Using an adr_type of TypePtr::BOTTOM to work around anti-dep problems.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  // A better solution might be to use TypeRawPtr::BOTTOM with RC_NARROW_MEM.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  make_runtime_call(RC_LEAF, OptoRuntime::profile_receiver_type_Type(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
                    CAST_FROM_FN_PTR(address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
                                     OptoRuntime::profile_receiver_type_C),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
                    "profile_receiver_type_C",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
                    TypePtr::BOTTOM,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
                    method_data, receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
//---------------------------------profile_ret---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
void Parse::profile_ret(int target_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  if (!method_data_update()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  // Skip if we aren't tracking ret targets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  if (TypeProfileWidth < 1) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  ciProfileData* data = md->bci_to_data(bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  assert(data->is_RetData(), "need RetData for ret");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  ciRetData* ret_data = (ciRetData*)data->as_RetData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  // Look for the target_bci is already in the table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  uint row;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  bool table_full = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  for (row = 0; row < ret_data->row_limit(); row++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    int key = ret_data->bci(row);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    table_full &= (key != RetData::no_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    if (key == target_bci) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  if (row >= ret_data->row_limit()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    // The target_bci was not found in the table.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    if (!table_full) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
      // XXX: Make slow call to update RetData
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  // the target_bci is already in the table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  increment_md_counter_at(md, data, RetData::bci_count_offset(row));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
//--------------------------profile_null_checkcast----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
void Parse::profile_null_checkcast() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  // Set the null-seen flag, done in conjunction with the usual null check. We
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  // never unset the flag, so this is a one-way switch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  if (!method_data_update()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  ciProfileData* data = md->bci_to_data(bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  assert(data->is_BitData(), "need BitData for checkcast");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  set_md_flag_at(md, data, BitData::null_seen_byte_constant());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
//-----------------------------profile_switch_case-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
void Parse::profile_switch_case(int table_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  if (!method_data_update()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  ciMethodData* md = method()->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  assert(md != NULL, "expected valid ciMethodData");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  ciProfileData* data = md->bci_to_data(bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  assert(data->is_MultiBranchData(), "need MultiBranchData for switch case");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  if (table_index >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    increment_md_counter_at(md, data, MultiBranchData::case_count_offset(table_index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    increment_md_counter_at(md, data, MultiBranchData::default_count_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
}