hotspot/src/share/vm/c1/c1_Instruction.hpp
author zmajo
Thu, 09 Mar 2017 14:27:21 +0100
changeset 44315 1e2f842b0c96
parent 39263 d139a133ba27
child 44738 11431bbc9549
permissions -rw-r--r--
8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL Summary: Check values returned by ciMethodData::bci_to_data() where necessary. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
     2
 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    25
#ifndef SHARE_VM_C1_C1_INSTRUCTION_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    26
#define SHARE_VM_C1_C1_INSTRUCTION_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    28
#include "c1/c1_Compilation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    29
#include "c1/c1_LIR.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    30
#include "c1/c1_ValueType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    31
#include "ci/ciField.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Predefined classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class ciField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class ValueStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class InstructionPrinter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class IRScope;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class LIR_OprDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
typedef LIR_OprDesc* LIR_Opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// Instruction class hierarchy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
// All leaf classes in the class hierarchy are concrete classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// (i.e., are instantiated). All other classes are abstract and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// serve factoring.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class Instruction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class   Phi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class   Local;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class   Constant;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class   AccessField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class     LoadField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class     StoreField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
class   AccessArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class     ArrayLength;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class     AccessIndexed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class       LoadIndexed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
class       StoreIndexed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
class   NegateOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class   Op2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class     ArithmeticOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class     ShiftOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
class     LogicOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class     CompareOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class     IfOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class   Convert;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class   NullCheck;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
    69
class   TypeCast;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
class   OsrEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class   ExceptionObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class   StateSplit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class     Invoke;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
class     NewInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
class     NewArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
class       NewTypeArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
class       NewObjectArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
class       NewMultiArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
class     TypeCheck;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
class       CheckCast;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
class       InstanceOf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class     AccessMonitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
class       MonitorEnter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
class       MonitorExit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
class     Intrinsic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
class     BlockBegin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
class     BlockEnd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
class       Goto;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
class       If;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
class       IfInstanceOf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
class       Switch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
class         TableSwitch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
class         LookupSwitch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
class       Return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
class       Throw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
class       Base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
class   RoundFP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
class   UnsafeOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
class     UnsafeRawOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
class       UnsafeGetRaw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
class       UnsafePutRaw;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
class     UnsafeObjectOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
class       UnsafeGetObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
class       UnsafePutObject;
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
   105
class         UnsafeGetAndSetObject;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
class   ProfileCall;
20709
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
   107
class   ProfileReturnType;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
   108
class   ProfileInvoke;
8065
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
   109
class   RuntimeCall;
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
   110
class   MemBar;
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   111
class   RangeCheckPredicate;
17011
def8879c5b81 8011648: C1: optimized build is broken after 7153771
roland
parents: 16611
diff changeset
   112
