< prev index next >

src/share/vm/oops/oop.inline.hpp

Print this page




  28 #include "gc_implementation/shared/ageTable.hpp"
  29 #include "gc_implementation/shared/markSweep.inline.hpp"
  30 #include "gc_interface/collectedHeap.inline.hpp"
  31 #include "memory/barrierSet.inline.hpp"
  32 #include "memory/cardTableModRefBS.hpp"
  33 #include "memory/genCollectedHeap.hpp"
  34 #include "memory/generation.hpp"
  35 #include "memory/specialized_oop_closures.hpp"
  36 #include "oops/arrayKlass.hpp"
  37 #include "oops/arrayOop.hpp"
  38 #include "oops/klass.inline.hpp"
  39 #include "oops/markOop.inline.hpp"
  40 #include "oops/oop.hpp"
  41 #include "runtime/atomic.inline.hpp"
  42 #include "runtime/orderAccess.inline.hpp"
  43 #include "runtime/os.hpp"
  44 #include "utilities/macros.hpp"
  45 #ifdef TARGET_ARCH_x86
  46 # include "bytes_x86.hpp"
  47 #endif



  48 #ifdef TARGET_ARCH_sparc
  49 # include "bytes_sparc.hpp"
  50 #endif
  51 #ifdef TARGET_ARCH_zero
  52 # include "bytes_zero.hpp"
  53 #endif
  54 #ifdef TARGET_ARCH_arm
  55 # include "bytes_arm.hpp"
  56 #endif
  57 #ifdef TARGET_ARCH_ppc
  58 # include "bytes_ppc.hpp"
  59 #endif
  60 




  61 // Implementation of all inlined member functions defined in oop.hpp
  62 // We need a separate file to avoid circular references
  63 
  64 inline void oopDesc::release_set_mark(markOop m) {
  65   OrderAccess::release_store_ptr(&_mark, m);
  66 }
  67 
  68 inline markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
  69   return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark);
  70 }
  71 
  72 inline Klass* oopDesc::klass() const {
  73   if (UseCompressedClassPointers) {
  74     return Klass::decode_klass_not_null(_metadata._compressed_klass);
  75   } else {
  76     return _metadata._klass;
  77   }
  78 }
  79 
  80 inline Klass* oopDesc::klass_or_null() const volatile {


 271 }
 272 
 273 inline void oopDesc::release_encode_store_heap_oop_not_null(
 274                                                       volatile oop* p, oop v) {
 275   OrderAccess::release_store_ptr(p, v);
 276 }
 277 
 278 inline void oopDesc::release_encode_store_heap_oop(volatile oop* p,
 279                                                            oop v) {
 280   OrderAccess::release_store_ptr(p, v);
 281 }
 282 inline void oopDesc::release_encode_store_heap_oop(
 283                                                 volatile narrowOop* p, oop v) {
 284   OrderAccess::release_store(p, encode_heap_oop(v));
 285 }
 286 
 287 
 288 // These functions are only used to exchange oop fields in instances,
 289 // not headers.
 290 inline oop oopDesc::atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest) {

 291   if (UseCompressedOops) {
 292     // encode exchange value from oop to T
 293     narrowOop val = encode_heap_oop(exchange_value);
 294     narrowOop old = (narrowOop)Atomic::xchg(val, (narrowOop*)dest);
 295     // decode old from T to oop
 296     return decode_heap_oop(old);
 297   } else {
 298     return (oop)Atomic::xchg_ptr(exchange_value, (oop*)dest);
 299   }









 300 }
 301 
 302 // In order to put or get a field out of an instance, must first check
 303 // if the field has been compressed and uncompress it.
 304 inline oop oopDesc::obj_field(int offset) const {
 305   return UseCompressedOops ?
 306     load_decode_heap_oop(obj_field_addr<narrowOop>(offset)) :
 307     load_decode_heap_oop(obj_field_addr<oop>(offset));






 308 }
 309 inline volatile oop oopDesc::obj_field_volatile(int offset) const {
 310   volatile oop value = obj_field(offset);
 311   OrderAccess::acquire();
 312   return value;
 313 }
 314 inline void oopDesc::obj_field_put(int offset, oop value) {
 315   UseCompressedOops ? oop_store(obj_field_addr<narrowOop>(offset), value) :
 316                       oop_store(obj_field_addr<oop>(offset),       value);
 317 }
 318 
 319 inline Metadata* oopDesc::metadata_field(int offset) const {
 320   return *metadata_field_addr(offset);
 321 }
 322 
 323 inline void oopDesc::metadata_field_put(int offset, Metadata* value) {
 324   *metadata_field_addr(offset) = value;
 325 }
 326 
 327 inline void oopDesc::obj_field_put_raw(int offset, oop value) {
 328   UseCompressedOops ?
 329     encode_store_heap_oop(obj_field_addr<narrowOop>(offset), value) :
 330     encode_store_heap_oop(obj_field_addr<oop>(offset),       value);
 331 }
 332 inline void oopDesc::obj_field_put_volatile(int offset, oop value) {
 333   OrderAccess::release();
 334   obj_field_put(offset, value);
 335   OrderAccess::fence();
 336 }
 337 
 338 inline jbyte oopDesc::byte_field(int offset) const                  { return (jbyte) *byte_field_addr(offset);    }
 339 inline void oopDesc::byte_field_put(int offset, jbyte contents)     { *byte_field_addr(offset) = (jint) contents; }
 340 
 341 inline jboolean oopDesc::bool_field(int offset) const               { return (jboolean) *bool_field_addr(offset); }
 342 inline void oopDesc::bool_field_put(int offset, jboolean contents)  { *bool_field_addr(offset) = (( (jint) contents) & 1); }
 343 
 344 inline jchar oopDesc::char_field(int offset) const                  { return (jchar) *char_field_addr(offset);    }
 345 inline void oopDesc::char_field_put(int offset, jchar contents)     { *char_field_addr(offset) = (jint) contents; }
 346 
 347 inline jint oopDesc::int_field(int offset) const                    { return *int_field_addr(offset);        }
 348 inline void oopDesc::int_field_put(int offset, jint contents)       { *int_field_addr(offset) = contents;    }
 349 
 350 inline jshort oopDesc::short_field(int offset) const                { return (jshort) *short_field_addr(offset);  }
 351 inline void oopDesc::short_field_put(int offset, jshort contents)   { *short_field_addr(offset) = (jint) contents;}
 352 
 353 inline jlong oopDesc::long_field(int offset) const                  { return *long_field_addr(offset);       }
 354 inline void oopDesc::long_field_put(int offset, jlong contents)     { *long_field_addr(offset) = contents;   }
 355 
 356 inline jfloat oopDesc::float_field(int offset) const                { return *float_field_addr(offset);      }
 357 inline void oopDesc::float_field_put(int offset, jfloat contents)   { *float_field_addr(offset) = contents;  }
 358 
 359 inline jdouble oopDesc::double_field(int offset) const              { return *double_field_addr(offset);     }
 360 inline void oopDesc::double_field_put(int offset, jdouble contents) { *double_field_addr(offset) = contents; }
 361 
 362 inline address oopDesc::address_field(int offset) const              { return *address_field_addr(offset);     }
 363 inline void oopDesc::address_field_put(int offset, address contents) { *address_field_addr(offset) = contents; }
 364 
 365 inline oop oopDesc::obj_field_acquire(int offset) const {
 366   return UseCompressedOops ?
 367              decode_heap_oop((narrowOop)
 368                OrderAccess::load_acquire(obj_field_addr<narrowOop>(offset)))
 369            : decode_heap_oop((oop)
 370                OrderAccess::load_ptr_acquire(obj_field_addr<oop>(offset)));






 371 }
 372 inline void oopDesc::release_obj_field_put(int offset, oop value) {
 373   UseCompressedOops ?
 374     oop_store((volatile narrowOop*)obj_field_addr<narrowOop>(offset), value) :
 375     oop_store((volatile oop*)      obj_field_addr<oop>(offset),       value);
 376 }
 377 
 378 inline jbyte oopDesc::byte_field_acquire(int offset) const                  { return OrderAccess::load_acquire(byte_field_addr(offset));     }
 379 inline void oopDesc::release_byte_field_put(int offset, jbyte contents)     { OrderAccess::release_store(byte_field_addr(offset), contents); }
 380 
 381 inline jboolean oopDesc::bool_field_acquire(int offset) const               { return OrderAccess::load_acquire(bool_field_addr(offset));     }
 382 inline void oopDesc::release_bool_field_put(int offset, jboolean contents)  { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); }
 383 
 384 inline jchar oopDesc::char_field_acquire(int offset) const                  { return OrderAccess::load_acquire(char_field_addr(offset));     }
 385 inline void oopDesc::release_char_field_put(int offset, jchar contents)     { OrderAccess::release_store(char_field_addr(offset), contents); }
 386 
 387 inline jint oopDesc::int_field_acquire(int offset) const                    { return OrderAccess::load_acquire(int_field_addr(offset));      }
 388 inline void oopDesc::release_int_field_put(int offset, jint contents)       { OrderAccess::release_store(int_field_addr(offset), contents);  }
 389 
 390 inline jshort oopDesc::short_field_acquire(int offset) const                { return (jshort)OrderAccess::load_acquire(short_field_addr(offset)); }
 391 inline void oopDesc::release_short_field_put(int offset, jshort contents)   { OrderAccess::release_store(short_field_addr(offset), contents);     }
 392 
 393 inline jlong oopDesc::long_field_acquire(int offset) const                  { return OrderAccess::load_acquire(long_field_addr(offset));       }
 394 inline void oopDesc::release_long_field_put(int offset, jlong contents)     { OrderAccess::release_store(long_field_addr(offset), contents);   }
 395 
 396 inline jfloat oopDesc::float_field_acquire(int offset) const                { return OrderAccess::load_acquire(float_field_addr(offset));      }
 397 inline void oopDesc::release_float_field_put(int offset, jfloat contents)   { OrderAccess::release_store(float_field_addr(offset), contents);  }
 398 
 399 inline jdouble oopDesc::double_field_acquire(int offset) const              { return OrderAccess::load_acquire(double_field_addr(offset));     }
 400 inline void oopDesc::release_double_field_put(int offset, jdouble contents) { OrderAccess::release_store(double_field_addr(offset), contents); }
 401 
 402 inline address oopDesc::address_field_acquire(int offset) const             { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); }
 403 inline void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); }
 404 
 405 inline int oopDesc::size_given_klass(Klass* klass)  {
 406   int lh = klass->layout_helper();
 407   int s;
 408 
 409   // lh is now a value computed at class initialization that may hint
 410   // at the size.  For instances, this is positive and equal to the
 411   // size.  For arrays, this is negative and provides log2 of the


 523   // not the new value v at p due to reordering of the two
 524   // stores. Note that CMS has a concurrent precleaning phase, where
 525   // it reads the card table while the Java threads are running.
 526   update_barrier_set((void*)p, v, true /* release */);    // cast away type
 527 }
 528 
 529 // Should replace *addr = oop assignments where addr type depends on UseCompressedOops
 530 // (without having to remember the function name this calls).
 531 inline void oop_store_raw(HeapWord* addr, oop value) {
 532   if (UseCompressedOops) {
 533     oopDesc::encode_store_heap_oop((narrowOop*)addr, value);
 534   } else {
 535     oopDesc::encode_store_heap_oop((oop*)addr, value);
 536   }
 537 }
 538 
 539 inline oop oopDesc::atomic_compare_exchange_oop(oop exchange_value,
 540                                                 volatile HeapWord *dest,
 541                                                 oop compare_value,
 542                                                 bool prebarrier) {





 543   if (UseCompressedOops) {
 544     if (prebarrier) {
 545       update_barrier_set_pre((narrowOop*)dest, exchange_value);
 546     }
 547     // encode exchange and compare value from oop to T
 548     narrowOop val = encode_heap_oop(exchange_value);
 549     narrowOop cmp = encode_heap_oop(compare_value);
 550 
 551     narrowOop old = (narrowOop) Atomic::cmpxchg(val, (narrowOop*)dest, cmp);
 552     // decode old from T to oop
 553     return decode_heap_oop(old);
 554   } else {
 555     if (prebarrier) {
 556       update_barrier_set_pre((oop*)dest, exchange_value);
 557     }
 558     return (oop)Atomic::cmpxchg_ptr(exchange_value, (oop*)dest, compare_value);
 559   }
 560 }
 561 
 562 // Used only for markSweep, scavenging




  28 #include "gc_implementation/shared/ageTable.hpp"
  29 #include "gc_implementation/shared/markSweep.inline.hpp"
  30 #include "gc_interface/collectedHeap.inline.hpp"
  31 #include "memory/barrierSet.inline.hpp"
  32 #include "memory/cardTableModRefBS.hpp"
  33 #include "memory/genCollectedHeap.hpp"
  34 #include "memory/generation.hpp"
  35 #include "memory/specialized_oop_closures.hpp"
  36 #include "oops/arrayKlass.hpp"
  37 #include "oops/arrayOop.hpp"
  38 #include "oops/klass.inline.hpp"
  39 #include "oops/markOop.inline.hpp"
  40 #include "oops/oop.hpp"
  41 #include "runtime/atomic.inline.hpp"
  42 #include "runtime/orderAccess.inline.hpp"
  43 #include "runtime/os.hpp"
  44 #include "utilities/macros.hpp"
  45 #ifdef TARGET_ARCH_x86
  46 # include "bytes_x86.hpp"
  47 #endif
  48 #ifdef TARGET_ARCH_aarch64
  49 # include "bytes_aarch64.hpp"
  50 #endif
  51 #ifdef TARGET_ARCH_sparc
  52 # include "bytes_sparc.hpp"
  53 #endif
  54 #ifdef TARGET_ARCH_zero
  55 # include "bytes_zero.hpp"
  56 #endif
  57 #ifdef TARGET_ARCH_arm
  58 # include "bytes_arm.hpp"
  59 #endif
  60 #ifdef TARGET_ARCH_ppc
  61 # include "bytes_ppc.hpp"
  62 #endif
  63 
  64 #if INCLUDE_ALL_GCS
  65 #include "gc_implementation/shenandoah/shenandoahBarrierSet.hpp"
  66 #endif
  67 
  68 // Implementation of all inlined member functions defined in oop.hpp
  69 // We need a separate file to avoid circular references
  70 
  71 inline void oopDesc::release_set_mark(markOop m) {
  72   OrderAccess::release_store_ptr(&_mark, m);
  73 }
  74 
  75 inline markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
  76   return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark);
  77 }
  78 
  79 inline Klass* oopDesc::klass() const {
  80   if (UseCompressedClassPointers) {
  81     return Klass::decode_klass_not_null(_metadata._compressed_klass);
  82   } else {
  83     return _metadata._klass;
  84   }
  85 }
  86 
  87 inline Klass* oopDesc::klass_or_null() const volatile {


 278 }
 279 
 280 inline void oopDesc::release_encode_store_heap_oop_not_null(
 281                                                       volatile oop* p, oop v) {
 282   OrderAccess::release_store_ptr(p, v);
 283 }
 284 
 285 inline void oopDesc::release_encode_store_heap_oop(volatile oop* p,
 286                                                            oop v) {
 287   OrderAccess::release_store_ptr(p, v);
 288 }
 289 inline void oopDesc::release_encode_store_heap_oop(
 290                                                 volatile narrowOop* p, oop v) {
 291   OrderAccess::release_store(p, encode_heap_oop(v));
 292 }
 293 
 294 
 295 // These functions are only used to exchange oop fields in instances,
 296 // not headers.
 297 inline oop oopDesc::atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest) {
 298   oop result;
 299   if (UseCompressedOops) {
 300     // encode exchange value from oop to T
 301     narrowOop val = encode_heap_oop(exchange_value);
 302     narrowOop old = (narrowOop)Atomic::xchg(val, (narrowOop*)dest);
 303     // decode old from T to oop
 304     result = decode_heap_oop(old);
 305   } else {
 306     result = (oop)Atomic::xchg_ptr(exchange_value, (oop*)dest);
 307   }
 308 #if INCLUDE_ALL_GCS
 309   if (UseShenandoahGC) {
 310     if (exchange_value != NULL) {
 311       ShenandoahBarrierSet::barrier_set()->storeval_barrier(exchange_value);
 312     }
 313     result = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(result);
 314   }
 315 #endif
 316   return result;
 317 }
 318 
 319 // In order to put or get a field out of an instance, must first check
 320 // if the field has been compressed and uncompress it.
 321 inline oop oopDesc::obj_field(int offset) const {
 322   oop obj = UseCompressedOops ?
 323     load_decode_heap_oop(obj_field_addr<narrowOop>(offset)) :
 324     load_decode_heap_oop(obj_field_addr<oop>(offset));
 325 #if INCLUDE_ALL_GCS
 326   if (UseShenandoahGC) {
 327     obj = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(obj);
 328   }
 329 #endif
 330   return obj;
 331 }
 332 inline volatile oop oopDesc::obj_field_volatile(int offset) const {
 333   volatile oop value = obj_field(offset);
 334   OrderAccess::acquire();
 335   return value;
 336 }
 337 inline void oopDesc::obj_field_put(int offset, oop value) {
 338   UseCompressedOops ? oop_store(obj_field_addr<narrowOop>(offset), value) :
 339                       oop_store(obj_field_addr<oop>(offset),       value);
 340 }
 341 
 342 inline Metadata* oopDesc::metadata_field(int offset) const {
 343   return *metadata_field_addr(offset);
 344 }
 345 
 346 inline void oopDesc::metadata_field_put(int offset, Metadata* value) {
 347   *metadata_field_addr(offset) = value;
 348 }
 349 
 350 inline void oopDesc::obj_field_put_raw(int offset, oop value) {
 351   UseCompressedOops ?
 352     encode_store_heap_oop(obj_field_addr<narrowOop>(offset), value) :
 353     encode_store_heap_oop(obj_field_addr<oop>(offset),       value);
 354 }
 355 inline void oopDesc::obj_field_put_volatile(int offset, oop value) {
 356   OrderAccess::release();
 357   obj_field_put(offset, value);
 358   OrderAccess::fence();
 359 }
 360 
 361 inline jbyte oopDesc::byte_field(int offset) const                  { return (jbyte) *byte_field_addr(offset);    }
 362 inline void oopDesc::byte_field_put(int offset, jbyte contents)     { *byte_field_addr(offset) = (jint) contents; }
 363 
 364 inline jboolean oopDesc::bool_field(int offset) const               { return (jboolean) *bool_field_addr(offset); }
 365 inline void oopDesc::bool_field_put(int offset, jboolean contents)  { *bool_field_addr(offset) =  (( (jint) contents) & 1); }
 366 
 367 inline jchar oopDesc::char_field(int offset) const                  { return (jchar) *char_field_addr(offset);    }
 368 inline void oopDesc::char_field_put(int offset, jchar contents)     { *char_field_addr(offset) = (jint) contents; }
 369 
 370 inline jint oopDesc::int_field(int offset) const                    { return *int_field_addr(offset);        }
 371 inline void oopDesc::int_field_put(int offset, jint contents)       { *int_field_addr(offset) = contents;    }
 372 
 373 inline jshort oopDesc::short_field(int offset) const                { return (jshort) *short_field_addr(offset);  }
 374 inline void oopDesc::short_field_put(int offset, jshort contents)   { *short_field_addr(offset) = (jint) contents;}
 375 
 376 inline jlong oopDesc::long_field(int offset) const                  { return *long_field_addr(offset);       }
 377 inline void oopDesc::long_field_put(int offset, jlong contents)     { *long_field_addr(offset) = contents;   }
 378 
 379 inline jfloat oopDesc::float_field(int offset) const                { return *float_field_addr(offset);      }
 380 inline void oopDesc::float_field_put(int offset, jfloat contents)   { *float_field_addr(offset) = contents;  }
 381 
 382 inline jdouble oopDesc::double_field(int offset) const              { return *double_field_addr(offset);     }
 383 inline void oopDesc::double_field_put(int offset, jdouble contents) { *double_field_addr(offset) = contents; }
 384 
 385 inline address oopDesc::address_field(int offset) const              { return *address_field_addr(offset);     }
 386 inline void oopDesc::address_field_put(int offset, address contents) { *address_field_addr(offset) = contents; }
 387 
 388 inline oop oopDesc::obj_field_acquire(int offset) const {
 389   oop obj = UseCompressedOops ?
 390              decode_heap_oop((narrowOop)
 391                OrderAccess::load_acquire(obj_field_addr<narrowOop>(offset)))
 392            : decode_heap_oop((oop)
 393                OrderAccess::load_ptr_acquire(obj_field_addr<oop>(offset)));
 394 #if INCLUDE_ALL_GCS
 395   if (UseShenandoahGC) {
 396     obj = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(obj);
 397   }
 398 #endif
 399   return obj;
 400 }
 401 inline void oopDesc::release_obj_field_put(int offset, oop value) {
 402   UseCompressedOops ?
 403     oop_store((volatile narrowOop*)obj_field_addr<narrowOop>(offset), value) :
 404     oop_store((volatile oop*)      obj_field_addr<oop>(offset),       value);
 405 }
 406 
 407 inline jbyte oopDesc::byte_field_acquire(int offset) const                  { return OrderAccess::load_acquire(byte_field_addr(offset));     }
 408 inline void oopDesc::release_byte_field_put(int offset, jbyte contents)     { OrderAccess::release_store(byte_field_addr(offset), contents); }
 409 
 410 inline jboolean oopDesc::bool_field_acquire(int offset) const               { return OrderAccess::load_acquire(bool_field_addr(offset));     }
 411 inline void oopDesc::release_bool_field_put(int offset, jboolean contents)  { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); }
 412 
 413 inline jchar oopDesc::char_field_acquire(int offset) const                  { return OrderAccess::load_acquire(char_field_addr(offset));     }
 414 inline void oopDesc::release_char_field_put(int offset, jchar contents)     { OrderAccess::release_store(char_field_addr(offset), contents); }
 415 
 416 inline jint oopDesc::int_field_acquire(int offset) const                    { return OrderAccess::load_acquire(int_field_addr(offset));      }
 417 inline void oopDesc::release_int_field_put(int offset, jint contents)       { OrderAccess::release_store(int_field_addr(offset), contents);  }
 418 
 419 inline jshort oopDesc::short_field_acquire(int offset) const                { return (jshort)OrderAccess::load_acquire(short_field_addr(offset)); }
 420 inline void oopDesc::release_short_field_put(int offset, jshort contents)   { OrderAccess::release_store(short_field_addr(offset), contents); }
 421 
 422 inline jlong oopDesc::long_field_acquire(int offset) const                  { return OrderAccess::load_acquire(long_field_addr(offset));       }
 423 inline void oopDesc::release_long_field_put(int offset, jlong contents)     { OrderAccess::release_store(long_field_addr(offset), contents);   }
 424 
 425 inline jfloat oopDesc::float_field_acquire(int offset) const                { return OrderAccess::load_acquire(float_field_addr(offset));      }
 426 inline void oopDesc::release_float_field_put(int offset, jfloat contents)   { OrderAccess::release_store(float_field_addr(offset), contents);  }
 427 
 428 inline jdouble oopDesc::double_field_acquire(int offset) const              { return OrderAccess::load_acquire(double_field_addr(offset));     }
 429 inline void oopDesc::release_double_field_put(int offset, jdouble contents) { OrderAccess::release_store(double_field_addr(offset), contents); }
 430 
 431 inline address oopDesc::address_field_acquire(int offset) const             { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); }
 432 inline void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); }
 433 
 434 inline int oopDesc::size_given_klass(Klass* klass)  {
 435   int lh = klass->layout_helper();
 436   int s;
 437 
 438   // lh is now a value computed at class initialization that may hint
 439   // at the size.  For instances, this is positive and equal to the
 440   // size.  For arrays, this is negative and provides log2 of the


 552   // not the new value v at p due to reordering of the two
 553   // stores. Note that CMS has a concurrent precleaning phase, where
 554   // it reads the card table while the Java threads are running.
 555   update_barrier_set((void*)p, v, true /* release */);    // cast away type
 556 }
 557 
 558 // Should replace *addr = oop assignments where addr type depends on UseCompressedOops
 559 // (without having to remember the function name this calls).
 560 inline void oop_store_raw(HeapWord* addr, oop value) {
 561   if (UseCompressedOops) {
 562     oopDesc::encode_store_heap_oop((narrowOop*)addr, value);
 563   } else {
 564     oopDesc::encode_store_heap_oop((oop*)addr, value);
 565   }
 566 }
 567 
 568 inline oop oopDesc::atomic_compare_exchange_oop(oop exchange_value,
 569                                                 volatile HeapWord *dest,
 570                                                 oop compare_value,
 571                                                 bool prebarrier) {
 572 #if INCLUDE_ALL_GCS
 573   if (UseShenandoahGC && ShenandoahCASBarrier) {
 574     return ShenandoahBarrierSet::barrier_set()->oop_atomic_cmpxchg_in_heap(exchange_value, dest, compare_value);
 575   }
 576 #endif
 577   if (UseCompressedOops) {
 578     if (prebarrier) {
 579       update_barrier_set_pre((narrowOop*)dest, exchange_value);
 580     }
 581     // encode exchange and compare value from oop to T
 582     narrowOop val = encode_heap_oop(exchange_value);
 583     narrowOop cmp = encode_heap_oop(compare_value);
 584 
 585     narrowOop old = (narrowOop) Atomic::cmpxchg(val, (narrowOop*)dest, cmp);
 586     // decode old from T to oop
 587     return decode_heap_oop(old);
 588   } else {
 589     if (prebarrier) {
 590       update_barrier_set_pre((oop*)dest, exchange_value);
 591     }
 592     return (oop)Atomic::cmpxchg_ptr(exchange_value, (oop*)dest, compare_value);
 593   }
 594 }
 595 
 596 // Used only for markSweep, scavenging


< prev index next >