304 template <DecoratorSet decorators> |
304 template <DecoratorSet decorators> |
305 oop resolve(oop src); |
305 oop resolve(oop src); |
306 |
306 |
307 // Infer the type that should be returned from a load. |
307 // Infer the type that should be returned from a load. |
308 template <typename P, DecoratorSet decorators> |
308 template <typename P, DecoratorSet decorators> |
309 class LoadProxy: public StackObj { |
309 class OopLoadProxy: public StackObj { |
310 private: |
310 private: |
311 P *const _addr; |
311 P *const _addr; |
312 public: |
312 public: |
313 LoadProxy(P* addr) : _addr(addr) {} |
313 OopLoadProxy(P* addr) : _addr(addr) {} |
314 |
314 |
315 template <typename T> |
315 inline operator oop() { |
316 inline operator T() { |
316 return load<decorators | INTERNAL_VALUE_IS_OOP, P, oop>(_addr); |
317 return load<decorators, P, T>(_addr); |
317 } |
318 } |
318 |
319 |
319 inline operator narrowOop() { |
320 inline operator P() { |
320 return load<decorators | INTERNAL_VALUE_IS_OOP, P, narrowOop>(_addr); |
321 return load<decorators, P, P>(_addr); |
321 } |
|
322 |
|
323 template <typename T> |
|
324 inline bool operator ==(const T& other) const { |
|
325 return load<decorators | INTERNAL_VALUE_IS_OOP, P, T>(_addr) == other; |
|
326 } |
|
327 |
|
328 template <typename T> |
|
329 inline bool operator !=(const T& other) const { |
|
330 return load<decorators | INTERNAL_VALUE_IS_OOP, P, T>(_addr) != other; |
322 } |
331 } |
323 }; |
332 }; |
324 |
333 |
325 // Infer the type that should be returned from a load_at. |
334 // Infer the type that should be returned from a load_at. |
326 template <DecoratorSet decorators> |
335 template <DecoratorSet decorators> |
332 LoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {} |
341 LoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {} |
333 |
342 |
334 template <typename T> |
343 template <typename T> |
335 inline operator T() const { |
344 inline operator T() const { |
336 return load_at<decorators, T>(_base, _offset); |
345 return load_at<decorators, T>(_base, _offset); |
|
346 } |
|
347 |
|
348 template <typename T> |
|
349 inline bool operator ==(const T& other) const { return load_at<decorators, T>(_base, _offset) == other; } |
|
350 |
|
351 template <typename T> |
|
352 inline bool operator !=(const T& other) const { return load_at<decorators, T>(_base, _offset) != other; } |
|
353 }; |
|
354 |
|
355 template <DecoratorSet decorators> |
|
356 class OopLoadAtProxy: public StackObj { |
|
357 private: |
|
358 const oop _base; |
|
359 const ptrdiff_t _offset; |
|
360 public: |
|
361 OopLoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {} |
|
362 |
|
363 inline operator oop() const { |
|
364 return load_at<decorators | INTERNAL_VALUE_IS_OOP, oop>(_base, _offset); |
|
365 } |
|
366 |
|
367 inline operator narrowOop() const { |
|
368 return load_at<decorators | INTERNAL_VALUE_IS_OOP, narrowOop>(_base, _offset); |
|
369 } |
|
370 |
|
371 template <typename T> |
|
372 inline bool operator ==(const T& other) const { |
|
373 return load_at<decorators | INTERNAL_VALUE_IS_OOP, T>(_base, _offset) == other; |
|
374 } |
|
375 |
|
376 template <typename T> |
|
377 inline bool operator !=(const T& other) const { |
|
378 return load_at<decorators | INTERNAL_VALUE_IS_OOP, T>(_base, _offset) != other; |
337 } |
379 } |
338 }; |
380 }; |
339 } |
381 } |
340 |
382 |
341 template <DecoratorSet decorators = INTERNAL_EMPTY> |
383 template <DecoratorSet decorators = INTERNAL_EMPTY> |
407 AS_DECORATOR_MASK>(); |
449 AS_DECORATOR_MASK>(); |
408 AccessInternal::arraycopy<decorators>(src_obj, dst_obj, src, dst, length); |
450 AccessInternal::arraycopy<decorators>(src_obj, dst_obj, src, dst, length); |
409 } |
451 } |
410 |
452 |
411 // Oop heap accesses |
453 // Oop heap accesses |
412 static inline AccessInternal::LoadAtProxy<decorators | INTERNAL_VALUE_IS_OOP> oop_load_at(oop base, ptrdiff_t offset) { |
454 static inline AccessInternal::OopLoadAtProxy<decorators> oop_load_at(oop base, ptrdiff_t offset) { |
413 verify_heap_oop_decorators<load_mo_decorators>(); |
455 verify_heap_oop_decorators<load_mo_decorators>(); |
414 return AccessInternal::LoadAtProxy<decorators | INTERNAL_VALUE_IS_OOP>(base, offset); |
456 return AccessInternal::OopLoadAtProxy<decorators>(base, offset); |
415 } |
457 } |
416 |
458 |
417 template <typename T> |
459 template <typename T> |
418 static inline void oop_store_at(oop base, ptrdiff_t offset, T value) { |
460 static inline void oop_store_at(oop base, ptrdiff_t offset, T value) { |
419 verify_heap_oop_decorators<store_mo_decorators>(); |
461 verify_heap_oop_decorators<store_mo_decorators>(); |
476 return AccessInternal::atomic_xchg<decorators>(new_value, addr); |
518 return AccessInternal::atomic_xchg<decorators>(new_value, addr); |
477 } |
519 } |
478 |
520 |
479 // Oop accesses |
521 // Oop accesses |
480 template <typename P> |
522 template <typename P> |
481 static inline AccessInternal::LoadProxy<P, decorators | INTERNAL_VALUE_IS_OOP> oop_load(P* addr) { |
523 static inline AccessInternal::OopLoadProxy<P, decorators> oop_load(P* addr) { |
482 verify_oop_decorators<load_mo_decorators>(); |
524 verify_oop_decorators<load_mo_decorators>(); |
483 return AccessInternal::LoadProxy<P, decorators | INTERNAL_VALUE_IS_OOP>(addr); |
525 return AccessInternal::OopLoadProxy<P, decorators>(addr); |
484 } |
526 } |
485 |
527 |
486 template <typename P, typename T> |
528 template <typename P, typename T> |
487 static inline void oop_store(P* addr, T value) { |
529 static inline void oop_store(P* addr, T value) { |
488 verify_oop_decorators<store_mo_decorators>(); |
530 verify_oop_decorators<store_mo_decorators>(); |