#ifdef ASSERT
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   113
class   Assert;
17011
def8879c5b81 8011648: C1: optimized build is broken after 7153771
roland
parents: 16611
diff changeset
   114
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
// A Value is a reference to the instruction creating the value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
typedef Instruction* Value;
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   118
typedef GrowableArray<Value> Values;
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   119
typedef GrowableArray<ValueStack*> ValueStackStack;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// BlockClosure is the base class for block traversal/iteration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
class BlockClosure: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  virtual void block_do(BlockBegin* block)       = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   129
// A simple closure class for visiting the values of an Instruction
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   130
class ValueVisitor: public StackObj {
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   131
 public:
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   132
  virtual void visit(Value* v) = 0;
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   133
};
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   134
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   135
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
// Some array and list classes
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   137
typedef GrowableArray<BlockBegin*> BlockBeginArray;
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   138
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   139
class BlockList: public GrowableArray<BlockBegin*> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
 public:
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   141
  BlockList(): GrowableArray<BlockBegin*>() {}
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   142
  BlockList(const int size): GrowableArray<BlockBegin*>(size) {}
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
   143
  BlockList(const int size, BlockBegin* init): GrowableArray<BlockBegin*>(size, size, init) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  void iterate_forward(BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  void iterate_backward(BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  void blocks_do(void f(BlockBegin*));
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   148
  void values_do(ValueVisitor* f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// InstructionVisitors provide type-based dispatch for instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// For each concrete Instruction class X, a virtual function do_X is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// provided. Functionality that needs to be implemented for all classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// (e.g., printing, code generation) is factored out into a specialised
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// visitor instead of added to the Instruction classes itself.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
class InstructionVisitor: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  virtual void do_Phi            (Phi*             x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  virtual void do_Local          (Local*           x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  virtual void do_Constant       (Constant*        x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  virtual void do_LoadField      (LoadField*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  virtual void do_StoreField     (StoreField*      x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  virtual void do_ArrayLength    (ArrayLength*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  virtual void do_LoadIndexed    (LoadIndexed*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  virtual void do_StoreIndexed   (StoreIndexed*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  virtual void do_NegateOp       (NegateOp*        x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  virtual void do_ArithmeticOp   (ArithmeticOp*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  virtual void do_ShiftOp        (ShiftOp*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  virtual void do_LogicOp        (LogicOp*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  virtual void do_CompareOp      (CompareOp*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual void do_IfOp           (IfOp*            x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual void do_Convert        (Convert*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  virtual void do_NullCheck      (NullCheck*       x) = 0;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
   177
  virtual void do_TypeCast       (TypeCast*        x) = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  virtual void do_Invoke         (Invoke*          x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  virtual void do_NewInstance    (NewInstance*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  virtual void do_NewTypeArray   (NewTypeArray*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  virtual void do_NewObjectArray (NewObjectArray*  x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  virtual void do_NewMultiArray  (NewMultiArray*   x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  virtual void do_CheckCast      (CheckCast*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  virtual void do_InstanceOf     (InstanceOf*      x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  virtual void do_MonitorExit    (MonitorExit*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  virtual void do_Intrinsic      (Intrinsic*       x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  virtual void do_BlockBegin     (BlockBegin*      x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  virtual void do_Goto           (Goto*            x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  virtual void do_If             (If*              x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  virtual void do_IfInstanceOf   (IfInstanceOf*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  virtual void do_TableSwitch    (TableSwitch*     x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  virtual void do_Return         (Return*          x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  virtual void do_Throw          (Throw*           x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  virtual void do_Base           (Base*            x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  virtual void do_OsrEntry       (OsrEntry*        x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  virtual void do_ExceptionObject(ExceptionObject* x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  virtual void do_RoundFP        (RoundFP*         x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  virtual void do_UnsafePutRaw   (UnsafePutRaw*    x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  virtual void do_UnsafeGetObject(UnsafeGetObject* x) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  virtual void do_UnsafePutObject(UnsafePutObject* x) = 0;
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
   204
  virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  virtual void do_ProfileCall    (ProfileCall*     x) = 0;
20709
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
   206
  virtual void do_ProfileReturnType (ProfileReturnType*  x) = 0;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
   207
  virtual void do_ProfileInvoke  (ProfileInvoke*   x) = 0;
8065
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
   208
  virtual void do_RuntimeCall    (RuntimeCall*     x) = 0;
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
   209
  virtual void do_MemBar         (MemBar*          x) = 0;
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   210
  virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   211
#ifdef ASSERT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   212
  virtual void do_Assert         (Assert*          x) = 0;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   213
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
// Hashing support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// Note: This hash functions affect the performance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
//       of ValueMap - make changes carefully!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
#define HASH1(x1            )                    ((intx)(x1))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
#define HASH2(x1, x2        )                    ((HASH1(x1        ) << 7) ^ HASH1(x2))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
#define HASH3(x1, x2, x3    )                    ((HASH2(x1, x2    ) << 7) ^ HASH1(x3))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
#define HASH4(x1, x2, x3, x4)                    ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// The following macros are used to implement instruction-specific hashing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
// By default, each instruction implements hash() and is_equal(Value), used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
// for value numbering/common subexpression elimination. The default imple-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// mentation disables value numbering. Each instruction which can be value-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
// numbered, should define corresponding hash() and is_equal(Value) functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// via the macros below. The f arguments specify all the values/op codes, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
// that need to be identical for two instructions to be identical.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
// Note: The default implementation of hash() returns 0 in order to indicate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
//       that the instruction should not be considered for value numbering.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
//       The currently used hash functions do not guarantee that never a 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
//       is produced. While this is still correct, it may be a performance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
//       bug (no value numbering for that node). However, this situation is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
//       so unlikely, that we are not going to handle it specially.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
#define HASHING1(class_name, enabled, f1)             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  virtual intx hash() const {                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    return (enabled) ? HASH2(name(), f1) : 0;         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  virtual bool is_equal(Value v) const {              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    if (!(enabled)  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    class_name* _v = v->as_##class_name();            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    if (_v == NULL  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    if (f1 != _v->f1) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    return true;                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
#define HASHING2(class_name, enabled, f1, f2)         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  virtual intx hash() const {                         \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    return (enabled) ? HASH3(name(), f1, f2) : 0;     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  virtual bool is_equal(Value v) const {              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    if (!(enabled)  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    class_name* _v = v->as_##class_name();            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    if (_v == NULL  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    if (f1 != _v->f1) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    if (f2 != _v->f2) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    return true;                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
#define HASHING3(class_name, enabled, f1, f2, f3)     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  virtual intx hash() const {                          \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  virtual bool is_equal(Value v) const {              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    if (!(enabled)  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    class_name* _v = v->as_##class_name();            \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    if (_v == NULL  ) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    if (f1 != _v->f1) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    if (f2 != _v->f2) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    if (f3 != _v->f3) return false;                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    return true;                                      \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  }                                                   \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
// The mother of all instructions...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
class Instruction: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  int          _id;                              // the unique instruction id
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   290
#ifndef PRODUCT
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   291
  int          _printable_bci;                   // the bci of the instruction for printing
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   292
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  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
   294
  int          _pin_state;                       // set of PinReason describing the reason for pinning
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  ValueType*   _type;                            // the instruction value type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  Instruction* _next;                            // the next instruction if any (NULL for BlockEnd instructions)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  Instruction* _subst;                           // the substitution instruction if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  LIR_Opr      _operand;                         // LIR specific information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  unsigned int _flags;                           // Flag bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   301
  ValueStack*  _state_before;                    // Copy of state with input operands still on stack (or NULL)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   302
  ValueStack*  _exception_state;                 // Copy of state for exception handling
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  XHandlers*   _exception_handlers;              // Flat list of exception handlers covering this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  friend class UseCountComputer;
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   306
  friend class BlockBegin;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   308
  void update_exception_state(ValueStack* state);
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   309
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   310
 protected:
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   311
  BlockBegin*  _block;                           // Block that contains this instruction
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   312
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  void set_type(ValueType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    assert(type != NULL, "type must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    _type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   318
  // Helper class to keep track of which arguments need a null check
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   319
  class ArgsNonNullState {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   320
  private:
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   321
    int _nonnull_state; // mask identifying which args are nonnull
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   322
  public:
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   323
    ArgsNonNullState()
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   324
      : _nonnull_state(AllBits) {}
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   325
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   326
    // Does argument number i needs a null check?
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   327
    bool arg_needs_null_check(int i) const {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   328
      // No data is kept for arguments starting at position 33 so
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   329
      // conservatively assume that they need a null check.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   330
      if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   331
        return is_set_nth_bit(_nonnull_state, i);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   332
      }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   333
      return true;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   334
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   335
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   336
    // Set whether argument number i needs a null check or not
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   337
    void set_arg_needs_null_check(int i, bool check) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   338
      if (i >= 0 && i < (int)sizeof(_nonnull_state) * BitsPerByte) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   339
        if (check) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   340
          _nonnull_state |= nth_bit(i);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   341
        } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   342
          _nonnull_state &= ~(nth_bit(i));
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   343
        }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   344
      }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   345
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   346
  };
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   347
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
 public:
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 17011
diff changeset
   349
  void* operator new(size_t size) throw() {
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   350
    Compilation* c = Compilation::current();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   351
    void* res = c->arena()->Amalloc(size);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   352
    ((Instruction*)res)->_id = c->get_next_id();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   353
    return res;
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   354
  }
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   355
8107
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8065
diff changeset
   356
  static const int no_bci = -99;
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8065
diff changeset
   357
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  enum InstructionFlag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    NeedsNullCheckFlag = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    CanTrapFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    DirectCompareFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    IsEliminatedFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    IsSafepointFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    IsStaticFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    IsStrictfpFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    NeedsStoreCheckFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    NeedsWriteBarrierFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    PreservesStateFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    TargetIsFinalFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    TargetIsLoadedFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    TargetIsStrictfpFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    UnorderedIsTrueFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    NeedsPatchingFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    ThrowIncompatibleClassChangeErrorFlag,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    ProfileMDOFlag,
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   376
    IsLinkedInBlockFlag,
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   377
    NeedsRangeCheckFlag,
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   378
    InWorkListFlag,
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   379
    DeoptimizeOnException,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    InstructionLastFlag
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  bool check_flag(InstructionFlag id) const      { return (_flags & (1 << id)) != 0;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  void set_flag(InstructionFlag id, bool f)      { _flags = f ? (_flags | (1 << id)) : (_flags & ~(1 << id)); };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  // 'globally' used condition values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  enum Condition {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   389
    eql, neq, lss, leq, gtr, geq, aeq, beq
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // Instructions may be pinned for many reasons and under certain conditions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // with enough knowledge it's possible to safely unpin them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  enum PinReason {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
      PinUnknown           = 1 << 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    , PinExplicitNullCheck = 1 << 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    , PinStackForStateSplit= 1 << 12
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    , PinStateSplitConstructor= 1 << 13
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    , PinGlobalValueNumbering= 1 << 14
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  static Condition mirror(Condition cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  static Condition negate(Condition cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  // initialization
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   406
  static int number_of_instructions() {
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   407
    return Compilation::current()->number_of_instructions();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   408
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // creation
6750
b84813b41757 6988303: 6986046 breaks build with recent gcc
roland
parents: 6745
diff changeset
   411
  Instruction(ValueType* type, ValueStack* state_before = NULL, bool type_is_constant = false)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   412
  : _use_count(0)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   413
#ifndef PRODUCT
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   414
  , _printable_bci(-99)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   415
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  , _pin_state(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  , _type(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  , _next(NULL)
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   419
  , _block(NULL)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  , _subst(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  , _flags(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  , _operand(LIR_OprFact::illegalOpr)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   423
  , _state_before(state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  , _exception_handlers(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   426
    check_state(state_before);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist");
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   428
    update_exception_state(_state_before);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  int id() const                                 { return _id; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   433
#ifndef PRODUCT
12947
ba8ba6c2dd83 7172843: C1: fix "assert(has_printable_bci()) failed: _printable_bci should have been set"
twisti
parents: 11886
diff changeset
   434
  bool has_printable_bci() const                 { return _printable_bci != -99; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   435
  int printable_bci() const                      { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
12947
ba8ba6c2dd83 7172843: C1: fix "assert(has_printable_bci()) failed: _printable_bci should have been set"
twisti
parents: 11886
diff changeset
   436
  void set_printable_bci(int bci)                { _printable_bci = bci; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   437
#endif
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   438
  int dominator_depth();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  int use_count() const                          { return _use_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  int pin_state() const                          { return _pin_state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  bool is_pinned() const                         { return _pin_state != 0 || PinAllInstructions; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  ValueType* type() const                        { return _type; }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   443
  BlockBegin *block() const                      { return _block; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   444
  Instruction* prev();                           // use carefully, expensive operation
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  Instruction* next() const                      { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  bool has_subst() const                         { return _subst != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  Instruction* subst()                           { return _subst == NULL ? this : _subst->subst(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  LIR_Opr operand() const                        { return _operand; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  void set_needs_null_check(bool f)              { set_flag(NeedsNullCheckFlag, f); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  bool needs_null_check() const                  { return check_flag(NeedsNullCheckFlag); }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   452
  bool is_linked() const                         { return check_flag(IsLinkedInBlockFlag); }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   453
  bool can_be_linked()                           { return as_Local() == NULL && as_Phi() == NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  bool has_uses() const                          { return use_count() > 0; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   456
  ValueStack* state_before() const               { return _state_before; }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   457
  ValueStack* exception_state() const            { return _exception_state; }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   458
  virtual bool needs_exception_state() const     { return true; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  XHandlers* exception_handlers() const          { return _exception_handlers; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  void pin(PinReason reason)                     { _pin_state |= reason; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  void pin()                                     { _pin_state |= PinUnknown; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  // DANGEROUS: only used by EliminateStores
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  void unpin(PinReason reason)                   { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   466
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   467
  Instruction* set_next(Instruction* next) {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   468
    assert(next->has_printable_bci(), "_printable_bci should have been set");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   469
    assert(next != NULL, "must not be NULL");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   470
    assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   471
    assert(next->can_be_linked(), "shouldn't link these instructions into list");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   472
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   473
    BlockBegin *block = this->block();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   474
    next->_block = block;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   475
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   476
    next->set_flag(Instruction::IsLinkedInBlockFlag, true);
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   477
    _next = next;
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   478
    return next;
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   479
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  Instruction* set_next(Instruction* next, int bci) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   482
#ifndef PRODUCT
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   483
    next->set_printable_bci(bci);
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   484
#endif
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   485
    return set_next(next);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   488
  // when blocks are merged
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   489
  void fixup_block_pointers() {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   490
    Instruction *cur = next()->next(); // next()'s block is set in set_next
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   491
    while (cur && cur->_block != block()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   492
      cur->_block = block();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   493
      cur = cur->next();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   494
    }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   495
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   496
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   497
  Instruction *insert_after(Instruction *i) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   498
    Instruction* n = _next;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   499
    set_next(i);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   500
    i->set_next(n);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   501
    return _next;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   502
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   503
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   504
  Instruction *insert_after_same_bci(Instruction *i) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   505
#ifndef PRODUCT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   506
    i->set_printable_bci(printable_bci());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   507
#endif
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   508
    return insert_after(i);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   509
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   510
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  void set_subst(Instruction* subst)             {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    assert(subst == NULL ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
           type()->base() == subst->type()->base() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
           subst->type()->base() == illegalType, "type can't change");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    _subst = subst;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   518
  void set_exception_state(ValueStack* s)        { check_state(s); _exception_state = s; }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   519
  void set_state_before(ValueStack* s)           { check_state(s); _state_before = s; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  // machine-specifics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  void set_operand(LIR_Opr operand)              { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  void clear_operand()                           { _operand = LIR_OprFact::illegalOpr; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  virtual Instruction*      as_Instruction()     { return this; } // to satisfy HASHING1 macro
7100
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   527
  virtual Phi*              as_Phi()             { return NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  virtual Local*            as_Local()           { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  virtual Constant*         as_Constant()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  virtual AccessField*      as_AccessField()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  virtual LoadField*        as_LoadField()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  virtual StoreField*       as_StoreField()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  virtual AccessArray*      as_AccessArray()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  virtual ArrayLength*      as_ArrayLength()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  virtual AccessIndexed*    as_AccessIndexed()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  virtual LoadIndexed*      as_LoadIndexed()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  virtual StoreIndexed*     as_StoreIndexed()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  virtual NegateOp*         as_NegateOp()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  virtual Op2*              as_Op2()             { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  virtual ArithmeticOp*     as_ArithmeticOp()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  virtual ShiftOp*          as_ShiftOp()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  virtual LogicOp*          as_LogicOp()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  virtual CompareOp*        as_CompareOp()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  virtual IfOp*             as_IfOp()            { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  virtual Convert*          as_Convert()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  virtual NullCheck*        as_NullCheck()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  virtual OsrEntry*         as_OsrEntry()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  virtual StateSplit*       as_StateSplit()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  virtual Invoke*           as_Invoke()          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  virtual NewInstance*      as_NewInstance()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  virtual NewArray*         as_NewArray()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  virtual NewTypeArray*     as_NewTypeArray()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  virtual NewObjectArray*   as_NewObjectArray()  { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  virtual NewMultiArray*    as_NewMultiArray()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  virtual TypeCheck*        as_TypeCheck()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  virtual CheckCast*        as_CheckCast()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  virtual InstanceOf*       as_InstanceOf()      { return NULL; }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
   558
  virtual TypeCast*         as_TypeCast()        { return NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  virtual AccessMonitor*    as_AccessMonitor()   { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  virtual MonitorEnter*     as_MonitorEnter()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  virtual MonitorExit*      as_MonitorExit()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  virtual Intrinsic*        as_Intrinsic()       { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  virtual BlockBegin*       as_BlockBegin()      { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  virtual BlockEnd*         as_BlockEnd()        { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  virtual Goto*             as_Goto()            { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  virtual If*               as_If()              { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  virtual IfInstanceOf*     as_IfInstanceOf()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  virtual TableSwitch*      as_TableSwitch()     { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  virtual LookupSwitch*     as_LookupSwitch()    { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  virtual Return*           as_Return()          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  virtual Throw*            as_Throw()           { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  virtual Base*             as_Base()            { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  virtual RoundFP*          as_RoundFP()         { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  virtual ExceptionObject*  as_ExceptionObject() { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  virtual UnsafeOp*         as_UnsafeOp()        { return NULL; }
11192
ff37c2093a0d 7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents: 10509
diff changeset
   576
  virtual ProfileInvoke*    as_ProfileInvoke()   { return NULL; }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   577
  virtual RangeCheckPredicate* as_RangeCheckPredicate() { return NULL; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   578
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   579
#ifdef ASSERT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   580
  virtual Assert*           as_Assert()          { return NULL; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   581
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  virtual void visit(InstructionVisitor* v)      = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  virtual bool can_trap() const                  { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   587
  virtual void input_values_do(ValueVisitor* f)   = 0;
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   588
  virtual void state_values_do(ValueVisitor* f);
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   589
  virtual void other_values_do(ValueVisitor* f)   { /* usually no other - override on demand */ }
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   590
          void       values_do(ValueVisitor* f)   { input_values_do(f); state_values_do(f); other_values_do(f); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
   592
  virtual ciType* exact_type() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  virtual ciType* declared_type() const          { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  // hashing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  virtual const char* name() const               = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  HASHING1(Instruction, false, id())             // hashing disabled by default
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  // debugging
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   600
  static void check_state(ValueStack* state)     PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  void print()                                   PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  void print_line()                              PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  void print(InstructionPrinter& ip)             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
// The following macros are used to define base (i.e., non-leaf)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
// and leaf instruction classes. They define class-name related
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
// generic functionality in one place.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
#define BASE(class_name, super_class_name)       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  class class_name: public super_class_name {    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
   public:                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    virtual class_name* as_##class_name()        { return this; }              \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
#define LEAF(class_name, super_class_name)       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  BASE(class_name, super_class_name)             \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
   public:                                       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    virtual const char* name() const             { return #class_name; }       \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
    virtual void visit(InstructionVisitor* v)    { v->do_##class_name(this); } \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
// Debugging support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   626
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
#ifdef ASSERT
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   628
class AssertValues: public ValueVisitor {
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   629
  void visit(Value* x)             { assert((*x) != NULL, "value must exist"); }
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   630
};
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   631
  #define ASSERT_VALUES                          { AssertValues assert_value; values_do(&assert_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  #define ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
// A Phi is a phi function in the sense of SSA form. It stands for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
// the value of a local variable at the beginning of a join block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
// A Phi consists of n operands, one for every incoming branch.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
LEAF(Phi, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  int         _pf_flags; // the flags of the phi function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  int         _index;    // to value on operand stack (index < 0) or to local
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
  Phi(ValueType* type, BlockBegin* b, int index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  : Instruction(type->base())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  , _pf_flags(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   652
    _block = b;
12947
ba8ba6c2dd83 7172843: C1: fix "assert(has_printable_bci()) failed: _printable_bci should have been set"
twisti
parents: 11886
diff changeset
   653
    NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    if (type->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
      make_illegal();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  // flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  enum Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    no_flag         = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    visited         = 1 << 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    cannot_simplify = 1 << 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  bool  is_local() const          { return _index >= 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  bool  is_on_stack() const       { return !is_local(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  int   local_index() const       { assert(is_local(), ""); return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  int   stack_index() const       { assert(is_on_stack(), ""); return -(_index+1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  Value operand_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  int   operand_count() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  void   set(Flag f)              { _pf_flags |=  f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  void   clear(Flag f)            { _pf_flags &= ~f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  bool   is_set(Flag f) const     { return (_pf_flags & f) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  // Invalidates phis corresponding to merges of locals of two different types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  // (these should never be referenced, otherwise the bytecodes are illegal)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
  void   make_illegal() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    set(cannot_simplify);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    set_type(illegalType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  bool is_illegal() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    return type()->is_illegal();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   691
  virtual void input_values_do(ValueVisitor* f) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
// A local is a placeholder for an incoming argument to a function call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
LEAF(Local, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  int      _java_index;                          // the local index within the method to which the local belongs
33633
8a83967eb351 8141044: C1 should fold (this == null) to false
shade
parents: 28954
diff changeset
   700
  bool     _is_receiver;                         // if local variable holds the receiver: "this" for non-static methods
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
   701
  ciType*  _declared_type;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  // creation
33633
8a83967eb351 8141044: C1 should fold (this == null) to false
shade
parents: 28954
diff changeset
   704
  Local(ciType* declared, ValueType* type, int index, bool receiver)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    : Instruction(type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
    , _java_index(index)
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
   707
    , _declared_type(declared)
33633
8a83967eb351 8141044: C1 should fold (this == null) to false
shade
parents: 28954
diff changeset
   708
    , _is_receiver(receiver)
12947
ba8ba6c2dd83 7172843: C1: fix "assert(has_printable_bci()) failed: _printable_bci should have been set"
twisti
parents: 11886
diff changeset
   709
  {
ba8ba6c2dd83 7172843: C1: fix "assert(has_printable_bci()) failed: _printable_bci should have been set"
twisti
parents: 11886
diff changeset
   710
    NOT_PRODUCT(set_printable_bci(-1));
ba8ba6c2dd83 7172843: C1: fix "assert(has_printable_bci()) failed: _printable_bci should have been set"
twisti
parents: 11886
diff changeset
   711
  }
1
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
  int java_index() const                         { return _java_index; }
33633
8a83967eb351 8141044: C1 should fold (this == null) to false
shade
parents: 28954
diff changeset
   715
  bool is_receiver() const                       { return _is_receiver; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
   717
  virtual ciType* declared_type() const          { return _declared_type; }
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
   718
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   720
  virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
LEAF(Constant, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  Constant(ValueType* type):
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
   728
      Instruction(type, NULL, /*type_is_constant*/ true)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   729
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
    assert(type->is_constant(), "must be a constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   733
  Constant(ValueType* type, ValueStack* state_before):
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
   734
    Instruction(type, state_before, /*type_is_constant*/ true)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   735
  {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   736
    assert(state_before != NULL, "only used for constants which need patching");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
    assert(type->is_constant(), "must be a constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    // since it's patching it needs to be pinned
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   742
  // generic
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   743
  virtual bool can_trap() const                  { return state_before() != NULL; }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   744
  virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  virtual intx hash() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  virtual bool is_equal(Value v) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
   749
  virtual ciType* exact_type() const;
7100
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   750
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   751
  enum CompareResult { not_comparable = -1, cond_false, cond_true };
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   752
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   753
  virtual CompareResult compare(Instruction::Condition condition, Value right) const;
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   754
  BlockBegin* compare(Instruction::Condition cond, Value right,
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   755
                      BlockBegin* true_sux, BlockBegin* false_sux) const {
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   756
    switch (compare(cond, right)) {
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   757
    case not_comparable:
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   758
      return NULL;
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   759
    case cond_false:
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   760
      return false_sux;
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   761
    case cond_true:
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   762
      return true_sux;
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   763
    default:
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   764
      ShouldNotReachHere();
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   765
      return NULL;
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   766
    }
6bcf9255d470 6991577: add IfOp optimization to C1
roland
parents: 6751
diff changeset
   767
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
BASE(AccessField, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
  int         _offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  ciField*    _field;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  NullCheck*  _explicit_null_check;              // For explicit null check elimination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   780
  AccessField(Value obj, int offset, ciField* field, bool is_static,
8671
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   781
              ValueStack* state_before, bool needs_patching)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   782
  : Instruction(as_ValueType(field->type()->basic_type()), state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  , _obj(obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  , _offset(offset)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  , _field(field)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  , _explicit_null_check(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
    set_needs_null_check(!is_static);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    set_flag(IsStaticFlag, is_static);
8671
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   790
    set_flag(NeedsPatchingFlag, needs_patching);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    // pin of all instructions with memory access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  int offset() const                             { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  ciField* field() const                         { return _field; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  BasicType field_type() const                   { return _field->type()->basic_type(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  bool is_static() const                         { return check_flag(IsStaticFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  NullCheck* explicit_null_check() const         { return _explicit_null_check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  bool needs_patching() const                    { return check_flag(NeedsPatchingFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
8671
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   805
  // Unresolved getstatic and putstatic can cause initialization.
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   806
  // Technically it occurs at the Constant that materializes the base
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   807
  // of the static fields but it's simpler to model it here.
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   808
  bool is_init_point() const                     { return is_static() && (needs_patching() || !_field->holder()->is_initialized()); }
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   809
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  // manipulation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   811
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  // Under certain circumstances, if a previous NullCheck instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  // proved the target object non-null, we can eliminate the explicit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  // null check and do an implicit one, simply specifying the debug
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  // information from the NullCheck. This field should only be consulted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
  // if needs_null_check() is true.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
  void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
  virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   821
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
LEAF(LoadField, AccessField)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   828
  LoadField(Value obj, int offset, ciField* field, bool is_static,
8671
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   829
            ValueStack* state_before, bool needs_patching)
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   830
  : AccessField(obj, offset, field, is_static, state_before, needs_patching)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
  ciType* declared_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  // generic
8671
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   836
  HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if needs patching or if volatile
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
LEAF(StoreField, AccessField)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  Value _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   846
  StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
8671
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   847
             ValueStack* state_before, bool needs_patching)
13ffa40a2f0a 6965570: assert(!needs_patching && x->is_loaded(),"how do we know it's volatile if it's not loaded")
never
parents: 8107
diff changeset
   848
  : AccessField(obj, offset, field, is_static, state_before, needs_patching)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
    set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  Value value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   861
  virtual void input_values_do(ValueVisitor* f)   { AccessField::input_values_do(f); f->visit(&_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
BASE(AccessArray, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
  Value       _array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   871
  AccessArray(ValueType* type, Value array, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   872
  : Instruction(type, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
  , _array(array)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   874
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    set_needs_null_check(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
    pin(); // instruction with side effect (null exception or range check throwing)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  Value array() const                            { return _array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  virtual bool can_trap() const                  { return needs_null_check(); }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   884
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_array); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
LEAF(ArrayLength, AccessArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  NullCheck*  _explicit_null_check;              // For explicit null check elimination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   894
  ArrayLength(Value array, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   895
  : AccessArray(intType, array, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
  , _explicit_null_check(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  NullCheck* explicit_null_check() const         { return _explicit_null_check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  // See LoadField::set_explicit_null_check for documentation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  HASHING1(ArrayLength, true, array()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
BASE(AccessIndexed, AccessArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  Value     _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  Value     _length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  BasicType _elt_type;
39263
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   915
  bool      _mismatched;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  // creation
39263
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   919
  AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
   920
  : AccessArray(as_ValueType(elt_type), array, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  , _length(length)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  , _elt_type(elt_type)
39263
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   924
  , _mismatched(mismatched)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   926
    set_flag(Instruction::NeedsRangeCheckFlag, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  Value index() const                            { return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
  Value length() const                           { return _length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  BasicType elt_type() const                     { return _elt_type; }
39263
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   934
  bool mismatched() const                        { return _mismatched; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
   936
  void clear_length()                            { _length = NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  // perform elimination of range checks involving constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
  bool compute_needs_range_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   941
  virtual void input_values_do(ValueVisitor* f)   { AccessArray::input_values_do(f); f->visit(&_index); if (_length != NULL) f->visit(&_length); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
LEAF(LoadIndexed, AccessIndexed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
  NullCheck*  _explicit_null_check;              // For explicit null check elimination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  // creation
39263
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   951
  LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   952
  : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
  , _explicit_null_check(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
  NullCheck* explicit_null_check() const         { return _explicit_null_check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
  // See LoadField::set_explicit_null_check for documentation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
  void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
  ciType* declared_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
  HASHING2(LoadIndexed, true, array()->subst(), index()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
LEAF(StoreIndexed, AccessIndexed)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
  Value       _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
   974
  ciMethod* _profiled_method;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
   975
  int       _profiled_bci;
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 33633
diff changeset
   976
  bool      _check_boolean;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 33633
diff changeset
   977
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
  // creation
39263
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   980
  StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   981
               bool check_boolean, bool mismatched = false)
d139a133ba27 8158228: C1 incorrectly folds mismatched loads from stable arrays
thartmann
parents: 38177
diff changeset
   982
  : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 33633
diff changeset
   983
  , _value(value), _profiled_method(NULL), _profiled_bci(0), _check_boolean(check_boolean)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
    set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
    set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
  Value value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
  bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  bool needs_store_check() const                 { return check_flag(NeedsStoreCheckFlag); }
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 33633
diff changeset
   995
  bool check_boolean() const                     { return _check_boolean; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   996
  // Helpers for MethodData* profiling
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
   997
  void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
   998
  void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
   999
  void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1000
  bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1001
  ciMethod* profiled_method() const                  { return _profiled_method;     }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1002
  int       profiled_bci() const                     { return _profiled_bci;        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1004
  virtual void input_values_do(ValueVisitor* f)   { AccessIndexed::input_values_do(f); f->visit(&_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
LEAF(NegateOp, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  Value _x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
  NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  Value x() const                                { return _x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1022
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
BASE(Op2, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
  Bytecodes::Code _op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
  Value           _x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  Value           _y;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1034
  Op2(ValueType* type, Bytecodes::Code op, Value x, Value y, ValueStack* state_before = NULL)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1035
  : Instruction(type, state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1036
  , _op(op)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1037
  , _x(x)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1038
  , _y(y)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1039
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  Bytecodes::Code op() const                     { return _op; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  Value x() const                                { return _x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  Value y() const                                { return _y; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  // manipulators
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  void swap_operands() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
    assert(is_commutative(), "operation must be commutative");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
    Value t = _x; _x = _y; _y = t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
  virtual bool is_commutative() const            { return false; }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1056
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); f->visit(&_y); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
LEAF(ArithmeticOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1063
  ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1064
  : Op2(x->type()->meet(y->type()), op, x, y, state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1065
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
    set_flag(IsStrictfpFlag, is_strictfp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
    if (can_trap()) pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
  bool        is_strictfp() const                { return check_flag(IsStrictfpFlag); }
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 bool is_commutative() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
  virtual bool can_trap() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
LEAF(ShiftOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
  ShiftOp(Bytecodes::Code op, Value x, Value s) : Op2(x->type()->base(), op, x, s) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
LEAF(LogicOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
  LogicOp(Bytecodes::Code op, Value x, Value y) : Op2(x->type()->meet(y->type()), op, x, y) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  virtual bool is_commutative() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
LEAF(CompareOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
  CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1105
  : Op2(intType, op, x, y, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  HASHING3(Op2, true, op(), x()->subst(), y()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1111
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
LEAF(IfOp, Op2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  Value _tval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1116
  Value _fval;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1117
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1119
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
  IfOp(Value x, Condition cond, Value y, Value tval, Value fval)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
  : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  , _tval(tval)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
  , _fval(fval)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
    assert(tval->type()->tag() == fval->type()->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
  virtual bool is_commutative() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
  Bytecodes::Code op() const                     { ShouldNotCallThis(); return Bytecodes::_illegal; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
  Condition cond() const                         { return (Condition)Op2::op(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
  Value tval() const                             { return _tval; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
  Value fval() const                             { return _fval; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1137
  virtual void input_values_do(ValueVisitor* f)   { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
LEAF(Convert, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
  Bytecodes::Code _op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
  Value           _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
  Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
  Bytecodes::Code op() const                     { return _op; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
  Value value() const                            { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1157
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
  HASHING2(Convert, true, op(), value()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
LEAF(NullCheck, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1168
  NullCheck(Value obj, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1169
  : Instruction(obj->type()->base(), state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1170
  , _obj(obj)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1171
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
    set_can_trap(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
    assert(_obj->type()->is_object(), "null check must be applied to objects only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
    pin(Instruction::PinExplicitNullCheck);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
  void set_can_trap(bool can_trap)               { set_flag(CanTrapFlag, can_trap); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
  virtual bool can_trap() const                  { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1186
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
  HASHING1(NullCheck, true, obj()->subst())
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1191
// This node is supposed to cast the type of another node to a more precise
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1192
// declared type.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1193
LEAF(TypeCast, Instruction)
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1194
 private:
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1195
  ciType* _declared_type;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1196
  Value   _obj;
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1197
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1198
 public:
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1199
  // The type of this node is the same type as the object type (and it might be constant).
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1200
  TypeCast(ciType* type, Value obj, ValueStack* state_before)
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1201
  : Instruction(obj->type(), state_before, obj->type()->is_constant()),
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1202
    _declared_type(type),
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1203
    _obj(obj) {}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1204
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1205
  // accessors
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1206
  ciType* declared_type() const                  { return _declared_type; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1207
  Value   obj() const                            { return _obj; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1208
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1209
  // generic
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1210
  virtual void input_values_do(ValueVisitor* f)  { f->visit(&_obj); }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1211
};
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1212
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1213
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1214
BASE(StateSplit, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
  ValueStack* _state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
  static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1220
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1223
  StateSplit(ValueType* type, ValueStack* state_before = NULL)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1224
  : Instruction(type, state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1225
  , _state(NULL)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1226
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
    pin(PinStateSplitConstructor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
  ValueStack* state() const                      { return _state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
  IRScope* scope() const;                        // the state's scope
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
  // manipulation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1235
  void set_state(ValueStack* state)              { assert(_state == NULL, "overwriting existing state"); check_state(state); _state = state; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1238
  virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1239
  virtual void state_values_do(ValueVisitor* f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
LEAF(Invoke, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
 private:
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1245
  Bytecodes::Code _code;
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1246
  Value           _recv;
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1247
  Values*         _args;
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1248
  BasicTypeList*  _signature;
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1249
  int             _vtable_index;
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1250
  ciMethod*       _target;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1251
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1252
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1253
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1254
  Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1255
         int vtable_index, ciMethod* target, ValueStack* state_before);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1256
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1257
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1258
  Bytecodes::Code code() const                   { return _code; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1259
  Value receiver() const                         { return _recv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1260
  bool has_receiver() const                      { return receiver() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1261
  int number_of_arguments() const                { return _args->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1262
  Value argument_at(int i) const                 { return _args->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1263
  int vtable_index() const                       { return _vtable_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1264
  BasicTypeList* signature() const               { return _signature; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
  ciMethod* target() const                       { return _target; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1267
  ciType* declared_type() const;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1268
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  // Returns false if target is not loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
  bool target_is_final() const                   { return check_flag(TargetIsFinalFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
  bool target_is_loaded() const                  { return check_flag(TargetIsLoadedFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  // Returns false if target is not loaded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
  bool target_is_strictfp() const                { return check_flag(TargetIsStrictfpFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1275
  // JSR 292 support
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1276
  bool is_invokedynamic() const                  { return code() == Bytecodes::_invokedynamic; }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  1277
  bool is_method_handle_intrinsic() const        { return target()->is_method_handle_intrinsic(); }
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1
diff changeset
  1278
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1279
  virtual bool needs_exception_state() const     { return false; }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1280
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
  virtual bool can_trap() const                  { return true; }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1283
  virtual void input_values_do(ValueVisitor* f) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
    StateSplit::input_values_do(f);
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1285
    if (has_receiver()) f->visit(&_recv);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1286
    for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
  }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1288
  virtual void state_values_do(ValueVisitor *f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
LEAF(NewInstance, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
  ciInstanceKlass* _klass;
24933
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 20709
diff changeset
  1295
  bool _is_unresolved;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
  // creation
24933
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 20709
diff changeset
  1299
  NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1300
  : StateSplit(instanceType, state_before)
24933
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 20709
diff changeset
  1301
  , _klass(klass), _is_unresolved(is_unresolved)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1302
  {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
  ciInstanceKlass* klass() const                 { return _klass; }
24933
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 20709
diff changeset
  1306
  bool is_unresolved() const                     { return _is_unresolved; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1308
  virtual bool needs_exception_state() const     { return false; }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1309
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  ciType* exact_type() const;
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1313
  ciType* declared_type() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
BASE(NewArray, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  Value       _length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1323
  NewArray(Value length, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1324
  : StateSplit(objectType, state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1325
  , _length(length)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1326
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
    // Do not ASSERT_VALUES since length is NULL for NewMultiArray
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
  Value length() const                           { return _length; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1333
  virtual bool needs_exception_state() const     { return false; }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1334
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  1335
  ciType* exact_type() const                     { return NULL; }
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1336
  ciType* declared_type() const;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1337
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
  virtual bool can_trap() const                  { return true; }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1340
  virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_length); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
LEAF(NewTypeArray, NewArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
  BasicType _elt_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1350
  NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1351
  : NewArray(length, state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1352
  , _elt_type(elt_type)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1353
  {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  BasicType elt_type() const                     { return _elt_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
LEAF(NewObjectArray, NewArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
  ciKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
  NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
  ciType* exact_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
LEAF(NewMultiArray, NewArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
  ciKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  Values*  _dims;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
  Values* dims() const                           { return _dims; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
  int rank() const                               { return dims()->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1392
  virtual void input_values_do(ValueVisitor* f) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
    // NOTE: we do not call NewArray::input_values_do since "length"
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
    // is meaningless for a multi-dimensional array; passing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
    // zeroth element down to NewArray as its length is a bad idea
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
    // since there will be a copy in the "dims" array which doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
    // get updated, and the value must not be traversed twice. Was bug
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
    // - kbr 4/10/2001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
    StateSplit::input_values_do(f);
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1400
    for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
BASE(TypeCheck, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
  ciKlass*    _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1410
  ciMethod* _profiled_method;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1411
  int       _profiled_bci;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1412
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
  // creation
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1415
  TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1416
  : StateSplit(type, state_before), _klass(klass), _obj(obj),
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1417
    _profiled_method(NULL), _profiled_bci(0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
    set_direct_compare(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
  bool is_loaded() const                         { return klass() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
  bool direct_compare() const                    { return check_flag(DirectCompareFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
  void set_direct_compare(bool flag)             { set_flag(DirectCompareFlag, flag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
  virtual bool can_trap() const                  { return true; }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1433
  virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1434
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1435
  // Helpers for MethodData* profiling
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1436
  void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1437
  void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1438
  void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1439
  bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1440
  ciMethod* profiled_method() const                  { return _profiled_method;     }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1441
  int       profiled_bci() const                     { return _profiled_bci;        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
LEAF(CheckCast, TypeCheck)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
  CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6453
diff changeset
  1449
  : TypeCheck(klass, obj, objectType, state_before) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
  void set_incompatible_class_change_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
    set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
  bool is_incompatible_class_change_check() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
    return check_flag(ThrowIncompatibleClassChangeErrorFlag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
  ciType* declared_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
LEAF(InstanceOf, TypeCheck)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
  InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {}
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1466
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1467
  virtual bool needs_exception_state() const     { return false; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
BASE(AccessMonitor, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
  Value       _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
  int         _monitor_no;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1478
  AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = NULL)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1479
  : StateSplit(illegalType, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
  , _obj(obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
  , _monitor_no(monitor_no)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
    set_needs_null_check(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
  int monitor_no() const                         { return _monitor_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1492
  virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
LEAF(MonitorEnter, AccessMonitor)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1499
  MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1500
  : AccessMonitor(obj, monitor_no, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
  virtual bool can_trap() const                  { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
LEAF(MonitorExit, AccessMonitor)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
  // creation
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1513
  MonitorExit(Value obj, int monitor_no)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1514
  : AccessMonitor(obj, monitor_no, NULL)
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1515
  {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1516
    ASSERT_VALUES
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1517
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
LEAF(Intrinsic, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
  vmIntrinsics::ID _id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
  Values*          _args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
  Value            _recv;
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  1526
  ArgsNonNullState _nonnull_state;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1528
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
  // preserves_state can be set to true for Intrinsics
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1530
  // which are guaranteed to preserve register state across any slow
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
  // cases; setting it to true does not mean that the Intrinsic can
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
  // not trap, only that if we continue execution in the same basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
  // block after the Intrinsic, all of the registers are intact. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
  // allows load elimination and common expression elimination to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
  // performed across the Intrinsic.  The default value is false.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
  Intrinsic(ValueType* type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
            vmIntrinsics::ID id,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
            Values* args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
            bool has_receiver,
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1540
            ValueStack* state_before,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
            bool preserves_state,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
            bool cantrap = true)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1543
  : StateSplit(type, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
  , _id(id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
  , _args(args)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
  , _recv(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
    assert(args != NULL, "args must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
    set_flag(PreservesStateFlag, preserves_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1551
    set_flag(CanTrapFlag,        cantrap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1552
    if (has_receiver) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
      _recv = argument_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
    set_needs_null_check(has_receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
    // some intrinsics can't trap, so don't force them to be pinned
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
    if (!can_trap()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
      unpin(PinStateSplitConstructor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1561
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
  vmIntrinsics::ID id() const                    { return _id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
  int number_of_arguments() const                { return _args->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
  Value argument_at(int i) const                 { return _args->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
  bool has_receiver() const                      { return (_recv != NULL); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
  Value receiver() const                         { assert(has_receiver(), "must have receiver"); return _recv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  bool preserves_state() const                   { return check_flag(PreservesStateFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  1572
  bool arg_needs_null_check(int i) const {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  1573
    return _nonnull_state.arg_needs_null_check(i);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1574
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1575
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1576
  void set_arg_needs_null_check(int i, bool check) {
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  1577
    _nonnull_state.set_arg_needs_null_check(i, check);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1578
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8671
diff changeset
  1579
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  virtual bool can_trap() const                  { return check_flag(CanTrapFlag); }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1582
  virtual void input_values_do(ValueVisitor* f) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
    StateSplit::input_values_do(f);
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1584
    for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
class LIR_List;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
LEAF(BlockBegin, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1592
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1593
  int        _block_id;                          // the unique block id
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1594
  int        _bci;                               // start-bci of block
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
  int        _depth_first_number;                // number of this block in a depth-first ordering
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1596
  int        _linear_scan_number;                // number of this block in linear-scan ordering
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1597
  int        _dominator_depth;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
  int        _loop_depth;                        // the loop nesting level of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
  int        _loop_index;                        // number of the innermost loop of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
  int        _flags;                             // the flags associated with this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
  // fields used by BlockListBuilder
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1603
  int            _total_preds;                   // number of predecessors found by BlockListBuilder
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1604
  ResourceBitMap _stores_to_locals;              // bit is set when a local variable is stored in the block
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
  // SSA specific fields: (factor out later)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
  BlockList   _successors;                       // the successors of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
  BlockList   _predecessors;                     // the predecessors of this block
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1609
  BlockList   _dominates;                        // list of blocks that are dominated by this block
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1610
  BlockBegin* _dominator;                        // the dominator of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
  // SSA specific ends
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
  BlockEnd*  _end;                               // the last instruction of this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
  BlockList  _exception_handlers;                // the exception handlers potentially invoked by this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
  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
  1615
  int        _exception_handler_pco;             // if this block is the start of an exception handler,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
                                                 // this records the PC offset in the assembly code of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
                                                 // first instruction in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
  Label      _label;                             // the label associated with this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
  LIR_List*  _lir;                               // the low level intermediate representation for this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1621
  ResourceBitMap _live_in;                       // set of live LIR_Opr registers at entry to this block
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1622
  ResourceBitMap _live_out;                      // set of live LIR_Opr registers at exit from this block
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1623
  ResourceBitMap _live_gen;                      // set of registers used before any redefinition in this block
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1624
  ResourceBitMap _live_kill;                     // set of registers defined in this block
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1625
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1626
  ResourceBitMap _fpu_register_usage;
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1627
  intArray*      _fpu_stack_state;               // For x86 FPU code generation with UseLinearScan
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1628
  int            _first_lir_instruction_id;      // ID of first LIR instruction in this block
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1629
  int            _last_lir_instruction_id;       // ID of last LIR instruction in this block
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1630
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1631
  void iterate_preorder (boolArray& mark, BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1632
  void iterate_postorder(boolArray& mark, BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1633
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1634
  friend class SuxAndWeightAdjuster;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1635
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1636
 public:
19696
bd5a0131bde1 8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents: 17011
diff changeset
  1637
   void* operator new(size_t size) throw() {
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1638
    Compilation* c = Compilation::current();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1639
    void* res = c->arena()->Amalloc(size);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1640
    ((BlockBegin*)res)->_id = c->get_next_id();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1641
    ((BlockBegin*)res)->_block_id = c->get_next_block_id();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1642
    return res;
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1643
  }
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1644
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1645
  // initialization/counting
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1646
  static int  number_of_blocks() {
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1647
    return Compilation::current()->number_of_blocks();
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1648
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1649
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1650
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1651
  BlockBegin(int bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1652
  : StateSplit(illegalType)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1653
  , _bci(bci)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1654
  , _depth_first_number(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1655
  , _linear_scan_number(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1656
  , _loop_depth(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1657
  , _flags(0)
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1658
  , _dominator_depth(-1)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1659
  , _dominator(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1660
  , _end(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1661
  , _predecessors(2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1662
  , _successors(2)
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1663
  , _dominates(2)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1664
  , _exception_handlers(1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1665
  , _exception_states(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1666
  , _exception_handler_pco(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1667
  , _lir(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1668
  , _loop_index(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1669
  , _live_in()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1670
  , _live_out()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1671
  , _live_gen()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1672
  , _live_kill()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1673
  , _fpu_register_usage()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1674
  , _fpu_stack_state(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1675
  , _first_lir_instruction_id(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1676
  , _last_lir_instruction_id(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1677
  , _total_preds(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1678
  , _stores_to_locals()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1679
  {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1680
    _block = this;
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1681
#ifndef PRODUCT
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1682
    set_printable_bci(bci);
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1683
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1684
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1685
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1686
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
  int block_id() const                           { return _block_id; }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1688
  int bci() const                                { return _bci; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1689
  BlockList* successors()                        { return &_successors; }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1690
  BlockList* dominates()                         { return &_dominates; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1691
  BlockBegin* dominator() const                  { return _dominator; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1692
  int loop_depth() const                         { return _loop_depth; }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1693
  int dominator_depth() const                    { return _dominator_depth; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1694
  int depth_first_number() const                 { return _depth_first_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1695
  int linear_scan_number() const                 { return _linear_scan_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1696
  BlockEnd* end() const                          { return _end; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
  Label* label()                                 { return &_label; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
  LIR_List* lir() const                          { return _lir; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
  int exception_handler_pco() const              { return _exception_handler_pco; }
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1700
  ResourceBitMap& live_in()                      { return _live_in;        }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1701
  ResourceBitMap& live_out()                     { return _live_out;       }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1702
  ResourceBitMap& live_gen()                     { return _live_gen;       }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1703
  ResourceBitMap& live_kill()                    { return _live_kill;      }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1704
  ResourceBitMap& fpu_register_usage()           { return _fpu_register_usage; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
  intArray* fpu_stack_state() const              { return _fpu_stack_state;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  int first_lir_instruction_id() const           { return _first_lir_instruction_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
  int last_lir_instruction_id() const            { return _last_lir_instruction_id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
  int total_preds() const                        { return _total_preds; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1709
  BitMap& stores_to_locals()                     { return _stores_to_locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
  void set_dominator(BlockBegin* dom)            { _dominator = dom; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
  void set_loop_depth(int d)                     { _loop_depth = d; }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1714
  void set_dominator_depth(int d)                { _dominator_depth = d; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
  void set_depth_first_number(int dfn)           { _depth_first_number = dfn; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
  void set_linear_scan_number(int lsn)           { _linear_scan_number = lsn; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  void set_end(BlockEnd* end);
10509
43d670e5701e 7079673: JSR 292: C1 should inline bytecoded method handle adapters
twisti
parents: 9102
diff changeset
  1718
  void clear_end();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1719
  void disconnect_from_graph();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
  static void disconnect_edge(BlockBegin* from, BlockBegin* to);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
  BlockBegin* insert_block_between(BlockBegin* sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1722
  void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
  void set_lir(LIR_List* lir)                    { _lir = lir; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1724
  void set_exception_handler_pco(int pco)        { _exception_handler_pco = pco; }
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1725
  void set_live_in  (const ResourceBitMap& map)  { _live_in = map;   }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1726
  void set_live_out (const ResourceBitMap& map)  { _live_out = map;  }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1727
  void set_live_gen (const ResourceBitMap& map)  { _live_gen = map;  }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1728
  void set_live_kill(const ResourceBitMap& map)  { _live_kill = map; }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1729
  void set_fpu_register_usage(const ResourceBitMap& map) { _fpu_register_usage = map; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1730
  void set_fpu_stack_state(intArray* state)      { _fpu_stack_state = state;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1731
  void set_first_lir_instruction_id(int id)      { _first_lir_instruction_id = id;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1732
  void set_last_lir_instruction_id(int id)       { _last_lir_instruction_id = id;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1733
  void increment_total_preds(int n = 1)          { _total_preds += n; }
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 38060
diff changeset
  1734
  void init_stores_to_locals(int locals_count)   { _stores_to_locals.initialize(locals_count); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1735
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1736
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1737
  virtual void state_values_do(ValueVisitor* f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1738
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1739
  // successors and predecessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
  int number_of_sux() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
  BlockBegin* sux_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1742
  void add_successor(BlockBegin* sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1743
  void remove_successor(BlockBegin* pred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1744
  bool is_successor(BlockBegin* sux) const       { return _successors.contains(sux); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1746
  void add_predecessor(BlockBegin* pred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1747
  void remove_predecessor(BlockBegin* pred);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1748
  bool is_predecessor(BlockBegin* pred) const    { return _predecessors.contains(pred); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1749
  int number_of_preds() const                    { return _predecessors.length(); }
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
  1750
  BlockBegin* pred_at(int i) const               { return _predecessors.at(i); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1751
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1752
  // exception handlers potentially invoked by this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1753
  void add_exception_handler(BlockBegin* b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
  bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
  int  number_of_exception_handlers() const      { return _exception_handlers.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
  BlockBegin* exception_handler_at(int i) const  { return _exception_handlers.at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
  // states of the instructions that have an edge to this exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
  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
  1760
  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
  1761
  int add_exception_state(ValueStack* state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
  // flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
  enum Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
    no_flag                       = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
    std_entry_flag                = 1 << 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
    osr_entry_flag                = 1 << 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
    exception_entry_flag          = 1 << 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
    subroutine_entry_flag         = 1 << 3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
    backward_branch_target_flag   = 1 << 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
    is_on_work_list_flag          = 1 << 5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
    was_visited_flag              = 1 << 6,
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5046
diff changeset
  1773
    parser_loop_header_flag       = 1 << 7,  // set by parser to identify blocks where phi functions can not be created on demand
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5046
diff changeset
  1774
    critical_edge_split_flag      = 1 << 8, // set for all blocks that are introduced when critical edges are split
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5046
diff changeset
  1775
    linear_scan_loop_header_flag  = 1 << 9, // set during loop-detection for LinearScan
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1776
    linear_scan_loop_end_flag     = 1 << 10, // set during loop-detection for LinearScan
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1777
    donot_eliminate_range_checks  = 1 << 11  // Should be try to eliminate range checks in this block
1
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(Flag f)                               { _flags |= f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
  void clear(Flag f)                             { _flags &= ~f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
  bool is_set(Flag f) const                      { return (_flags & f) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
  bool is_entry_block() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
    const int entry_mask = std_entry_flag | osr_entry_flag | exception_entry_flag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
    return (_flags & entry_mask) != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
  // iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
  void iterate_preorder   (BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
  void iterate_postorder  (BlockClosure* closure);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  1792
  void block_values_do(ValueVisitor* f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
  // loops
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
  void set_loop_index(int ix)                    { _loop_index = ix;        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
  int  loop_index() const                        { return _loop_index;      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
  // merging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
  bool try_merge(ValueStack* state);             // try to merge states at block begin
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
  void merge(ValueStack* state)                  { bool b = try_merge(state); assert(b, "merge failed"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
  void print_block()                             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
  void print_block(InstructionPrinter& ip, bool live_only = false) PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1808
BASE(BlockEnd, StateSplit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
  BlockList*  _sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  BlockList* sux() const                         { return _sux; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
  void set_sux(BlockList* sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
    assert(sux != NULL, "sux must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
    for (int i = sux->length() - 1; i >= 0; i--) assert(sux->at(i) != NULL, "sux must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
    _sux = sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1822
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1823
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1824
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1825
  BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1826
  : StateSplit(type, state_before)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
  , _sux(NULL)
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  1828
  {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
    set_flag(IsSafepointFlag, is_safepoint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
  bool is_safepoint() const                      { return check_flag(IsSafepointFlag); }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1834
  // For compatibility with old code, for new code use block()
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1835
  BlockBegin* begin() const                      { return _block; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
  void set_begin(BlockBegin* begin);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
  // successors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
  int number_of_sux() const                      { return _sux != NULL ? _sux->length() : 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
  BlockBegin* sux_at(int i) const                { return _sux->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
  BlockBegin* default_sux() const                { return sux_at(number_of_sux() - 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
  BlockBegin** addr_sux_at(int i) const          { return _sux->adr_at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
  int sux_index(BlockBegin* sux) const           { return _sux->find(sux); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1846
  void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1847
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1848
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1849
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1850
LEAF(Goto, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
 public:
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1852
  enum Direction {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1853
    none,            // Just a regular goto
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1854
    taken, not_taken // Goto produced from If
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1855
  };
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1856
 private:
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1857
  ciMethod*   _profiled_method;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1858
  int         _profiled_bci;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1859
  Direction   _direction;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1860
 public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
  // creation
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1862
  Goto(BlockBegin* sux, ValueStack* state_before, bool is_safepoint = false)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1863
    : BlockEnd(illegalType, state_before, is_safepoint)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1864
    , _direction(none)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1865
    , _profiled_method(NULL)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1866
    , _profiled_bci(0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
    BlockList* s = new BlockList(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1868
    s->append(sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1870
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1871
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1872
  Goto(BlockBegin* sux, bool is_safepoint) : BlockEnd(illegalType, NULL, is_safepoint)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1873
                                           , _direction(none)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1874
                                           , _profiled_method(NULL)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1875
                                           , _profiled_bci(0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
    BlockList* s = new BlockList(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
    s->append(sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1881
  bool should_profile() const                    { return check_flag(ProfileMDOFlag); }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1882
  ciMethod* profiled_method() const              { return _profiled_method; } // set only for profiled branches
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1883
  int profiled_bci() const                       { return _profiled_bci; }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1884
  Direction direction() const                    { return _direction; }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1885
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1886
  void set_should_profile(bool value)            { set_flag(ProfileMDOFlag, value); }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1887
  void set_profiled_method(ciMethod* method)     { _profiled_method = method; }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1888
  void set_profiled_bci(int bci)                 { _profiled_bci = bci; }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1889
  void set_direction(Direction d)                { _direction = d; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1890
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1891
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1892
#ifdef ASSERT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1893
LEAF(Assert, Instruction)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1894
  private:
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1895
  Value       _x;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1896
  Condition   _cond;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1897
  Value       _y;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1898
  char        *_message;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1899
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1900
 public:
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1901
  // creation
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1902
  // unordered_is_true is valid for float/double compares only
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1903
   Assert(Value x, Condition cond, bool unordered_is_true, Value y);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1904
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1905
  // accessors
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1906
  Value x() const                                { return _x; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1907
  Condition cond() const                         { return _cond; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1908
  bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1909
  Value y() const                                { return _y; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1910
  const char *message() const                    { return _message; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1911
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1912
  // generic
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1913
  virtual void input_values_do(ValueVisitor* f)  { f->visit(&_x); f->visit(&_y); }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1914
};
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1915
#endif
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1916
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1917
LEAF(RangeCheckPredicate, StateSplit)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1918
 private:
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1919
  Value       _x;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1920
  Condition   _cond;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1921
  Value       _y;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1922
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1923
  void check_state();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1924
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1925
 public:
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1926
  // creation
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1927
  // unordered_is_true is valid for float/double compares only
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1928
   RangeCheckPredicate(Value x, Condition cond, bool unordered_is_true, Value y, ValueStack* state) : StateSplit(illegalType)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1929
  , _x(x)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1930
  , _cond(cond)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1931
  , _y(y)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1932
  {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1933
    ASSERT_VALUES
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1934
    set_flag(UnorderedIsTrueFlag, unordered_is_true);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1935
    assert(x->type()->tag() == y->type()->tag(), "types must match");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1936
    this->set_state(state);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1937
    check_state();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1938
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1939
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1940
  // Always deoptimize
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1941
  RangeCheckPredicate(ValueStack* state) : StateSplit(illegalType)
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1942
  {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1943
    this->set_state(state);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1944
    _x = _y = NULL;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1945
    check_state();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1946
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1947
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1948
  // accessors
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1949
  Value x() const                                { return _x; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1950
  Condition cond() const                         { return _cond; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1951
  bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1952
  Value y() const                                { return _y; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1953
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1954
  void always_fail()                             { _x = _y = NULL; }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1955
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1956
  // generic
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1957
  virtual void input_values_do(ValueVisitor* f)  { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1958
  HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 13886
diff changeset
  1959
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
LEAF(If, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
  Value       _x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
  Condition   _cond;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
  Value       _y;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
  ciMethod*   _profiled_method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
  int         _profiled_bci; // Canonicalizer may alter bci of If node
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1968
  bool        _swapped;      // Is the order reversed with respect to the original If in the
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1969
                             // bytecode stream?
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1970
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  // unordered_is_true is valid for float/double compares only
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
  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
  1974
    : BlockEnd(illegalType, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
  , _x(x)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  , _cond(cond)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
  , _y(y)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
  , _profiled_method(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  , _profiled_bci(0)
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  1980
  , _swapped(false)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
    set_flag(UnorderedIsTrueFlag, unordered_is_true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
    assert(x->type()->tag() == y->type()->tag(), "types must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
    BlockList* s = new BlockList(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
    s->append(tsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
    s->append(fsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
  Value x() const                                { return _x; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
  Condition cond() const                         { return _cond; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
  bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
  Value y() const                                { return _y; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
  BlockBegin* sux_for(bool is_true) const        { return sux_at(is_true ? 0 : 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
  BlockBegin* tsux() const                       { return sux_for(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
  BlockBegin* fsux() const                       { return sux_for(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
  BlockBegin* usux() const                       { return sux_for(unordered_is_true()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
  bool should_profile() const                    { return check_flag(ProfileMDOFlag); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
  ciMethod* profiled_method() const              { return _profiled_method; } // set only for profiled branches
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2002
  int profiled_bci() const                       { return _profiled_bci; }    // set for profiled branches and tiered
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2003
  bool is_swapped() const                        { return _swapped; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2006
  void swap_operands() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
    Value t = _x; _x = _y; _y = t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
    _cond = mirror(_cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2010
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2011
  void swap_sux() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
    assert(number_of_sux() == 2, "wrong number of successors");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
    BlockList* s = sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
    BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2015
    _cond = negate(_cond);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2016
    set_flag(UnorderedIsTrueFlag, !check_flag(UnorderedIsTrueFlag));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
  void set_should_profile(bool value)             { set_flag(ProfileMDOFlag, value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
  void set_profiled_method(ciMethod* method)      { _profiled_method = method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
  void set_profiled_bci(int bci)                  { _profiled_bci = bci;       }
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2022
  void set_swapped(bool value)                    { _swapped = value;         }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2024
  virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
LEAF(IfInstanceOf, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
  ciKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
  Value    _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
  bool     _test_is_instance;                    // jump if instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
  int      _instanceof_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
  IfInstanceOf(ciKlass* klass, Value obj, bool test_is_instance, int instanceof_bci, BlockBegin* tsux, BlockBegin* fsux)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
  : BlockEnd(illegalType, NULL, false) // temporary set to false
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  , _klass(klass)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
  , _obj(obj)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  , _test_is_instance(test_is_instance)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
  , _instanceof_bci(instanceof_bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
    assert(instanceof_bci >= 0, "illegal bci");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
    BlockList* s = new BlockList(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
    s->append(tsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
    s->append(fsux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
  // Note 1: If test_is_instance() is true, IfInstanceOf tests if obj *is* an
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
  //         instance of klass; otherwise it tests if it is *not* and instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
  //         of klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
  // Note 2: IfInstanceOf instructions are created by combining an InstanceOf
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
  //         and an If instruction. The IfInstanceOf bci() corresponds to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
  //         bci that the If would have had; the (this->) instanceof_bci() is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
  //         the bci of the original InstanceOf instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  ciKlass* klass() const                         { return _klass; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
  Value obj() const                              { return _obj; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
  int instanceof_bci() const                     { return _instanceof_bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
  bool test_is_instance() const                  { return _test_is_instance; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
  BlockBegin* sux_for(bool is_true) const        { return sux_at(is_true ? 0 : 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
  BlockBegin* tsux() const                       { return sux_for(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
  BlockBegin* fsux() const                       { return sux_for(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  // manipulation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
  void swap_sux() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
    assert(number_of_sux() == 2, "wrong number of successors");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
    BlockList* s = sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
    BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
    _test_is_instance = !_test_is_instance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2078
  virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_obj); }
1
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
BASE(Switch, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
  Value       _tag;
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
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
  Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
  : BlockEnd(illegalType, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
  , _tag(tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
    set_sux(sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
  Value tag() const                              { return _tag; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
  int length() const                             { return number_of_sux() - 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  2099
  virtual bool needs_exception_state() const     { return false; }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6461
diff changeset
  2100
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2101
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2102
  virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_tag); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2104
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2106
LEAF(TableSwitch, Switch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
  int _lo_key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
  TableSwitch(Value tag, BlockList* sux, int lo_key, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2113
    : Switch(tag, sux, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
  , _lo_key(lo_key) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
  int lo_key() const                             { return _lo_key; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
  int hi_key() const                             { return _lo_key + length() - 1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2121
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2122
LEAF(LookupSwitch, Switch)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2123
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2124
  intArray* _keys;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2126
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2127
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2128
  LookupSwitch(Value tag, BlockList* sux, intArray* keys, ValueStack* state_before, bool is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
  : Switch(tag, sux, state_before, is_safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
  , _keys(keys) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
    assert(keys != NULL, "keys must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
    assert(keys->length() == length(), "sux & keys have incompatible lengths");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2134
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
  int key_at(int i) const                        { return _keys->at(i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2139
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
LEAF(Return, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
  Value _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
  Return(Value result) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
    BlockEnd(result == NULL ? voidType : result->type()->base(), NULL, true),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
    _result(result) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
  Value result() const                           { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
  bool has_result() const                        { return result() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2155
  virtual void input_values_do(ValueVisitor* f) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
    BlockEnd::input_values_do(f);
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2157
    if (has_result()) f->visit(&_result);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
  }
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
LEAF(Throw, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
  Value _exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
  Throw(Value exception, ValueStack* state_before) : BlockEnd(illegalType, state_before, true), _exception(exception) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
  Value exception() const                        { return _exception; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
  // generic
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
  virtual bool can_trap() const                  { return true; }
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2177
  virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_exception); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
LEAF(Base, BlockEnd)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
  Base(BlockBegin* std_entry, BlockBegin* osr_entry) : BlockEnd(illegalType, NULL, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
    assert(std_entry->is_set(BlockBegin::std_entry_flag), "std entry must be flagged");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
    assert(osr_entry == NULL || osr_entry->is_set(BlockBegin::osr_entry_flag), "osr entry must be flagged");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
    BlockList* s = new BlockList(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
    if (osr_entry != NULL) s->append(osr_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
    s->append(std_entry); // must be default sux!
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
    set_sux(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
  BlockBegin* std_entry() const                  { return default_sux(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
  BlockBegin* osr_entry() const                  { return number_of_sux() < 2 ? NULL : sux_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
LEAF(OsrEntry, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
#ifdef _LP64
6750
b84813b41757 6988303: 6986046 breaks build with recent gcc
roland
parents: 6745
diff changeset
  2203
  OsrEntry() : Instruction(longType) { pin(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
#else
6750
b84813b41757 6988303: 6986046 breaks build with recent gcc
roland
parents: 6745
diff changeset
  2205
  OsrEntry() : Instruction(intType)  { pin(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2209
  virtual void input_values_do(ValueVisitor* f)   { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
// Models the incoming exception at a catch site
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
LEAF(ExceptionObject, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
  // creation
6750
b84813b41757 6988303: 6986046 breaks build with recent gcc
roland
parents: 6745
diff changeset
  2217
  ExceptionObject() : Instruction(objectType) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2222
  virtual void input_values_do(ValueVisitor* f)   { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
// Models needed rounding for floating-point values on Intel.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
// Currently only used to represent rounding of double-precision
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
// values stored into local variables, but could be used to model
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
// intermediate rounding of single-precision values as well.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
LEAF(RoundFP, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
  Value _input;             // floating-point value to be rounded
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
  RoundFP(Value input)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
  : Instruction(input->type()) // Note: should not be used for constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
  , _input(input)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
  Value input() const                            { return _input; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2246
  virtual void input_values_do(ValueVisitor* f)   { f->visit(&_input); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
BASE(UnsafeOp, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
  BasicType _basic_type;    // ValueType can not express byte-sized integers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  // creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
  UnsafeOp(BasicType basic_type, bool is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
  : Instruction(is_put ? voidType : as_ValueType(basic_type))
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
  , _basic_type(basic_type)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
    //Note:  Unsafe ops are not not guaranteed to throw NPE.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
    // Convservatively, Unsafe operations must be pinned though we could be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
    // looser about this if we wanted to..
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
  BasicType basic_type()                         { return _basic_type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2271
  virtual void input_values_do(ValueVisitor* f)   { }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
BASE(UnsafeRawOp, UnsafeOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
  Value _base;                                   // Base address (a Java long)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
  Value _index;                                  // Index if computed by optimizer; initialized to NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
  int   _log2_scale;                             // Scale factor: 0, 1, 2, or 3.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
                                                 // Indicates log2 of number of bytes (1, 2, 4, or 8)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
                                                 // to scale index by.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
  UnsafeRawOp(BasicType basic_type, Value addr, bool is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
  : UnsafeOp(basic_type, is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
  , _base(addr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
  , _index(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
  , _log2_scale(0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
    // Can not use ASSERT_VALUES because index may be NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
    assert(addr != NULL && addr->type()->is_long(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2292
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2293
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
  UnsafeRawOp(BasicType basic_type, Value base, Value index, int log2_scale, bool is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
  : UnsafeOp(basic_type, is_put)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2296
  , _base(base)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2298
  , _log2_scale(log2_scale)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2299
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2300
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
  Value base()                                   { return _base; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
  Value index()                                  { return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
  bool  has_index()                              { return (_index != NULL); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
  int   log2_scale()                             { return _log2_scale; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
  // setters
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
  void set_base (Value base)                     { _base  = base; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
  void set_index(Value index)                    { _index = index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
  void set_log2_scale(int log2_scale)            { _log2_scale = log2_scale; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2315
  virtual void input_values_do(ValueVisitor* f)   { UnsafeOp::input_values_do(f);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2316
                                                   f->visit(&_base);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2317
                                                   if (has_index()) f->visit(&_index); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
LEAF(UnsafeGetRaw, UnsafeRawOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2322
 private:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2323
 bool _may_be_unaligned, _is_wide;  // For OSREntry
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2324
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2325
 public:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2326
 UnsafeGetRaw(BasicType basic_type, Value addr, bool may_be_unaligned, bool is_wide = false)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2327
  : UnsafeRawOp(basic_type, addr, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2328
    _may_be_unaligned = may_be_unaligned;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2329
    _is_wide = is_wide;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2330
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2331
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2332
 UnsafeGetRaw(BasicType basic_type, Value base, Value index, int log2_scale, bool may_be_unaligned, bool is_wide = false)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2333
  : UnsafeRawOp(basic_type, base, index, log2_scale, false) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2334
    _may_be_unaligned = may_be_unaligned;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2335
    _is_wide = is_wide;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2336
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2337
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2338
  bool may_be_unaligned()                         { return _may_be_unaligned; }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2339
  bool is_wide()                                  { return _is_wide; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2341
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2342
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2343
LEAF(UnsafePutRaw, UnsafeRawOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
  Value _value;                                  // Value to be stored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2347
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2348
  UnsafePutRaw(BasicType basic_type, Value addr, Value value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2349
  : UnsafeRawOp(basic_type, addr, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2350
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2351
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2352
    assert(value != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2353
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2354
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2355
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2356
  UnsafePutRaw(BasicType basic_type, Value base, Value index, int log2_scale, Value value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2357
  : UnsafeRawOp(basic_type, base, index, log2_scale, true)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2358
  , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2359
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
    assert(value != NULL, "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
  Value value()                                  { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2367
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2368
  virtual void input_values_do(ValueVisitor* f)   { UnsafeRawOp::input_values_do(f);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2369
                                                   f->visit(&_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2370
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
BASE(UnsafeObjectOp, UnsafeOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
  Value _object;                                 // Object to be fetched from or mutated
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
  Value _offset;                                 // Offset within object
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
  bool  _is_volatile;                            // true if volatile - dl/JSR166
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
  UnsafeObjectOp(BasicType basic_type, Value object, Value offset, bool is_put, bool is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2380
    : UnsafeOp(basic_type, is_put), _object(object), _offset(offset), _is_volatile(is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2381
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
  Value object()                                 { return _object; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
  Value offset()                                 { return _offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2387
  bool  is_volatile()                            { return _is_volatile; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2388
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2389
  virtual void input_values_do(ValueVisitor* f)   { UnsafeOp::input_values_do(f);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2390
                                                   f->visit(&_object);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2391
                                                   f->visit(&_offset); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2392
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2393
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2394
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2395
LEAF(UnsafeGetObject, UnsafeObjectOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2396
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2397
  UnsafeGetObject(BasicType basic_type, Value object, Value offset, bool is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2398
  : UnsafeObjectOp(basic_type, object, offset, false, is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2399
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2400
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2402
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2403
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2404
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2405
LEAF(UnsafePutObject, UnsafeObjectOp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2406
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2407
  Value _value;                                  // Value to be stored
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2408
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2409
  UnsafePutObject(BasicType basic_type, Value object, Value offset, Value value, bool is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2410
  : UnsafeObjectOp(basic_type, object, offset, true, is_volatile)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2411
    , _value(value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2412
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2413
    ASSERT_VALUES
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2414
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2415
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2416
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2417
  Value value()                                  { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2418
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2419
  // generic
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2420
  virtual void input_values_do(ValueVisitor* f)   { UnsafeObjectOp::input_values_do(f);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
  2421
                                                   f->visit(&_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2422
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2424
LEAF(UnsafeGetAndSetObject, UnsafeObjectOp)
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2425
 private:
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2426
  Value _value;                                  // Value to be stored
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2427
  bool  _is_add;
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2428
 public:
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2429
  UnsafeGetAndSetObject(BasicType basic_type, Value object, Value offset, Value value, bool is_add)
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2430
  : UnsafeObjectOp(basic_type, object, offset, false, false)
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2431
    , _value(value)
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2432
    , _is_add(is_add)
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2433
  {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2434
    ASSERT_VALUES
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2435
  }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2436
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2437
  // accessors
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2438
  bool is_add() const                            { return _is_add; }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2439
  Value value()                                  { return _value; }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2440
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2441
  // generic
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2442
  virtual void input_values_do(ValueVisitor* f)   { UnsafeObjectOp::input_values_do(f);
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2443
                                                   f->visit(&_value); }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13728
diff changeset
  2444
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2445
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2446
LEAF(ProfileCall, Instruction)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2447
 private:
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2448
  ciMethod*        _method;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2449
  int              _bci_of_invoke;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2450
  ciMethod*        _callee;         // the method that is called at the given bci
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2451
  Value            _recv;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2452
  ciKlass*         _known_holder;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2453
  Values*          _obj_args;       // arguments for type profiling
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2454
  ArgsNonNullState _nonnull_state;  // Do we know whether some arguments are never null?
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2455
  bool             _inlined;        // Are we profiling a call that is inlined
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2456
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2457
 public:
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2458
  ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder, Values* obj_args, bool inlined)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2459
    : Instruction(voidType)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2460
    , _method(method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2461
    , _bci_of_invoke(bci)
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12947
diff changeset
  2462
    , _callee(callee)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2463
    , _recv(recv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2464
    , _known_holder(known_holder)
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2465
    , _obj_args(obj_args)
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2466
    , _inlined(inlined)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2467
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2468
    // The ProfileCall has side-effects and must occur precisely where located
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2469
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2470
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2471
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2472
  ciMethod* method()             const { return _method; }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2473
  int bci_of_invoke()            const { return _bci_of_invoke; }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2474
  ciMethod* callee()             const { return _callee; }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2475
  Value recv()                   const { return _recv; }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2476
  ciKlass* known_holder()        const { return _known_holder; }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2477
  int nb_profiled_args()         const { return _obj_args == NULL ? 0 : _obj_args->length(); }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2478
  Value profiled_arg_at(int i)   const { return _obj_args->at(i); }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2479
  bool arg_needs_null_check(int i) const {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2480
    return _nonnull_state.arg_needs_null_check(i);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2481
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2482
  bool inlined()                 const { return _inlined; }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2483
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2484
  void set_arg_needs_null_check(int i, bool check) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2485
    _nonnull_state.set_arg_needs_null_check(i, check);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2486
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2487
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2488
  virtual void input_values_do(ValueVisitor* f)   {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2489
    if (_recv != NULL) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2490
      f->visit(&_recv);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2491
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2492
    for (int i = 0; i < nb_profiled_args(); i++) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2493
      f->visit(_obj_args->adr_at(i));
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2494
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19696
diff changeset
  2495
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2496
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2497
20709
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2498
LEAF(ProfileReturnType, Instruction)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2499
 private:
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2500
  ciMethod*        _method;
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2501
  ciMethod*        _callee;
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2502
  int              _bci_of_invoke;
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2503
  Value            _ret;
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2504
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2505
 public:
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2506
  ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2507
    : Instruction(voidType)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2508
    , _method(method)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2509
    , _callee(callee)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2510
    , _bci_of_invoke(bci)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2511
    , _ret(ret)
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2512
  {
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2513
    set_needs_null_check(true);
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2514
    // The ProfileType has side-effects and must occur precisely where located
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2515
    pin();
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2516
  }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2517
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2518
  ciMethod* method()             const { return _method; }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2519
  ciMethod* callee()             const { return _callee; }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2520
  int bci_of_invoke()            const { return _bci_of_invoke; }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2521
  Value ret()                    const { return _ret; }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2522
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2523
  virtual void input_values_do(ValueVisitor* f)   {
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2524
    if (_ret != NULL) {
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2525
      f->visit(&_ret);
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2526
    }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2527
  }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2528
};
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  2529
8065
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2530
// Call some C runtime function that doesn't safepoint,
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2531
// optionally passing the current thread as the first argument.
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2532
LEAF(RuntimeCall, Instruction)
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2533
 private:
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2534
  const char* _entry_name;
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2535
  address     _entry;
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2536
  Values*     _args;
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2537
  bool        _pass_thread;  // Pass the JavaThread* as an implicit first argument
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2538
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2539
 public:
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2540
  RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2541
    : Instruction(type)
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2542
    , _entry(entry)
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2543
    , _args(args)
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2544
    , _entry_name(entry_name)
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2545
    , _pass_thread(pass_thread) {
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2546
    ASSERT_VALUES
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2547
    pin();
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2548
  }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2549
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2550
  const char* entry_name() const  { return _entry_name; }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2551
  address entry() const           { return _entry; }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2552
  int number_of_arguments() const { return _args->length(); }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2553
  Value argument_at(int i) const  { return _args->at(i); }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2554
  bool pass_thread() const        { return _pass_thread; }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2555
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2556
  virtual void input_values_do(ValueVisitor* f)   {
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2557
    for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2558
  }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2559
};
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7427
diff changeset
  2560
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2561
// Use to trip invocation counter of an inlined method
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2562
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2563
LEAF(ProfileInvoke, Instruction)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2564
 private:
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2565
  ciMethod*   _inlinee;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2566
  ValueStack* _state;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2567
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2568
 public:
6751
b399fd234e47 6988346: 6986046 breaks tiered
iveresov
parents: 6750
diff changeset
  2569
  ProfileInvoke(ciMethod* inlinee,  ValueStack* state)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2570
    : Instruction(voidType)
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2571
    , _inlinee(inlinee)
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2572
    , _state(state)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2573
  {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2574
    // The ProfileInvoke has side-effects and must occur precisely where located QQQ???
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2575
    pin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2576
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2577
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2578
  ciMethod* inlinee()      { return _inlinee; }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2579
  ValueStack* state()      { return _state; }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2580
  virtual void input_values_do(ValueVisitor*)   {}
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5707
diff changeset
  2581
  virtual void state_values_do(ValueVisitor*);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2582
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2583
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2584
LEAF(MemBar, Instruction)
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2585
 private:
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2586
  LIR_Code _code;
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2587
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2588
 public:
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2589
  MemBar(LIR_Code code)
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2590
    : Instruction(voidType)
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2591
    , _code(code)
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2592
  {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2593
    pin();
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2594
  }
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2595
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2596
  LIR_Code code()           { return _code; }
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2597
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2598
  virtual void input_values_do(ValueVisitor*)   {}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2599
};
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11192
diff changeset
  2600
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2601
class BlockPair: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2602
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2603
  BlockBegin* _from;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2604
  BlockBegin* _to;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2605
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2606
  BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2607
  BlockBegin* from() const { return _from; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2608
  BlockBegin* to() const   { return _to;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2609
  bool is_same(BlockBegin* from, BlockBegin* to) const { return  _from == from && _to == to; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2610
  bool is_same(BlockPair* p) const { return  _from == p->from() && _to == p->to(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2611
  void set_to(BlockBegin* b)   { _to = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2612
  void set_from(BlockBegin* b) { _from = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2613
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2614
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 33633
diff changeset
  2615
typedef GrowableArray<BlockPair*> BlockPairList;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2616
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2617
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
  2618
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
  2619
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
  2620
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2621
#undef ASSERT_VALUES
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
  2622
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7100
diff changeset
  2623
#endif // SHARE_VM_C1_C1_INSTRUCTION_HPP