hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
author iveresov
Thu, 02 Dec 2010 17:21:12 -0800
changeset 7432 f06f1253c317
parent 7397 5b173b4ca846
child 8065 7ca689ce3d32
permissions -rw-r--r--
7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer Summary: C1 with profiling doesn't check whether the MDO has been really allocated, which can silently fail if the perm gen is full. The solution is to check if the allocation failed and bailout out of inlining or compilation. Reviewed-by: kvn, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
     2
 * Copyright (c) 2005, 2010, 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: 1374
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
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: 1374
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: 6453
diff changeset
    25
#ifndef SHARE_VM_C1_C1_LIRGENERATOR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    26
#define SHARE_VM_C1_C1_LIRGENERATOR_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    28
#include "c1/c1_Instruction.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    29
#include "c1/c1_LIR.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    30
#include "ci/ciMethodData.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    31
#include "utilities/sizes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// The classes responsible for code emission and register allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class LIRGenerator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class LIREmitter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class Invoke;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class SwitchRange;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class LIRItem;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
define_array(LIRItemArray, LIRItem*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
define_stack(LIRItemList, LIRItemArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class SwitchRange: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  int _low_key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  int _high_key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  BlockBegin* _sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  void set_high_key(int key) { _high_key = key; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  int high_key() const { return _high_key; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  int low_key() const { return _low_key; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  BlockBegin* sux() const { return _sux; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
define_array(SwitchRangeArray, SwitchRange*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
define_stack(SwitchRangeList, SwitchRangeArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class ResolveNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
define_array(NodeArray, ResolveNode*);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
define_stack(NodeList, NodeArray);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// Node objects form a directed graph of LIR_Opr
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// Edges between Nodes represent moves from one Node to its destinations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class ResolveNode: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  LIR_Opr    _operand;       // the source or destinaton
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  NodeList   _destinations;  // for the operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  bool       _assigned;      // Value assigned to this Node?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  bool       _visited;       // Node already visited?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  bool       _start_node;    // Start node already visited?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  ResolveNode(LIR_Opr operand)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    : _operand(operand)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    , _assigned(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    , _visited(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    , _start_node(false) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  LIR_Opr operand() const           { return _operand; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  int no_of_destinations() const    { return _destinations.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  ResolveNode* destination_at(int i)     { return _destinations[i]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  bool assigned() const             { return _assigned; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  bool visited() const              { return _visited; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  bool start_node() const           { return _start_node; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // modifiers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  void append(ResolveNode* dest)         { _destinations.append(dest); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void set_assigned()               { _assigned = true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void set_visited()                { _visited = true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  void set_start_node()             { _start_node = true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// This is shared state to be used by the PhiResolver so the operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// arrays don't have to be reallocated for reach resolution.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
class PhiResolverState: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  friend class PhiResolver;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  NodeList _virtual_operands; // Nodes where the operand is a virtual register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  NodeList _other_operands;   // Nodes where the operand is not a virtual register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  NodeList _vreg_table;       // Mapping from virtual register to Node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  PhiResolverState() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  void reset(int max_vregs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// class used to move value of phi operand to phi function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
class PhiResolver: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  LIRGenerator*     _gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  PhiResolverState& _state; // temporary state cached by LIRGenerator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  ResolveNode*   _loop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  LIR_Opr _temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // access to shared state arrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  NodeList& virtual_operands() { return _state._virtual_operands; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  NodeList& other_operands()   { return _state._other_operands;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  NodeList& vreg_table()       { return _state._vreg_table;       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  ResolveNode* create_node(LIR_Opr opr, bool source);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  ResolveNode* source_node(LIR_Opr opr)      { return create_node(opr, true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  ResolveNode* destination_node(LIR_Opr opr) { return create_node(opr, false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  void emit_move(LIR_Opr src, LIR_Opr dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  void move_to_temp(LIR_Opr src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  void move_temp_to(LIR_Opr dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  void move(ResolveNode* src, ResolveNode* dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  LIRGenerator* gen() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    return _gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  PhiResolver(LIRGenerator* _lir_gen, int max_vregs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  ~PhiResolver();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  void move(LIR_Opr src, LIR_Opr dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// only the classes below belong in the same file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
class LIRGenerator: public InstructionVisitor, public BlockClosure {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   156
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  Compilation*  _compilation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  ciMethod*     _method;    // method that we are compiling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  PhiResolverState  _resolver_state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  BlockBegin*   _block;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  int           _virtual_register_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  Values        _instruction_for_operand;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  BitMap2D      _vreg_flags; // flags which can be set on a per-vreg basis
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  LIR_List*     _lir;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   166
  BarrierSet*   _bs;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  LIRGenerator* gen() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    return this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  LIR_List* lir(const char * file, int line) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    _lir->set_file_and_line(file, line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    return _lir;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  LIR_List* lir() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    return _lir;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // a simple cache of constants used within a block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  GrowableArray<LIR_Const*>       _constants;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  LIR_OprList                     _reg_for_constants;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  Values                          _unpinned_constants;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  friend class PhiResolver;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // unified bailout support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  void bailout(const char* msg) const            { compilation()->bailout(msg); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  bool bailed_out() const                        { return compilation()->bailed_out(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  void block_do_prolog(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void block_do_epilog(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // register allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  LIR_Opr rlock(Value instr);                      // lock a free register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  LIR_Opr rlock_result(Value instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  LIR_Opr rlock_result(Value instr, BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  LIR_Opr rlock_byte(BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  LIR_Opr rlock_callee_saved(BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // get a constant into a register and get track of what register was used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  LIR_Opr load_constant(Constant* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  LIR_Opr load_constant(LIR_Const* constant);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   207
  // Given an immediate value, return an operand usable in logical ops.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   208
  LIR_Opr load_immediate(int x, BasicType type);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   209
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  void  set_result(Value x, LIR_Opr opr)           {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    assert(opr->is_valid(), "must set to valid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    assert(x->operand()->is_illegal(), "operand should never change");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    x->set_operand(opr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    assert(opr == x->operand(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    if (opr->is_virtual()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  void  set_no_result(Value x)                     { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  friend class LIRItem;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  LIR_Opr round_item(LIR_Opr opr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  LIR_Opr force_to_spill(LIR_Opr value, BasicType t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  PhiResolverState& resolver_state() { return _resolver_state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  void  move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  void  move_to_phi(ValueStack* cur_state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // code emission
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  void do_ArithmeticOp_Long   (ArithmeticOp*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  void do_ArithmeticOp_Int    (ArithmeticOp*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  void do_ArithmeticOp_FPU    (ArithmeticOp*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // platform dependent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  LIR_Opr getThreadPointer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  void do_RegisterFinalizer(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  void do_getClass(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  void do_currentThread(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  void do_MathIntrinsic(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  void do_ArrayCopy(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  void do_CompareAndSwap(Intrinsic* x, ValueType* type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  void do_AttemptUpdate(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  void do_NIOCheckIndex(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  void do_FPIntrinsics(Intrinsic* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // convenience functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  // GC Barriers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // generic interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   263
  void pre_barrier(LIR_Opr addr_opr, bool patch,  CodeEmitInfo* info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // specific implementations
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   267
  // pre barriers
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   268
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   269
  void G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, bool patch,  CodeEmitInfo* info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  // post barriers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   273
  void G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  static LIR_Opr result_register_for(ValueType* type, bool callee = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  ciObject* get_jobject_constant(Value value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  LIRItemList* invoke_visit_arguments(Invoke* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  void trace_block_entry(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // volatile field operations are never patchable because a klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // must be loaded to know it's volatile which means that the offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // it always known as well.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   297
  void increment_counter(address counter, BasicType type, int step = 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  void increment_counter(LIR_Address* addr, int step = 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // is_strictfp is only needed for mul and div (and only generates different code on i486)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // machine dependent.  returns true if it emitted code for the multiply
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  bool strength_reduce_multiply(LIR_Opr left, int constant, LIR_Opr result, LIR_Opr tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  void jobject2reg_with_patching(LIR_Opr r, ciObject* obj, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  // this loads the length and compares against the index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  void array_range_check          (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // For java.nio.Buffer.checkIndex
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  void nio_range_check            (LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  void arithmetic_op_int  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  void arithmetic_op_fpu  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp = LIR_OprFact::illegalOpr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  void shift_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  void logic_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   323
  void monitor_exit  (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  void new_instance    (LIR_Opr  dst, ciInstanceKlass* klass, LIR_Opr  scratch1, LIR_Opr  scratch2, LIR_Opr  scratch3,  LIR_Opr scratch4, LIR_Opr  klass_reg, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  // machine dependent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // returns a LIR_Address to address an array location.  May also
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // emit some code as part of address calculation.  If
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // needs_card_mark is true then compute the full address for use by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // both the store and the card mark.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  LIR_Address* generate_address(LIR_Opr base,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
                                LIR_Opr index, int shift,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
                                int disp,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
                                BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   347
  // the helper for generate_address
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   348
  void add_large_constant(LIR_Opr src, int c, LIR_Opr dest);
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   349
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  // machine preferences and characteristics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  bool can_inline_as_constant(Value i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  bool can_inline_as_constant(LIR_Const* c) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  bool can_store_as_constant(Value i, BasicType type) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  LIR_Opr safepoint_poll_register();
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   356
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   357
  void profile_branch(If* if_instr, If::Condition cond);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   358
  void increment_event_counter_impl(CodeEmitInfo* info,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   359
                                    ciMethod *method, int frequency,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   360
                                    int bci, bool backedge, bool notify);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   361
  void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   362
  void increment_invocation_counter(CodeEmitInfo *info) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   363
    if (compilation()->count_invocations()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   364
      increment_event_counter(info, InvocationEntryBci, false);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   365
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   366
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   367
  void increment_backedge_counter(CodeEmitInfo* info, int bci) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   368
    if (compilation()->count_backedges()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   369
      increment_event_counter(info, bci, true);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   370
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  CodeEmitInfo* state_for(Instruction* x, ValueStack* state, bool ignore_xhandler = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  CodeEmitInfo* state_for(Instruction* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  // allocates a virtual register for this instruction if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // one isn't already allocated.  Only for Phi and Local.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  LIR_Opr operand_for_instruction(Instruction *x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  void set_block(BlockBegin* block)              { _block = block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  void block_prolog(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  void block_epilog(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  void do_root (Instruction* instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  void walk    (Instruction* instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  void bind_block_entry(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  void start_block(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  LIR_Opr new_register(BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  LIR_Opr new_register(Value value)              { return new_register(as_BasicType(value->type())); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  LIR_Opr new_register(ValueType* type)          { return new_register(as_BasicType(type)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  // returns a register suitable for doing pointer math
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  LIR_Opr new_pointer_register() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    return new_register(T_LONG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    return new_register(T_INT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  static LIR_Condition lir_cond(If::Condition cond) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    LIR_Condition l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    switch (cond) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    case If::eql: l = lir_cond_equal;        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    case If::neq: l = lir_cond_notEqual;     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    case If::lss: l = lir_cond_less;         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    case If::leq: l = lir_cond_lessEqual;    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    case If::geq: l = lir_cond_greaterEqual; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    case If::gtr: l = lir_cond_greater;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    return l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   417
#ifdef __SOFTFP__
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   418
  void do_soft_float_compare(If *x);
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   419
#endif // __SOFTFP__
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   420
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  void init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  Compilation*  compilation() const              { return _compilation; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  FrameMap*     frame_map() const                { return _compilation->frame_map(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  ciMethod*     method() const                   { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  BlockBegin*   block() const                    { return _block; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  IRScope*      scope() const                    { return block()->scope(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  int max_virtual_register_number() const        { return _virtual_register_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  void block_do(BlockBegin* block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  // Flags that can be set on vregs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  enum VregFlag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      must_start_in_memory = 0  // needs to be assigned a memory location at beginning, but may then be loaded in a register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    , callee_saved     = 1    // must be in a callee saved register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    , byte_reg         = 2    // must be in a byte register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    , num_vreg_flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  LIRGenerator(Compilation* compilation, ciMethod* method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    : _compilation(compilation)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    , _method(method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    , _virtual_register_number(LIR_OprDesc::vreg_base)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    , _vreg_flags(NULL, 0, num_vreg_flags) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // for virtual registers, maps them back to Phi's or Local's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  Instruction* instruction_for_opr(LIR_Opr opr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  Instruction* instruction_for_vreg(int reg_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  void set_vreg_flag   (int vreg_num, VregFlag f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  bool is_vreg_flag_set(int vreg_num, VregFlag f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  // statics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  static LIR_Opr exceptionOopOpr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  static LIR_Opr exceptionPcOpr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  static LIR_Opr divInOpr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  static LIR_Opr divOutOpr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  static LIR_Opr remOutOpr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  static LIR_Opr shiftCountOpr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  LIR_Opr syncTempOpr();
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
   472
  LIR_Opr atomicLockOpr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  // returns a register suitable for saving the thread in a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  // call_runtime_leaf if one is needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  LIR_Opr getThreadTemp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  // visitor functionality
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  virtual void do_Phi            (Phi*             x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  virtual void do_Local          (Local*           x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  virtual void do_Constant       (Constant*        x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  virtual void do_LoadField      (LoadField*       x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  virtual void do_StoreField     (StoreField*      x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  virtual void do_ArrayLength    (ArrayLength*     x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  virtual void do_LoadIndexed    (LoadIndexed*     x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  virtual void do_StoreIndexed   (StoreIndexed*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  virtual void do_NegateOp       (NegateOp*        x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  virtual void do_ArithmeticOp   (ArithmeticOp*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  virtual void do_ShiftOp        (ShiftOp*         x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  virtual void do_LogicOp        (LogicOp*         x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  virtual void do_CompareOp      (CompareOp*       x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  virtual void do_IfOp           (IfOp*            x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  virtual void do_Convert        (Convert*         x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  virtual void do_NullCheck      (NullCheck*       x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  virtual void do_Invoke         (Invoke*          x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  virtual void do_NewInstance    (NewInstance*     x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  virtual void do_NewTypeArray   (NewTypeArray*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  virtual void do_NewObjectArray (NewObjectArray*  x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  virtual void do_NewMultiArray  (NewMultiArray*   x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  virtual void do_CheckCast      (CheckCast*       x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  virtual void do_InstanceOf     (InstanceOf*      x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  virtual void do_MonitorEnter   (MonitorEnter*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  virtual void do_MonitorExit    (MonitorExit*     x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  virtual void do_Intrinsic      (Intrinsic*       x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  virtual void do_BlockBegin     (BlockBegin*      x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  virtual void do_Goto           (Goto*            x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  virtual void do_If             (If*              x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  virtual void do_IfInstanceOf   (IfInstanceOf*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  virtual void do_TableSwitch    (TableSwitch*     x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  virtual void do_LookupSwitch   (LookupSwitch*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  virtual void do_Return         (Return*          x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  virtual void do_Throw          (Throw*           x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  virtual void do_Base           (Base*            x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  virtual void do_OsrEntry       (OsrEntry*        x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  virtual void do_ExceptionObject(ExceptionObject* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  virtual void do_RoundFP        (RoundFP*         x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  virtual void do_UnsafePutRaw   (UnsafePutRaw*    x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  virtual void do_UnsafeGetObject(UnsafeGetObject* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  virtual void do_UnsafePutObject(UnsafePutObject* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  virtual void do_ProfileCall    (ProfileCall*     x);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   524
  virtual void do_ProfileInvoke  (ProfileInvoke*   x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
class LIRItem: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  Value         _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  LIRGenerator* _gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  LIR_Opr       _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  bool          _destroys_register;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  LIR_Opr       _new_result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  LIRGenerator* gen() const { return _gen; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  LIRItem(Value value, LIRGenerator* gen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    _destroys_register = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    _gen = gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    set_instruction(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  LIRItem(LIRGenerator* gen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    _destroys_register = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    _gen = gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    _result = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
    set_instruction(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  void set_instruction(Value value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
    _value = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    _result = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
    if (_value != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      _gen->walk(_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
      _result = _value->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    _new_result = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  Value value() const          { return _value;          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  ValueType* type() const      { return value()->type(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  LIR_Opr result()             {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
           "shouldn't use set_destroys_register with physical regsiters");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    if (_destroys_register && _result->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
      if (_new_result->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
        _new_result = _gen->new_register(type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
        gen()->lir()->move(_result, _new_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
      return _new_result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
      return _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    return _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  void set_result(LIR_Opr opr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  void load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  void load_byte_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  void load_nonconstant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  // load any values which can't be expressed as part of a single store instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  void load_for_store(BasicType store_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  void load_item_force(LIR_Opr reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  void dont_load_item() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    // do nothing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  void set_destroys_register() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    _destroys_register = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  bool is_constant() const { return value()->as_Constant() != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  bool is_stack()          { return result()->is_stack(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  bool is_register()       { return result()->is_register(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  ciObject* get_jobject_constant() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  jint      get_jint_constant() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  jlong     get_jlong_constant() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  jfloat    get_jfloat_constant() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  jdouble   get_jdouble_constant() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  jint      get_address_constant() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
   607
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6453
diff changeset
   608
#endif // SHARE_VM_C1_C1_LIRGENERATOR_HPP