hotspot/src/share/vm/c1/c1_Instruction.hpp
author jrose
Tue, 21 Apr 2009 23:21:04 -0700
changeset 2570 ecc7862946d4
parent 1 489c9b5090e2
child 5046 27e801a857cb
permissions -rw-r--r--
6655646: dynamic languages need dynamically linked call sites Summary: invokedynamic instruction (JSR 292 RI) Reviewed-by: twisti, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Predefined classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class ciField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class ValueStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class InstructionPrinter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class IRScope;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class LIR_OprDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
typedef LIR_OprDesc* LIR_Opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// Instruction class hierarchy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// All leaf classes in the class hierarchy are concrete classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// (i.e., are instantiated). All other classes are abstract and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// serve factoring.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class Instruction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class   HiWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class   Phi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class   Local;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class   Constant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class   AccessField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class     LoadField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class     StoreField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class   AccessArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class     ArrayLength;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class     AccessIndexed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class       LoadIndexed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class       StoreIndexed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class   NegateOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class   Op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
class     ArithmeticOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class     ShiftOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class     LogicOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class     CompareOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
class     IfOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
class   Convert;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class   NullCheck;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class   OsrEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class   ExceptionObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
class   StateSplit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class     Invoke;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class     NewInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class     NewArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class       NewTypeArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
class       NewObjectArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
class       NewMultiArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class     TypeCheck;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class       CheckCast;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class       InstanceOf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
class     AccessMonitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
class       MonitorEnter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
class       MonitorExit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
class     Intrinsic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
class     BlockBegin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
class     BlockEnd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
class       Goto;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
class       If;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class       IfInstanceOf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
class       Switch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
class         TableSwitch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
class         LookupSwitch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
class       Return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
class       Throw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
class       Base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
class   RoundFP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
class   UnsafeOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
class     UnsafeRawOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
class       UnsafeGetRaw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
class       UnsafePutRaw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
class     UnsafeObjectOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
class       UnsafeGetObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
class       UnsafePutObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
class       UnsafePrefetch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
class         UnsafePrefetchRead;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
class         UnsafePrefetchWrite;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
class   ProfileCall;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
class   ProfileCounter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// A Value is a reference to the instruction creating the value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
typedef Instruction* Value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
define_array(ValueArray, Value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
define_stack(Values, ValueArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
define_array(ValueStackArray, ValueStack*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
define_stack(ValueStackStack, ValueStackArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
// BlockClosure is the base class for block traversal/iteration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
class BlockClosure: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  virtual void block_do(BlockBegin* block)       = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// Some array and list classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
define_array(BlockBeginArray, BlockBegin*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
define_stack(_BlockList, BlockBeginArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
class BlockList: public _BlockList {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  BlockList(): _BlockList() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  BlockList(const int size): _BlockList(size) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  BlockList(const int size, BlockBegin* init): _BlockList(size, init) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void iterate_forward(BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  void iterate_backward(BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  void blocks_do(void f(BlockBegin*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  void values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
// InstructionVisitors provide type-based dispatch for instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
// For each concrete Instruction class X, a virtual function do_X is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
// provided. Functionality that needs to be implemented for all classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
// (e.g., printing, code generation) is factored out into a specialised
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
// visitor instead of added to the Instruction classes itself.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
class InstructionVisitor: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
          void do_HiWord         (HiWord*          x) { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  virtual void do_Phi            (Phi*             x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  virtual void do_Local          (Local*           x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  virtual void do_Constant       (Constant*        x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  virtual void do_LoadField      (LoadField*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  virtual void do_StoreField     (StoreField*      x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  virtual void do_ArrayLength    (ArrayLength*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  virtual void do_LoadIndexed    (LoadIndexed*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  virtual void do_StoreIndexed   (StoreIndexed*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  virtual void do_NegateOp       (NegateOp*        x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  virtual void do_ArithmeticOp   (ArithmeticOp*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  virtual void do_ShiftOp        (ShiftOp*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  virtual void do_LogicOp        (LogicOp*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  virtual void do_CompareOp      (CompareOp*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  virtual void do_IfOp           (IfOp*            x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  virtual void do_Convert        (Convert*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  virtual void do_NullCheck      (NullCheck*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  virtual void do_Invoke         (Invoke*          x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  virtual void do_NewInstance    (NewInstance*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  virtual void do_NewTypeArray   (NewTypeArray*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  virtual void do_NewObjectArray (NewObjectArray*  x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  virtual void do_NewMultiArray  (NewMultiArray*   x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  virtual void do_CheckCast      (CheckCast*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  virtual void do_InstanceOf     (InstanceOf*      x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  virtual void do_MonitorExit    (MonitorExit*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  virtual void do_Intrinsic      (Intrinsic*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  virtual void do_BlockBegin     (BlockBegin*      x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  virtual void do_Goto           (Goto*            x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual void do_If             (If*              x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual void do_IfInstanceOf   (IfInstanceOf*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  virtual void do_TableSwitch    (TableSwitch*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  virtual void do_Return         (Return*          x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  virtual void do_Throw          (Throw*           x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  virtual void do_Base           (Base*            x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  virtual void do_OsrEntry       (OsrEntry*        x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  virtual void do_ExceptionObject(ExceptionObject* x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  virtual void do_RoundFP        (RoundFP*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  virtual void do_UnsafePutRaw   (UnsafePutRaw*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  virtual void do_UnsafeGetObject(UnsafeGetObject* x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  virtual void do_UnsafePutObject(UnsafePutObject* x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  virtual void do_ProfileCall    (ProfileCall*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  virtual void do_ProfileCounter (ProfileCounter*  x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
// Hashing support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
// Note: This hash functions affect the performance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
//       of ValueMap - make changes carefully!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
#define HASH1(x1            )                    ((intx)(x1))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#define HASH2(x1, x2        )                    ((HASH1(x1        ) << 7) ^ HASH1(x2))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
#define HASH3(x1, x2, x3    )                    ((HASH2(x1, x2    ) << 7) ^ HASH1(x3))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
#define HASH4(x1, x2, x3, x4)                    ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
// The following macros are used to implement instruction-specific hashing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
// By default, each instruction implements hash() and is_equal(Value), used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
// for value numbering/common subexpression elimination. The default imple-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
// mentation disables value numbering. Each instruction which can be value-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
// numbered, should define corresponding hash() and is_equal(Value) functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
// via the macros below. The f arguments specify all the values/op codes, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
// that need to be identical for two instructions to be identical.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
// Note: The default implementation of hash() returns 0 in order to indicate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
//       that the instruction should not be considered for value numbering.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
//       The currently used hash functions do not guarantee that never a 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
//       is produced. While this is still correct, it may be a performance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
//       bug (no value numbering for that node). However, this situation is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
//       so unlikely, that we are not going to handle it specially.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
#define HASHING1(class_name, enabled, f1)             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  virtual intx hash() const {                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    return (enabled) ? HASH2(name(), f1) : 0;         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  virtual bool is_equal(Value v) const {              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    if (!(enabled)  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    class_name* _v = v->as_##class_name();            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    if (_v == NULL  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    if (f1 != _v->f1) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    return true;                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
#define HASHING2(class_name, enabled, f1, f2)         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  virtual intx hash() const {                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    return (enabled) ? HASH3(name(), f1, f2) : 0;     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  virtual bool is_equal(Value v) const {              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    if (!(enabled)  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    class_name* _v = v->as_##class_name();            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    if (_v == NULL  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    if (f1 != _v->f1) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    if (f2 != _v->f2) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    return true;                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
#define HASHING3(class_name, enabled, f1, f2, f3)     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  virtual intx hash() const {                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  virtual bool is_equal(Value v) const {              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    if (!(enabled)  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    class_name* _v = v->as_##class_name();            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    if (_v == NULL  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    if (f1 != _v->f1) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    if (f2 != _v->f2) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    if (f3 != _v->f3) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    return true;                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
// The mother of all instructions...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
class Instruction: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  static int   _next_id;                         // the node counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  int          _id;                              // the unique instruction id
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  int          _bci;                             // the instruction bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  int          _use_count;                       // the number of instructions refering to this value (w/o prev/next); only roots can have use count = 0 or > 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  int          _pin_state;                       // set of PinReason describing the reason for pinning
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  ValueType*   _type;                            // the instruction value type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  Instruction* _next;                            // the next instruction if any (NULL for BlockEnd instructions)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  Instruction* _subst;                           // the substitution instruction if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  LIR_Opr      _operand;                         // LIR specific information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  unsigned int _flags;                           // Flag bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  XHandlers*   _exception_handlers;              // Flat list of exception handlers covering this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  HiWord*      _hi_word;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  friend class UseCountComputer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  void set_bci(int bci)                          { assert(bci == SynchronizationEntryBCI || bci >= 0, "illegal bci"); _bci = bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  void set_type(ValueType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    assert(type != NULL, "type must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    _type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  enum InstructionFlag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    NeedsNullCheckFlag = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    CanTrapFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    DirectCompareFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    IsEliminatedFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    IsInitializedFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    IsLoadedFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    IsSafepointFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    IsStaticFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    IsStrictfpFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    NeedsStoreCheckFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    NeedsWriteBarrierFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    PreservesStateFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    TargetIsFinalFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    TargetIsLoadedFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    TargetIsStrictfpFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    UnorderedIsTrueFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    NeedsPatchingFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    ThrowIncompatibleClassChangeErrorFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    ProfileMDOFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    InstructionLastFlag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  bool check_flag(InstructionFlag id) const      { return (_flags & (1 << id)) != 0;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  void set_flag(InstructionFlag id, bool f)      { _flags = f ? (_flags | (1 << id)) : (_flags & ~(1 << id)); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  // 'globally' used condition values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  enum Condition {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    eql, neq, lss, leq, gtr, geq
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  // Instructions may be pinned for many reasons and under certain conditions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  // with enough knowledge it's possible to safely unpin them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  enum PinReason {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      PinUnknown           = 1 << 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    , PinExplicitNullCheck = 1 << 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    , PinStackForStateSplit= 1 << 12
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    , PinStateSplitConstructor= 1 << 13
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    , PinGlobalValueNumbering= 1 << 14
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  static Condition mirror(Condition cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  static Condition negate(Condition cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  static void initialize()                       { _next_id = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  static int number_of_instructions()            { return _next_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  Instruction(ValueType* type, bool type_is_constant = false, bool create_hi = true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  : _id(_next_id++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  , _bci(-99)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  , _use_count(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  , _pin_state(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  , _type(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  , _next(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  , _subst(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  , _flags(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  , _operand(LIR_OprFact::illegalOpr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  , _exception_handlers(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  , _hi_word(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    if (create_hi && type->is_double_word()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
      create_hi_word();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  int id() const                                 { return _id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  int bci() const                                { return _bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  int use_count() const                          { return _use_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  int pin_state() const                          { return _pin_state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  bool is_pinned() const                         { return _pin_state != 0 || PinAllInstructions; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  ValueType* type() const                        { return _type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  Instruction* prev(BlockBegin* block);          // use carefully, expensive operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  Instruction* next() const                      { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  bool has_subst() const                         { return _subst != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  Instruction* subst()                           { return _subst == NULL ? this : _subst->subst(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  LIR_Opr operand() const                        { return _operand; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  void set_needs_null_check(bool f)              { set_flag(NeedsNullCheckFlag, f); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  bool needs_null_check() const                  { return check_flag(NeedsNullCheckFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  bool has_uses() const                          { return use_count() > 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  bool is_root() const                           { return is_pinned() || use_count() > 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  XHandlers* exception_handlers() const          { return _exception_handlers; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  void pin(PinReason reason)                     { _pin_state |= reason; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  void pin()                                     { _pin_state |= PinUnknown; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  // DANGEROUS: only used by EliminateStores
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  void unpin(PinReason reason)                   { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  virtual void set_lock_stack(ValueStack* l)     { /* do nothing*/ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  virtual ValueStack* lock_stack() const         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  Instruction* set_next(Instruction* next, int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    if (next != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
      assert(next->as_Phi() == NULL && next->as_Local() == NULL, "shouldn't link these instructions into list");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
      next->set_bci(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    _next = next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    return next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  void set_subst(Instruction* subst)             {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    assert(subst == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
           type()->base() == subst->type()->base() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
           subst->type()->base() == illegalType, "type can't change");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    _subst = subst;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  // HiWord is used for debugging and is allocated early to avoid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  // allocation at inconvenient points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  HiWord* hi_word() { return _hi_word; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  void create_hi_word();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  // machine-specifics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  void set_operand(LIR_Opr operand)              { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  void clear_operand()                           { _operand = LIR_OprFact::illegalOpr; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  virtual Instruction*      as_Instruction()     { return this; } // to satisfy HASHING1 macro
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  virtual HiWord*           as_HiWord()          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  virtual Phi*           as_Phi()          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  virtual Local*            as_Local()           { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  virtual Constant*         as_Constant()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  virtual AccessField*      as_AccessField()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  virtual LoadField*        as_LoadField()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  virtual StoreField*       as_StoreField()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  virtual AccessArray*      as_AccessArray()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  virtual ArrayLength*      as_ArrayLength()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  virtual AccessIndexed*    as_AccessIndexed()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  virtual LoadIndexed*      as_LoadIndexed()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  virtual StoreIndexed*     as_StoreIndexed()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  virtual NegateOp*         as_NegateOp()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  virtual Op2*              as_Op2()             { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  virtual ArithmeticOp*     as_ArithmeticOp()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  virtual ShiftOp*          as_ShiftOp()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  virtual LogicOp*          as_LogicOp()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  virtual CompareOp*        as_CompareOp()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  virtual IfOp*             as_IfOp()            { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  virtual Convert*          as_Convert()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  virtual NullCheck*        as_NullCheck()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  virtual OsrEntry*         as_OsrEntry()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  virtual StateSplit*       as_StateSplit()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  virtual Invoke*           as_Invoke()          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  virtual NewInstance*      as_NewInstance()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  virtual NewArray*         as_NewArray()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  virtual NewTypeArray*     as_NewTypeArray()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  virtual NewObjectArray*   as_NewObjectArray()  { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  virtual NewMultiArray*    as_NewMultiArray()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  virtual TypeCheck*        as_TypeCheck()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  virtual CheckCast*        as_CheckCast()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  virtual InstanceOf*       as_InstanceOf()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  virtual AccessMonitor*    as_AccessMonitor()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  virtual MonitorEnter*     as_MonitorEnter()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  virtual MonitorExit*      as_MonitorExit()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  virtual Intrinsic*        as_Intrinsic()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  virtual BlockBegin*       as_BlockBegin()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  virtual BlockEnd*         as_BlockEnd()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  virtual Goto*             as_Goto()            { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  virtual If*               as_If()              { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  virtual IfInstanceOf*     as_IfInstanceOf()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  virtual TableSwitch*      as_TableSwitch()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  virtual LookupSwitch*     as_LookupSwitch()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  virtual Return*           as_Return()          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  virtual Throw*            as_Throw()           { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  virtual Base*             as_Base()            { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  virtual RoundFP*          as_RoundFP()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  virtual ExceptionObject*  as_ExceptionObject() { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  virtual UnsafeOp*         as_UnsafeOp()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  virtual void visit(InstructionVisitor* v)      = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  virtual bool can_trap() const                  { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  virtual void input_values_do(void f(Value*))   = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  virtual void state_values_do(void f(Value*))   { /* usually no state - override on demand */ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  virtual void other_values_do(void f(Value*))   { /* usually no other - override on demand */ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
          void       values_do(void f(Value*))   { input_values_do(f); state_values_do(f); other_values_do(f); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  virtual ciType* exact_type() const             { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  virtual ciType* declared_type() const          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // hashing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  virtual const char* name() const               = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  HASHING1(Instruction, false, id())             // hashing disabled by default
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  void print()                                   PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  void print_line()                              PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  void print(InstructionPrinter& ip)             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
// The following macros are used to define base (i.e., non-leaf)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
// and leaf instruction classes. They define class-name related
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
// generic functionality in one place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
#define BASE(class_name, super_class_name)       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  class class_name: public super_class_name {    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
   public:                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    virtual class_name* as_##class_name()        { return this; }              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
#define LEAF(class_name, super_class_name)       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  BASE(class_name, super_class_name)             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
   public:                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    virtual const char* name() const             { return #class_name; }       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    virtual void visit(InstructionVisitor* v)    { v->do_##class_name(this); } \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
// Debugging support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  static void assert_value(Value* x)             { assert((*x) != NULL, "value must exist"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  #define ASSERT_VALUES                          values_do(assert_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  #define ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
// A HiWord occupies the 'high word' of a 2-word
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
// expression stack entry. Hi & lo words must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
// paired on the expression stack (otherwise the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
// bytecode sequence is illegal). Note that 'hi'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
// refers to the IR expression stack format and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
// does *not* imply a machine word ordering. No
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
// HiWords are used in optimized mode for speed,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
// but NULL pointers are used instead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
LEAF(HiWord, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  Value _lo_word;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  HiWord(Value lo_word)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    : Instruction(illegalType, false, false),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
      _lo_word(lo_word) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    // hi-words are also allowed for illegal lo-words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    assert(lo_word->type()->is_double_word() || lo_word->type()->is_illegal(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
           "HiWord must be used for 2-word values only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  Value lo_word() const                          { return _lo_word->subst(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  // for invalidating of HiWords
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  void make_illegal()                            { set_type(illegalType); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  virtual void input_values_do(void f(Value*))   { ShouldNotReachHere(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
// A Phi is a phi function in the sense of SSA form. It stands for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
// the value of a local variable at the beginning of a join block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
// A Phi consists of n operands, one for every incoming branch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
LEAF(Phi, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  BlockBegin* _block;    // the block to which the phi function belongs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  int         _pf_flags; // the flags of the phi function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  int         _index;    // to value on operand stack (index < 0) or to local
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  Phi(ValueType* type, BlockBegin* b, int index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  : Instruction(type->base())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  , _pf_flags(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  , _block(b)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    if (type->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      make_illegal();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  // flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  enum Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    no_flag         = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    visited         = 1 << 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    cannot_simplify = 1 << 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  bool  is_local() const          { return _index >= 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  bool  is_on_stack() const       { return !is_local(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  int   local_index() const       { assert(is_local(), ""); return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  int   stack_index() const       { assert(is_on_stack(), ""); return -(_index+1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  Value operand_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  int   operand_count() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  BlockBegin* block() const       { return _block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  void   set(Flag f)              { _pf_flags |=  f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  void   clear(Flag f)            { _pf_flags &= ~f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  bool   is_set(Flag f) const     { return (_pf_flags & f) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  // Invalidates phis corresponding to merges of locals of two different types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  // (these should never be referenced, otherwise the bytecodes are illegal)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  void   make_illegal() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    set(cannot_simplify);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    set_type(illegalType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  bool is_illegal() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    return type()->is_illegal();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  virtual void input_values_do(void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
// A local is a placeholder for an incoming argument to a function call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
LEAF(Local, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  int      _java_index;                          // the local index within the method to which the local belongs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  Local(ValueType* type, int index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    : Instruction(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    , _java_index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  int java_index() const                         { return _java_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  virtual void input_values_do(void f(Value*))   { /* no values */ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
LEAF(Constant, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  ValueStack* _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  Constant(ValueType* type):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
      Instruction(type, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  , _state(NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
    assert(type->is_constant(), "must be a constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  Constant(ValueType* type, ValueStack* state):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    Instruction(type, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  , _state(state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
    assert(state != NULL, "only used for constants which need patching");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
    assert(type->is_constant(), "must be a constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    // since it's patching it needs to be pinned
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  ValueStack* state() const               { return _state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  virtual bool can_trap() const                  { return state() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  virtual void input_values_do(void f(Value*))   { /* no values */ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  virtual intx hash() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  virtual bool is_equal(Value v) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  virtual BlockBegin* compare(Instruction::Condition condition, Value right,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
                              BlockBegin* true_sux, BlockBegin* false_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
BASE(AccessField, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  int         _offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
  ciField*    _field;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  ValueStack* _state_before;                     // state is set only for unloaded or uninitialized fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  ValueStack* _lock_stack;                       // contains lock and scope information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  NullCheck*  _explicit_null_check;              // For explicit null check elimination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  AccessField(Value obj, int offset, ciField* field, bool is_static, ValueStack* lock_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
              ValueStack* state_before, bool is_loaded, bool is_initialized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  : Instruction(as_ValueType(field->type()->basic_type()))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  , _obj(obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  , _offset(offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  , _field(field)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  , _lock_stack(lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  , _state_before(state_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  , _explicit_null_check(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    set_needs_null_check(!is_static);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
    set_flag(IsLoadedFlag, is_loaded);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    set_flag(IsInitializedFlag, is_initialized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
    set_flag(IsStaticFlag, is_static);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
      if (!is_loaded || (PatchALot && !field->is_volatile())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
      // need to patch if the holder wasn't loaded or we're testing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
      // using PatchALot.  Don't allow PatchALot for fields which are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
      // known to be volatile they aren't patchable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
      set_flag(NeedsPatchingFlag, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    // pin of all instructions with memory access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  int offset() const                             { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  ciField* field() const                         { return _field; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  BasicType field_type() const                   { return _field->type()->basic_type(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  bool is_static() const                         { return check_flag(IsStaticFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  bool is_loaded() const                         { return check_flag(IsLoadedFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  bool is_initialized() const                    { return check_flag(IsInitializedFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  ValueStack* state_before() const               { return _state_before; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  ValueStack* lock_stack() const                 { return _lock_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  NullCheck* explicit_null_check() const         { return _explicit_null_check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  bool needs_patching() const                    { return check_flag(NeedsPatchingFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  void set_lock_stack(ValueStack* l)             { _lock_stack = l; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
  // Under certain circumstances, if a previous NullCheck instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  // proved the target object non-null, we can eliminate the explicit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  // null check and do an implicit one, simply specifying the debug
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  // information from the NullCheck. This field should only be consulted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  // if needs_null_check() is true.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  virtual void input_values_do(void f(Value*))   { f(&_obj); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
LEAF(LoadField, AccessField)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  LoadField(Value obj, int offset, ciField* field, bool is_static, ValueStack* lock_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
            ValueStack* state_before, bool is_loaded, bool is_initialized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  : AccessField(obj, offset, field, is_static, lock_stack, state_before, is_loaded, is_initialized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  ciType* declared_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  HASHING2(LoadField, is_loaded() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if not yet loaded or if volatile
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
LEAF(StoreField, AccessField)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  Value _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  StoreField(Value obj, int offset, ciField* field, Value value, bool is_static, ValueStack* lock_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
             ValueStack* state_before, bool is_loaded, bool is_initialized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  : AccessField(obj, offset, field, is_static, lock_stack, state_before, is_loaded, is_initialized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  Value value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  virtual void input_values_do(void f(Value*))   { AccessField::input_values_do(f); f(&_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
BASE(AccessArray, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  Value       _array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  ValueStack* _lock_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  AccessArray(ValueType* type, Value array, ValueStack* lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  : Instruction(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  , _array(array)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
  , _lock_stack(lock_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
    set_needs_null_check(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
    pin(); // instruction with side effect (null exception or range check throwing)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  Value array() const                            { return _array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  ValueStack* lock_stack() const                 { return _lock_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  void set_lock_stack(ValueStack* l)             { _lock_stack = l; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  virtual bool can_trap() const                  { return needs_null_check(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
  virtual void input_values_do(void f(Value*))   { f(&_array); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
LEAF(ArrayLength, AccessArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  NullCheck*  _explicit_null_check;              // For explicit null check elimination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
  ArrayLength(Value array, ValueStack* lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  : AccessArray(intType, array, lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
  , _explicit_null_check(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  NullCheck* explicit_null_check() const         { return _explicit_null_check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  // See LoadField::set_explicit_null_check for documentation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  HASHING1(ArrayLength, true, array()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
BASE(AccessIndexed, AccessArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  Value     _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
  Value     _length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  BasicType _elt_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  : AccessArray(as_ValueType(elt_type), array, lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  , _length(length)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  , _elt_type(elt_type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  Value index() const                            { return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  Value length() const                           { return _length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  BasicType elt_type() const                     { return _elt_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  // perform elimination of range checks involving constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  bool compute_needs_range_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  virtual void input_values_do(void f(Value*))   { AccessArray::input_values_do(f); f(&_index); if (_length != NULL) f(&_length); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
LEAF(LoadIndexed, AccessIndexed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
  NullCheck*  _explicit_null_check;              // For explicit null check elimination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  : AccessIndexed(array, index, length, elt_type, lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  , _explicit_null_check(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
  NullCheck* explicit_null_check() const         { return _explicit_null_check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  // See LoadField::set_explicit_null_check for documentation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  ciType* declared_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
  HASHING2(LoadIndexed, true, array()->subst(), index()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
LEAF(StoreIndexed, AccessIndexed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  Value       _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  : AccessIndexed(array, index, length, elt_type, lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
    set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
    set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  Value value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
  IRScope* scope() const;                        // the state's scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  bool needs_store_check() const                 { return check_flag(NeedsStoreCheckFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  virtual void input_values_do(void f(Value*))   { AccessIndexed::input_values_do(f); f(&_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
LEAF(NegateOp, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  Value _x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
  Value x() const                                { return _x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  virtual void input_values_do(void f(Value*))   { f(&_x); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
BASE(Op2, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  Bytecodes::Code _op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  Value           _x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  Value           _y;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  Op2(ValueType* type, Bytecodes::Code op, Value x, Value y) : Instruction(type), _op(op), _x(x), _y(y) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
  Bytecodes::Code op() const                     { return _op; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  Value x() const                                { return _x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
  Value y() const                                { return _y; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
  // manipulators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
  void swap_operands() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
    assert(is_commutative(), "operation must be commutative");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
    Value t = _x; _x = _y; _y = t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  virtual bool is_commutative() const            { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
  virtual void input_values_do(void f(Value*))   { f(&_x); f(&_y); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
LEAF(ArithmeticOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
  ValueStack* _lock_stack;                       // used only for division operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
  ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
  : Op2(x->type()->meet(y->type()), op, x, y)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
  ,  _lock_stack(lock_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
    set_flag(IsStrictfpFlag, is_strictfp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
    if (can_trap()) pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
  ValueStack* lock_stack() const                 { return _lock_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
  bool        is_strictfp() const                { return check_flag(IsStrictfpFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
  void set_lock_stack(ValueStack* l)             { _lock_stack = l; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
  virtual bool is_commutative() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
  virtual bool can_trap() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
LEAF(ShiftOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
  ShiftOp(Bytecodes::Code op, Value x, Value s) : Op2(x->type()->base(), op, x, s) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
LEAF(LogicOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  LogicOp(Bytecodes::Code op, Value x, Value y) : Op2(x->type()->meet(y->type()), op, x, y) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
  virtual bool is_commutative() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
LEAF(CompareOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  ValueStack* _state_before;                     // for deoptimization, when canonicalizing
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
  CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
  : Op2(intType, op, x, y)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  , _state_before(state_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
  ValueStack* state_before() const               { return _state_before; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
LEAF(IfOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  Value _tval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
  Value _fval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
  IfOp(Value x, Condition cond, Value y, Value tval, Value fval)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
  : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
  , _tval(tval)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
  , _fval(fval)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
    assert(tval->type()->tag() == fval->type()->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  virtual bool is_commutative() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  Bytecodes::Code op() const                     { ShouldNotCallThis(); return Bytecodes::_illegal; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  Condition cond() const                         { return (Condition)Op2::op(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  Value tval() const                             { return _tval; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
  Value fval() const                             { return _fval; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
  virtual void input_values_do(void f(Value*))   { Op2::input_values_do(f); f(&_tval); f(&_fval); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
LEAF(Convert, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
  Bytecodes::Code _op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
  Value           _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
  Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
  Bytecodes::Code op() const                     { return _op; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
  Value value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
  virtual void input_values_do(void f(Value*))   { f(&_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
  HASHING2(Convert, true, op(), value()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
LEAF(NullCheck, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
  ValueStack* _lock_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
  NullCheck(Value obj, ValueStack* lock_stack) : Instruction(obj->type()->base()), _obj(obj), _lock_stack(lock_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
    set_can_trap(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
    assert(_obj->type()->is_object(), "null check must be applied to objects only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
    pin(Instruction::PinExplicitNullCheck);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
  ValueStack* lock_stack() const                 { return _lock_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
  void set_lock_stack(ValueStack* l)             { _lock_stack = l; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
  void set_can_trap(bool can_trap)               { set_flag(CanTrapFlag, can_trap); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
  virtual bool can_trap() const                  { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
  virtual void input_values_do(void f(Value*))   { f(&_obj); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
  HASHING1(NullCheck, true, obj()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
BASE(StateSplit, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
  ValueStack* _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
  static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
  StateSplit(ValueType* type) : Instruction(type), _state(NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
    pin(PinStateSplitConstructor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
  ValueStack* state() const                      { return _state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
  IRScope* scope() const;                        // the state's scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  void set_state(ValueStack* state)              { _state = state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
  virtual void input_values_do(void f(Value*))   { /* no values */ }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
  virtual void state_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
LEAF(Invoke, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
  Bytecodes::Code           _code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
  Value                     _recv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  Values*                   _args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
  BasicTypeList*            _signature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
  int                       _vtable_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
  ciMethod*                 _target;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
  Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
         int vtable_index, ciMethod* target);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
  Bytecodes::Code code() const                   { return _code; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  Value receiver() const                         { return _recv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
  bool has_receiver() const                      { return receiver() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
  int number_of_arguments() const                { return _args->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  Value argument_at(int i) const                 { return _args->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
  int vtable_index() const                       { return _vtable_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  BasicTypeList* signature() const               { return _signature; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
  ciMethod* target() const                       { return _target; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
  // Returns false if target is not loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
  bool target_is_final() const                   { return check_flag(TargetIsFinalFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
  bool target_is_loaded() const                  { return check_flag(TargetIsLoadedFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
  // Returns false if target is not loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
  bool target_is_strictfp() const                { return check_flag(TargetIsStrictfpFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
  virtual void input_values_do(void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
    StateSplit::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
    if (has_receiver()) f(&_recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
    for (int i = 0; i < _args->length(); i++) f(_args->adr_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
LEAF(NewInstance, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
  ciInstanceKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
  NewInstance(ciInstanceKlass* klass) : StateSplit(instanceType), _klass(klass) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
  ciInstanceKlass* klass() const                 { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
BASE(NewArray, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
  Value       _length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
  ValueStack* _state_before;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
  NewArray(Value length, ValueStack* state_before) : StateSplit(objectType), _length(length), _state_before(state_before) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
    // Do not ASSERT_VALUES since length is NULL for NewMultiArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
  ValueStack* state_before() const               { return _state_before; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
  Value length() const                           { return _length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
  virtual void input_values_do(void f(Value*))   { StateSplit::input_values_do(f); f(&_length); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1213
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
LEAF(NewTypeArray, NewArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
  BasicType _elt_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
  NewTypeArray(Value length, BasicType elt_type) : NewArray(length, NULL), _elt_type(elt_type) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
  BasicType elt_type() const                     { return _elt_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
LEAF(NewObjectArray, NewArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
  ciKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
  NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
LEAF(NewMultiArray, NewArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
  ciKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
  Values*  _dims;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
  NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1255
  Values* dims() const                           { return _dims; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
  int rank() const                               { return dims()->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  virtual void input_values_do(void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
    // NOTE: we do not call NewArray::input_values_do since "length"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
    // is meaningless for a multi-dimensional array; passing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
    // zeroth element down to NewArray as its length is a bad idea
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
    // since there will be a copy in the "dims" array which doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
    // get updated, and the value must not be traversed twice. Was bug
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
    // - kbr 4/10/2001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
    StateSplit::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
    for (int i = 0; i < _dims->length(); i++) f(_dims->adr_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
BASE(TypeCheck, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  ciKlass*    _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  ValueStack* _state_before;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
  TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before) : StateSplit(type), _klass(klass), _obj(obj), _state_before(state_before) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
    set_direct_compare(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1286
  ValueStack* state_before() const               { return _state_before; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
  bool is_loaded() const                         { return klass() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
  bool direct_compare() const                    { return check_flag(DirectCompareFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
  void set_direct_compare(bool flag)             { set_flag(DirectCompareFlag, flag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
  virtual void input_values_do(void f(Value*))   { StateSplit::input_values_do(f); f(&_obj); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
LEAF(CheckCast, TypeCheck)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  ciMethod* _profiled_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  int       _profiled_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
  CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
  : TypeCheck(klass, obj, objectType, state_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  , _profiled_method(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  , _profiled_bci(0) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
  void set_incompatible_class_change_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
    set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
  bool is_incompatible_class_change_check() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
    return check_flag(ThrowIncompatibleClassChangeErrorFlag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
  // Helpers for methodDataOop profiling
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
  void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
  void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
  bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
  ciMethod* profiled_method() const                  { return _profiled_method;     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
  int       profiled_bci() const                     { return _profiled_bci;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
  ciType* declared_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
LEAF(InstanceOf, TypeCheck)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
BASE(AccessMonitor, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
  int         _monitor_no;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  AccessMonitor(Value obj, int monitor_no)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
  : StateSplit(illegalType)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
  , _obj(obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
  , _monitor_no(monitor_no)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
    set_needs_null_check(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
  int monitor_no() const                         { return _monitor_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
  virtual void input_values_do(void f(Value*))   { StateSplit::input_values_do(f); f(&_obj); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
LEAF(MonitorEnter, AccessMonitor)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
  ValueStack* _lock_stack_before;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
  MonitorEnter(Value obj, int monitor_no, ValueStack* lock_stack_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
  : AccessMonitor(obj, monitor_no)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
  , _lock_stack_before(lock_stack_before)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
  ValueStack* lock_stack_before() const          { return _lock_stack_before; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  virtual void state_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
LEAF(MonitorExit, AccessMonitor)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
  MonitorExit(Value obj, int monitor_no) : AccessMonitor(obj, monitor_no) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
LEAF(Intrinsic, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
  vmIntrinsics::ID _id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  Values*          _args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
  ValueStack*      _lock_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
  Value            _recv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
  // preserves_state can be set to true for Intrinsics
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
  // which are guaranteed to preserve register state across any slow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
  // cases; setting it to true does not mean that the Intrinsic can
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  // not trap, only that if we continue execution in the same basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
  // block after the Intrinsic, all of the registers are intact. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
  // allows load elimination and common expression elimination to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1410
  // performed across the Intrinsic.  The default value is false.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1411
  Intrinsic(ValueType* type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
            vmIntrinsics::ID id,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
            Values* args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
            bool has_receiver,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
            ValueStack* lock_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
            bool preserves_state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
            bool cantrap = true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
  : StateSplit(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
  , _id(id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  , _args(args)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
  , _lock_stack(lock_stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
  , _recv(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
    assert(args != NULL, "args must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
    set_flag(PreservesStateFlag, preserves_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
    set_flag(CanTrapFlag,        cantrap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
    if (has_receiver) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
      _recv = argument_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
    set_needs_null_check(has_receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
    // some intrinsics can't trap, so don't force them to be pinned
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
    if (!can_trap()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
      unpin(PinStateSplitConstructor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
  vmIntrinsics::ID id() const                    { return _id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
  int number_of_arguments() const                { return _args->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
  Value argument_at(int i) const                 { return _args->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
  ValueStack* lock_stack() const                 { return _lock_stack; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
  bool has_receiver() const                      { return (_recv != NULL); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
  Value receiver() const                         { assert(has_receiver(), "must have receiver"); return _recv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
  bool preserves_state() const                   { return check_flag(PreservesStateFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
  virtual bool can_trap() const                  { return check_flag(CanTrapFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
  virtual void input_values_do(void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
    StateSplit::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
    for (int i = 0; i < _args->length(); i++) f(_args->adr_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
  virtual void state_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
class LIR_List;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
LEAF(BlockBegin, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
  static int _next_block_id;                     // the block counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
  int        _block_id;                          // the unique block id
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
  int        _depth_first_number;                // number of this block in a depth-first ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
  int        _linear_scan_number;                // number of this block in linear-scan ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
  int        _loop_depth;                        // the loop nesting level of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
  int        _loop_index;                        // number of the innermost loop of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
  int        _flags;                             // the flags associated with this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
  // fields used by BlockListBuilder
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
  int        _total_preds;                       // number of predecessors found by BlockListBuilder
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
  BitMap     _stores_to_locals;                  // bit is set when a local variable is stored in the block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
  // SSA specific fields: (factor out later)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
  BlockList   _successors;                       // the successors of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
  BlockList   _predecessors;                     // the predecessors of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
  BlockBegin* _dominator;                        // the dominator of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
  // SSA specific ends
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
  BlockEnd*  _end;                               // the last instruction of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
  BlockList  _exception_handlers;                // the exception handlers potentially invoked by this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  ValueStackStack* _exception_states;            // only for xhandler entries: states of all instructions that have an edge to this xhandler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  int        _exception_handler_pco;             // if this block is the start of an exception handler,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
                                                 // this records the PC offset in the assembly code of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
                                                 // first instruction in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  Label      _label;                             // the label associated with this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  LIR_List*  _lir;                               // the low level intermediate representation for this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  BitMap      _live_in;                          // set of live LIR_Opr registers at entry to this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
  BitMap      _live_out;                         // set of live LIR_Opr registers at exit from this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
  BitMap      _live_gen;                         // set of registers used before any redefinition in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
  BitMap      _live_kill;                        // set of registers defined in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
  BitMap      _fpu_register_usage;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  intArray*   _fpu_stack_state;                  // For x86 FPU code generation with UseLinearScan
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  int         _first_lir_instruction_id;         // ID of first LIR instruction in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
  int         _last_lir_instruction_id;          // ID of last LIR instruction in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
  void iterate_preorder (boolArray& mark, BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  void iterate_postorder(boolArray& mark, BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
  friend class SuxAndWeightAdjuster;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
  // initialization/counting
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
  static void initialize()                       { _next_block_id = 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
  static int  number_of_blocks()                 { return _next_block_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
  BlockBegin(int bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
  : StateSplit(illegalType)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
  , _block_id(_next_block_id++)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
  , _depth_first_number(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
  , _linear_scan_number(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
  , _loop_depth(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
  , _flags(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
  , _dominator(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
  , _end(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
  , _predecessors(2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
  , _successors(2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
  , _exception_handlers(1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
  , _exception_states(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
  , _exception_handler_pco(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
  , _lir(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
  , _loop_index(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
  , _live_in()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
  , _live_out()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
  , _live_gen()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
  , _live_kill()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
  , _fpu_register_usage()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
  , _fpu_stack_state(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
  , _first_lir_instruction_id(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
  , _last_lir_instruction_id(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  , _total_preds(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
  , _stores_to_locals()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
    set_bci(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
  int block_id() const                           { return _block_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  BlockList* successors()                        { return &_successors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  BlockBegin* dominator() const                  { return _dominator; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
  int loop_depth() const                         { return _loop_depth; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
  int depth_first_number() const                 { return _depth_first_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
  int linear_scan_number() const                 { return _linear_scan_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
  BlockEnd* end() const                          { return _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
  Label* label()                                 { return &_label; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
  LIR_List* lir() const                          { return _lir; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
  int exception_handler_pco() const              { return _exception_handler_pco; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
  BitMap& live_in()                              { return _live_in;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
  BitMap& live_out()                             { return _live_out;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
  BitMap& live_gen()                             { return _live_gen;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
  BitMap& live_kill()                            { return _live_kill;      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
  BitMap& fpu_register_usage()                   { return _fpu_register_usage; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
  intArray* fpu_stack_state() const              { return _fpu_stack_state;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
  int first_lir_instruction_id() const           { return _first_lir_instruction_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
  int last_lir_instruction_id() const            { return _last_lir_instruction_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
  int total_preds() const                        { return _total_preds; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
  BitMap& stores_to_locals()                     { return _stores_to_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
  void set_bci(int bci)                          { Instruction::set_bci(bci); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
  void set_dominator(BlockBegin* dom)            { _dominator = dom; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
  void set_loop_depth(int d)                     { _loop_depth = d; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
  void set_depth_first_number(int dfn)           { _depth_first_number = dfn; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
  void set_linear_scan_number(int lsn)           { _linear_scan_number = lsn; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  void set_end(BlockEnd* end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
  void disconnect_from_graph();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
  static void disconnect_edge(BlockBegin* from, BlockBegin* to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
  BlockBegin* insert_block_between(BlockBegin* sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
  void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1575
  void set_lir(LIR_List* lir)                    { _lir = lir; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1576
  void set_exception_handler_pco(int pco)        { _exception_handler_pco = pco; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1577
  void set_live_in       (BitMap map)            { _live_in = map;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1578
  void set_live_out      (BitMap map)            { _live_out = map;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
  void set_live_gen      (BitMap map)            { _live_gen = map;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
  void set_live_kill     (BitMap map)            { _live_kill = map;      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  void set_fpu_register_usage(BitMap map)        { _fpu_register_usage = map; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
  void set_fpu_stack_state(intArray* state)      { _fpu_stack_state = state;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
  void set_first_lir_instruction_id(int id)      { _first_lir_instruction_id = id;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
  void set_last_lir_instruction_id(int id)       { _last_lir_instruction_id = id;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
  void increment_total_preds(int n = 1)          { _total_preds += n; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
  void init_stores_to_locals(int locals_count)   { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
  virtual void state_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
  // successors and predecessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
  int number_of_sux() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
  BlockBegin* sux_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1594
  void add_successor(BlockBegin* sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
  void remove_successor(BlockBegin* pred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
  bool is_successor(BlockBegin* sux) const       { return _successors.contains(sux); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1597
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  void add_predecessor(BlockBegin* pred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
  void remove_predecessor(BlockBegin* pred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  bool is_predecessor(BlockBegin* pred) const    { return _predecessors.contains(pred); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
  int number_of_preds() const                    { return _predecessors.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
  BlockBegin* pred_at(int i) const               { return _predecessors[i]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
  // exception handlers potentially invoked by this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
  void add_exception_handler(BlockBegin* b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
  bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
  int  number_of_exception_handlers() const      { return _exception_handlers.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  BlockBegin* exception_handler_at(int i) const  { return _exception_handlers.at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  // states of the instructions that have an edge to this exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
  int number_of_exception_states()               { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states == NULL ? 0 : _exception_states->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
  ValueStack* exception_state_at(int idx) const  { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states->at(idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
  int add_exception_state(ValueStack* state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
  // flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
  enum Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
    no_flag                       = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
    std_entry_flag                = 1 << 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
    osr_entry_flag                = 1 << 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
    exception_entry_flag          = 1 << 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
    subroutine_entry_flag         = 1 << 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
    backward_branch_target_flag   = 1 << 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
    is_on_work_list_flag          = 1 << 5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1624
    was_visited_flag              = 1 << 6,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1625
    default_exception_handler_flag = 1 << 8, // identify block which represents the default exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1626
    parser_loop_header_flag       = 1 << 9,  // set by parser to identify blocks where phi functions can not be created on demand
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1627
    critical_edge_split_flag      = 1 << 10, // set for all blocks that are introduced when critical edges are split
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1628
    linear_scan_loop_header_flag  = 1 << 11, // set during loop-detection for LinearScan
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1629
    linear_scan_loop_end_flag     = 1 << 12  // set during loop-detection for LinearScan
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
  void set(Flag f)                               { _flags |= f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
  void clear(Flag f)                             { _flags &= ~f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
  bool is_set(Flag f) const                      { return (_flags & f) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
  bool is_entry_block() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
    const int entry_mask = std_entry_flag | osr_entry_flag | exception_entry_flag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1637
    return (_flags & entry_mask) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1638
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1639
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1640
  // iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1641
  void iterate_preorder   (BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1642
  void iterate_postorder  (BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1643
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1644
  void block_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1646
  // loops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1647
  void set_loop_index(int ix)                    { _loop_index = ix;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1648
  int  loop_index() const                        { return _loop_index;      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
  // merging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
  bool try_merge(ValueStack* state);             // try to merge states at block begin
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
  void merge(ValueStack* state)                  { bool b = try_merge(state); assert(b, "merge failed"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1653
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
  void print_block()                             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
  void print_block(InstructionPrinter& ip, bool live_only = false) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1658
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
BASE(BlockEnd, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
  BlockBegin* _begin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1663
  BlockList*  _sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
  ValueStack* _state_before;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
  BlockList* sux() const                         { return _sux; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
  void set_sux(BlockList* sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
    assert(sux != NULL, "sux must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
    for (int i = sux->length() - 1; i >= 0; i--) assert(sux->at(i) != NULL, "sux must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
    _sux = sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
  BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1680
  : StateSplit(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1681
  , _begin(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1682
  , _sux(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1683
  , _state_before(state_before) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
    set_flag(IsSafepointFlag, is_safepoint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1688
  ValueStack* state_before() const               { return _state_before; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
  bool is_safepoint() const                      { return check_flag(IsSafepointFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1690
  BlockBegin* begin() const                      { return _begin; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1693
  void set_begin(BlockBegin* begin);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
  virtual void other_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
  // successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
  int number_of_sux() const                      { return _sux != NULL ? _sux->length() : 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
  BlockBegin* sux_at(int i) const                { return _sux->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
  BlockBegin* default_sux() const                { return sux_at(number_of_sux() - 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
  BlockBegin** addr_sux_at(int i) const          { return _sux->adr_at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
  int sux_index(BlockBegin* sux) const           { return _sux->find(sux); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
  void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
LEAF(Goto, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
  Goto(BlockBegin* sux, ValueStack* state_before, bool is_safepoint = false) : BlockEnd(illegalType, state_before, is_safepoint) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
    BlockList* s = new BlockList(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
    s->append(sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  Goto(BlockBegin* sux, bool is_safepoint) : BlockEnd(illegalType, NULL, is_safepoint) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
    BlockList* s = new BlockList(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
    s->append(sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1726
LEAF(If, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
  Value       _x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1729
  Condition   _cond;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
  Value       _y;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
  ciMethod*   _profiled_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  int         _profiled_bci; // Canonicalizer may alter bci of If node
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1734
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
  // unordered_is_true is valid for float/double compares only
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
  If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1737
    : BlockEnd(illegalType, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
  , _x(x)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
  , _cond(cond)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
  , _y(y)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
  , _profiled_method(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
  , _profiled_bci(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
    set_flag(UnorderedIsTrueFlag, unordered_is_true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
    assert(x->type()->tag() == y->type()->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
    BlockList* s = new BlockList(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
    s->append(tsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
    s->append(fsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1750
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
  Value x() const                                { return _x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
  Condition cond() const                         { return _cond; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
  bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
  Value y() const                                { return _y; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
  BlockBegin* sux_for(bool is_true) const        { return sux_at(is_true ? 0 : 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
  BlockBegin* tsux() const                       { return sux_for(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
  BlockBegin* fsux() const                       { return sux_for(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
  BlockBegin* usux() const                       { return sux_for(unordered_is_true()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
  bool should_profile() const                    { return check_flag(ProfileMDOFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
  ciMethod* profiled_method() const              { return _profiled_method; } // set only for profiled branches
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
  int profiled_bci() const                       { return _profiled_bci; }    // set only for profiled branches
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
  void swap_operands() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
    Value t = _x; _x = _y; _y = t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
    _cond = mirror(_cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
  void swap_sux() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1773
    assert(number_of_sux() == 2, "wrong number of successors");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1774
    BlockList* s = sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
    BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1776
    _cond = negate(_cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
    set_flag(UnorderedIsTrueFlag, !check_flag(UnorderedIsTrueFlag));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1779
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
  void set_should_profile(bool value)             { set_flag(ProfileMDOFlag, value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  void set_profiled_method(ciMethod* method)      { _profiled_method = method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
  void set_profiled_bci(int bci)                  { _profiled_bci = bci;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
  virtual void input_values_do(void f(Value*))   { BlockEnd::input_values_do(f); f(&_x); f(&_y); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
LEAF(IfInstanceOf, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
  ciKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
  Value    _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
  bool     _test_is_instance;                    // jump if instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
  int      _instanceof_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
  IfInstanceOf(ciKlass* klass, Value obj, bool test_is_instance, int instanceof_bci, BlockBegin* tsux, BlockBegin* fsux)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
  : BlockEnd(illegalType, NULL, false) // temporary set to false
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
  , _klass(klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
  , _obj(obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
  , _test_is_instance(test_is_instance)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
  , _instanceof_bci(instanceof_bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
    assert(instanceof_bci >= 0, "illegal bci");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
    BlockList* s = new BlockList(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
    s->append(tsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
    s->append(fsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
  // Note 1: If test_is_instance() is true, IfInstanceOf tests if obj *is* an
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
  //         instance of klass; otherwise it tests if it is *not* and instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
  //         of klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
  // Note 2: IfInstanceOf instructions are created by combining an InstanceOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
  //         and an If instruction. The IfInstanceOf bci() corresponds to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
  //         bci that the If would have had; the (this->) instanceof_bci() is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
  //         the bci of the original InstanceOf instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1823
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
  int instanceof_bci() const                     { return _instanceof_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
  bool test_is_instance() const                  { return _test_is_instance; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1826
  BlockBegin* sux_for(bool is_true) const        { return sux_at(is_true ? 0 : 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
  BlockBegin* tsux() const                       { return sux_for(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
  BlockBegin* fsux() const                       { return sux_for(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
  void swap_sux() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
    assert(number_of_sux() == 2, "wrong number of successors");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
    BlockList* s = sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
    BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
    _test_is_instance = !_test_is_instance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
  virtual void input_values_do(void f(Value*))   { BlockEnd::input_values_do(f); f(&_obj); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
BASE(Switch, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
  Value       _tag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
  Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
  : BlockEnd(illegalType, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
  , _tag(tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
    set_sux(sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1855
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1856
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
  Value tag() const                              { return _tag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
  int length() const                             { return number_of_sux() - 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1860
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
  virtual void input_values_do(void f(Value*))   { BlockEnd::input_values_do(f); f(&_tag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
LEAF(TableSwitch, Switch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
  int _lo_key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
  TableSwitch(Value tag, BlockList* sux, int lo_key, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1872
    : Switch(tag, sux, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1873
  , _lo_key(lo_key) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
  int lo_key() const                             { return _lo_key; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
  int hi_key() const                             { return _lo_key + length() - 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
LEAF(LookupSwitch, Switch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
  intArray* _keys;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1887
  LookupSwitch(Value tag, BlockList* sux, intArray* keys, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1888
  : Switch(tag, sux, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1889
  , _keys(keys) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
    assert(keys != NULL, "keys must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
    assert(keys->length() == length(), "sux & keys have incompatible lengths");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1892
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1893
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1894
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
  int key_at(int i) const                        { return _keys->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
LEAF(Return, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
  Value _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1904
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
  Return(Value result) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
    BlockEnd(result == NULL ? voidType : result->type()->base(), NULL, true),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
    _result(result) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
  Value result() const                           { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
  bool has_result() const                        { return result() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
  virtual void input_values_do(void f(Value*)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
    BlockEnd::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
    if (has_result()) f(&_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
LEAF(Throw, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
  Value _exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
  Throw(Value exception, ValueStack* state_before) : BlockEnd(illegalType, state_before, true), _exception(exception) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1928
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
  Value exception() const                        { return _exception; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
  virtual void input_values_do(void f(Value*))   { BlockEnd::input_values_do(f); f(&_exception); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
  virtual void state_values_do(void f(Value*));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
LEAF(Base, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
  Base(BlockBegin* std_entry, BlockBegin* osr_entry) : BlockEnd(illegalType, NULL, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
    assert(std_entry->is_set(BlockBegin::std_entry_flag), "std entry must be flagged");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1946
    assert(osr_entry == NULL || osr_entry->is_set(BlockBegin::osr_entry_flag), "osr entry must be flagged");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
    BlockList* s = new BlockList(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
    if (osr_entry != NULL) s->append(osr_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
    s->append(std_entry); // must be default sux!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
  BlockBegin* std_entry() const                  { return default_sux(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
  BlockBegin* osr_entry() const                  { return number_of_sux() < 2 ? NULL : sux_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
LEAF(OsrEntry, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
  OsrEntry() : Instruction(longType, false) { pin(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
  OsrEntry() : Instruction(intType,  false) { pin(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1969
  virtual void input_values_do(void f(Value*))   { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
// Models the incoming exception at a catch site
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
LEAF(ExceptionObject, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
  ExceptionObject() : Instruction(objectType, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
  virtual void input_values_do(void f(Value*))   { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
// Models needed rounding for floating-point values on Intel.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
// Currently only used to represent rounding of double-precision
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
// values stored into local variables, but could be used to model
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
// intermediate rounding of single-precision values as well.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
LEAF(RoundFP, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
  Value _input;             // floating-point value to be rounded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
  RoundFP(Value input)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
  : Instruction(input->type()) // Note: should not be used for constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
  , _input(input)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
  Value input() const                            { return _input; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
  virtual void input_values_do(void f(Value*))   { f(&_input); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
BASE(UnsafeOp, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
  BasicType _basic_type;    // ValueType can not express byte-sized integers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
  UnsafeOp(BasicType basic_type, bool is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
  : Instruction(is_put ? voidType : as_ValueType(basic_type))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
  , _basic_type(basic_type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
    //Note:  Unsafe ops are not not guaranteed to throw NPE.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
    // Convservatively, Unsafe operations must be pinned though we could be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
    // looser about this if we wanted to..
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
  BasicType basic_type()                         { return _basic_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
  virtual void input_values_do(void f(Value*))   { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
  virtual void other_values_do(void f(Value*))   { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
BASE(UnsafeRawOp, UnsafeOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  Value _base;                                   // Base address (a Java long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
  Value _index;                                  // Index if computed by optimizer; initialized to NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  int   _log2_scale;                             // Scale factor: 0, 1, 2, or 3.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
                                                 // Indicates log2 of number of bytes (1, 2, 4, or 8)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
                                                 // to scale index by.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  UnsafeRawOp(BasicType basic_type, Value addr, bool is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
  : UnsafeOp(basic_type, is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
  , _base(addr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
  , _index(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  , _log2_scale(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
    // Can not use ASSERT_VALUES because index may be NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
    assert(addr != NULL && addr->type()->is_long(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
  UnsafeRawOp(BasicType basic_type, Value base, Value index, int log2_scale, bool is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
  : UnsafeOp(basic_type, is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
  , _base(base)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
  , _log2_scale(log2_scale)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
  Value base()                                   { return _base; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
  Value index()                                  { return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
  bool  has_index()                              { return (_index != NULL); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
  int   log2_scale()                             { return _log2_scale; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
  void set_base (Value base)                     { _base  = base; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
  void set_index(Value index)                    { _index = index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
  void set_log2_scale(int log2_scale)            { _log2_scale = log2_scale; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
  virtual void input_values_do(void f(Value*))   { UnsafeOp::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
                                                   f(&_base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
                                                   if (has_index()) f(&_index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
LEAF(UnsafeGetRaw, UnsafeRawOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
  bool _may_be_unaligned;  // For OSREntry
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
  UnsafeGetRaw(BasicType basic_type, Value addr, bool may_be_unaligned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
  : UnsafeRawOp(basic_type, addr, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
    _may_be_unaligned = may_be_unaligned;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
  UnsafeGetRaw(BasicType basic_type, Value base, Value index, int log2_scale, bool may_be_unaligned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  : UnsafeRawOp(basic_type, base, index, log2_scale, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
    _may_be_unaligned = may_be_unaligned;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
  bool may_be_unaligned()                               { return _may_be_unaligned; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2100
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
LEAF(UnsafePutRaw, UnsafeRawOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
  Value _value;                                  // Value to be stored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
  UnsafePutRaw(BasicType basic_type, Value addr, Value value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
  : UnsafeRawOp(basic_type, addr, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
    assert(value != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
  UnsafePutRaw(BasicType basic_type, Value base, Value index, int log2_scale, Value value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
  : UnsafeRawOp(basic_type, base, index, log2_scale, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
    assert(value != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
  Value value()                                  { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
  virtual void input_values_do(void f(Value*))   { UnsafeRawOp::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
                                                   f(&_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
BASE(UnsafeObjectOp, UnsafeOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
  Value _object;                                 // Object to be fetched from or mutated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
  Value _offset;                                 // Offset within object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
  bool  _is_volatile;                            // true if volatile - dl/JSR166
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
  UnsafeObjectOp(BasicType basic_type, Value object, Value offset, bool is_put, bool is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
    : UnsafeOp(basic_type, is_put), _object(object), _offset(offset), _is_volatile(is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
  Value object()                                 { return _object; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
  Value offset()                                 { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
  bool  is_volatile()                            { return _is_volatile; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
  virtual void input_values_do(void f(Value*))   { UnsafeOp::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
                                                   f(&_object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
                                                   f(&_offset); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
LEAF(UnsafeGetObject, UnsafeObjectOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
  UnsafeGetObject(BasicType basic_type, Value object, Value offset, bool is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
  : UnsafeObjectOp(basic_type, object, offset, false, is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2161
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
LEAF(UnsafePutObject, UnsafeObjectOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
  Value _value;                                  // Value to be stored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
  UnsafePutObject(BasicType basic_type, Value object, Value offset, Value value, bool is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
  : UnsafeObjectOp(basic_type, object, offset, true, is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
    , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
  Value value()                                  { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
  virtual void input_values_do(void f(Value*))   { UnsafeObjectOp::input_values_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
                                                   f(&_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
BASE(UnsafePrefetch, UnsafeObjectOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
  UnsafePrefetch(Value object, Value offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
  : UnsafeObjectOp(T_VOID, object, offset, false, false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
LEAF(UnsafePrefetchRead, UnsafePrefetch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
  UnsafePrefetchRead(Value object, Value offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
  : UnsafePrefetch(object, offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
LEAF(UnsafePrefetchWrite, UnsafePrefetch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
  UnsafePrefetchWrite(Value object, Value offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
  : UnsafePrefetch(object, offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
LEAF(ProfileCall, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
  ciMethod* _method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
  int       _bci_of_invoke;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
  Value     _recv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
  ciKlass*  _known_holder;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
  ProfileCall(ciMethod* method, int bci, Value recv, ciKlass* known_holder)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
    : Instruction(voidType)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
    , _method(method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
    , _bci_of_invoke(bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
    , _recv(recv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
    , _known_holder(known_holder)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
    // The ProfileCall has side-effects and must occur precisely where located
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
  ciMethod* method()      { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
  int bci_of_invoke()     { return _bci_of_invoke; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
  Value recv()            { return _recv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
  ciKlass* known_holder() { return _known_holder; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
  virtual void input_values_do(void f(Value*))   { if (_recv != NULL) f(&_recv); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
// Simple node representing a counter update generally used for updating MDOs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
LEAF(ProfileCounter, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
  Value     _mdo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
  int       _offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
  int       _increment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
  ProfileCounter(Value mdo, int offset, int increment = 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
    : Instruction(voidType)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
    , _mdo(mdo)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
    , _offset(offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
    , _increment(increment)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
    // The ProfileCounter has side-effects and must occur precisely where located
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
  Value mdo()      { return _mdo; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
  int offset()     { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
  int increment()  { return _increment; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
  virtual void input_values_do(void f(Value*))   { f(&_mdo); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
class BlockPair: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
  BlockBegin* _from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
  BlockBegin* _to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
  BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
  BlockBegin* from() const { return _from; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
  BlockBegin* to() const   { return _to;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
  bool is_same(BlockBegin* from, BlockBegin* to) const { return  _from == from && _to == to; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
  bool is_same(BlockPair* p) const { return  _from == p->from() && _to == p->to(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
  void set_to(BlockBegin* b)   { _to = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
  void set_from(BlockBegin* b) { _from = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
define_array(BlockPairArray, BlockPair*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
define_stack(BlockPairList, BlockPairArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
inline int         BlockBegin::number_of_sux() const            { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
inline BlockBegin* BlockBegin::sux_at(int i) const              { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch");          return _successors.at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
inline void        BlockBegin::add_successor(BlockBegin* sux)   { assert(_end == NULL, "Would create mismatch with successors of BlockEnd");         _successors.append(sux); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
#undef ASSERT_VALUES