[vmkit-commits] [PATCH] In OpenJDK, use the 'classes' field of ClassLoader to track VMClassLoader.

Nicolas Geoffray nicolas.geoffray at gmail.com
Fri Nov 4 14:43:54 PDT 2011


Looks good!

On Thu, Nov 3, 2011 at 3:36 PM, Will Dietz <wdietz2 at illinois.edu> wrote:

> Inlined below.
>
> Traces the internal classloader by stashing a VMClassLoader into the
> 'classes' field.
>
> FWIW the *only* time anyone 'writes' to the classes field is
> initializing it to empty in the constructor.
>
> ~Will
>
> >From 1b728ad7ab762680abe320eaf9f66e1e5c981560 Mon Sep 17 00:00:00 2001
> From: Will Dietz <w at wdtz.org>
> Date: Wed, 2 Nov 2011 22:48:26 -0500
> Subject: [PATCH 13/17] In OpenJDK, use the 'classes' field of ClassLoader
> to
>  track VMClassLoader.
>
> Also, don't just check the 'vmdata' field for non-null, since in OJ it
> will be
> initialized to an empty vector.  Instead, consider the field uninitialized
> if
> it's either null or of the wrong type.
> ---
>  lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp |    7 +++----
>  lib/J3/VMCore/JnjvmClassLoader.cpp      |    7 +++++--
>  2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp
> b/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp
> index 43ff227..22db276 100644
> --- a/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp
> +++ b/lib/J3/ClassLib/OpenJDK/JavaUpcalls.cpp
> @@ -552,10 +552,9 @@ void
> Classpath::initialiseClasspath(JnjvmClassLoader* loader) {
>     UPCALL_FIELD(loader, "java/nio/Buffer", "address",
> "Lgnu/classpath/Pointer;",
>                  ACC_VIRTUAL);
>
> -  // TODO: Resolve how to tie a ClassLoader to its internal representation
> -  //vmdataClassLoader =
> -  //  UPCALL_FIELD(loader, "java/lang/ClassLoader", "vmdata",
> "Ljava/lang/Object;",
> -  //               ACC_VIRTUAL);
> +  vmdataClassLoader =
> +    UPCALL_FIELD(loader, "java/lang/ClassLoader", "classes",
> "Ljava/util/Vector;",
> +                 ACC_VIRTUAL);
>
>   newStackTraceElement =
>     UPCALL_CLASS(loader, "java/lang/StackTraceElement");
> diff --git a/lib/J3/VMCore/JnjvmClassLoader.cpp
> b/lib/J3/VMCore/JnjvmClassLoader.cpp
> index 5444941..fd1eabb 100644
> --- a/lib/J3/VMCore/JnjvmClassLoader.cpp
> +++ b/lib/J3/VMCore/JnjvmClassLoader.cpp
> @@ -808,11 +808,14 @@
> JnjvmClassLoader::getJnjvmLoaderFromJavaObject(JavaObject* loader,
> Jnjvm* vm) {
>   vmdata =
>
> (VMClassLoader*)(upcalls->vmdataClassLoader->getInstanceObjectField(loader));
>
> -  if (vmdata == NULL) {
> +  // If the vmdata field isn't set yet, or it's set to something other
> than
> +  // a VMClassLoader (which happens in the OpenJDK port), then initialize
> +  // the field now.
> +  if (vmdata == NULL || !VMClassLoader::isVMClassLoader(vmdata)) {
>     JavaObject::acquire(loader);
>     vmdata =
>
> (VMClassLoader*)(upcalls->vmdataClassLoader->getInstanceObjectField(loader));
> -    if (!vmdata) {
> +    if (!vmdata || !VMClassLoader::isVMClassLoader(vmdata)) {
>       vmdata = VMClassLoader::allocate();
>       mvm::BumpPtrAllocator* A = new mvm::BumpPtrAllocator();
>       JCL = new(*A, "Class loader") JnjvmClassLoader(*A,
> *vm->bootstrapLoader,
> --
> 1.7.5.1
> _______________________________________________
> vmkit-commits mailing list
> vmkit-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/vmkit-commits/attachments/20111104/5f672281/attachment.html>


More information about the vmkit-commits mailing list