src/share/vm/oops/klass.inline.hpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
bug_8003424.4 Cdiff src/share/vm/oops/klass.inline.hpp
src/share/vm/oops/klass.inline.hpp
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 23,36 ****
--- 23,74 ----
*/
#ifndef SHARE_VM_OOPS_KLASS_INLINE_HPP
#define SHARE_VM_OOPS_KLASS_INLINE_HPP
+ #include "memory/universe.hpp"
#include "oops/klass.hpp"
#include "oops/markOop.hpp"
inline void Klass::set_prototype_header(markOop header) {
assert(!header->has_bias_pattern() || oop_is_instance(), "biased locking currently only supported for Java instances");
_prototype_header = header;
}
+ inline bool Klass::is_null(Klass* obj) { return obj == NULL; }
+ inline bool Klass::is_null(narrowKlass obj) { return obj == 0; }
+
+ // Encoding and decoding for klass field.
+
+ inline bool check_klass_alignment(Klass* obj) {
+ return (intptr_t)obj % KlassAlignmentInBytes == 0;
+ }
+
+ inline narrowKlass Klass::encode_klass_not_null(Klass* v) {
+ assert(!is_null(v), "klass value can never be zero");
+ assert(check_klass_alignment(v), "Address not aligned");
+ int shift = Universe::narrow_klass_shift();
+ uint64_t pd = (uint64_t)(pointer_delta((void*)v, Universe::narrow_klass_base(), 1));
+ assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding");
+ uint64_t result = pd >> shift;
+ assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow");
+ assert(decode_klass(result) == v, "reversibility");
+ return (narrowKlass)result;
+ }
+
+ inline narrowKlass Klass::encode_klass(Klass* v) {
+ return is_null(v) ? (narrowKlass)0 : encode_klass_not_null(v);
+ }
+
+ inline Klass* Klass::decode_klass_not_null(narrowKlass v) {
+ assert(!is_null(v), "narrow klass value can never be zero");
+ int shift = Universe::narrow_klass_shift();
+ Klass* result = (Klass*)(void*)((uintptr_t)Universe::narrow_klass_base() + ((uintptr_t)v << shift));
+ assert(check_klass_alignment(result), err_msg("address not aligned: " PTR_FORMAT, (void*) result));
+ return result;
+ }
+
+ inline Klass* Klass::decode_klass(narrowKlass v) {
+ return is_null(v) ? (Klass*)NULL : decode_klass_not_null(v);
+ }
+
#endif // SHARE_VM_OOPS_KLASS_INLINE_HPP
src/share/vm/oops/klass.inline.hpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File