hotspot/src/share/vm/ci/ciTypeFlow.cpp
author thartmann
Tue, 26 Jan 2016 10:46:15 +0100
changeset 35602 1513b6586d6d
parent 34151 8e0bebdbc29e
child 37248 11a660dbbb8e
permissions -rw-r--r--
8147876: ciTypeFlow::is_dominated_by() writes outside dominated array Summary: ciTypeFlow::is_dominated_by() should use block_count() instead of _methodBlocks->num_blocks(). Reviewed-by: neliasso, vlivanov, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27908
diff changeset
     2
 * Copyright (c) 2000, 2015, 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: 4566
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4566
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: 4566
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: 6772
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    26
#include "ci/ciConstant.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    27
#include "ci/ciField.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    28
#include "ci/ciMethod.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    29
#include "ci/ciMethodData.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    30
#include "ci/ciObjArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    31
#include "ci/ciStreams.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    32
#include "ci/ciTypeArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    33
#include "ci/ciTypeFlow.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    34
#include "compiler/compileLog.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    35
#include "interpreter/bytecode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    36
#include "interpreter/bytecodes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    37
#include "memory/allocation.inline.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 27908
diff changeset
    38
#include "oops/oop.inline.hpp"
27707
f7d26e5b8b5d 8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents: 26944
diff changeset
    39
#include "opto/compile.hpp"
27908
699648af1ee6 8065915: Fix includes after 8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
goetz
parents: 27707
diff changeset
    40
#include "opto/node.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    41
#include "runtime/deoptimization.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6772
diff changeset
    42
