Mercurial > hg > truffle
comparison src/share/vm/prims/whitebox.cpp @ 17817:4abb719c5620
8038240: new WB API to get nmethod
Reviewed-by: morris, kvn
author | iignatyev |
---|---|
date | Thu, 27 Mar 2014 11:17:26 +0400 |
parents | a48e16541e6b |
children | b127b0d6de7f |
comparison
equal
deleted
inserted
replaced
17816:3829d0343db0 | 17817:4abb719c5620 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
507 | 507 |
508 CHECK_JNI_EXCEPTION_(env, NULL); | 508 CHECK_JNI_EXCEPTION_(env, NULL); |
509 | 509 |
510 return features_string; | 510 return features_string; |
511 WB_END | 511 WB_END |
512 | |
513 | |
514 WB_ENTRY(jobjectArray, WB_GetNMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) | |
515 ResourceMark rm(THREAD); | |
516 jmethodID jmid = reflected_method_to_jmid(thread, env, method); | |
517 CHECK_JNI_EXCEPTION_(env, NULL); | |
518 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); | |
519 nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); | |
520 jobjectArray result = NULL; | |
521 if (code == NULL) { | |
522 return result; | |
523 } | |
524 int insts_size = code->insts_size(); | |
525 | |
526 ThreadToNativeFromVM ttn(thread); | |
527 jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); | |
528 CHECK_JNI_EXCEPTION_(env, NULL); | |
529 result = env->NewObjectArray(2, clazz, NULL); | |
530 if (result == NULL) { | |
531 return result; | |
532 } | |
533 | |
534 clazz = env->FindClass(vmSymbols::java_lang_Integer()->as_C_string()); | |
535 CHECK_JNI_EXCEPTION_(env, NULL); | |
536 jmethodID constructor = env->GetMethodID(clazz, vmSymbols::object_initializer_name()->as_C_string(), vmSymbols::int_void_signature()->as_C_string()); | |
537 CHECK_JNI_EXCEPTION_(env, NULL); | |
538 jobject obj = env->NewObject(clazz, constructor, code->comp_level()); | |
539 CHECK_JNI_EXCEPTION_(env, NULL); | |
540 env->SetObjectArrayElement(result, 0, obj); | |
541 | |
542 jbyteArray insts = env->NewByteArray(insts_size); | |
543 CHECK_JNI_EXCEPTION_(env, NULL); | |
544 env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin()); | |
545 env->SetObjectArrayElement(result, 1, insts); | |
546 | |
547 return result; | |
548 WB_END | |
549 | |
512 | 550 |
513 //Some convenience methods to deal with objects from java | 551 //Some convenience methods to deal with objects from java |
514 int WhiteBox::offset_for_field(const char* field_name, oop object, | 552 int WhiteBox::offset_for_field(const char* field_name, oop object, |
515 Symbol* signature_symbol) { | 553 Symbol* signature_symbol) { |
516 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); | 554 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid"); |
620 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, | 658 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, |
621 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, | 659 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, |
622 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, | 660 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, |
623 {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, | 661 {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, |
624 {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures }, | 662 {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures }, |
663 {CC"getNMethod", CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;", | |
664 (void*)&WB_GetNMethod }, | |
625 }; | 665 }; |
626 | 666 |
627 #undef CC | 667 #undef CC |
628 | 668 |
629 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) | 669 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) |