src/share/vm/c1/c1_CodeStubs.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6198
55fb97c4c58d
parent 0
f90c822e73f8
child 8856
ac27a9c85bea
permissions
-rw-r--r--

merge

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

mercurial