#include "utilities/growableArray.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// ciTypeFlow::JsrSet
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// A JsrSet represents some set of JsrRecords.  This class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// is used to record a set of all jsr routines which we permit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// execution to return (ret) from.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// During abstract interpretation, JsrSets are used to determine
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// whether two paths which reach a given block are unique, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// should be cloned apart, or are compatible, and should merge
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// together.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// ciTypeFlow::JsrSet::JsrSet
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  if (arena != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    // Allocate growable array in Arena.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    _set = new (arena) GrowableArray<JsrRecord*>(arena, default_len, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    // Allocate growable array in current ResourceArea.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    _set = new GrowableArray<JsrRecord*>(4, 0, NULL, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// ciTypeFlow::JsrSet::copy_into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
void ciTypeFlow::JsrSet::copy_into(JsrSet* jsrs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  int len = size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  jsrs->_set->clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    jsrs->_set->append(_set->at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
// ciTypeFlow::JsrSet::is_compatible_with
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// !!!! MISGIVINGS ABOUT THIS... disregard
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// Is this JsrSet compatible with some other JsrSet?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// In set-theoretic terms, a JsrSet can be viewed as a partial function
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// from entry addresses to return addresses.  Two JsrSets A and B are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// compatible iff
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
//   For any x,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
//   A(x) defined and B(x) defined implies A(x) == B(x)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// Less formally, two JsrSets are compatible when they have identical
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// return addresses for any entry addresses they share in common.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
bool ciTypeFlow::JsrSet::is_compatible_with(JsrSet* other) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // Walk through both sets in parallel.  If the same entry address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // appears in both sets, then the return address must match for
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // the sets to be compatible.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  int size1 = size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  int size2 = other->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Special case.  If nothing is on the jsr stack, then there can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // be no ret.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  if (size2 == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  } else if (size1 != size2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    for (int i = 0; i < size1; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      JsrRecord* record1 = record_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      JsrRecord* record2 = other->record_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      if (record1->entry_address() != record2->entry_address() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
          record1->return_address() != record2->return_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
#if 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  int pos1 = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  int pos2 = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  int size1 = size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  int size2 = other->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  while (pos1 < size1 && pos2 < size2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    JsrRecord* record1 = record_at(pos1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    JsrRecord* record2 = other->record_at(pos2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    int entry1 = record1->entry_address();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    int entry2 = record2->entry_address();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    if (entry1 < entry2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
      pos1++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    } else if (entry1 > entry2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      pos2++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      if (record1->return_address() == record2->return_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
        pos1++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
        pos2++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        // These two JsrSets are incompatible.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // The two JsrSets agree.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
// ciTypeFlow::JsrSet::insert_jsr_record
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
// Insert the given JsrRecord into the JsrSet, maintaining the order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
// of the set and replacing any element with the same entry address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
void ciTypeFlow::JsrSet::insert_jsr_record(JsrRecord* record) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  int len = size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  int entry = record->entry_address();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  int pos = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  for ( ; pos < len; pos++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    JsrRecord* current = record_at(pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    if (entry == current->entry_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
      // Stomp over this entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
      _set->at_put(pos, record);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      assert(size() == len, "must be same size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    } else if (entry < current->entry_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Insert the record into the list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  JsrRecord* swap = record;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  JsrRecord* temp = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  for ( ; pos < len; pos++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    temp = _set->at(pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    _set->at_put(pos, swap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    swap = temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  _set->append(swap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  assert(size() == len+1, "must be larger");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
// ciTypeFlow::JsrSet::remove_jsr_record
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
// Remove the JsrRecord with the given return address from the JsrSet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
void ciTypeFlow::JsrSet::remove_jsr_record(int return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  int len = size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    if (record_at(i)->return_address() == return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
      // We have found the proper entry.  Remove it from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
      // JsrSet and exit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      for (int j = i+1; j < len ; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
        _set->at_put(j-1, _set->at(j));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      _set->trunc_to(len-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      assert(size() == len-1, "must be smaller");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  assert(false, "verify: returning from invalid subroutine");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
// ciTypeFlow::JsrSet::apply_control
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
// Apply the effect of a control-flow bytecode on the JsrSet.  The
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
// only bytecodes that modify the JsrSet are jsr and ret.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
void ciTypeFlow::JsrSet::apply_control(ciTypeFlow* analyzer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
                                       ciBytecodeStream* str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
                                       ciTypeFlow::StateVector* state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  Bytecodes::Code code = str->cur_bc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  if (code == Bytecodes::_jsr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    JsrRecord* record =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      analyzer->make_jsr_record(str->get_dest(), str->next_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    insert_jsr_record(record);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  } else if (code == Bytecodes::_jsr_w) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    JsrRecord* record =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      analyzer->make_jsr_record(str->get_far_dest(), str->next_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    insert_jsr_record(record);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  } else if (code == Bytecodes::_ret) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    Cell local = state->local(str->get_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    ciType* return_address = state->type_at(local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    assert(return_address->is_return_address(), "verify: wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    if (size() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      // Ret-state underflow:  Hit a ret w/o any previous jsrs.  Bail out.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
      // This can happen when a loop is inside a finally clause (4614060).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      analyzer->record_failure("OSR in finally clause");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    remove_jsr_record(return_address->as_return_address()->bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
// ciTypeFlow::JsrSet::print_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
void ciTypeFlow::JsrSet::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  st->print("{ ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  int num_elements = size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  if (num_elements > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    for( ; i < num_elements - 1; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      _set->at(i)->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
      st->print(", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    _set->at(i)->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    st->print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  st->print("}");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
// ciTypeFlow::StateVector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
// A StateVector summarizes the type information at some point in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// the program.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
// ciTypeFlow::StateVector::type_meet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
// Meet two types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
// The semi-lattice of types use by this analysis are modeled on those
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
// of the verifier.  The lattice is as follows:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
//        top_type() >= all non-extremal types >= bottom_type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
//                             and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
//   Every primitive type is comparable only with itself.  The meet of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
//   reference types is determined by their kind: instance class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
//   interface, or array class.  The meet of two types of the same
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
//   kind is their least common ancestor.  The meet of two types of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
//   different kinds is always java.lang.Object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
ciType* ciTypeFlow::StateVector::type_meet_internal(ciType* t1, ciType* t2, ciTypeFlow* analyzer) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  assert(t1 != t2, "checked in caller");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  if (t1->equals(top_type())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    return t2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  } else if (t2->equals(top_type())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    return t1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  } else if (t1->is_primitive_type() || t2->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    // Special case null_type.  null_type meet any reference type T
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    // is T.  null_type meet null_type is null_type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    if (t1->equals(null_type())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
      if (!t2->is_primitive_type() || t2->equals(null_type())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        return t2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
    } else if (t2->equals(null_type())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      if (!t1->is_primitive_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
        return t1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    // At least one of the two types is a non-top primitive type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    // The other type is not equal to it.  Fall to bottom.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    return bottom_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    // Both types are non-top non-primitive types.  That is,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    // both types are either instanceKlasses or arrayKlasses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    ciKlass* object_klass = analyzer->env()->Object_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    ciKlass* k1 = t1->as_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    ciKlass* k2 = t2->as_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    if (k1->equals(object_klass) || k2->equals(object_klass)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
      return object_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    } else if (!k1->is_loaded() || !k2->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
      // Unloaded classes fall to java.lang.Object at a merge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
      return object_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    } else if (k1->is_interface() != k2->is_interface()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      // When an interface meets a non-interface, we get Object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      // This is what the verifier does.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      return object_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    } else if (k1->is_array_klass() || k2->is_array_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      // When an array meets a non-array, we get Object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      // When objArray meets typeArray, we also get Object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      // And when typeArray meets different typeArray, we again get Object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      // But when objArray meets objArray, we look carefully at element types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      if (k1->is_obj_array_klass() && k2->is_obj_array_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
        // Meet the element types, then construct the corresponding array type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
        ciKlass* elem1 = k1->as_obj_array_klass()->element_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
        ciKlass* elem2 = k2->as_obj_array_klass()->element_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
        ciKlass* elem  = type_meet_internal(elem1, elem2, analyzer)->as_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
        // Do an easy shortcut if one type is a super of the other.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
        if (elem == elem1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
          assert(k1 == ciObjArrayKlass::make(elem), "shortcut is OK");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
          return k1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        } else if (elem == elem2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
          assert(k2 == ciObjArrayKlass::make(elem), "shortcut is OK");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
          return k2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
          return ciObjArrayKlass::make(elem);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
        return object_klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      // Must be two plain old instance klasses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      assert(k1->is_instance_klass(), "previous cases handle non-instances");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      assert(k2->is_instance_klass(), "previous cases handle non-instances");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
      return k1->least_common_ancestor(k2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
}
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
// ciTypeFlow::StateVector::StateVector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
// Build a new state vector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
ciTypeFlow::StateVector::StateVector(ciTypeFlow* analyzer) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  _outer = analyzer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  _stack_size = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  _monitor_count = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  // Allocate the _types array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  int max_cells = analyzer->max_cells();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  _types = (ciType**)analyzer->arena()->Amalloc(sizeof(ciType*) * max_cells);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  for (int i=0; i<max_cells; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    _types[i] = top_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  _trap_bci = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  _trap_index = 0;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
   357
  _def_locals.clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
   360
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
// ciTypeFlow::get_start_state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
// Set this vector to the method entry state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
const ciTypeFlow::StateVector* ciTypeFlow::get_start_state() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  StateVector* state = new StateVector(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  if (is_osr_flow()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    ciTypeFlow* non_osr_flow = method()->get_flow_analysis();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    if (non_osr_flow->failing()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
      record_failure(non_osr_flow->failure_reason());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
      return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    JsrSet* jsrs = new JsrSet(NULL, 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    Block* non_osr_block = non_osr_flow->existing_block_at(start_bci(), jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    if (non_osr_block == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      record_failure("cannot reach OSR point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    // load up the non-OSR state at this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    non_osr_block->copy_state_into(state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    int non_osr_start = non_osr_block->start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    if (non_osr_start != start_bci()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      // must flow forward from it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
        tty->print_cr(">> Interpreting pre-OSR block %d:", non_osr_start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
      Block* block = block_at(non_osr_start, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      assert(block->limit() == start_bci(), "must flow forward to start");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
      flow_block(block, state, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
    return state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    // Note:  The code below would be an incorrect for an OSR flow,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    // even if it were possible for an OSR entry point to be at bci zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  // "Push" the method signature into the first few locals.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  state->set_stack_size(-max_locals());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  if (!method()->is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    state->push(method()->holder());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    assert(state->tos() == state->local(0), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  for (ciSignatureStream str(method()->signature());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
       !str.at_return_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
       str.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    state->push_translate(str.type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // Set the rest of the locals to bottom.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  Cell cell = state->next_cell(state->tos());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  state->set_stack_size(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  int limit = state->limit_cell();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  for (; cell < limit; cell = state->next_cell(cell)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    state->set_type_at(cell, state->bottom_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // Lock an object, if necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  state->set_monitor_count(method()->is_synchronized() ? 1 : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  return state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
// ciTypeFlow::StateVector::copy_into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
// Copy our value into some other StateVector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
void ciTypeFlow::StateVector::copy_into(ciTypeFlow::StateVector* copy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  copy->set_stack_size(stack_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  copy->set_monitor_count(monitor_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  Cell limit = limit_cell();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  for (Cell c = start_cell(); c < limit; c = next_cell(c)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    copy->set_type_at(c, type_at(c));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
// ciTypeFlow::StateVector::meet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
// Meets this StateVector with another, destructively modifying this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
// one.  Returns true if any modification takes place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
bool ciTypeFlow::StateVector::meet(const ciTypeFlow::StateVector* incoming) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  if (monitor_count() == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    set_monitor_count(incoming->monitor_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  assert(monitor_count() == incoming->monitor_count(), "monitors must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  if (stack_size() == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    set_stack_size(incoming->stack_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    Cell limit = limit_cell();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    { for (Cell c = start_cell(); c < limit; c = next_cell(c)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
        assert(type_at(c) == top_type(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    } }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    // Make a simple copy of the incoming state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    for (Cell c = start_cell(); c < limit; c = next_cell(c)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      set_type_at(c, incoming->type_at(c));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    return true;  // it is always different the first time
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  if (stack_size() != incoming->stack_size()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    _outer->method()->print_codes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    tty->print_cr("!!!! Stack size conflict");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    tty->print_cr("Current state:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    tty->print_cr("Incoming state:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    ((StateVector*)incoming)->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  assert(stack_size() == incoming->stack_size(), "sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  bool different = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  Cell limit = limit_cell();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  for (Cell c = start_cell(); c < limit; c = next_cell(c)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    ciType* t1 = type_at(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    ciType* t2 = incoming->type_at(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    if (!t1->equals(t2)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
      ciType* new_type = type_meet(t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
      if (!t1->equals(new_type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
        set_type_at(c, new_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
        different = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  return different;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
// ciTypeFlow::StateVector::meet_exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
// Meets this StateVector with another, destructively modifying this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
// one.  The incoming state is coming via an exception.  Returns true
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
// if any modification takes place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
bool ciTypeFlow::StateVector::meet_exception(ciInstanceKlass* exc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
                                     const ciTypeFlow::StateVector* incoming) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  if (monitor_count() == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    set_monitor_count(incoming->monitor_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  assert(monitor_count() == incoming->monitor_count(), "monitors must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  if (stack_size() == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    set_stack_size(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  assert(stack_size() ==  1, "must have one-element stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  bool different = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  // Meet locals from incoming array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  Cell limit = local(_outer->max_locals()-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  for (Cell c = start_cell(); c <= limit; c = next_cell(c)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
    ciType* t1 = type_at(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    ciType* t2 = incoming->type_at(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    if (!t1->equals(t2)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
      ciType* new_type = type_meet(t1, t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      if (!t1->equals(new_type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        set_type_at(c, new_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        different = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  // Handle stack separately.  When an exception occurs, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  // only stack entry is the exception instance.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  ciType* tos_type = type_at_tos();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  if (!tos_type->equals(exc)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    ciType* new_type = type_meet(tos_type, exc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    if (!tos_type->equals(new_type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      set_type_at_tos(new_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      different = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  return different;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
// ciTypeFlow::StateVector::push_translate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
void ciTypeFlow::StateVector::push_translate(ciType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  BasicType basic_type = type->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  if (basic_type == T_BOOLEAN || basic_type == T_CHAR ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
      basic_type == T_BYTE    || basic_type == T_SHORT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    push(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    if (type->is_two_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
      push(half_type(type));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
// ciTypeFlow::StateVector::do_aaload
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
void ciTypeFlow::StateVector::do_aaload(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  ciObjArrayKlass* array_klass = pop_objArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  if (array_klass == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
    // Did aaload on a null reference; push a null and ignore the exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    // This instruction will never continue normally.  All we have to do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    // is report a value that will meet correctly with any downstream
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    // reference types on paths that will truly be executed.  This null type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    // meets with any reference type to yield that same reference type.
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1623
diff changeset
   560
    // (The compiler will generate an unconditional exception here.)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    push(null_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  if (!array_klass->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    // Only fails for some -Xcomp runs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    trap(str, array_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
         Deoptimization::make_trap_request
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
         (Deoptimization::Reason_unloaded,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
          Deoptimization::Action_reinterpret));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  ciKlass* element_klass = array_klass->element_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  if (!element_klass->is_loaded() && element_klass->is_instance_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    Untested("unloaded array element class in ciTypeFlow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    trap(str, element_klass,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
         Deoptimization::make_trap_request
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
         (Deoptimization::Reason_unloaded,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
          Deoptimization::Action_reinterpret));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    push_object(element_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
// ciTypeFlow::StateVector::do_checkcast
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
void ciTypeFlow::StateVector::do_checkcast(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  ciKlass* klass = str->get_klass(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
    // VM's interpreter will not load 'klass' if object is NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    // Type flow after this block may still be needed in two situations:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    // 1) C2 uses do_null_assert() and continues compilation for later blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    // 2) C2 does an OSR compile in a later block (see bug 4778368).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    do_null_assert(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    push_object(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
// ciTypeFlow::StateVector::do_getfield
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
void ciTypeFlow::StateVector::do_getfield(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  // could add assert here for type of object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  do_getstatic(str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
// ciTypeFlow::StateVector::do_getstatic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
void ciTypeFlow::StateVector::do_getstatic(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  ciField* field = str->get_field(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    trap(str, field->holder(), str->get_field_holder_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    ciType* field_type = field->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    if (!field_type->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
      // Normally, we need the field's type to be loaded if we are to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
      // do anything interesting with its value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      // We used to do this:  trap(str, str->get_field_signature_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      // There is one good reason not to trap here.  Execution can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
      // get past this "getfield" or "getstatic" if the value of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      // the field is null.  As long as the value is null, the class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      // does not need to be loaded!  The compiler must assume that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
      // the value of the unloaded class reference is null; if the code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
      // ever sees a non-null value, loading has occurred.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
      // This actually happens often enough to be annoying.  If the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
      // compiler throws an uncommon trap at this bytecode, you can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
      // get an endless loop of recompilations, when all the code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
      // needs to do is load a series of null values.  Also, a trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
      // here can make an OSR entry point unreachable, triggering the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
      // assert on non_osr_block in ciTypeFlow::get_start_state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      // (See bug 4379915.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      do_null_assert(field_type->as_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      push_translate(field_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
// ciTypeFlow::StateVector::do_invoke
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
void ciTypeFlow::StateVector::do_invoke(ciBytecodeStream* str,
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   649
                                        bool has_receiver) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  bool will_link;
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   651
  ciSignature* declared_signature = NULL;
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   652
  ciMethod* callee = str->get_method(will_link, &declared_signature);
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   653
  assert(declared_signature != NULL, "cannot be null");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    // We weren't able to find the method.
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   656
    if (str->cur_bc() == Bytecodes::_invokedynamic) {
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   657
      trap(str, NULL,
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   658
           Deoptimization::make_trap_request
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   659
           (Deoptimization::Reason_uninitialized,
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   660
            Deoptimization::Action_reinterpret));
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   661
    } else {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 11445
diff changeset
   662
      ciKlass* unloaded_holder = callee->holder();
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   663
      trap(str, unloaded_holder, str->get_method_holder_index());
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
   664
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  } else {
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   666
    // We are using the declared signature here because it might be
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   667
    // different from the callee signature (Cf. invokedynamic and
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   668
    // invokehandle).
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   669
    ciSignatureStream sigstr(declared_signature);
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   670
    const int arg_size = declared_signature->size();
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   671
    const int stack_base = stack_size() - arg_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
    int i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    for( ; !sigstr.at_return_type(); sigstr.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
      ciType* type = sigstr.type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
      ciType* stack_type = type_at(stack(stack_base + i++));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
      // Do I want to check this type?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
      // assert(stack_type->is_subtype_of(type), "bad type for field value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
      if (type->is_two_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
        ciType* stack_type2 = type_at(stack(stack_base + i++));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
        assert(stack_type2->equals(half_type(type)), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    assert(arg_size == i, "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
    for (int j = 0; j < arg_size; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    if (has_receiver) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
      // Check this?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
    assert(!sigstr.is_done(), "must have return type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
    ciType* return_type = sigstr.type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
    if (!return_type->is_void()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
      if (!return_type->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
        // As in do_getstatic(), generally speaking, we need the return type to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
        // be loaded if we are to do anything interesting with its value.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
        // We used to do this:  trap(str, str->get_method_signature_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
        //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
        // We do not trap here since execution can get past this invoke if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
        // the return value is null.  As long as the value is null, the class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
        // does not need to be loaded!  The compiler must assume that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
        // the value of the unloaded class reference is null; if the code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
        // ever sees a non-null value, loading has occurred.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
        //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
        // See do_getstatic() for similar explanation, as well as bug 4684993.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
        do_null_assert(return_type->as_klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
        push_translate(return_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
// ciTypeFlow::StateVector::do_jsr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
void ciTypeFlow::StateVector::do_jsr(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  push(ciReturnAddress::make(str->next_bci()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
// ciTypeFlow::StateVector::do_ldc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
void ciTypeFlow::StateVector::do_ldc(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  ciConstant con = str->get_constant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  BasicType basic_type = con.basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  if (basic_type == T_ILLEGAL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    // OutOfMemoryError in the CI while loading constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    push_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
    outer()->record_failure("ldc did not link");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  if (basic_type == T_OBJECT || basic_type == T_ARRAY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
    ciObject* obj = con.as_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
    if (obj->is_null_object()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
      push_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    } else {
26944
d515f86283be 8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents: 22234
diff changeset
   736
      assert(obj->is_instance() || obj->is_array(), "must be java_mirror of klass");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
      push_object(obj->klass());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
    push_translate(ciType::make(basic_type));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
// ciTypeFlow::StateVector::do_multianewarray
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
void ciTypeFlow::StateVector::do_multianewarray(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  int dimensions = str->get_dimensions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  ciArrayKlass* array_klass = str->get_klass(will_link)->as_array_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    trap(str, array_klass, str->get_klass_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    for (int i = 0; i < dimensions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
    push_object(array_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
// ciTypeFlow::StateVector::do_new
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
void ciTypeFlow::StateVector::do_new(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  ciKlass* klass = str->get_klass(will_link);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
   765
  if (!will_link || str->is_unresolved_klass()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
    trap(str, klass, str->get_klass_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    push_object(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
// ciTypeFlow::StateVector::do_newarray
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
void ciTypeFlow::StateVector::do_newarray(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  ciKlass* klass = ciTypeArrayKlass::make((BasicType)str->get_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  push_object(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
// ciTypeFlow::StateVector::do_putfield
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
void ciTypeFlow::StateVector::do_putfield(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  do_putstatic(str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  if (_trap_bci != -1)  return;  // unloaded field holder, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  // could add assert here for type of object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
// ciTypeFlow::StateVector::do_putstatic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
void ciTypeFlow::StateVector::do_putstatic(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
  ciField* field = str->get_field(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
  if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
    trap(str, field->holder(), str->get_field_holder_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    ciType* field_type = field->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    ciType* type = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
    // Do I want to check this type?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    //      assert(type->is_subtype_of(field_type), "bad type for field value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    if (field_type->is_two_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
      ciType* type2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
      assert(type2->is_two_word(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
      assert(type == half_type(type2), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
// ciTypeFlow::StateVector::do_ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
void ciTypeFlow::StateVector::do_ret(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  Cell index = local(str->get_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  ciType* address = type_at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  assert(address->is_return_address(), "bad return address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
  set_type_at(index, bottom_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
// ciTypeFlow::StateVector::trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
// Stop interpretation of this path with a trap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
void ciTypeFlow::StateVector::trap(ciBytecodeStream* str, ciKlass* klass, int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  _trap_bci = str->cur_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  _trap_index = index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  // Log information about this trap:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  CompileLog* log = outer()->env()->log();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  if (log != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
    int mid = log->identify(outer()->method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
    int kid = (klass == NULL)? -1: log->identify(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
    log->begin_elem("uncommon_trap method='%d' bci='%d'", mid, str->cur_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    char buf[100];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
    log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
                                                          index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
    if (kid >= 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
      log->print(" klass='%d'", kid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
    log->end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
// ciTypeFlow::StateVector::do_null_assert
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
// Corresponds to graphKit::do_null_assert.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
void ciTypeFlow::StateVector::do_null_assert(ciKlass* unloaded_klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  if (unloaded_klass->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
    // We failed to link, but we can still compute with this class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
    // since it is loaded somewhere.  The compiler will uncommon_trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
    // if the object is not null, but the typeflow pass can not assume
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
    // that the object will be null, otherwise it may incorrectly tell
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
    // the parser that an object is known to be null. 4761344, 4807707
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
    push_object(unloaded_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
    // The class is not loaded anywhere.  It is safe to model the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
    // null in the typestates, because we can compile in a null check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    // which will deoptimize us if someone manages to load the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
    // class later.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
    push_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
// ciTypeFlow::StateVector::apply_one_bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
// Apply the effect of one bytecode to this StateVector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
bool ciTypeFlow::StateVector::apply_one_bytecode(ciBytecodeStream* str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  _trap_bci = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
  _trap_index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
    tty->print_cr(">> Interpreting bytecode %d:%s", str->cur_bci(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
                  Bytecodes::name(str->cur_bc()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  switch(str->cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  case Bytecodes::_aaload: do_aaload(str);                       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  case Bytecodes::_aastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
      pop_objArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
  case Bytecodes::_aconst_null:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
      push_null();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  case Bytecodes::_aload:   load_local_object(str->get_index());    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
  case Bytecodes::_aload_0: load_local_object(0);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  case Bytecodes::_aload_1: load_local_object(1);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  case Bytecodes::_aload_2: load_local_object(2);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  case Bytecodes::_aload_3: load_local_object(3);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  case Bytecodes::_anewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
      bool will_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
      ciKlass* element_klass = str->get_klass(will_link);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
      if (!will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
        trap(str, element_klass, str->get_klass_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
        push_object(ciObjArrayKlass::make(element_klass));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
  case Bytecodes::_ifnonnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  case Bytecodes::_ifnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  case Bytecodes::_monitorenter:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
      set_monitor_count(monitor_count() + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  case Bytecodes::_monitorexit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
      assert(monitor_count() > 0, "must be a monitor to exit from");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
      set_monitor_count(monitor_count() - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  case Bytecodes::_arraylength:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
      pop_array();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  case Bytecodes::_astore:   store_local_object(str->get_index());  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  case Bytecodes::_astore_0: store_local_object(0);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  case Bytecodes::_astore_1: store_local_object(1);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  case Bytecodes::_astore_2: store_local_object(2);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  case Bytecodes::_astore_3: store_local_object(3);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  case Bytecodes::_athrow:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
      NEEDS_CLEANUP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
  case Bytecodes::_baload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  case Bytecodes::_caload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
  case Bytecodes::_iaload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  case Bytecodes::_saload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
      ciTypeArrayKlass* array_klass = pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
      // Put assert here for right type?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  case Bytecodes::_bastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
  case Bytecodes::_castore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
  case Bytecodes::_iastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
  case Bytecodes::_sastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
      pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
      // assert here?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
  case Bytecodes::_bipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
  case Bytecodes::_iconst_m1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
  case Bytecodes::_iconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
  case Bytecodes::_iconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
  case Bytecodes::_iconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
  case Bytecodes::_iconst_3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  case Bytecodes::_iconst_4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
  case Bytecodes::_iconst_5:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
  case Bytecodes::_sipush:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
  case Bytecodes::_checkcast: do_checkcast(str);                  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
  case Bytecodes::_d2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
  case Bytecodes::_d2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  case Bytecodes::_d2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
  case Bytecodes::_dadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  case Bytecodes::_ddiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
  case Bytecodes::_dmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
  case Bytecodes::_drem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
  case Bytecodes::_dsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  case Bytecodes::_daload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
      ciTypeArrayKlass* array_klass = pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
      // Put assert here for right type?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  case Bytecodes::_dastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
      pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
      // assert here?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
  case Bytecodes::_dcmpg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  case Bytecodes::_dcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
  case Bytecodes::_dconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
  case Bytecodes::_dconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  case Bytecodes::_dload:   load_local_double(str->get_index());    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  case Bytecodes::_dload_0: load_local_double(0);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  case Bytecodes::_dload_1: load_local_double(1);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  case Bytecodes::_dload_2: load_local_double(2);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  case Bytecodes::_dload_3: load_local_double(3);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  case Bytecodes::_dneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
  case Bytecodes::_dreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
      pop_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
  case Bytecodes::_dstore:   store_local_double(str->get_index());  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
  case Bytecodes::_dstore_0: store_local_double(0);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
  case Bytecodes::_dstore_1: store_local_double(1);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
  case Bytecodes::_dstore_2: store_local_double(2);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  case Bytecodes::_dstore_3: store_local_double(3);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
  case Bytecodes::_dup:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
      push(type_at_tos());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
  case Bytecodes::_dup_x1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
      ciType* value1 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
      ciType* value2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
  case Bytecodes::_dup_x2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
      ciType* value1 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
      ciType* value2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
      ciType* value3 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
      push(value3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
  case Bytecodes::_dup2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
      ciType* value1 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
      ciType* value2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
  case Bytecodes::_dup2_x1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
      ciType* value1 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
      ciType* value2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
      ciType* value3 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
      push(value3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  case Bytecodes::_dup2_x2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
      ciType* value1 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
      ciType* value2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
      ciType* value3 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
      ciType* value4 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
      push(value4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
      push(value3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  case Bytecodes::_f2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
  case Bytecodes::_f2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  case Bytecodes::_f2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
  case Bytecodes::_fadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
  case Bytecodes::_fdiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
  case Bytecodes::_fmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
  case Bytecodes::_frem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  case Bytecodes::_fsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  case Bytecodes::_faload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
      ciTypeArrayKlass* array_klass = pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
      // Put assert here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
  case Bytecodes::_fastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
      ciTypeArrayKlass* array_klass = pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
      // Put assert here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
  case Bytecodes::_fcmpg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
  case Bytecodes::_fcmpl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
  case Bytecodes::_fconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
  case Bytecodes::_fconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
  case Bytecodes::_fconst_2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
  case Bytecodes::_fload:   load_local_float(str->get_index());     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
  case Bytecodes::_fload_0: load_local_float(0);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
  case Bytecodes::_fload_1: load_local_float(1);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
  case Bytecodes::_fload_2: load_local_float(2);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
  case Bytecodes::_fload_3: load_local_float(3);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
  case Bytecodes::_fneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
  case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
      pop_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
  case Bytecodes::_fstore:    store_local_float(str->get_index());   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  case Bytecodes::_fstore_0:  store_local_float(0);                  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
  case Bytecodes::_fstore_1:  store_local_float(1);                  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  case Bytecodes::_fstore_2:  store_local_float(2);                  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  case Bytecodes::_fstore_3:  store_local_float(3);                  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  case Bytecodes::_getfield:  do_getfield(str);                      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
  case Bytecodes::_getstatic: do_getstatic(str);                     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
  case Bytecodes::_goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
  case Bytecodes::_goto_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
  case Bytecodes::_nop:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
  case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
      // do nothing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
  case Bytecodes::_i2b:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
  case Bytecodes::_i2c:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
  case Bytecodes::_i2s:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
  case Bytecodes::_ineg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
  case Bytecodes::_i2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
  case Bytecodes::_i2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
  case Bytecodes::_i2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
  case Bytecodes::_iadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
  case Bytecodes::_iand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
  case Bytecodes::_idiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  case Bytecodes::_imul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
  case Bytecodes::_ior:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  case Bytecodes::_irem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  case Bytecodes::_ishl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
  case Bytecodes::_ishr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  case Bytecodes::_isub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
  case Bytecodes::_iushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  case Bytecodes::_ixor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
  case Bytecodes::_if_acmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
  case Bytecodes::_if_acmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  case Bytecodes::_if_icmpeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
  case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  case Bytecodes::_if_icmpgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  case Bytecodes::_if_icmple:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  case Bytecodes::_if_icmplt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
  case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
  case Bytecodes::_ifeq:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
  case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
  case Bytecodes::_iflt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
  case Bytecodes::_ifgt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
  case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
  case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
  case Bytecodes::_tableswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
  case Bytecodes::_iinc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
    {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1298
      int lnum = str->get_index();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1299
      check_int(local(lnum));
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1300
      store_to_local(lnum);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
  case Bytecodes::_iload:   load_local_int(str->get_index()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  case Bytecodes::_iload_0: load_local_int(0);                      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  case Bytecodes::_iload_1: load_local_int(1);                      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
  case Bytecodes::_iload_2: load_local_int(2);                      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
  case Bytecodes::_iload_3: load_local_int(3);                      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  case Bytecodes::_instanceof:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
      // Check for uncommon trap:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
      do_checkcast(str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
      pop_object();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  case Bytecodes::_invokeinterface: do_invoke(str, true);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
  case Bytecodes::_invokespecial:   do_invoke(str, true);           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  case Bytecodes::_invokestatic:    do_invoke(str, false);          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
  case Bytecodes::_invokevirtual:   do_invoke(str, true);           break;
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 3910
diff changeset
  1321
  case Bytecodes::_invokedynamic:   do_invoke(str, false);          break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  case Bytecodes::_istore:   store_local_int(str->get_index());     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
  case Bytecodes::_istore_0: store_local_int(0);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
  case Bytecodes::_istore_1: store_local_int(1);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
  case Bytecodes::_istore_2: store_local_int(2);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
  case Bytecodes::_istore_3: store_local_int(3);                    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
  case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  case Bytecodes::_jsr_w: do_jsr(str);                              break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
  case Bytecodes::_l2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
      push_double();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  case Bytecodes::_l2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
      push_float();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
  case Bytecodes::_l2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
  case Bytecodes::_ladd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
  case Bytecodes::_land:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
  case Bytecodes::_ldiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
  case Bytecodes::_lmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
  case Bytecodes::_lor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
  case Bytecodes::_lrem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  case Bytecodes::_lsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
  case Bytecodes::_lxor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
  case Bytecodes::_laload:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
      ciTypeArrayKlass* array_klass = pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
      // Put assert here for right type?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
  case Bytecodes::_lastore:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
      pop_typeArray();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
      // assert here?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  case Bytecodes::_lcmp:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
      push_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
  case Bytecodes::_lconst_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
  case Bytecodes::_lconst_1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
  case Bytecodes::_ldc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
  case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
  case Bytecodes::_ldc2_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
      do_ldc(str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
  case Bytecodes::_lload:   load_local_long(str->get_index());      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
  case Bytecodes::_lload_0: load_local_long(0);                     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
  case Bytecodes::_lload_1: load_local_long(1);                     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
  case Bytecodes::_lload_2: load_local_long(2);                     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
  case Bytecodes::_lload_3: load_local_long(3);                     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  case Bytecodes::_lneg:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
  case Bytecodes::_lreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  case Bytecodes::_lshl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
  case Bytecodes::_lshr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  case Bytecodes::_lushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
      pop_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
      pop_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
      push_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
  case Bytecodes::_lstore:   store_local_long(str->get_index());    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
  case Bytecodes::_lstore_0: store_local_long(0);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
  case Bytecodes::_lstore_1: store_local_long(1);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
  case Bytecodes::_lstore_2: store_local_long(2);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
  case Bytecodes::_lstore_3: store_local_long(3);                   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
  case Bytecodes::_multianewarray: do_multianewarray(str);          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
  case Bytecodes::_new:      do_new(str);                           break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
  case Bytecodes::_newarray: do_newarray(str);                      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
  case Bytecodes::_pop:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
  case Bytecodes::_pop2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
  case Bytecodes::_putfield:       do_putfield(str);                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
  case Bytecodes::_putstatic:      do_putstatic(str);                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
  case Bytecodes::_ret: do_ret(str);                                 break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
  case Bytecodes::_swap:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
      ciType* value1 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
      ciType* value2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
      push(value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
      push(value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
  case Bytecodes::_wide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
      // The iterator should skip this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
    print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
  return (_trap_bci != -1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
// ciTypeFlow::StateVector::print_cell_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
void ciTypeFlow::StateVector::print_cell_on(outputStream* st, Cell c) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  ciType* type = type_at(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  if (type == top_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
    st->print("top");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
  } else if (type == bottom_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
    st->print("bottom");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  } else if (type == null_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
    st->print("null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  } else if (type == long2_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
    st->print("long2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
  } else if (type == double2_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
    st->print("double2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
  } else if (is_int(type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
    st->print("int");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  } else if (is_long(type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
    st->print("long");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
  } else if (is_float(type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
    st->print("float");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
  } else if (is_double(type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
    st->print("double");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
  } else if (type->is_return_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
    st->print("address(%d)", type->as_return_address()->bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
    if (type->is_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
      type->as_klass()->name()->print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
      st->print("UNEXPECTED TYPE");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
      type->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
// ciTypeFlow::StateVector::print_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
void ciTypeFlow::StateVector::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
  int num_locals   = _outer->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
  int num_stack    = stack_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
  int num_monitors = monitor_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
  st->print_cr("  State : locals %d, stack %d, monitors %d", num_locals, num_stack, num_monitors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
  if (num_stack >= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
    int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
    for (i = 0; i < num_locals; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
      st->print("    local %2d : ", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
      print_cell_on(st, local(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
      st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
    for (i = 0; i < num_stack; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
      st->print("    stack %2d : ", i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
      print_cell_on(st, stack(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
      st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1538
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1539
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1540
// ciTypeFlow::SuccIter::next
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1541
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1542
void ciTypeFlow::SuccIter::next() {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1543
  int succ_ct = _pred->successors()->length();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1544
  int next = _index + 1;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1545
  if (next < succ_ct) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1546
    _index = next;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1547
    _succ = _pred->successors()->at(next);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1548
    return;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1549
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1550
  for (int i = next - succ_ct; i < _pred->exceptions()->length(); i++) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1551
    // Do not compile any code for unloaded exception types.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1552
    // Following compiler passes are responsible for doing this also.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1553
    ciInstanceKlass* exception_klass = _pred->exc_klasses()->at(i);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1554
    if (exception_klass->is_loaded()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1555
      _index = next;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1556
      _succ = _pred->exceptions()->at(i);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1557
      return;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1558
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1559
    next++;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1560
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1561
  _index = -1;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1562
  _succ = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1563
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1564
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1565
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1566
// ciTypeFlow::SuccIter::set_succ
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1567
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1568
void ciTypeFlow::SuccIter::set_succ(Block* succ) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1569
  int succ_ct = _pred->successors()->length();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1570
  if (_index < succ_ct) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1571
    _pred->successors()->at_put(_index, succ);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1572
  } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1573
    int idx = _index - succ_ct;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1574
    _pred->exceptions()->at_put(idx, succ);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1575
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1576
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1577
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
// ciTypeFlow::Block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
// A basic block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
// ciTypeFlow::Block::Block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
ciTypeFlow::Block::Block(ciTypeFlow* outer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
                         ciBlock *ciblk,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
                         ciTypeFlow::JsrSet* jsrs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
  _ciblock = ciblk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
  _exceptions = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
  _exc_klasses = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
  _successors = NULL;
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1591
  _predecessors = new (outer->arena()) GrowableArray<Block*>(outer->arena(), 1, 0, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
  _state = new (outer->arena()) StateVector(outer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
  JsrSet* new_jsrs =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
    new (outer->arena()) JsrSet(outer->arena(), jsrs->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
  jsrs->copy_into(new_jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
  _jsrs = new_jsrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
  _next = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  _on_work_list = false;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1599
  _backedge_copy = false;
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  1600
  _has_monitorenter = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
  _trap_bci = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
  _trap_index = 0;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1603
  df_init();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
    tty->print_cr(">> Created new block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
    print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  assert(this->outer() == outer, "outer link set up");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
  assert(!outer->have_block_count(), "must not have mapped blocks yet");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
// ------------------------------------------------------------------
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1615
// ciTypeFlow::Block::df_init
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1616
void ciTypeFlow::Block::df_init() {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1617
  _pre_order = -1; assert(!has_pre_order(), "");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1618
  _post_order = -1; assert(!has_post_order(), "");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1619
  _loop = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1620
  _irreducible_entry = false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1621
  _rpo_next = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
// ciTypeFlow::Block::successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
// Get the successors for this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
GrowableArray<ciTypeFlow::Block*>*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
ciTypeFlow::Block::successors(ciBytecodeStream* str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
                              ciTypeFlow::StateVector* state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
                              ciTypeFlow::JsrSet* jsrs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
  if (_successors == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
    if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
      tty->print(">> Computing successors for block ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
      print_value_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
    ciTypeFlow* analyzer = outer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
    Arena* arena = analyzer->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
    Block* block = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
    bool has_successor = !has_trap() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
                         (control() != ciBlock::fall_through_bci || limit() < analyzer->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
    if (!has_successor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
      _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
        new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
      // No successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
    } else if (control() == ciBlock::fall_through_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
      assert(str->cur_bci() == limit(), "bad block end");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
      // This block simply falls through to the next.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
      _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
        new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
      Block* block = analyzer->block_at(limit(), _jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
      assert(_successors->length() == FALL_THROUGH, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
      _successors->append(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
      int current_bci = str->cur_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
      int next_bci = str->next_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
      int branch_bci = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
      Block* target = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
      assert(str->next_bci() == limit(), "bad block end");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
      // This block is not a simple fall-though.  Interpret
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
      // the current bytecode to find our successors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
      switch (str->cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
      case Bytecodes::_ifeq:         case Bytecodes::_ifne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
      case Bytecodes::_iflt:         case Bytecodes::_ifge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
      case Bytecodes::_ifgt:         case Bytecodes::_ifle:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
      case Bytecodes::_if_icmpeq:    case Bytecodes::_if_icmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
      case Bytecodes::_if_icmplt:    case Bytecodes::_if_icmpge:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
      case Bytecodes::_if_icmpgt:    case Bytecodes::_if_icmple:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
      case Bytecodes::_if_acmpeq:    case Bytecodes::_if_acmpne:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
      case Bytecodes::_ifnull:       case Bytecodes::_ifnonnull:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
        // Our successors are the branch target and the next bci.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
        branch_bci = str->get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
          new (arena) GrowableArray<Block*>(arena, 2, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
        assert(_successors->length() == IF_NOT_TAKEN, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
        _successors->append(analyzer->block_at(next_bci, jsrs));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
        assert(_successors->length() == IF_TAKEN, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
        _successors->append(analyzer->block_at(branch_bci, jsrs));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
      case Bytecodes::_goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
        branch_bci = str->get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
          new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
        assert(_successors->length() == GOTO_TARGET, "");
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1689
        _successors->append(analyzer->block_at(branch_bci, jsrs));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
      case Bytecodes::_jsr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
        branch_bci = str->get_dest();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
          new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
        assert(_successors->length() == GOTO_TARGET, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
        _successors->append(analyzer->block_at(branch_bci, jsrs));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
      case Bytecodes::_goto_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
      case Bytecodes::_jsr_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
          new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
        assert(_successors->length() == GOTO_TARGET, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
        _successors->append(analyzer->block_at(str->get_far_dest(), jsrs));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
      case Bytecodes::_tableswitch:  {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1709
        Bytecode_tableswitch tableswitch(str);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1711
        int len = tableswitch.length();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
          new (arena) GrowableArray<Block*>(arena, len+1, 0, NULL);
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1714
        int bci = current_bci + tableswitch.default_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
        Block* block = analyzer->block_at(bci, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
        assert(_successors->length() == SWITCH_DEFAULT, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
        _successors->append(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
        while (--len >= 0) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1719
          int bci = current_bci + tableswitch.dest_offset_at(len);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
          block = analyzer->block_at(bci, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
          assert(_successors->length() >= SWITCH_CASES, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
          _successors->append_if_missing(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
      case Bytecodes::_lookupswitch: {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1728
        Bytecode_lookupswitch lookupswitch(str);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1730
        int npairs = lookupswitch.number_of_pairs();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
          new (arena) GrowableArray<Block*>(arena, npairs+1, 0, NULL);
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1733
        int bci = current_bci + lookupswitch.default_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
        Block* block = analyzer->block_at(bci, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
        assert(_successors->length() == SWITCH_DEFAULT, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
        _successors->append(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
        while(--npairs >= 0) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1738
          LookupswitchPair pair = lookupswitch.pair_at(npairs);
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
  1739
          int bci = current_bci + pair.offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
          Block* block = analyzer->block_at(bci, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
          assert(_successors->length() >= SWITCH_CASES, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
          _successors->append_if_missing(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
      case Bytecodes::_athrow:     case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
      case Bytecodes::_lreturn:    case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
      case Bytecodes::_dreturn:    case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
      case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
          new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
        // No successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
      case Bytecodes::_ret: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
        _successors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
          new (arena) GrowableArray<Block*>(arena, 1, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
        Cell local = state->local(str->get_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
        ciType* return_address = state->type_at(local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
        assert(return_address->is_return_address(), "verify: wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
        int bci = return_address->as_return_address()->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
        assert(_successors->length() == GOTO_TARGET, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
        _successors->append(analyzer->block_at(bci, jsrs));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
      case Bytecodes::_wide:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
    }
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1775
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1776
    // Set predecessor information
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1777
    for (int i = 0; i < _successors->length(); i++) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1778
      Block* block = _successors->at(i);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1779
      block->predecessors()->append(this);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1780
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
  return _successors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
// ciTypeFlow::Block:compute_exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
// Compute the exceptional successors and types for this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
void ciTypeFlow::Block::compute_exceptions() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
  assert(_exceptions == NULL && _exc_klasses == NULL, "repeat");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
    tty->print(">> Computing exceptions for block ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
    print_value_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
  ciTypeFlow* analyzer = outer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
  Arena* arena = analyzer->arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
  // Any bci in the block will do.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
  ciExceptionHandlerStream str(analyzer->method(), start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
  // Allocate our growable arrays.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
  int exc_count = str.count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
  _exceptions = new (arena) GrowableArray<Block*>(arena, exc_count, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
  _exc_klasses = new (arena) GrowableArray<ciInstanceKlass*>(arena, exc_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
                                                             0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
  for ( ; !str.is_done(); str.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
    ciExceptionHandler* handler = str.handler();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
    int bci = handler->handler_bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
    ciInstanceKlass* klass = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
    if (bci == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
      // There is no catch all.  It is possible to exit the method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
    if (handler->is_catch_all()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
      klass = analyzer->env()->Throwable_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
      klass = handler->catch_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
    }
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1823
    Block* block = analyzer->block_at(bci, _jsrs);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1824
    _exceptions->append(block);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1825
    block->predecessors()->append(this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
    _exc_klasses->append(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
// ------------------------------------------------------------------
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1831
// ciTypeFlow::Block::set_backedge_copy
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1832
// Use this only to make a pre-existing public block into a backedge copy.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1833
void ciTypeFlow::Block::set_backedge_copy(bool z) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1834
  assert(z || (z == is_backedge_copy()), "cannot make a backedge copy public");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1835
  _backedge_copy = z;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
// ------------------------------------------------------------------
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1839
// ciTypeFlow::Block::is_clonable_exit
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1840
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1841
// At most 2 normal successors, one of which continues looping,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1842
// and all exceptional successors must exit.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1843
bool ciTypeFlow::Block::is_clonable_exit(ciTypeFlow::Loop* lp) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1844
  int normal_cnt  = 0;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1845
  int in_loop_cnt = 0;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1846
  for (SuccIter iter(this); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1847
    Block* succ = iter.succ();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1848
    if (iter.is_normal_ctrl()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1849
      if (++normal_cnt > 2) return false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1850
      if (lp->contains(succ->loop())) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1851
        if (++in_loop_cnt > 1) return false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1852
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1853
    } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1854
      if (lp->contains(succ->loop())) return false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1855
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1856
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1857
  return in_loop_cnt == 1;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1858
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1859
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1860
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1861
// ciTypeFlow::Block::looping_succ
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1862
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1863
ciTypeFlow::Block* ciTypeFlow::Block::looping_succ(ciTypeFlow::Loop* lp) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1864
  assert(successors()->length() <= 2, "at most 2 normal successors");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1865
  for (SuccIter iter(this); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1866
    Block* succ = iter.succ();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1867
    if (lp->contains(succ->loop())) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1868
      return succ;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1869
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1870
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1871
  return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
// ciTypeFlow::Block::print_value_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
void ciTypeFlow::Block::print_value_on(outputStream* st) const {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1878
  if (has_pre_order()) st->print("#%-2d ", pre_order());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1879
  if (has_rpo())       st->print("rpo#%-2d ", rpo());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
  st->print("[%d - %d)", start(), limit());
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1881
  if (is_loop_head()) st->print(" lphd");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1882
  if (is_irreducible_entry()) st->print(" irred");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
  if (_jsrs->size() > 0) { st->print("/");  _jsrs->print_on(st); }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1884
  if (is_backedge_copy())  st->print("/backedge_copy");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
// ciTypeFlow::Block::print_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
void ciTypeFlow::Block::print_on(outputStream* st) const {
8865
634fdd9b3425 7025708: Assertion if using "-XX:+CITraceTypeFlow -XX:+Verbose" together
never
parents: 7913
diff changeset
  1890
  if ((Verbose || WizardMode) && (limit() >= 0)) {
634fdd9b3425 7025708: Assertion if using "-XX:+CITraceTypeFlow -XX:+Verbose" together
never
parents: 7913
diff changeset
  1891
    // Don't print 'dummy' blocks (i.e. blocks with limit() '-1')
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
    outer()->method()->print_codes_on(start(), limit(), st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
  st->print_cr("  ====================================================  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
  st->print ("  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
  print_value_on(st);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1897
  st->print(" Stored locals: "); def_locals()->print_on(st, outer()->method()->max_locals()); tty->cr();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1898
  if (loop() && loop()->parent() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1899
    st->print(" loops:");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1900
    Loop* lp = loop();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1901
    do {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1902
      st->print(" %d<-%d", lp->head()->pre_order(),lp->tail()->pre_order());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1903
      if (lp->is_irreducible()) st->print("(ir)");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1904
      lp = lp->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1905
    } while (lp->parent() != NULL);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1906
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
  st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
  _state->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
  if (_successors == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
    st->print_cr("  No successor information");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
    int num_successors = _successors->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
    st->print_cr("  Successors : %d", num_successors);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
    for (int i = 0; i < num_successors; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
      Block* successor = _successors->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
      st->print("    ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
      successor->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
      st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
  }
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1921
  if (_predecessors == NULL) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1922
    st->print_cr("  No predecessor information");
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1923
  } else {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1924
    int num_predecessors = _predecessors->length();
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1925
    st->print_cr("  Predecessors : %d", num_predecessors);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1926
    for (int i = 0; i < num_predecessors; i++) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1927
      Block* predecessor = _predecessors->at(i);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1928
      st->print("    ");
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1929
      predecessor->print_value_on(st);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1930
      st->cr();
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1931
    }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  1932
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
  if (_exceptions == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
    st->print_cr("  No exception information");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
    int num_exceptions = _exceptions->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
    st->print_cr("  Exceptions : %d", num_exceptions);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
    for (int i = 0; i < num_exceptions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
      Block* exc_succ = _exceptions->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
      ciInstanceKlass* exc_klass = _exc_klasses->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
      st->print("    ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
      exc_succ->print_value_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
      st->print(" -- ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
      exc_klass->name()->print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
      st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
  if (has_trap()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
    st->print_cr("  Traps on %d with trap index %d", trap_bci(), trap_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
  st->print_cr("  ====================================================  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1955
#ifndef PRODUCT
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1956
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1957
// ciTypeFlow::LocalSet::print_on
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1958
void ciTypeFlow::LocalSet::print_on(outputStream* st, int limit) const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1959
  st->print("{");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1960
  for (int i = 0; i < max; i++) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1961
    if (test(i)) st->print(" %d", i);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1962
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1963
  if (limit > max) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1964
    st->print(" %d..%d ", max, limit);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1965
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1966
  st->print(" }");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1967
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1968
#endif
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1969
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
// ciTypeFlow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
// This is a pass over the bytecodes which computes the following:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
//   basic block structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
//   interpreter type-states (a la the verifier)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
// ciTypeFlow::ciTypeFlow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
ciTypeFlow::ciTypeFlow(ciEnv* env, ciMethod* method, int osr_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
  _method = method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
  _methodBlocks = method->get_method_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
  _max_locals = method->max_locals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
  _max_stack = method->max_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
  _code_size = method->code_size();
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  1985
  _has_irreducible_entry = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
  _osr_bci = osr_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
  _failure_reason = NULL;
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 29081
diff changeset
  1988
  assert(0 <= start_bci() && start_bci() < code_size() , "correct osr_bci argument: 0 <= %d < %d", start_bci(), code_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
  _work_list = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
  _ciblock_count = _methodBlocks->num_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
  _idx_to_blocklist = NEW_ARENA_ARRAY(arena(), GrowableArray<Block*>*, _ciblock_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
  for (int i = 0; i < _ciblock_count; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
    _idx_to_blocklist[i] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
  _block_map = NULL;  // until all blocks are seen
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
  _jsr_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
  _jsr_records = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
// ciTypeFlow::work_list_next
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
// Get the next basic block from our work list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
ciTypeFlow::Block* ciTypeFlow::work_list_next() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
  assert(!work_list_empty(), "work list must not be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
  Block* next_block = _work_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
  _work_list = next_block->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
  next_block->set_next(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
  next_block->set_on_work_list(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
  return next_block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
// ciTypeFlow::add_to_work_list
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
// Add a basic block to our work list.
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2018
// List is sorted by decreasing postorder sort (same as increasing RPO)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
void ciTypeFlow::add_to_work_list(ciTypeFlow::Block* block) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
  assert(!block->is_on_work_list(), "must not already be on work list");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
  if (CITraceTypeFlow) {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2023
    tty->print(">> Adding block ");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
    block->print_value_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
    tty->print_cr(" to the work list : ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
  block->set_on_work_list(true);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2029
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2030
  // decreasing post order sort
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2031
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2032
  Block* prev = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2033
  Block* current = _work_list;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2034
  int po = block->post_order();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2035
  while (current != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2036
    if (!current->has_post_order() || po > current->post_order())
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2037
      break;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2038
    prev = current;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2039
    current = current->next();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2040
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2041
  if (prev == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
    block->set_next(_work_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
    _work_list = block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
  } else {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2045
    block->set_next(current);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2046
    prev->set_next(block);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2048
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
// ciTypeFlow::block_at
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
// Return the block beginning at bci which has a JsrSet compatible
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
// with jsrs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
ciTypeFlow::Block* ciTypeFlow::block_at(int bci, ciTypeFlow::JsrSet* jsrs, CreateOption option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
  // First find the right ciBlock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
    tty->print(">> Requesting block for %d/", bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
    jsrs->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
  ciBlock* ciblk = _methodBlocks->block_containing(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
  assert(ciblk->start_bci() == bci, "bad ciBlock boundaries");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  Block* block = get_block_for(ciblk->index(), jsrs, option);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2071
  assert(block == NULL? (option == no_create): block->is_backedge_copy() == (option == create_backedge_copy), "create option consistent with result");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
    if (block != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
      tty->print(">> Found block ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
      block->print_value_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
      tty->print_cr(">> No such block.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
  return block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
// ciTypeFlow::make_jsr_record
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
// Make a JsrRecord for a given (entry, return) pair, if such a record
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
// does not already exist.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
ciTypeFlow::JsrRecord* ciTypeFlow::make_jsr_record(int entry_address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
                                                   int return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  if (_jsr_records == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
    _jsr_records = new (arena()) GrowableArray<JsrRecord*>(arena(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
                                                           _jsr_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
                                                           0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
                                                           NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
  JsrRecord* record = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
  int len = _jsr_records->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
    JsrRecord* record = _jsr_records->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
    if (record->entry_address() == entry_address &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
        record->return_address() == return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
      return record;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
  record = new (arena()) JsrRecord(entry_address, return_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
  _jsr_records->append(record);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
  return record;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
// ciTypeFlow::flow_exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
// Merge the current state into all exceptional successors at the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
// current point in the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
void ciTypeFlow::flow_exceptions(GrowableArray<ciTypeFlow::Block*>* exceptions,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
                                 GrowableArray<ciInstanceKlass*>* exc_klasses,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
                                 ciTypeFlow::StateVector* state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
  int len = exceptions->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
  assert(exc_klasses->length() == len, "must have same length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
    Block* block = exceptions->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
    ciInstanceKlass* exception_klass = exc_klasses->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
    if (!exception_klass->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
      // Do not compile any code for unloaded exception types.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
      // Following compiler passes are responsible for doing this also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
      continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
    if (block->meet_exception(exception_klass, state)) {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2135
      // Block was modified and has PO.  Add it to the work list.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2136
      if (block->has_post_order() &&
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2137
          !block->is_on_work_list()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
        add_to_work_list(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
// ciTypeFlow::flow_successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
// Merge the current state into all successors at the current point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
// in the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
void ciTypeFlow::flow_successors(GrowableArray<ciTypeFlow::Block*>* successors,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
                                 ciTypeFlow::StateVector* state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
  int len = successors->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
    Block* block = successors->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
    if (block->meet(state)) {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2155
      // Block was modified and has PO.  Add it to the work list.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2156
      if (block->has_post_order() &&
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2157
          !block->is_on_work_list()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
        add_to_work_list(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2161
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
// ciTypeFlow::can_trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
// Tells if a given instruction is able to generate an exception edge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
bool ciTypeFlow::can_trap(ciBytecodeStream& str) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
  // Cf. GenerateOopMap::do_exception_edge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
  if (!Bytecodes::can_trap(str.cur_bc()))  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
  switch (str.cur_bc()) {
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4566
diff changeset
  2173
    // %%% FIXME: ldc of Class can generate an exception
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
    case Bytecodes::_ldc:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
    case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
    case Bytecodes::_ldc2_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
    case Bytecodes::_aload_0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
      // These bytecodes can trap for rewriting.  We need to assume that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
      // they do not throw exceptions to make the monitor analysis work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
    case Bytecodes::_ireturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
    case Bytecodes::_lreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
    case Bytecodes::_freturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
    case Bytecodes::_dreturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
    case Bytecodes::_areturn:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
    case Bytecodes::_return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
      // We can assume the monitor stack is empty in this analysis.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
    case Bytecodes::_monitorexit:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
      // We can assume monitors are matched in this analysis.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2199
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2200
// ciTypeFlow::clone_loop_heads
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2201
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2202
// Clone the loop heads
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2203
bool ciTypeFlow::clone_loop_heads(Loop* lp, StateVector* temp_vector, JsrSet* temp_set) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2204
  bool rslt = false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2205
  for (PreorderLoops iter(loop_tree_root()); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2206
    lp = iter.current();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2207
    Block* head = lp->head();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2208
    if (lp == loop_tree_root() ||
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2209
        lp->is_irreducible() ||
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2210
        !head->is_clonable_exit(lp))
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2211
      continue;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2212
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2213
    // Avoid BoxLock merge.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2214
    if (EliminateNestedLocks && head->has_monitorenter())
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2215
      continue;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2216
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2217
    // check not already cloned
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2218
    if (head->backedge_copy_count() != 0)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2219
      continue;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2220
13931
37366c0290fc 7199742: A lot of C2 OSR compilations of the same method's bci
kvn
parents: 13728
diff changeset
  2221
    // Don't clone head of OSR loop to get correct types in start block.
37366c0290fc 7199742: A lot of C2 OSR compilations of the same method's bci
kvn
parents: 13728
diff changeset
  2222
    if (is_osr_flow() && head->start() == start_bci())
37366c0290fc 7199742: A lot of C2 OSR compilations of the same method's bci
kvn
parents: 13728
diff changeset
  2223
      continue;
37366c0290fc 7199742: A lot of C2 OSR compilations of the same method's bci
kvn
parents: 13728
diff changeset
  2224
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2225
    // check _no_ shared head below us
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2226
    Loop* ch;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2227
    for (ch = lp->child(); ch != NULL && ch->head() != head; ch = ch->sibling());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2228
    if (ch != NULL)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2229
      continue;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2230
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2231
    // Clone head
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2232
    Block* new_head = head->looping_succ(lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2233
    Block* clone = clone_loop_head(lp, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2234
    // Update lp's info
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2235
    clone->set_loop(lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2236
    lp->set_head(new_head);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2237
    lp->set_tail(clone);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2238
    // And move original head into outer loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2239
    head->set_loop(lp->parent());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2240
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2241
    rslt = true;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2242
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2243
  return rslt;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2244
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2245
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2246
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2247
// ciTypeFlow::clone_loop_head
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2248
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2249
// Clone lp's head and replace tail's successors with clone.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2250
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2251
//  |
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2252
//  v
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2253
// head <-> body
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2254
//  |
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2255
//  v
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2256
// exit
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2257
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2258
// new_head
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2259
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2260
//  |
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2261
//  v
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2262
// head ----------\
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2263
//  |             |
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2264
//  |             v
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2265
//  |  clone <-> body
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2266
//  |    |
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2267
//  | /--/
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2268
//  | |
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2269
//  v v
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2270
// exit
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2271
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2272
ciTypeFlow::Block* ciTypeFlow::clone_loop_head(Loop* lp, StateVector* temp_vector, JsrSet* temp_set) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2273
  Block* head = lp->head();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2274
  Block* tail = lp->tail();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2275
  if (CITraceTypeFlow) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2276
    tty->print(">> Requesting clone of loop head "); head->print_value_on(tty);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2277
    tty->print("  for predecessor ");                tail->print_value_on(tty);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2278
    tty->cr();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2279
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2280
  Block* clone = block_at(head->start(), head->jsrs(), create_backedge_copy);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2281
  assert(clone->backedge_copy_count() == 1, "one backedge copy for all back edges");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2282
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2283
  assert(!clone->has_pre_order(), "just created");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2284
  clone->set_next_pre_order();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2285
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2286
  // Insert clone after (orig) tail in reverse post order
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2287
  clone->set_rpo_next(tail->rpo_next());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2288
  tail->set_rpo_next(clone);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2289
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2290
  // tail->head becomes tail->clone
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2291
  for (SuccIter iter(tail); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2292
    if (iter.succ() == head) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2293
      iter.set_succ(clone);
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2294
      // Update predecessor information
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2295
      head->predecessors()->remove(tail);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2296
      clone->predecessors()->append(tail);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2297
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2298
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2299
  flow_block(tail, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2300
  if (head == tail) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2301
    // For self-loops, clone->head becomes clone->clone
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2302
    flow_block(clone, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2303
    for (SuccIter iter(clone); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2304
      if (iter.succ() == head) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2305
        iter.set_succ(clone);
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2306
        // Update predecessor information
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2307
        head->predecessors()->remove(clone);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2308
        clone->predecessors()->append(clone);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2309
        break;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2310
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2311
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2312
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2313
  flow_block(clone, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2314
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2315
  return clone;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2316
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
// ciTypeFlow::flow_block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
// Interpret the effects of the bytecodes on the incoming state
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2322
// vector of a basic block.  Push the changed state to succeeding
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2323
// basic blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2324
void ciTypeFlow::flow_block(ciTypeFlow::Block* block,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2325
                            ciTypeFlow::StateVector* state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2326
                            ciTypeFlow::JsrSet* jsrs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2327
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2328
    tty->print("\n>> ANALYZING BLOCK : ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2329
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2330
    block->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2331
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2332
  assert(block->has_pre_order(), "pre-order is assigned before 1st flow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2333
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2334
  int start = block->start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2335
  int limit = block->limit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2336
  int control = block->control();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2337
  if (control != ciBlock::fall_through_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2338
    limit = control;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2339
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2341
  // Grab the state from the current block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2342
  block->copy_state_into(state);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2343
  state->def_locals()->clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
  GrowableArray<Block*>*           exceptions = block->exceptions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
  GrowableArray<ciInstanceKlass*>* exc_klasses = block->exc_klasses();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2347
  bool has_exceptions = exceptions->length() > 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2348
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2349
  bool exceptions_used = false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2350
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2351
  ciBytecodeStream str(method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2352
  str.reset_to_bci(start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2353
  Bytecodes::Code code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2354
  while ((code = str.next()) != ciBytecodeStream::EOBC() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2355
         str.cur_bci() < limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2356
    // Check for exceptional control flow from this point.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2357
    if (has_exceptions && can_trap(str)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2358
      flow_exceptions(exceptions, exc_klasses, state);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2359
      exceptions_used = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
    // Apply the effects of the current bytecode to our state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
    bool res = state->apply_one_bytecode(&str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
    // Watch for bailouts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
    if (failing())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2367
    if (str.cur_bc() == Bytecodes::_monitorenter) {
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2368
      block->set_has_monitorenter();
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2369
    }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 8865
diff changeset
  2370
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
    if (res) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
      // We have encountered a trap.  Record it in this block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
      block->set_trap(state->trap_bci(), state->trap_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
      if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
        tty->print_cr(">> Found trap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
        block->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2380
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2381
      // Save set of locals defined in this block
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2382
      block->def_locals()->add(state->def_locals());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2383
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
      // Record (no) successors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
      block->successors(&str, state, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2387
      assert(!has_exceptions || exceptions_used, "Not removing exceptions");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2388
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2389
      // Discontinue interpretation of this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2390
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2391
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2392
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2393
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2394
  GrowableArray<Block*>* successors = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2395
  if (control != ciBlock::fall_through_bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2396
    // Check for exceptional control flow from this point.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2397
    if (has_exceptions && can_trap(str)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2398
      flow_exceptions(exceptions, exc_klasses, state);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2399
      exceptions_used = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2400
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2401
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2402
    // Fix the JsrSet to reflect effect of the bytecode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2403
    block->copy_jsrs_into(jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2404
    jsrs->apply_control(this, &str, state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2405
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2406
    // Find successor edges based on old state and new JsrSet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2407
    successors = block->successors(&str, state, jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2408
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2409
    // Apply the control changes to the state.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2410
    state->apply_one_bytecode(&str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2411
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2412
    // Fall through control
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2413
    successors = block->successors(&str, NULL, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2414
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2415
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2416
  // Save set of locals defined in this block
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2417
  block->def_locals()->add(state->def_locals());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2418
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2419
  // Remove untaken exception paths
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2420
  if (!exceptions_used)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2421
    exceptions->clear();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2422
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
  // Pass our state to successors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2424
  flow_successors(successors, state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2425
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2426
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2427
// ------------------------------------------------------------------
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2428
// ciTypeFlow::PostOrderLoops::next
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2429
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2430
// Advance to next loop tree using a postorder, left-to-right traversal.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2431
void ciTypeFlow::PostorderLoops::next() {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2432
  assert(!done(), "must not be done.");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2433
  if (_current->sibling() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2434
    _current = _current->sibling();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2435
    while (_current->child() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2436
      _current = _current->child();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2437
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2438
  } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2439
    _current = _current->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2440
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2441
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2442
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2443
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2444
// ciTypeFlow::PreOrderLoops::next
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2445
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2446
// Advance to next loop tree using a preorder, left-to-right traversal.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2447
void ciTypeFlow::PreorderLoops::next() {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2448
  assert(!done(), "must not be done.");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2449
  if (_current->child() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2450
    _current = _current->child();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2451
  } else if (_current->sibling() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2452
    _current = _current->sibling();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2453
  } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2454
    while (_current != _root && _current->sibling() == NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2455
      _current = _current->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2456
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2457
    if (_current == _root) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2458
      _current = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2459
      assert(done(), "must be done.");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2460
    } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2461
      assert(_current->sibling() != NULL, "must be more to do");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2462
      _current = _current->sibling();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2463
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2464
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2465
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2466
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2467
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2468
// ciTypeFlow::Loop::sorted_merge
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2469
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2470
// Merge the branch lp into this branch, sorting on the loop head
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2471
// pre_orders. Returns the leaf of the merged branch.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2472
// Child and sibling pointers will be setup later.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2473
// Sort is (looking from leaf towards the root)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2474
//  descending on primary key: loop head's pre_order, and
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2475
//  ascending  on secondary key: loop tail's pre_order.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2476
ciTypeFlow::Loop* ciTypeFlow::Loop::sorted_merge(Loop* lp) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2477
  Loop* leaf = this;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2478
  Loop* prev = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2479
  Loop* current = leaf;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2480
  while (lp != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2481
    int lp_pre_order = lp->head()->pre_order();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2482
    // Find insertion point for "lp"
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2483
    while (current != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2484
      if (current == lp)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2485
        return leaf; // Already in list
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2486
      if (current->head()->pre_order() < lp_pre_order)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2487
        break;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2488
      if (current->head()->pre_order() == lp_pre_order &&
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2489
          current->tail()->pre_order() > lp->tail()->pre_order()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2490
        break;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2491
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2492
      prev = current;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2493
      current = current->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2494
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2495
    Loop* next_lp = lp->parent(); // Save future list of items to insert
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2496
    // Insert lp before current
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2497
    lp->set_parent(current);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2498
    if (prev != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2499
      prev->set_parent(lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2500
    } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2501
      leaf = lp;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2502
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2503
    prev = lp;     // Inserted item is new prev[ious]
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2504
    lp = next_lp;  // Next item to insert
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2505
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2506
  return leaf;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2507
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2508
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2509
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2510
// ciTypeFlow::build_loop_tree
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2511
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2512
// Incrementally build loop tree.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2513
void ciTypeFlow::build_loop_tree(Block* blk) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2514
  assert(!blk->is_post_visited(), "precondition");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2515
  Loop* innermost = NULL; // merge of loop tree branches over all successors
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2516
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2517
  for (SuccIter iter(blk); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2518
    Loop*  lp   = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2519
    Block* succ = iter.succ();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2520
    if (!succ->is_post_visited()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2521
      // Found backedge since predecessor post visited, but successor is not
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2522
      assert(succ->pre_order() <= blk->pre_order(), "should be backedge");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2523
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2524
      // Create a LoopNode to mark this loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2525
      lp = new (arena()) Loop(succ, blk);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2526
      if (succ->loop() == NULL)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2527
        succ->set_loop(lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2528
      // succ->loop will be updated to innermost loop on a later call, when blk==succ
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2529
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2530
    } else {  // Nested loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2531
      lp = succ->loop();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2532
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2533
      // If succ is loop head, find outer loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2534
      while (lp != NULL && lp->head() == succ) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2535
        lp = lp->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2536
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2537
      if (lp == NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2538
        // Infinite loop, it's parent is the root
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2539
        lp = loop_tree_root();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2540
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2541
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2542
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2543
    // Check for irreducible loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2544
    // Successor has already been visited. If the successor's loop head
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2545
    // has already been post-visited, then this is another entry into the loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2546
    while (lp->head()->is_post_visited() && lp != loop_tree_root()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2547
      _has_irreducible_entry = true;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2548
      lp->set_irreducible(succ);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2549
      if (!succ->is_on_work_list()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2550
        // Assume irreducible entries need more data flow
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2551
        add_to_work_list(succ);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2552
      }
3910
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2553
      Loop* plp = lp->parent();
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2554
      if (plp == NULL) {
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2555
        // This only happens for some irreducible cases.  The parent
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2556
        // will be updated during a later pass.
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2557
        break;
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2558
      }
67050ceda719 6854812: 6.0_14-b08 crashes with a SIGSEGV
never
parents: 3261
diff changeset
  2559
      lp = plp;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2560
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2561
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2562
    // Merge loop tree branch for all successors.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2563
    innermost = innermost == NULL ? lp : innermost->sorted_merge(lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2564
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2565
  } // end loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2566
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2567
  if (innermost == NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2568
    assert(blk->successors()->length() == 0, "CFG exit");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2569
    blk->set_loop(loop_tree_root());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2570
  } else if (innermost->head() == blk) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2571
    // If loop header, complete the tree pointers
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2572
    if (blk->loop() != innermost) {
15937
fd3d2d0175f9 8006498: #if <symbol> is wrong in the code.
jprovino
parents: 13931
diff changeset
  2573
#ifdef ASSERT
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2574
      assert(blk->loop()->head() == innermost->head(), "same head");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2575
      Loop* dl;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2576
      for (dl = innermost; dl != NULL && dl != blk->loop(); dl = dl->parent());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2577
      assert(dl == blk->loop(), "blk->loop() already in innermost list");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2578
#endif
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2579
      blk->set_loop(innermost);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2580
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2581
    innermost->def_locals()->add(blk->def_locals());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2582
    Loop* l = innermost;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2583
    Loop* p = l->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2584
    while (p && l->head() == blk) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2585
      l->set_sibling(p->child());  // Put self on parents 'next child'
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2586
      p->set_child(l);             // Make self the first child of parent
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2587
      p->def_locals()->add(l->def_locals());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2588
      l = p;                       // Walk up the parent chain
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2589
      p = l->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2590
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2591
  } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2592
    blk->set_loop(innermost);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2593
    innermost->def_locals()->add(blk->def_locals());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2594
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2595
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2596
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2597
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2598
// ciTypeFlow::Loop::contains
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2599
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2600
// Returns true if lp is nested loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2601
bool ciTypeFlow::Loop::contains(ciTypeFlow::Loop* lp) const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2602
  assert(lp != NULL, "");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2603
  if (this == lp || head() == lp->head()) return true;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2604
  int depth1 = depth();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2605
  int depth2 = lp->depth();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2606
  if (depth1 > depth2)
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2607
    return false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2608
  while (depth1 < depth2) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2609
    depth2--;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2610
    lp = lp->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2611
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2612
  return this == lp;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2613
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2614
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2615
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2616
// ciTypeFlow::Loop::depth
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2617
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2618
// Loop depth
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2619
int ciTypeFlow::Loop::depth() const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2620
  int dp = 0;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2621
  for (Loop* lp = this->parent(); lp != NULL; lp = lp->parent())
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2622
    dp++;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2623
  return dp;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2624
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2625
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2626
#ifndef PRODUCT
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2627
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2628
// ciTypeFlow::Loop::print
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2629
void ciTypeFlow::Loop::print(outputStream* st, int indent) const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2630
  for (int i = 0; i < indent; i++) st->print(" ");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2631
  st->print("%d<-%d %s",
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2632
            is_root() ? 0 : this->head()->pre_order(),
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2633
            is_root() ? 0 : this->tail()->pre_order(),
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2634
            is_irreducible()?" irr":"");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2635
  st->print(" defs: ");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2636
  def_locals()->print_on(st, _head->outer()->method()->max_locals());
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2637
  st->cr();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2638
  for (Loop* ch = child(); ch != NULL; ch = ch->sibling())
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2639
    ch->print(st, indent+2);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2640
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2641
#endif
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2642
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2643
// ------------------------------------------------------------------
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2644
// ciTypeFlow::df_flow_types
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2645
//
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2646
// Perform the depth first type flow analysis. Helper for flow_types.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2647
void ciTypeFlow::df_flow_types(Block* start,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2648
                               bool do_flow,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2649
                               StateVector* temp_vector,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2650
                               JsrSet* temp_set) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2651
  int dft_len = 100;
6180
53c1bf468c81 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 5884
diff changeset
  2652
  GrowableArray<Block*> stk(dft_len);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2653
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2654
  ciBlock* dummy = _methodBlocks->make_dummy_block();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2655
  JsrSet* root_set = new JsrSet(NULL, 0);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2656
  Block* root_head = new (arena()) Block(this, dummy, root_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2657
  Block* root_tail = new (arena()) Block(this, dummy, root_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2658
  root_head->set_pre_order(0);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2659
  root_head->set_post_order(0);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2660
  root_tail->set_pre_order(max_jint);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2661
  root_tail->set_post_order(max_jint);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2662
  set_loop_tree_root(new (arena()) Loop(root_head, root_tail));
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2663
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2664
  stk.push(start);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2665
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2666
  _next_pre_order = 0;  // initialize pre_order counter
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2667
  _rpo_list = NULL;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2668
  int next_po = 0;      // initialize post_order counter
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2669
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2670
  // Compute RPO and the control flow graph
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2671
  int size;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2672
  while ((size = stk.length()) > 0) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2673
    Block* blk = stk.top(); // Leave node on stack
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2674
    if (!blk->is_visited()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2675
      // forward arc in graph
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2676
      assert (!blk->has_pre_order(), "");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2677
      blk->set_next_pre_order();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2678
27707
f7d26e5b8b5d 8058148: MaxNodeLimit and LiveNodeCountInliningCutoff
vlivanov
parents: 26944
diff changeset
  2679
      if (_next_pre_order >= (int)Compile::current()->max_node_limit() / 2) {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2680
        // Too many basic blocks.  Bail out.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2681
        // This can happen when try/finally constructs are nested to depth N,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2682
        // and there is O(2**N) cloning of jsr bodies.  See bug 4697245!
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2683
        // "MaxNodeLimit / 2" is used because probably the parser will
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2684
        // generate at least twice that many nodes and bail out.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2685
        record_failure("too many basic blocks");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2686
        return;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2687
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2688
      if (do_flow) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2689
        flow_block(blk, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2690
        if (failing()) return; // Watch for bailouts.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2691
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2692
    } else if (!blk->is_post_visited()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2693
      // cross or back arc
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2694
      for (SuccIter iter(blk); !iter.done(); iter.next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2695
        Block* succ = iter.succ();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2696
        if (!succ->is_visited()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2697
          stk.push(succ);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2698
        }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2699
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2700
      if (stk.length() == size) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2701
        // There were no additional children, post visit node now
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2702
        stk.pop(); // Remove node from stack
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2703
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2704
        build_loop_tree(blk);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2705
        blk->set_post_order(next_po++);   // Assign post order
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2706
        prepend_to_rpo_list(blk);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2707
        assert(blk->is_post_visited(), "");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2708
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2709
        if (blk->is_loop_head() && !blk->is_on_work_list()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2710
          // Assume loop heads need more data flow
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2711
          add_to_work_list(blk);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2712
        }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2713
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2714
    } else {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2715
      stk.pop(); // Remove post-visited node from stack
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2716
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2717
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2718
}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2719
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2720
// ------------------------------------------------------------------
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
// ciTypeFlow::flow_types
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2723
// Perform the type flow analysis, creating and cloning Blocks as
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2724
// necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2725
void ciTypeFlow::flow_types() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
  StateVector* temp_vector = new StateVector(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2728
  JsrSet* temp_set = new JsrSet(NULL, 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2730
  // Create the method entry block.
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2731
  Block* start = block_at(start_bci(), temp_set);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2732
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2733
  // Load the initial state into it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2734
  const StateVector* start_state = get_start_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2735
  if (failing())  return;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2736
  start->meet(start_state);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2737
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2738
  // Depth first visit
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2739
  df_flow_types(start, true /*do flow*/, temp_vector, temp_set);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2740
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2741
  if (failing())  return;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2742
  assert(_rpo_list == start, "must be start");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2743
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2744
  // Any loops found?
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2745
  if (loop_tree_root()->child() != NULL &&
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2746
      env()->comp_level() >= CompLevel_full_optimization) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2747
      // Loop optimizations are not performed on Tier1 compiles.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2748
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2749
    bool changed = clone_loop_heads(loop_tree_root(), temp_vector, temp_set);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2751
    // If some loop heads were cloned, recompute postorder and loop tree
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2752
    if (changed) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2753
      loop_tree_root()->set_child(NULL);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2754
      for (Block* blk = _rpo_list; blk != NULL;) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2755
        Block* next = blk->rpo_next();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2756
        blk->df_init();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2757
        blk = next;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2758
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2759
      df_flow_types(start, false /*no flow*/, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2760
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2761
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2762
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2763
  if (CITraceTypeFlow) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2764
    tty->print_cr("\nLoop tree");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2765
    loop_tree_root()->print();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2766
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2767
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2768
  // Continue flow analysis until fixed point reached
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2769
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2770
  debug_only(int max_block = _next_pre_order;)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2772
  while (!work_list_empty()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2773
    Block* blk = work_list_next();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2774
    assert (blk->has_post_order(), "post order assigned above");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2775
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2776
    flow_block(blk, temp_vector, temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2777
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2778
    assert (max_block == _next_pre_order, "no new blocks");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2779
    assert (!failing(), "no more bailouts");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2780
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2781
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2782
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2783
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
// ciTypeFlow::map_blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
//
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2786
// Create the block map, which indexes blocks in reverse post-order.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
void ciTypeFlow::map_blocks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2788
  assert(_block_map == NULL, "single initialization");
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2789
  int block_ct = _next_pre_order;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2790
  _block_map = NEW_ARENA_ARRAY(arena(), Block*, block_ct);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2791
  assert(block_ct == block_count(), "");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2792
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2793
  Block* blk = _rpo_list;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2794
  for (int m = 0; m < block_ct; m++) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2795
    int rpo = blk->rpo();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2796
    assert(rpo == m, "should be sequential");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2797
    _block_map[rpo] = blk;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2798
    blk = blk->rpo_next();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2799
  }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2800
  assert(blk == NULL, "should be done");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2801
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2802
  for (int j = 0; j < block_ct; j++) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2803
    assert(_block_map[j] != NULL, "must not drop any blocks");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2804
    Block* block = _block_map[j];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
    // Remove dead blocks from successor lists:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2806
    for (int e = 0; e <= 1; e++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2807
      GrowableArray<Block*>* l = e? block->exceptions(): block->successors();
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2808
      for (int k = 0; k < l->length(); k++) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2809
        Block* s = l->at(k);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2810
        if (!s->has_post_order()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2811
          if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
            tty->print("Removing dead %s successor of #%d: ", (e? "exceptional":  "normal"), block->pre_order());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2813
            s->print_value_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2814
            tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2815
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2816
          l->remove(s);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2817
          --k;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2818
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2819
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2820
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2821
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2822
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2823
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2824
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2825
// ciTypeFlow::get_block_for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2826
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2827
// Find a block with this ciBlock which has a compatible JsrSet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2828
// If no such block exists, create it, unless the option is no_create.
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2829
// If the option is create_backedge_copy, always create a fresh backedge copy.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2830
ciTypeFlow::Block* ciTypeFlow::get_block_for(int ciBlockIndex, ciTypeFlow::JsrSet* jsrs, CreateOption option) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2831
  Arena* a = arena();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2832
  GrowableArray<Block*>* blocks = _idx_to_blocklist[ciBlockIndex];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2833
  if (blocks == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2834
    // Query only?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2835
    if (option == no_create)  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2836
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2837
    // Allocate the growable array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2838
    blocks = new (a) GrowableArray<Block*>(a, 4, 0, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2839
    _idx_to_blocklist[ciBlockIndex] = blocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2840
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2841
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2842
  if (option != create_backedge_copy) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2843
    int len = blocks->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2844
    for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2845
      Block* block = blocks->at(i);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2846
      if (!block->is_backedge_copy() && block->is_compatible_with(jsrs)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2847
        return block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2848
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2851
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2852
  // Query only?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2853
  if (option == no_create)  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2854
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2855
  // We did not find a compatible block.  Create one.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2856
  Block* new_block = new (a) Block(this, _methodBlocks->block(ciBlockIndex), jsrs);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2857
  if (option == create_backedge_copy)  new_block->set_backedge_copy(true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2858
  blocks->append(new_block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2859
  return new_block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2860
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2861
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2862
// ------------------------------------------------------------------
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2863
// ciTypeFlow::backedge_copy_count
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2864
//
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2865
int ciTypeFlow::backedge_copy_count(int ciBlockIndex, ciTypeFlow::JsrSet* jsrs) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2866
  GrowableArray<Block*>* blocks = _idx_to_blocklist[ciBlockIndex];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2867
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2868
  if (blocks == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2869
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2870
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2871
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2872
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2873
  int len = blocks->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2874
  for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2875
    Block* block = blocks->at(i);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2876
    if (block->is_backedge_copy() && block->is_compatible_with(jsrs)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2877
      count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2878
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2879
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2880
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2881
  return count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2882
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2883
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2884
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2885
// ciTypeFlow::do_flow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2886
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2887
// Perform type inference flow analysis.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2888
void ciTypeFlow::do_flow() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2889
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2890
    tty->print_cr("\nPerforming flow analysis on method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2891
    method()->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2892
    if (is_osr_flow())  tty->print(" at OSR bci %d", start_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2893
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2894
    method()->print_codes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2895
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2896
  if (CITraceTypeFlow) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2897
    tty->print_cr("Initial CI Blocks");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2898
    print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2899
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2900
  flow_types();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2901
  // Watch for bailouts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2902
  if (failing()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2903
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2904
  }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2905
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2906
  map_blocks();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2907
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2908
  if (CIPrintTypeFlow || CITraceTypeFlow) {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  2909
    rpo_print_on(tty);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2910
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2911
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2912
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2913
// ------------------------------------------------------------------
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2914
// ciTypeFlow::is_dominated_by
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2915
//
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2916
// Determine if the instruction at bci is dominated by the instruction at dom_bci.
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2917
bool ciTypeFlow::is_dominated_by(int bci, int dom_bci) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2918
  assert(!method()->has_jsrs(), "jsrs are not supported");
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2919
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2920
  ResourceMark rm;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2921
  JsrSet* jsrs = new ciTypeFlow::JsrSet(NULL);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2922
  int        index = _methodBlocks->block_containing(bci)->index();
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2923
  int    dom_index = _methodBlocks->block_containing(dom_bci)->index();
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2924
  Block*     block = get_block_for(index, jsrs, ciTypeFlow::no_create);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2925
  Block* dom_block = get_block_for(dom_index, jsrs, ciTypeFlow::no_create);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2926
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2927
  // Start block dominates all other blocks
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2928
  if (start_block()->rpo() == dom_block->rpo()) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2929
    return true;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2930
  }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2931
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2932
  // Dominated[i] is true if block i is dominated by dom_block
35602
1513b6586d6d 8147876: ciTypeFlow::is_dominated_by() writes outside dominated array
thartmann
parents: 34151
diff changeset
  2933
  int num_blocks = block_count();
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2934
  bool* dominated = NEW_RESOURCE_ARRAY(bool, num_blocks);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2935
  for (int i = 0; i < num_blocks; ++i) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2936
    dominated[i] = true;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2937
  }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2938
  dominated[start_block()->rpo()] = false;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2939
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2940
  // Iterative dominator algorithm
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2941
  bool changed = true;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2942
  while (changed) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2943
    changed = false;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2944
    // Use reverse postorder iteration
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2945
    for (Block* blk = _rpo_list; blk != NULL; blk = blk->rpo_next()) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2946
      if (blk->is_start()) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2947
        // Ignore start block
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2948
        continue;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2949
      }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2950
      // The block is dominated if it is the dominating block
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2951
      // itself or if all predecessors are dominated.
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2952
      int index = blk->rpo();
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2953
      bool dom = (index == dom_block->rpo());
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2954
      if (!dom) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2955
        // Check if all predecessors are dominated
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2956
        dom = true;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2957
        for (int i = 0; i < blk->predecessors()->length(); ++i) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2958
          Block* pred = blk->predecessors()->at(i);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2959
          if (!dominated[pred->rpo()]) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2960
            dom = false;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2961
            break;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2962
          }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2963
        }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2964
      }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2965
      // Update dominator information
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2966
      if (dominated[index] != dom) {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2967
        changed = true;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2968
        dominated[index] = dom;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2969
      }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2970
    }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2971
  }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2972
  // block dominated by dom_block?
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2973
  return dominated[block->rpo()];
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2974
}
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2975
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 33105
diff changeset
  2976
// ------------------------------------------------------------------
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2977
// ciTypeFlow::record_failure()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2978
// The ciTypeFlow object keeps track of failure reasons separately from the ciEnv.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2979
// This is required because there is not a 1-1 relation between the ciEnv and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2980
// the TypeFlow passes within a compilation task.  For example, if the compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2981
// is considering inlining a method, it will request a TypeFlow.  If that fails,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2982
// the compilation as a whole may continue without the inlining.  Some TypeFlow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2983
// requests are not optional; if they fail the requestor is responsible for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2984
// copying the failure reason up to the ciEnv.  (See Parse::Parse.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2985
void ciTypeFlow::record_failure(const char* reason) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2986
  if (env()->log() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2987
    env()->log()->elem("failure reason='%s' phase='typeflow'", reason);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2988
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2989
  if (_failure_reason == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2990
    // Record the first failure reason.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2991
    _failure_reason = reason;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2992
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2993
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2994
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2995
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2996
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2997
// ciTypeFlow::print_on
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2998
void ciTypeFlow::print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2999
  // Walk through CI blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3000
  st->print_cr("********************************************************");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3001
  st->print   ("TypeFlow for ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3002
  method()->name()->print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3003
  int limit_bci = code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
  st->print_cr("  %d bytes", limit_bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3005
  ciMethodBlocks  *mblks = _methodBlocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3006
  ciBlock* current = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3007
  for (int bci = 0; bci < limit_bci; bci++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3008
    ciBlock* blk = mblks->block_containing(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3009
    if (blk != NULL && blk != current) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3010
      current = blk;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3011
      current->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3012
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3013
      GrowableArray<Block*>* blocks = _idx_to_blocklist[blk->index()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3014
      int num_blocks = (blocks == NULL) ? 0 : blocks->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3015
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3016
      if (num_blocks == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3017
        st->print_cr("  No Blocks");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3018
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3019
        for (int i = 0; i < num_blocks; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3020
          Block* block = blocks->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3021
          block->print_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3022
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3023
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3024
      st->print_cr("--------------------------------------------------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3025
      st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3026
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3027
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3028
  st->print_cr("********************************************************");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3029
  st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3030
}
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3031
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3032
void ciTypeFlow::rpo_print_on(outputStream* st) const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3033
  st->print_cr("********************************************************");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3034
  st->print   ("TypeFlow for ");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3035
  method()->name()->print_symbol_on(st);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3036
  int limit_bci = code_size();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3037
  st->print_cr("  %d bytes", limit_bci);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3038
  for (Block* blk = _rpo_list; blk != NULL; blk = blk->rpo_next()) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3039
    blk->print_on(st);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3040
    st->print_cr("--------------------------------------------------------");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3041
    st->cr();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3042
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3043
  st->print_cr("********************************************************");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3044
  st->cr();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1
diff changeset
  3045
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3046
#endif