/* * Copyright (c) 2017, 2022, 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// = GENERAL = // Access is an API for performing accesses with declarative semantics. Each access can have a number of "decorators". // A decorator is an attribute or property that affects the way a memory access is performed in some way. // There are different groups of decorators. Some have to do with memory ordering, others to do with, // e.g. strength of references, strength of GC barriers, or whether compression should be applied or not. // Some decorators are set at buildtime, such as whether primitives require GC barriers or not, others // at callsites such as whether an access is in the heap or not, and others are resolved at runtime // such as GC-specific barriers and encoding/decoding compressed oops. For more information about what // decorators are available, cf. oops/accessDecorators.hpp. // By pipelining handling of these decorators, the design of the Access API allows separation of concern // over the different orthogonal concerns of decorators, while providing a powerful way of // expressing these orthogonal semantic properties in a unified way. // // == OPERATIONS == // * load: Load a value from an address. // * load_at: Load a value from an internal pointer relative to a base object. // * store: Store a value at an address. // * store_at: Store a value in an internal pointer relative to a base object. // * atomic_cmpxchg: Atomically compare-and-swap a new value at an address if previous value matched the compared value. // * atomic_cmpxchg_at: Atomically compare-and-swap a new value at an internal pointer address if previous value matched the compared value. // * atomic_xchg: Atomically swap a new value at an address if previous value matched the compared value. // * atomic_xchg_at: Atomically swap a new value at an internal pointer address if previous value matched the compared value. // * arraycopy: Copy data from one heap array to another heap array. The ArrayAccess class has convenience functions for this. // * clone: Clone the contents of an object to a newly allocated object. // // == IMPLEMENTATION == // Each access goes through the following steps in a template pipeline. // There are essentially 5 steps for each access: // * Step 1: Set default decorators and decay types. This step gets rid of CV qualifiers // and sets default decorators to sensible values. // * Step 2: Reduce types. This step makes sure there is only a single T type and not // multiple types. The P type of the address and T type of the value must // match. // * Step 3: Pre-runtime dispatch. This step checks whether a runtime call can be // avoided, and in that case avoids it (calling raw accesses or // primitive accesses in a build that does not require primitive GC barriers) // * Step 4: Runtime-dispatch. This step performs a runtime dispatch to the corresponding // BarrierSet::AccessBarrier accessor that attaches GC-required barriers // to the access. // * Step 5.a: Barrier resolution. This step is invoked the first time a runtime-dispatch // happens for an access. The appropriate BarrierSet::AccessBarrier accessor // is resolved, then the function pointer is updated to that accessor for // future invocations. // * Step 5.b: Post-runtime dispatch. This step now casts previously unknown types such // as the address type of an oop on the heap (is it oop* or narrowOop*) to // the appropriate type. It also splits sufficiently orthogonal accesses into // different functions, such as whether the access involves oops or primitives // and whether the access is performed on the heap or outside. Then the // appropriate BarrierSet::AccessBarrier is called to perform the access. // // The implementation of step 1-4 resides in in accessBackend.hpp, to allow selected // accesses to be accessible from only access.hpp, as opposed to access.inline.hpp. // Steps 5.a and 5.b require knowledge about the GC backends, and therefore needs to // include the various GC backend .inline.hpp headers. Their implementation resides in // access.inline.hpp. The accesses that are allowed through the access.hpp file // must be instantiated in access.cpp using the INSTANTIATE_HPP_ACCESS macro.
template <DecoratorSet decorators = DECORATORS_NONE> class Access: public AllStatic { // This function asserts that if an access gets passed in a decorator outside // of the expected_decorators, then something is wrong. It additionally checks // the consistency of the decorators so that supposedly disjoint decorators are indeed // disjoint. For example, an access can not be both in heap and on root at the // same time. template <DecoratorSet expected_decorators> staticvoid verify_decorators();
// Helper for performing raw accesses (knows only of memory ordering // atomicity decorators as well as compressed oops) template <DecoratorSet decorators = DECORATORS_NONE> class RawAccess: public Access<AS_RAW | decorators> {};
// Helper for performing normal accesses on the heap. These accesses // may resolve an accessor on a GC barrier set template <DecoratorSet decorators = DECORATORS_NONE> class HeapAccess: public Access<IN_HEAP | decorators> {};
// Helper for performing normal accesses in roots. These accesses // may resolve an accessor on a GC barrier set template <DecoratorSet decorators = DECORATORS_NONE> class NativeAccess: public Access<IN_NATIVE | decorators> {};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.