src/hotspot/share/ci/ciTypeFlow.hpp
author tschatzl
Wed, 08 Aug 2018 15:31:06 +0200
changeset 51333 f6641fcf7b7e
parent 49373 47b5652f2928
child 53244 9807daeb47c4
permissions -rw-r--r--
8208670: Compiler changes to allow enabling -Wreorder Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 47687
diff changeset
     2
 * Copyright (c) 2000, 2018, 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: 1412
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1412
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: 1412
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: 5547
diff changeset
    25
#ifndef SHARE_VM_CI_CITYPEFLOW_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CI_CITYPEFLOW_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#ifdef COMPILER2
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "ci/ciEnv.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "ci/ciKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "ci/ciMethodBlocks.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class ciTypeFlow : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  ciEnv*    _env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  ciMethod* _method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  ciMethodBlocks* _methodBlocks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  int       _osr_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  // information cached from the method:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  int _max_locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  int _max_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  int _code_size;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
    46
  bool      _has_irreducible_entry;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  const char* _failure_reason;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  class StateVector;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
    52
  class Loop;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  class Block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Build a type flow analyzer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Do an OSR analysis if osr_bci >= 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  ciTypeFlow(ciEnv* env, ciMethod* method, int osr_bci = InvocationEntryBci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  ciMethod* method() const     { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  ciEnv*    env()              { return _env; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  Arena*    arena()            { return _env->arena(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  bool      is_osr_flow() const{ return _osr_bci != InvocationEntryBci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  int       start_bci() const  { return is_osr_flow()? _osr_bci: 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  int       max_locals() const { return _max_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  int       max_stack() const  { return _max_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  int       max_cells() const  { return _max_locals + _max_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  int       code_size() const  { return _code_size; }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
    69
  bool      has_irreducible_entry() const { return _has_irreducible_entry; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Represents information about an "active" jsr call.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // class represents a call to the routine at some entry address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // with some distinct return address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  class JsrRecord : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    int _entry_address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    int _return_address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    JsrRecord(int entry_address, int return_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      _entry_address = entry_address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      _return_address = return_address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    int entry_address() const  { return _entry_address; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    int return_address() const { return _return_address; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    void print_on(outputStream* st) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      st->print("%d->%d", entry_address(), return_address());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // A JsrSet represents some set of JsrRecords.  This class
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // is used to record a set of all jsr routines which we permit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // execution to return (ret) from.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // During abstract interpretation, JsrSets are used to determine
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // whether two paths which reach a given block are unique, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // should be cloned apart, or are compatible, and should merge
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // together.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Note that different amounts of effort can be expended determining
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // if paths are compatible.  <DISCUSSION>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  class JsrSet : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    GrowableArray<JsrRecord*>* _set;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    JsrRecord* record_at(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      return _set->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    // Insert the given JsrRecord into the JsrSet, maintaining the order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    // of the set and replacing any element with the same entry address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    void insert_jsr_record(JsrRecord* record);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    // Remove the JsrRecord with the given return address from the JsrSet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    void remove_jsr_record(int return_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    JsrSet(Arena* arena, int default_len = 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    // Copy this JsrSet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    void copy_into(JsrSet* jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    // Is this JsrSet compatible with some other JsrSet?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    bool is_compatible_with(JsrSet* other);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    // Apply the effect of a single bytecode to the JsrSet.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    void apply_control(ciTypeFlow* analyzer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
                       ciBytecodeStream* str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
                       StateVector* state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    // What is the cardinality of this set?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    int size() const { return _set->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    void print_on(outputStream* st) const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 47687
diff changeset
   140
  class LocalSet {
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   141
  private:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   142
    enum Constants { max = 63 };
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   143
    uint64_t _bits;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   144
  public:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   145
    LocalSet() : _bits(0) {}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   146
    void add(uint32_t i)        { if (i < (uint32_t)max) _bits |=  (1LL << i); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   147
    void add(LocalSet* ls)      { _bits |= ls->_bits; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   148
    bool test(uint32_t i) const { return i < (uint32_t)max ? (_bits>>i)&1U : true; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   149
    void clear()                { _bits = 0; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   150
    void print_on(outputStream* st, int limit) const  PRODUCT_RETURN;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   151
  };
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   152
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Used as a combined index for locals and temps
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  enum Cell {
1065
dbeb68f8a0ee 6741642: bad enum definition in ciTypeFlow.hpp
never
parents: 1
diff changeset
   155
    Cell_0, Cell_max = INT_MAX
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // A StateVector summarizes the type information at some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // point in the program
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  class StateVector : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    ciType**    _types;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    int         _stack_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    int         _monitor_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    ciTypeFlow* _outer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    int         _trap_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    int         _trap_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   170
    LocalSet    _def_locals;  // For entire block
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   171
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    static ciType* type_meet_internal(ciType* t1, ciType* t2, ciTypeFlow* analyzer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    // Special elements in our type lattice.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      T_TOP     = T_VOID,      // why not?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      T_BOTTOM  = T_CONFLICT,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      T_LONG2   = T_SHORT,     // 2nd word of T_LONG
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
      T_DOUBLE2 = T_CHAR,      // 2nd word of T_DOUBLE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
      T_NULL    = T_BYTE       // for now.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    static ciType* top_type()    { return ciType::make((BasicType)T_TOP); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    static ciType* bottom_type() { return ciType::make((BasicType)T_BOTTOM); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    static ciType* long2_type()  { return ciType::make((BasicType)T_LONG2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    static ciType* double2_type(){ return ciType::make((BasicType)T_DOUBLE2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    static ciType* null_type()   { return ciType::make((BasicType)T_NULL); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    static ciType* half_type(ciType* t) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      switch (t->basic_type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      case T_LONG:    return long2_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      case T_DOUBLE:  return double2_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      default:        ShouldNotReachHere(); return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    // The meet operation for our type lattice.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    ciType* type_meet(ciType* t1, ciType* t2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      return type_meet_internal(t1, t2, outer());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    ciTypeFlow* outer() const          { return _outer; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    int         stack_size() const     { return _stack_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    void    set_stack_size(int ss)     { _stack_size = ss; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    int         monitor_count() const  { return _monitor_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    void    set_monitor_count(int mc)  { _monitor_count = mc; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   211
    LocalSet* def_locals() { return &_def_locals; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   212
    const LocalSet* def_locals() const { return &_def_locals; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   213
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    static Cell start_cell()           { return (Cell)0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    static Cell next_cell(Cell c)      { return (Cell)(((int)c) + 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    Cell        limit_cell() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      return (Cell)(outer()->max_locals() + stack_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    // Cell creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    Cell      local(int lnum) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      assert(lnum < outer()->max_locals(), "index check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      return (Cell)(lnum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    Cell      stack(int snum) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      assert(snum < stack_size(), "index check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      return (Cell)(outer()->max_locals() + snum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    Cell      tos() const { return stack(stack_size()-1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    // For external use only:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    ciType* local_type_at(int i) const { return type_at(local(i)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    ciType* stack_type_at(int i) const { return type_at(stack(i)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    // Accessors for the type of some Cell c
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    ciType*   type_at(Cell c) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      assert(start_cell() <= c && c < limit_cell(), "out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
      return _types[c];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    void      set_type_at(Cell c, ciType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      assert(start_cell() <= c && c < limit_cell(), "out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
      _types[c] = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    // Top-of-stack operations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    void      set_type_at_tos(ciType* type) { set_type_at(tos(), type); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    ciType*   type_at_tos() const           { return type_at(tos()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    void      push(ciType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      _stack_size++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      set_type_at_tos(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    void      pop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
      debug_only(set_type_at_tos(bottom_type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
      _stack_size--;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    ciType*   pop_value() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      ciType* t = type_at_tos();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
      return t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    // Convenience operations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    bool      is_reference(ciType* type) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      return type == null_type() || !type->is_primitive_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    bool      is_int(ciType* type) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
      return type->basic_type() == T_INT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    bool      is_long(ciType* type) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
      return type->basic_type() == T_LONG;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    bool      is_float(ciType* type) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      return type->basic_type() == T_FLOAT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    bool      is_double(ciType* type) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      return type->basic_type() == T_DOUBLE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   283
    void store_to_local(int lnum) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   284
      _def_locals.add((uint) lnum);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   285
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   286
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    void      push_translate(ciType* type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    void      push_int() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
      push(ciType::make(T_INT));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    void      pop_int() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
      assert(is_int(type_at_tos()), "must be integer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    void      check_int(Cell c) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      assert(is_int(type_at(c)), "must be integer");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    void      push_double() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
      push(ciType::make(T_DOUBLE));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      push(double2_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    void      pop_double() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
      assert(type_at_tos() == double2_type(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      assert(is_double(type_at_tos()), "must be double");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    void      push_float() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      push(ciType::make(T_FLOAT));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    void      pop_float() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      assert(is_float(type_at_tos()), "must be float");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    void      push_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      push(ciType::make(T_LONG));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
      push(long2_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    void      pop_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      assert(type_at_tos() == long2_type(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      assert(is_long(type_at_tos()), "must be long");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    void      push_object(ciKlass* klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      push(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    void      pop_object() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      assert(is_reference(type_at_tos()), "must be reference type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    void      pop_array() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      assert(type_at_tos() == null_type() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
             type_at_tos()->is_array_klass(), "must be array type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    // pop_objArray and pop_typeArray narrow the tos to ciObjArrayKlass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    // or ciTypeArrayKlass (resp.).  In the rare case that an explicit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    // null is popped from the stack, we return NULL.  Caller beware.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    ciObjArrayKlass* pop_objArray() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      ciType* array = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
      if (array == null_type())  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
      assert(array->is_obj_array_klass(), "must be object array type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
      return array->as_obj_array_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    ciTypeArrayKlass* pop_typeArray() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      ciType* array = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      if (array == null_type())  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
      assert(array->is_type_array_klass(), "must be prim array type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      return array->as_type_array_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    void      push_null() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
      push(null_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    void      do_null_assert(ciKlass* unloaded_klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    // Helper convenience routines.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    void do_aaload(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    void do_checkcast(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    void do_getfield(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    void do_getstatic(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    void do_invoke(ciBytecodeStream* str, bool has_receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    void do_jsr(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    void do_ldc(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    void do_multianewarray(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    void do_new(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    void do_newarray(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    void do_putfield(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    void do_putstatic(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    void do_ret(ciBytecodeStream* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    void overwrite_local_double_long(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      // Invalidate the previous local if it contains first half of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      // a double or long value since it's seconf half is being overwritten.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      int prev_index = index - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      if (prev_index >= 0 &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
          (is_double(type_at(local(prev_index))) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
           is_long(type_at(local(prev_index))))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
        set_type_at(local(prev_index), bottom_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    void load_local_object(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
      ciType* type = type_at(local(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      assert(is_reference(type), "must be reference type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
      push(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    void store_local_object(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
      ciType* type = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
      assert(is_reference(type) || type->is_return_address(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
             "must be reference type or return address");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
      overwrite_local_double_long(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
      set_type_at(local(index), type);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   395
      store_to_local(index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    void load_local_double(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
      ciType* type = type_at(local(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
      ciType* type2 = type_at(local(index+1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
      assert(is_double(type), "must be double type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
      assert(type2 == double2_type(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
      push(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      push(double2_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    void store_local_double(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      ciType* type2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
      ciType* type = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
      assert(is_double(type), "must be double");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      assert(type2 == double2_type(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
      overwrite_local_double_long(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
      set_type_at(local(index), type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
      set_type_at(local(index+1), type2);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   414
      store_to_local(index);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   415
      store_to_local(index+1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    void load_local_float(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      ciType* type = type_at(local(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      assert(is_float(type), "must be float type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      push(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    void store_local_float(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      ciType* type = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      assert(is_float(type), "must be float type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
      overwrite_local_double_long(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
      set_type_at(local(index), type);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   428
      store_to_local(index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    void load_local_int(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      ciType* type = type_at(local(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      assert(is_int(type), "must be int type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      push(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    void store_local_int(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
      ciType* type = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
      assert(is_int(type), "must be int type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      overwrite_local_double_long(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      set_type_at(local(index), type);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   441
      store_to_local(index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    void load_local_long(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
      ciType* type = type_at(local(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      ciType* type2 = type_at(local(index+1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      assert(is_long(type), "must be long type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      assert(type2 == long2_type(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      push(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      push(long2_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    void store_local_long(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      ciType* type2 = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
      ciType* type = pop_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
      assert(is_long(type), "must be long");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
      assert(type2 == long2_type(), "must be 2nd half");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
      overwrite_local_double_long(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
      set_type_at(local(index), type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
      set_type_at(local(index+1), type2);
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   460
      store_to_local(index);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   461
      store_to_local(index+1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    // Stop interpretation of this path with a trap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    void trap(ciBytecodeStream* str, ciKlass* klass, int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    StateVector(ciTypeFlow* outer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    // Copy our value into some other StateVector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
    void copy_into(StateVector* copy) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    // Meets this StateVector with another, destructively modifying this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    // one.  Returns true if any modification takes place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    bool meet(const StateVector* incoming);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    // Ditto, except that the incoming state is coming from an exception.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    bool meet_exception(ciInstanceKlass* exc, const StateVector* incoming);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    // Apply the effect of one bytecode to this StateVector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    bool apply_one_bytecode(ciBytecodeStream* stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    // What is the bci of the trap?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    int  trap_bci() { return _trap_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    // What is the index associated with the trap?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    int  trap_index() { return _trap_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    void print_cell_on(outputStream* st, Cell c) const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
    void print_on(outputStream* st) const              PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // Parameter for "find_block" calls:
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   494
  // Describes the difference between a public and backedge copy.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  enum CreateOption {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    create_public_copy,
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   497
    create_backedge_copy,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    no_create
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   501
  // Successor iterator
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   502
  class SuccIter : public StackObj {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   503
  private:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   504
    Block* _pred;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   505
    int    _index;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   506
    Block* _succ;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   507
  public:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   508
    SuccIter()                        : _pred(NULL), _index(-1), _succ(NULL) {}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   509
    SuccIter(Block* pred)             : _pred(pred), _index(-1), _succ(NULL) { next(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   510
    int    index()     { return _index; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   511
    Block* pred()      { return _pred; }           // Return predecessor
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   512
    bool   done()      { return _index < 0; }      // Finished?
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   513
    Block* succ()      { return _succ; }           // Return current successor
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   514
    void   next();                                 // Advance
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   515
    void   set_succ(Block* succ);                  // Update current successor
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   516
    bool   is_normal_ctrl() { return index() < _pred->successors()->length(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   517
  };
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   518
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  // A basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  class Block : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    ciBlock*                          _ciblock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    GrowableArray<Block*>*           _exceptions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    GrowableArray<ciInstanceKlass*>* _exc_klasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    GrowableArray<Block*>*           _successors;
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   526
    GrowableArray<Block*>*           _predecessors;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    StateVector*                     _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    JsrSet*                          _jsrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    int                              _trap_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    int                              _trap_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   533
    // pre_order, assigned at first visit. Used as block ID and "visited" tag
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    int                              _pre_order;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   536
    // A post-order, used to compute the reverse post order (RPO) provided to the client
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   537
    int                              _post_order;  // used to compute rpo
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   538
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   539
    // Has this block been cloned for a loop backedge?
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   540
    bool                             _backedge_copy;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   542
    // This block is entry to irreducible loop.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   543
    bool                             _irreducible_entry;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   544
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   545
    // This block has monitor entry point.
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   546
    bool                             _has_monitorenter;
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   547
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    // A pointer used for our internal work list
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   549
    bool                             _on_work_list;      // on the work list
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   550
    Block*                           _next;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   551
    Block*                           _rpo_next;          // Reverse post order list
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   552
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   553
    // Loop info
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   554
    Loop*                            _loop;              // nearest loop
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    ciBlock*     ciblock() const     { return _ciblock; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    StateVector* state() const     { return _state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    // Compute the exceptional successors and types for this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    void compute_exceptions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
    // constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    Block(ciTypeFlow* outer, ciBlock* ciblk, JsrSet* jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    void set_trap(int trap_bci, int trap_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
      _trap_bci = trap_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
      _trap_index = trap_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
      assert(has_trap(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    bool has_trap()   const  { return _trap_bci != -1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    int  trap_bci()   const  { assert(has_trap(), ""); return _trap_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    int  trap_index() const  { assert(has_trap(), ""); return _trap_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    ciTypeFlow* outer() const { return state()->outer(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    int start() const         { return _ciblock->start_bci(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    int limit() const         { return _ciblock->limit_bci(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    int control() const       { return _ciblock->control_bci(); }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   580
    JsrSet* jsrs() const      { return _jsrs; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   582
    bool    is_backedge_copy() const       { return _backedge_copy; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   583
    void   set_backedge_copy(bool z);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   584
    int        backedge_copy_count() const { return outer()->backedge_copy_count(ciblock()->index(), _jsrs); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    // access to entry state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    int     stack_size() const         { return _state->stack_size(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    int     monitor_count() const      { return _state->monitor_count(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    ciType* local_type_at(int i) const { return _state->local_type_at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    ciType* stack_type_at(int i) const { return _state->stack_type_at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   592
    // Data flow on locals
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   593
    bool is_invariant_local(uint v) const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   594
      assert(is_loop_head(), "only loop heads");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   595
      // Find outermost loop with same loop head
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   596
      Loop* lp = loop();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   597
      while (lp->parent() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   598
        if (lp->parent()->head() != lp->head()) break;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   599
        lp = lp->parent();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   600
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   601
      return !lp->def_locals()->test(v);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   602
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   603
    LocalSet* def_locals() { return _state->def_locals(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   604
    const LocalSet* def_locals() const { return _state->def_locals(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   605
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
    // Get the successors for this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    GrowableArray<Block*>* successors(ciBytecodeStream* str,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
                                      StateVector* state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
                                      JsrSet* jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    GrowableArray<Block*>* successors() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
      assert(_successors != NULL, "must be filled in");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
      return _successors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   615
    // Predecessors of this block (including exception edges)
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   616
    GrowableArray<Block*>* predecessors() {
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   617
      assert(_predecessors != NULL, "must be filled in");
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   618
      return _predecessors;
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   619
    }
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   620
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
    // Get the exceptional successors for this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    GrowableArray<Block*>* exceptions() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      if (_exceptions == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
        compute_exceptions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
      return _exceptions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    // Get the exception klasses corresponding to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    // exceptional successors for this Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    GrowableArray<ciInstanceKlass*>* exc_klasses() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
      if (_exc_klasses == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
        compute_exceptions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
      return _exc_klasses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    // Is this Block compatible with a given JsrSet?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
    bool is_compatible_with(JsrSet* other) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      return _jsrs->is_compatible_with(other);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    // Copy the value of our state vector into another.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    void copy_state_into(StateVector* copy) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      _state->copy_into(copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    // Copy the value of our JsrSet into another
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    void copy_jsrs_into(JsrSet* copy) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
      _jsrs->copy_into(copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    // Meets the start state of this block with another state, destructively
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    // modifying this one.  Returns true if any modification takes place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    bool meet(const StateVector* incoming) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
      return state()->meet(incoming);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    // Ditto, except that the incoming state is coming from an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    // exception path.  This means the stack is replaced by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    // appropriate exception type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    bool meet_exception(ciInstanceKlass* exc, const StateVector* incoming) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
      return state()->meet_exception(exc, incoming);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    // Work list manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    void   set_next(Block* block) { _next = block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
    Block* next() const           { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
    void   set_on_work_list(bool c) { _on_work_list = c; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
    bool   is_on_work_list() const  { return _on_work_list; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
    bool   has_pre_order() const  { return _pre_order >= 0; }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   674
    void   set_pre_order(int po)  { assert(!has_pre_order(), ""); _pre_order = po; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    int    pre_order() const      { assert(has_pre_order(), ""); return _pre_order; }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   676
    void   set_next_pre_order()   { set_pre_order(outer()->inc_next_pre_order()); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
    bool   is_start() const       { return _pre_order == outer()->start_block_num(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   679
    // Reverse post order
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   680
    void   df_init();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   681
    bool   has_post_order() const { return _post_order >= 0; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   682
    void   set_post_order(int po) { assert(!has_post_order() && po >= 0, ""); _post_order = po; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   683
    void   reset_post_order(int o){ _post_order = o; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   684
    int    post_order() const     { assert(has_post_order(), ""); return _post_order; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   685
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   686
    bool   has_rpo() const        { return has_post_order() && outer()->have_block_count(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   687
    int    rpo() const            { assert(has_rpo(), ""); return outer()->block_count() - post_order() - 1; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   688
    void   set_rpo_next(Block* b) { _rpo_next = b; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   689
    Block* rpo_next()             { return _rpo_next; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   690
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   691
    // Loops
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   692
    Loop*  loop() const                  { return _loop; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   693
    void   set_loop(Loop* lp)            { _loop = lp; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   694
    bool   is_loop_head() const          { return _loop && _loop->head() == this; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   695
    void   set_irreducible_entry(bool c) { _irreducible_entry = c; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   696
    bool   is_irreducible_entry() const  { return _irreducible_entry; }
11445
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   697
    void   set_has_monitorenter()        { _has_monitorenter = true; }
3c768dca60f5 7125896: Eliminate nested locks
kvn
parents: 9103
diff changeset
   698
    bool   has_monitorenter() const      { return _has_monitorenter; }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   699
    bool   is_visited() const            { return has_pre_order(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   700
    bool   is_post_visited() const       { return has_post_order(); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   701
    bool   is_clonable_exit(Loop* lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   702
    Block* looping_succ(Loop* lp);       // Successor inside of loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   703
    bool   is_single_entry_loop_head() const {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   704
      if (!is_loop_head()) return false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   705
      for (Loop* lp = loop(); lp != NULL && lp->head() == this; lp = lp->parent())
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   706
        if (lp->is_irreducible()) return false;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   707
      return true;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   708
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    void   print_value_on(outputStream* st) const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
    void   print_on(outputStream* st) const       PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   714
  // Loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   715
  class Loop : public ResourceObj {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   716
  private:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   717
    Loop* _parent;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   718
    Loop* _sibling;  // List of siblings, null terminated
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   719
    Loop* _child;    // Head of child list threaded thru sibling pointer
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   720
    Block* _head;    // Head of loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   721
    Block* _tail;    // Tail of loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   722
    bool   _irreducible;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   723
    LocalSet _def_locals;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   724
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   725
  public:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   726
    Loop(Block* head, Block* tail) :
51333
f6641fcf7b7e 8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents: 49373
diff changeset
   727
      _parent(NULL), _sibling(NULL), _child(NULL),
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   728
      _head(head),   _tail(tail),
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   729
      _irreducible(false), _def_locals() {}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   730
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   731
    Loop* parent()  const { return _parent; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   732
    Loop* sibling() const { return _sibling; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   733
    Loop* child()   const { return _child; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   734
    Block* head()   const { return _head; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   735
    Block* tail()   const { return _tail; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   736
    void set_parent(Loop* p)  { _parent = p; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   737
    void set_sibling(Loop* s) { _sibling = s; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   738
    void set_child(Loop* c)   { _child = c; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   739
    void set_head(Block* hd)  { _head = hd; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   740
    void set_tail(Block* tl)  { _tail = tl; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   741
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   742
    int depth() const;              // nesting depth
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   743
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   744
    // Returns true if lp is a nested loop or us.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   745
    bool contains(Loop* lp) const;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   746
    bool contains(Block* blk) const { return contains(blk->loop()); }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   747
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   748
    // Data flow on locals
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   749
    LocalSet* def_locals() { return &_def_locals; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   750
    const LocalSet* def_locals() const { return &_def_locals; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   751
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   752
    // 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: 1065
diff changeset
   753
    // pre_orders. Returns the new branch.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   754
    Loop* sorted_merge(Loop* lp);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   755
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   756
    // Mark non-single entry to loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   757
    void set_irreducible(Block* entry) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   758
      _irreducible = true;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   759
      entry->set_irreducible_entry(true);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   760
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   761
    bool is_irreducible() const { return _irreducible; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   762
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   763
    bool is_root() const { return _tail->pre_order() == max_jint; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   764
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   765
    void print(outputStream* st = tty, int indent = 0) const PRODUCT_RETURN;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   766
  };
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   767
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   768
  // Postorder iteration over the loop tree.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   769
  class PostorderLoops : public StackObj {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   770
  private:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   771
    Loop* _root;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   772
    Loop* _current;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   773
  public:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   774
    PostorderLoops(Loop* root) : _root(root), _current(root) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   775
      while (_current->child() != NULL) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   776
        _current = _current->child();
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   777
      }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   778
    }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   779
    bool done() { return _current == NULL; }  // Finished iterating?
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   780
    void next();                            // Advance to next loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   781
    Loop* current() { return _current; }      // Return current loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   782
  };
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   783
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   784
  // Preorder iteration over the loop tree.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   785
  class PreorderLoops : public StackObj {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   786
  private:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   787
    Loop* _root;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   788
    Loop* _current;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   789
  public:
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   790
    PreorderLoops(Loop* root) : _root(root), _current(root) {}
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   791
    bool done() { return _current == NULL; }  // Finished iterating?
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   792
    void next();                            // Advance to next loop
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   793
    Loop* current() { return _current; }      // Return current loop.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   794
  };
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   795
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  // Standard indexes of successors, for various bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    FALL_THROUGH   = 0,  // normal control
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
    IF_NOT_TAKEN   = 0,  // the not-taken branch of an if (i.e., fall-through)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
    IF_TAKEN       = 1,  // the taken branch of an if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
    GOTO_TARGET    = 0,  // unique successor for goto, jsr, or ret
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    SWITCH_DEFAULT = 0,  // default branch of a switch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    SWITCH_CASES   = 1   // first index for any non-default switch branches
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    // Unlike in other blocks, the successors of a switch are listed uniquely.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  // A mapping from pre_order to Blocks.  This array is created
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  // only at the end of the flow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  Block** _block_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  // For each ciBlock index, a list of Blocks which share this ciBlock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  GrowableArray<Block*>** _idx_to_blocklist;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  // count of ciBlocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  int _ciblock_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
  // Tells if a given instruction is able to generate an exception edge.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
  bool can_trap(ciBytecodeStream& str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   820
  // Clone the loop heads. Returns true if any cloning occurred.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   821
  bool 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: 1065
diff changeset
   822
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   823
  // 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: 1065
diff changeset
   824
  Block* 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: 1065
diff changeset
   825
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  // Return the block beginning at bci which has a JsrSet compatible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  // with jsrs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  Block* block_at(int bci, JsrSet* set, CreateOption option = create_public_copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  // block factory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  Block* get_block_for(int ciBlockIndex, JsrSet* jsrs, CreateOption option = create_public_copy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   834
  // How many of the blocks have the backedge_copy bit set?
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   835
  int backedge_copy_count(int ciBlockIndex, JsrSet* jsrs) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
  // Return an existing block containing bci which has a JsrSet compatible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  // with jsrs, or NULL if there is none.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
  Block* existing_block_at(int bci, JsrSet* set) { return block_at(bci, set, no_create); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  // Tell whether the flow analysis has encountered an error of some sort.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  bool failing() { return env()->failing() || _failure_reason != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  // Reason this compilation is failing, such as "too many basic blocks".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  const char* failure_reason() { return _failure_reason; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  // Note a failure.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  void record_failure(const char* reason);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  // Return the block of a given pre-order number.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  int have_block_count() const      { return _block_map != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  int block_count() const           { assert(have_block_count(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
                                      return _next_pre_order; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  Block* pre_order_at(int po) const { assert(0 <= po && po < block_count(), "out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
                                      return _block_map[po]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  Block* start_block() const        { return pre_order_at(start_block_num()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  int start_block_num() const       { return 0; }
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   858
  Block* rpo_at(int rpo) const      { assert(0 <= rpo && rpo < block_count(), "out of bounds");
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   859
                                      return _block_map[rpo]; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   860
  int next_pre_order()              { return _next_pre_order; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   861
  int inc_next_pre_order()          { return _next_pre_order++; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  // A work list used during flow analysis.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
  Block* _work_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   867
  // List of blocks in reverse post order
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   868
  Block* _rpo_list;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   869
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  // Next Block::_pre_order.  After mapping, doubles as block_count.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  int _next_pre_order;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
  // Are there more blocks on the work list?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  bool work_list_empty() { return _work_list == NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  // Get the next basic block from our work list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  Block* work_list_next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  // Add a basic block to our work list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  void add_to_work_list(Block* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   882
  // Prepend a basic block to rpo list.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   883
  void prepend_to_rpo_list(Block* blk) {
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   884
    blk->set_rpo_next(_rpo_list);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   885
    _rpo_list = blk;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   886
  }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   887
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   888
  // Root of the loop tree
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   889
  Loop* _loop_tree_root;
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   890
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  // State used for make_jsr_record
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
  int _jsr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  GrowableArray<JsrRecord*>* _jsr_records;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  // Make a JsrRecord for a given (entry, return) pair, if such a record
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  // does not already exist.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  JsrRecord* make_jsr_record(int entry_address, int return_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   900
  void  set_loop_tree_root(Loop* ltr) { _loop_tree_root = ltr; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   901
  Loop* loop_tree_root()              { return _loop_tree_root; }
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   902
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  // Get the initial state for start_bci:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  const StateVector* get_start_state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
  // Merge the current state into all exceptional successors at the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  // current point in the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  void flow_exceptions(GrowableArray<Block*>* exceptions,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
                       GrowableArray<ciInstanceKlass*>* exc_klasses,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
                       StateVector* state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  // Merge the current state into all successors at the current point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  // in the code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
  void flow_successors(GrowableArray<Block*>* successors,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
                       StateVector* state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  // Interpret the effects of the bytecodes on the incoming state
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  // vector of a basic block.  Push the changed state to succeeding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  // basic blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  void flow_block(Block* block,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
                  StateVector* scratch_state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
                  JsrSet* scratch_jsrs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  // Perform the type flow analysis, creating and cloning Blocks as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  // necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
  void flow_types();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   929
  // 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: 1065
diff changeset
   930
  void df_flow_types(Block* start,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   931
                     bool do_flow,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   932
                     StateVector* temp_vector,
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   933
                     JsrSet* temp_set);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   934
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   935
  // Incrementally build loop tree.
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   936
  void build_loop_tree(Block* blk);
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   937
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  // Create the block map, which indexes blocks in pre_order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  void map_blocks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  // Perform type inference flow analysis.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  void do_flow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
34151
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   945
  // Determine if bci is dominated by dom_bci
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   946
  bool is_dominated_by(int bci, int dom_bci);
8e0bebdbc29e 8140574: C2 must re-execute checks after deoptimizing from merged uncommon traps
thartmann
parents: 13963
diff changeset
   947
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  void print_on(outputStream* st) const PRODUCT_RETURN;
1399
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   949
9648dfd4ce09 6384206: Phis which are later unneeded are impairing our ability to inline based on static types
never
parents: 1065
diff changeset
   950
  void rpo_print_on(outputStream* st) const PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   952
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   953
#endif // SHARE_VM_CI_CITYPEFLOW_HPP