hotspot/src/share/vm/c1/c1_CodeStubs.hpp
author jrose
Tue, 21 Apr 2009 23:21:04 -0700
changeset 2570 ecc7862946d4
parent 1374 4c24294029a9
child 5046 27e801a857cb
permissions -rw-r--r--
6655646: dynamic languages need dynamically linked call sites Summary: invokedynamic instruction (JSR 292 RI) Reviewed-by: twisti, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
class CodeEmitInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class LIR_Assembler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class LIR_OpVisitState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// CodeStubs are little 'out-of-line' pieces of code that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// usually handle slow cases of operations. All code stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// are collected and code is emitted at the end of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// nmethod.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class CodeStub: public CompilationResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  Label _entry;                                  // label at the stub entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  Label _continuation;                           // label where stub continues, if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  CodeStub() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  // code generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  void assert_no_unbound_labels()                { assert(!_entry.is_unbound() && !_continuation.is_unbound(), "unbound label"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  virtual void emit_code(LIR_Assembler* e) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  virtual CodeEmitInfo* info() const             { return NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  virtual bool is_exception_throw_stub() const   { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  virtual bool is_range_check_stub() const       { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  virtual bool is_divbyzero_stub() const         { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  virtual void print_name(outputStream* out) const = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // label access
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  Label* entry()                                 { return &_entry; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  Label* continuation()                          { return &_continuation; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // for LIR
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  virtual void visit(LIR_OpVisitState* visit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    if (LIRTracePeephole && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
      tty->print("no visitor for ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
      print_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
define_array(CodeStubArray, CodeStub*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
define_stack(_CodeStubList, CodeStubArray)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class CodeStubList: public _CodeStubList {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  CodeStubList(): _CodeStubList() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  void append(CodeStub* stub) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    if (!contains(stub)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      _CodeStubList::append(stub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
class CounterOverflowStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  int           _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  CounterOverflowStub(CodeEmitInfo* info, int bci) : _info(info), _bci(bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  virtual void print_name(outputStream* out) const { out->print("CounterOverflowStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
class ConversionStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  Bytecodes::Code _bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  LIR_Opr         _input;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  LIR_Opr         _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  static float float_zero;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  static double double_zero;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  ConversionStub(Bytecodes::Code bytecode, LIR_Opr input, LIR_Opr result)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    : _bytecode(bytecode), _input(input), _result(result) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  Bytecodes::Code bytecode() { return _bytecode; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  LIR_Opr         input()    { return _input; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  LIR_Opr         result()   { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    visitor->do_slow_case();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    visitor->do_input(_input);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    visitor->do_output(_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  virtual void print_name(outputStream* out) const { out->print("ConversionStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
// Throws ArrayIndexOutOfBoundsException by default but can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
// configured to throw IndexOutOfBoundsException in constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
class RangeCheckStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  LIR_Opr       _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  bool          _throw_index_out_of_bounds_exception;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, bool throw_index_out_of_bounds_exception = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  virtual bool is_exception_throw_stub() const   { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  virtual bool is_range_check_stub() const       { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    visitor->do_input(_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  virtual void print_name(outputStream* out) const { out->print("RangeCheckStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
class DivByZeroStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  int           _offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  DivByZeroStub(CodeEmitInfo* info)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    : _info(info), _offset(-1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  DivByZeroStub(int offset, CodeEmitInfo* info)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    : _info(info), _offset(offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  virtual bool is_exception_throw_stub() const   { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  virtual bool is_divbyzero_stub() const         { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  virtual void print_name(outputStream* out) const { out->print("DivByZeroStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
class ImplicitNullCheckStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  int           _offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  ImplicitNullCheckStub(int offset, CodeEmitInfo* info)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    : _offset(offset), _info(info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  virtual bool is_exception_throw_stub() const   { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  virtual void print_name(outputStream* out) const { out->print("ImplicitNullCheckStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
class NewInstanceStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  ciInstanceKlass* _klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  LIR_Opr          _klass_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  LIR_Opr          _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  CodeEmitInfo*    _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  Runtime1::StubID _stub_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    visitor->do_input(_klass_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    visitor->do_output(_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  virtual void print_name(outputStream* out) const { out->print("NewInstanceStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
class NewTypeArrayStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  LIR_Opr       _klass_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  LIR_Opr       _length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  LIR_Opr       _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    visitor->do_input(_klass_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    visitor->do_input(_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    assert(_result->is_valid(), "must be valid"); visitor->do_output(_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  virtual void print_name(outputStream* out) const { out->print("NewTypeArrayStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
class NewObjectArrayStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  LIR_Opr        _klass_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  LIR_Opr        _length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  LIR_Opr        _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  CodeEmitInfo*  _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    visitor->do_input(_klass_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    visitor->do_input(_length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    assert(_result->is_valid(), "must be valid"); visitor->do_output(_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  virtual void print_name(outputStream* out) const { out->print("NewObjectArrayStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
class MonitorAccessStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  LIR_Opr _obj_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  LIR_Opr _lock_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  MonitorAccessStub(LIR_Opr obj_reg, LIR_Opr lock_reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    _obj_reg  = obj_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    _lock_reg  = lock_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  virtual void print_name(outputStream* out) const { out->print("MonitorAccessStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
class MonitorEnterStub: public MonitorAccessStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    visitor->do_input(_obj_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    visitor->do_input(_lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  virtual void print_name(outputStream* out) const { out->print("MonitorEnterStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
class MonitorExitStub: public MonitorAccessStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  bool _compute_lock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  int  _monitor_ix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  MonitorExitStub(LIR_Opr lock_reg, bool compute_lock, int monitor_ix)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    : MonitorAccessStub(LIR_OprFact::illegalOpr, lock_reg),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      _compute_lock(compute_lock), _monitor_ix(monitor_ix) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    assert(_obj_reg->is_illegal(), "unused");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    if (_compute_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      visitor->do_temp(_lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      visitor->do_input(_lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  virtual void print_name(outputStream* out) const { out->print("MonitorExitStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
class PatchingStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  enum PatchID {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    access_field_id,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
    load_klass_id
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  enum constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    patch_info_size = 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  PatchID       _id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  address       _pc_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  int           _bytes_to_copy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  Label         _patched_code_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  Label         _patch_site_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  Label         _patch_site_continuation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  Register      _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  int           _oop_index;  // index of the patchable oop in nmethod oop table if needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  static int    _patch_info_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  void align_patch_site(MacroAssembler* masm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  static int patch_info_offset() { return _patch_info_offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  PatchingStub(MacroAssembler* masm, PatchID id, int oop_index = -1):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
      _id(id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    , _info(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    , _oop_index(oop_index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    if (os::is_MP()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
      // force alignment of patch sites on MP hardware so we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
      // can guarantee atomic writes to the patch site.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
      align_patch_site(masm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    _pc_start = masm->pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    masm->bind(_patch_site_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  void install(MacroAssembler* masm, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    _info = info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    _obj = obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    masm->bind(_patch_site_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    _bytes_to_copy = masm->pc() - pc_start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    if (_id == PatchingStub::access_field_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      // embed a fixed offset to handle long patches which need to be offset by a word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      // the patching code will just add the field offset field to this offset so
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
      // that we can refernce either the high or low word of a double word field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      int field_offset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      switch (patch_code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
      case lir_patch_low:         field_offset = lo_word_offset_in_bytes; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      case lir_patch_high:        field_offset = hi_word_offset_in_bytes; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
      case lir_patch_normal:      field_offset = 0;                       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
      NativeMovRegMem* n_move = nativeMovRegMem_at(pc_start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
      n_move->set_offset(field_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    } else if (_id == load_klass_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
      assert(_obj != noreg, "must have register object for load_klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
      // verify that we're pointing at a NativeMovConstReg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
      nativeMovConstReg_at(pc_start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    assert(_bytes_to_copy <= (masm->pc() - pc_start()), "not enough bytes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  address pc_start() const                       { return _pc_start; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  PatchID id() const                             { return _id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  virtual void print_name(outputStream* out) const { out->print("PatchingStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
class SimpleExceptionStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  LIR_Opr          _obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  Runtime1::StubID _stub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  CodeEmitInfo*    _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  SimpleExceptionStub(Runtime1::StubID stub, LIR_Opr obj, CodeEmitInfo* info):
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    _obj(obj), _info(info), _stub(stub) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  virtual bool is_exception_throw_stub() const   { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    if (_obj->is_valid()) visitor->do_input(_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  virtual void print_name(outputStream* out) const { out->print("SimpleExceptionStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
class ArrayStoreExceptionStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  CodeEmitInfo* _info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  ArrayStoreExceptionStub(CodeEmitInfo* info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  virtual void emit_code(LIR_Assembler* emit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  virtual CodeEmitInfo* info() const             { return _info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  virtual bool is_exception_throw_stub() const   { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    visitor->do_slow_case(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  virtual void print_name(outputStream* out) const { out->print("ArrayStoreExceptionStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
class ArrayCopyStub: public CodeStub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  LIR_OpArrayCopy* _op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  ArrayCopyStub(LIR_OpArrayCopy* op): _op(op) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  LIR_Opr src() const                         { return _op->src(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  LIR_Opr src_pos() const                     { return _op->src_pos(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  LIR_Opr dst() const                         { return _op->dst(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  LIR_Opr dst_pos() const                     { return _op->dst_pos(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  LIR_Opr length() const                      { return _op->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  LIR_Opr tmp() const                         { return _op->tmp(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  virtual void emit_code(LIR_Assembler* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  virtual CodeEmitInfo* info() const          { return _op->info(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  virtual void visit(LIR_OpVisitState* visitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    // don't pass in the code emit info since it's processed in the fast path
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    visitor->do_slow_case();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  virtual void print_name(outputStream* out) const { out->print("ArrayCopyStub"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
};
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   485
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   486
//////////////////////////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   487
#ifndef SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   488
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   489
// Code stubs for Garbage-First barriers.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   490
class G1PreBarrierStub: public CodeStub {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   491
 private:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   492
  LIR_Opr _addr;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   493
  LIR_Opr _pre_val;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   494
  LIR_PatchCode _patch_code;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   495
  CodeEmitInfo* _info;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   496
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   497
 public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   498
  // pre_val (a temporary register) must be a register;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   499
  // addr (the address of the field to be read) must be a LIR_Address
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   500
  G1PreBarrierStub(LIR_Opr addr, LIR_Opr pre_val, LIR_PatchCode patch_code, CodeEmitInfo* info) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   501
    _addr(addr), _pre_val(pre_val), _patch_code(patch_code), _info(info)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   502
  {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   503
    assert(_pre_val->is_register(), "should be temporary register");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   504
    assert(_addr->is_address(), "should be the address of the field");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   505
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   506
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   507
  LIR_Opr addr() const { return _addr; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   508
  LIR_Opr pre_val() const { return _pre_val; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   509
  LIR_PatchCode patch_code() const { return _patch_code; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   510
  CodeEmitInfo* info() const { return _info; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   511
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   512
  virtual void emit_code(LIR_Assembler* e);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   513
  virtual void visit(LIR_OpVisitState* visitor) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   514
    // don't pass in the code emit info since it's processed in the fast
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   515
    // path
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   516
    if (_info != NULL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   517
      visitor->do_slow_case(_info);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   518
    else
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   519
      visitor->do_slow_case();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   520
    visitor->do_input(_addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   521
    visitor->do_temp(_pre_val);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   522
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   523
#ifndef PRODUCT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   524
  virtual void print_name(outputStream* out) const { out->print("G1PreBarrierStub"); }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   525
#endif // PRODUCT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   526
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   527
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   528
class G1PostBarrierStub: public CodeStub {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   529
 private:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   530
  LIR_Opr _addr;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   531
  LIR_Opr _new_val;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   532
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   533
  static jbyte* _byte_map_base;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   534
  static jbyte* byte_map_base_slow();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   535
  static jbyte* byte_map_base() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   536
    if (_byte_map_base == NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   537
      _byte_map_base = byte_map_base_slow();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   538
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   539
    return _byte_map_base;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   540
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   541
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   542
 public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   543
  // addr (the address of the object head) and new_val must be registers.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   544
  G1PostBarrierStub(LIR_Opr addr, LIR_Opr new_val): _addr(addr), _new_val(new_val) { }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   545
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   546
  LIR_Opr addr() const { return _addr; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   547
  LIR_Opr new_val() const { return _new_val; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   548
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   549
  virtual void emit_code(LIR_Assembler* e);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   550
  virtual void visit(LIR_OpVisitState* visitor) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   551
    // don't pass in the code emit info since it's processed in the fast path
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   552
    visitor->do_slow_case();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   553
    visitor->do_input(_addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   554
    visitor->do_input(_new_val);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   555
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   556
#ifndef PRODUCT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   557
  virtual void print_name(outputStream* out) const { out->print("G1PostBarrierStub"); }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   558
#endif // PRODUCT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   559
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   560
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   561
#endif // SERIALGC
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   562
//////////////////////////////////////////////////////////////////////////////////////////