[vmkit-commits] [PATCH] Impl JVM_GetClassContext

Nicolas Geoffray nicolas.geoffray at gmail.com
Fri Nov 4 14:10:53 PDT 2011


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

> Inlined below.
>
> ~Will
>
> >From 27a8b66190db992968e8674d3832bb6176cd9b35 Mon Sep 17 00:00:00 2001
> From: Will Dietz <w at wdtz.org>
> Date: Wed, 2 Nov 2011 20:36:57 -0500
> Subject: [PATCH 04/17] Impl JVM_GetClassContext
>
> ---
>  lib/J3/ClassLib/OpenJDK/OpenJDK.inc |   32
> +++++++++++++++++++++++++++++++-
>  1 files changed, 31 insertions(+), 1 deletions(-)
>
> diff --git a/lib/J3/ClassLib/OpenJDK/OpenJDK.inc
> b/lib/J3/ClassLib/OpenJDK/OpenJDK.inc
> index 30a670f..9305e66 100644
> --- a/lib/J3/ClassLib/OpenJDK/OpenJDK.inc
> +++ b/lib/J3/ClassLib/OpenJDK/OpenJDK.inc
> @@ -742,7 +742,37 @@ JVM_CurrentClassLoader(JNIEnv *env) {
>
>  JNIEXPORT jobjectArray JNICALL
>  JVM_GetClassContext(JNIEnv *env) {
> -  NYI();
> +  ArrayObject* result = NULL;
> +  JavaObject* delegatee = NULL;
> +  llvm_gcroot(result, 0);
> +  llvm_gcroot(delegatee, 0);
> +
> +  BEGIN_JNI_EXCEPTION
> +
> +  JavaThread* th = JavaThread::get();
> +  Jnjvm* vm = th->getJVM();
> +  uint32 length = th->getFrameContextLength();
> +
> +  mvm::ThreadAllocator allocator;
> +  uintptr_t* buffer = (uintptr_t*)allocator.Allocate(length *
> sizeof(uintptr_t));
> +
> +  uint32 finalSize = th->getJavaFrameContext((void**)buffer);
> +
> +  result = (ArrayObject*)
> +    vm->upcalls->stackTraceArray->doNew(finalSize, vm);
>

This should not be a stackTraceArray but a classArrayClass, right? You're
storing java.lang.Class in the lines above.


> +
> +  for (uint32 i = 0; i != finalSize; ++i) {
> +    JavaMethod* meth = ((JavaMethod**)buffer)[i];
> +    assert(meth && "Wrong stack trace");
> +    delegatee = meth->classDef->getClassDelegatee(vm);;
> +    ArrayObject::setElement(result, delegatee, i);
> +  }
> +
> +  RETURN_FROM_JNI((jobjectArray)th->pushJNIRef(result));
> +
> +  END_JNI_EXCEPTION
> +
> +  return 0;
>  }
>
>  JNIEXPORT jint JNICALL
> --
> 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/44254499/attachment.html>


More information about the vmkit-commits mailing list