/* * Copyright (c) 1997, 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. *
*/
class CodeBlob; class nmethod; class ReferenceDiscoverer; class DataLayout; class KlassClosure; class ClassLoaderData; class Symbol; class Metadata; class Thread;
// The following classes are C++ `closures` for iterating over objects, roots and spaces
// OopClosure is used for iterating through references to Java objects. class OopClosure : public Closure { public: virtualvoid do_oop(oop* o) = 0; virtualvoid do_oop(narrowOop* o) = 0;
};
class DoNothingClosure : public OopClosure { public: virtualvoid do_oop(oop* p) {} virtualvoid do_oop(narrowOop* p) {}
}; extern DoNothingClosure do_nothing_cl;
// OopIterateClosure adds extra code to be run during oop iterations. // This is needed by the GC and is extracted to a separate type to not // pollute the OopClosure interface. class OopIterateClosure : public OopClosure { private:
ReferenceDiscoverer* _ref_discoverer;
// Iteration of InstanceRefKlasses differ depending on the closure, // the below enum describes the different alternatives. enum ReferenceIterationMode {
DO_DISCOVERY, // Apply closure and discover references
DO_DISCOVERED_AND_DISCOVERY, // Apply closure to discovered field and do discovery
DO_FIELDS, // Apply closure to all fields
DO_FIELDS_EXCEPT_REFERENT // Apply closure to all fields except the referent field
};
// The default iteration mode is to do discovery. virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERY; }
// If the do_metadata functions return "true", // we invoke the following when running oop_iterate(): // // 1) do_klass on the header klass pointer. // 2) do_klass on the klass pointer in the mirrors. // 3) do_cld on the class loader data in class loaders. // // Used to determine metadata liveness for class unloading GCs.
// Class redefinition needs to get notified about methods from stackChunkOops virtualvoid do_method(Method* m) = 0; // The code cache unloading needs to get notified about methods from stackChunkOops virtualvoid do_nmethod(nmethod* nm) = 0;
};
// An OopIterateClosure that can be used when there's no need to visit the Metadata. class BasicOopIterateClosure : public OopIterateClosure { public:
BasicOopIterateClosure(ReferenceDiscoverer* rd = NULL) : OopIterateClosure(rd) {}
// The base class for all concurrent marking closures, // that participates in class unloading. // It's used to proxy through the metadata to the oops defined in them. class MetadataVisitingOopIterateClosure: public ClaimMetadataVisitingOopIterateClosure { public:
MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd = NULL);
};
// ObjectClosure is used for iterating through an object space
class ObjectClosure : public Closure { public: // Called for each object. virtualvoid do_object(oop obj) = 0;
};
class BoolObjectClosure : public Closure { public: virtualbool do_object_b(oop obj) = 0;
};
class AlwaysTrueClosure: public BoolObjectClosure { public: bool do_object_b(oop p) { returntrue; }
};
class AlwaysFalseClosure : public BoolObjectClosure { public: bool do_object_b(oop p) { returnfalse; }
};
// Applies an oop closure to all ref fields in objects iterated over in an // object iteration. class ObjectToOopClosure: public ObjectClosure {
OopIterateClosure* _cl; public: void do_object(oop obj);
ObjectToOopClosure(OopIterateClosure* cl) : _cl(cl) {}
};
// SpaceClosure is used for iterating over spaces
class Space; class CompactibleSpace;
class SpaceClosure : public StackObj { public: // Called for each space virtualvoid do_space(Space* s) = 0;
};
// CodeBlobClosure is used for iterating through code blobs // in the code cache or on thread stacks
class CodeBlobClosure : public Closure { public: // Called for each code blob. virtualvoid do_code_blob(CodeBlob* cb) = 0;
};
// Applies an oop closure to all ref fields in code blobs // iterated over in an object iteration. class CodeBlobToOopClosure : public CodeBlobClosure { protected:
OopClosure* _cl; bool _fix_relocations; void do_nmethod(nmethod* nm); public: // If fix_relocations(), then cl must copy objects to their new location immediately to avoid // patching nmethods with the old locations.
CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {} virtualvoid do_code_blob(CodeBlob* cb);
// MonitorClosure is used for iterating over monitors in the monitors cache
class ObjectMonitor;
class MonitorClosure : public StackObj { public: // called for each monitor in cache virtualvoid do_monitor(ObjectMonitor* m) = 0;
};
// A closure that is applied without any arguments. class VoidClosure : public StackObj { public: virtualvoid do_void() = 0;
};
// YieldClosure is intended for use by iteration loops // to incrementalize their work, allowing interleaving // of an interruptible task so as to allow other // threads to run (which may not otherwise be able to access // exclusive resources, for instance). Additionally, the // closure also allows for aborting an ongoing iteration // by means of checking the return value from the polling // call. class YieldClosure : public StackObj { public: virtualbool should_return() = 0;
// Yield on a fine-grain level. The check in case of not yielding should be very fast. virtualbool should_return_fine_grain() { returnfalse; }
};
// Abstract closure for serializing data (read or write).
class SerializeClosure : public Closure { public: // Return bool indicating whether closure implements read or write. virtualbool reading() const = 0;
// Read/write the void pointer pointed to by p. virtualvoid do_ptr(void** p) = 0;
// Read/write the 32-bit unsigned integer pointed to by p. virtualvoid do_u4(u4* p) = 0;
// Read/write the bool pointed to by p. virtualvoid do_bool(bool* p) = 0;
// Read/write the region specified. virtualvoid do_region(u_char* start, size_t size) = 0;
// Check/write the tag. If reading, then compare the tag against // the passed in value and fail is they don't match. This allows // for verification that sections of the serialized data are of the // correct length. virtualvoid do_tag(int tag) = 0;
// Read/write the oop virtualvoid do_oop(oop* o) = 0;
bool writing() { return !reading();
}
};
class SymbolClosure : public StackObj { public: virtualvoid do_symbol(Symbol**) = 0;
};
template <typename E> class CompareClosure : public Closure { public: virtualint do_compare(const E&, const E&) = 0;
};
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.