src/share/vm/c1/c1_CodeStubs.hpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 8856
ac27a9c85bea
permissions
-rw-r--r--

Merge

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

mercurial