comparison src/share/vm/prims/jvm.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 2a69cbe850a8 d4caf9c96afd
children be896a1983c0
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
22 * 22 *
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp" 26 #include "classfile/classLoader.hpp"
27 #include "classfile/classLoaderExt.hpp"
27 #include "classfile/javaAssertions.hpp" 28 #include "classfile/javaAssertions.hpp"
28 #include "classfile/javaClasses.hpp" 29 #include "classfile/javaClasses.hpp"
29 #include "classfile/symbolTable.hpp" 30 #include "classfile/symbolTable.hpp"
30 #include "classfile/systemDictionary.hpp" 31 #include "classfile/systemDictionary.hpp"
32 #if INCLUDE_CDS
33 #include "classfile/sharedClassUtil.hpp"
34 #include "classfile/systemDictionaryShared.hpp"
35 #endif
31 #include "classfile/vmSymbols.hpp" 36 #include "classfile/vmSymbols.hpp"
32 #include "gc_interface/collectedHeap.inline.hpp" 37 #include "gc_interface/collectedHeap.inline.hpp"
33 #include "interpreter/bytecode.hpp" 38 #include "interpreter/bytecode.hpp"
34 #include "memory/oopFactory.hpp" 39 #include "memory/oopFactory.hpp"
35 #include "memory/universe.inline.hpp" 40 #include "memory/universe.inline.hpp"
49 #include "runtime/init.hpp" 54 #include "runtime/init.hpp"
50 #include "runtime/interfaceSupport.hpp" 55 #include "runtime/interfaceSupport.hpp"
51 #include "runtime/java.hpp" 56 #include "runtime/java.hpp"
52 #include "runtime/javaCalls.hpp" 57 #include "runtime/javaCalls.hpp"
53 #include "runtime/jfieldIDWorkaround.hpp" 58 #include "runtime/jfieldIDWorkaround.hpp"
59 #include "runtime/orderAccess.inline.hpp"
54 #include "runtime/os.hpp" 60 #include "runtime/os.hpp"
55 #include "runtime/perfData.hpp" 61 #include "runtime/perfData.hpp"
56 #include "runtime/reflection.hpp" 62 #include "runtime/reflection.hpp"
57 #include "runtime/vframe.hpp" 63 #include "runtime/vframe.hpp"
58 #include "runtime/vm_operations.hpp" 64 #include "runtime/vm_operations.hpp"
388 (Arguments::mode() != Arguments::_int)) { 394 (Arguments::mode() != Arguments::_int)) {
389 PUTPROP(props, "sun.management.compiler", compiler_name); 395 PUTPROP(props, "sun.management.compiler", compiler_name);
390 } 396 }
391 } 397 }
392 398
399 const char* enableSharedLookupCache = "false";
400 #if INCLUDE_CDS
401 if (ClassLoaderExt::is_lookup_cache_enabled()) {
402 enableSharedLookupCache = "true";
403 }
404 #endif
405 PUTPROP(props, "sun.cds.enableSharedLookupCache", enableSharedLookupCache);
406
393 return properties; 407 return properties;
394 JVM_END 408 JVM_END
395 409
396 410
397 /* 411 /*
589 THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name()); 603 THROW_MSG_0(vmSymbols::java_lang_CloneNotSupportedException(), klass->external_name());
590 } 604 }
591 605
592 // Make shallow object copy 606 // Make shallow object copy
593 const int size = obj->size(); 607 const int size = obj->size();
594 oop new_obj = NULL; 608 oop new_obj_oop = NULL;
595 if (obj->is_array()) { 609 if (obj->is_array()) {
596 const int length = ((arrayOop)obj())->length(); 610 const int length = ((arrayOop)obj())->length();
597 new_obj = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL); 611 new_obj_oop = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL);
598 } else { 612 } else {
599 new_obj = CollectedHeap::obj_allocate(klass, size, CHECK_NULL); 613 new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL);
600 } 614 }
615
601 // 4839641 (4840070): We must do an oop-atomic copy, because if another thread 616 // 4839641 (4840070): We must do an oop-atomic copy, because if another thread
602 // is modifying a reference field in the clonee, a non-oop-atomic copy might 617 // is modifying a reference field in the clonee, a non-oop-atomic copy might
603 // be suspended in the middle of copying the pointer and end up with parts 618 // be suspended in the middle of copying the pointer and end up with parts
604 // of two different pointers in the field. Subsequent dereferences will crash. 619 // of two different pointers in the field. Subsequent dereferences will crash.
605 // 4846409: an oop-copy of objects with long or double fields or arrays of same 620 // 4846409: an oop-copy of objects with long or double fields or arrays of same
606 // won't copy the longs/doubles atomically in 32-bit vm's, so we copy jlongs instead 621 // won't copy the longs/doubles atomically in 32-bit vm's, so we copy jlongs instead
607 // of oops. We know objects are aligned on a minimum of an jlong boundary. 622 // of oops. We know objects are aligned on a minimum of an jlong boundary.
608 // The same is true of StubRoutines::object_copy and the various oop_copy 623 // The same is true of StubRoutines::object_copy and the various oop_copy
609 // variants, and of the code generated by the inline_native_clone intrinsic. 624 // variants, and of the code generated by the inline_native_clone intrinsic.
610 assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned"); 625 assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned");
611 Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj, 626 Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj_oop,
612 (size_t)align_object_size(size) / HeapWordsPerLong); 627 (size_t)align_object_size(size) / HeapWordsPerLong);
613 // Clear the header 628 // Clear the header
614 new_obj->init_mark(); 629 new_obj_oop->init_mark();
615 630
616 // Store check (mark entire object and let gc sort it out) 631 // Store check (mark entire object and let gc sort it out)
617 BarrierSet* bs = Universe::heap()->barrier_set(); 632 BarrierSet* bs = Universe::heap()->barrier_set();
618 assert(bs->has_write_region_opt(), "Barrier set does not have write_region"); 633 assert(bs->has_write_region_opt(), "Barrier set does not have write_region");
619 bs->write_region(MemRegion((HeapWord*)new_obj, size)); 634 bs->write_region(MemRegion((HeapWord*)new_obj_oop, size));
635
636 Handle new_obj(THREAD, new_obj_oop);
637 // Special handling for MemberNames. Since they contain Method* metadata, they
638 // must be registered so that RedefineClasses can fix metadata contained in them.
639 if (java_lang_invoke_MemberName::is_instance(new_obj()) &&
640 java_lang_invoke_MemberName::is_method(new_obj())) {
641 Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(new_obj());
642 // MemberName may be unresolved, so doesn't need registration until resolved.
643 if (method != NULL) {
644 methodHandle m(THREAD, method);
645 // This can safepoint and redefine method, so need both new_obj and method
646 // in a handle, for two different reasons. new_obj can move, method can be
647 // deleted if nothing is using it on the stack.
648 m->method_holder()->add_member_name(new_obj());
649 }
650 }
620 651
621 // Caution: this involves a java upcall, so the clone should be 652 // Caution: this involves a java upcall, so the clone should be
622 // "gc-robust" by this stage. 653 // "gc-robust" by this stage.
623 if (klass->has_finalizer()) { 654 if (klass->has_finalizer()) {
624 assert(obj->is_instance(), "should be instanceOop"); 655 assert(obj->is_instance(), "should be instanceOop");
625 new_obj = InstanceKlass::register_finalizer(instanceOop(new_obj), CHECK_NULL); 656 new_obj_oop = InstanceKlass::register_finalizer(instanceOop(new_obj()), CHECK_NULL);
626 } 657 new_obj = Handle(THREAD, new_obj_oop);
627 658 }
628 return JNIHandles::make_local(env, oop(new_obj)); 659
660 return JNIHandles::make_local(env, new_obj());
629 JVM_END 661 JVM_END
630 662
631 // java.lang.Compiler //////////////////////////////////////////////////// 663 // java.lang.Compiler ////////////////////////////////////////////////////
632 664
633 // The initial cuts of the HotSpot VM will not support JITs, and all existing 665 // The initial cuts of the HotSpot VM will not support JITs, and all existing
761 JVMWrapper("JVM_ResolveClass"); 793 JVMWrapper("JVM_ResolveClass");
762 if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented"); 794 if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented");
763 JVM_END 795 JVM_END
764 796
765 797
798 JVM_ENTRY(jboolean, JVM_KnownToNotExist(JNIEnv *env, jobject loader, const char *classname))
799 JVMWrapper("JVM_KnownToNotExist");
800 #if INCLUDE_CDS
801 return ClassLoaderExt::known_to_not_exist(env, loader, classname, CHECK_(false));
802 #else
803 return false;
804 #endif
805 JVM_END
806
807
808 JVM_ENTRY(jobjectArray, JVM_GetResourceLookupCacheURLs(JNIEnv *env, jobject loader))
809 JVMWrapper("JVM_GetResourceLookupCacheURLs");
810 #if INCLUDE_CDS
811 return ClassLoaderExt::get_lookup_cache_urls(env, loader, CHECK_NULL);
812 #else
813 return NULL;
814 #endif
815 JVM_END
816
817
818 JVM_ENTRY(jintArray, JVM_GetResourceLookupCache(JNIEnv *env, jobject loader, const char *resource_name))
819 JVMWrapper("JVM_GetResourceLookupCache");
820 #if INCLUDE_CDS
821 return ClassLoaderExt::get_lookup_cache(env, loader, resource_name, CHECK_NULL);
822 #else
823 return NULL;
824 #endif
825 JVM_END
826
827
766 // Returns a class loaded by the bootstrap class loader; or null 828 // Returns a class loaded by the bootstrap class loader; or null
767 // if not found. ClassNotFoundException is not thrown. 829 // if not found. ClassNotFoundException is not thrown.
768 // 830 //
769 // Rationale behind JVM_FindClassFromBootLoader 831 // Rationale behind JVM_FindClassFromBootLoader
770 // a> JVM_FindClassFromClassLoader was never exported in the export tables. 832 // a> JVM_FindClassFromClassLoader was never exported in the export tables.
1032 1094
1033 Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name, 1095 Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name,
1034 h_loader, 1096 h_loader,
1035 Handle(), 1097 Handle(),
1036 CHECK_NULL); 1098 CHECK_NULL);
1037 1099 #if INCLUDE_CDS
1100 if (k == NULL) {
1101 // If the class is not already loaded, try to see if it's in the shared
1102 // archive for the current classloader (h_loader).
1103 instanceKlassHandle ik = SystemDictionaryShared::find_or_load_shared_class(
1104 klass_name, h_loader, CHECK_NULL);
1105 k = ik();
1106 }
1107 #endif
1038 return (k == NULL) ? NULL : 1108 return (k == NULL) ? NULL :
1039 (jclass) JNIHandles::make_local(env, k->java_mirror()); 1109 (jclass) JNIHandles::make_local(env, k->java_mirror());
1040 JVM_END 1110 JVM_END
1041 1111
1042 1112
4474 } 4544 }
4475 JVM_END 4545 JVM_END
4476 4546
4477 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size)) 4547 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size))
4478 { 4548 {
4479 memset(info, 0, sizeof(info_size)); 4549 memset(info, 0, info_size);
4480 4550
4481 info->jvm_version = Abstract_VM_Version::jvm_version(); 4551 info->jvm_version = Abstract_VM_Version::jvm_version();
4482 info->update_version = 0; /* 0 in HotSpot Express VM */ 4552 info->update_version = 0; /* 0 in HotSpot Express VM */
4483 info->special_update_version = 0; /* 0 in HotSpot Express VM */ 4553 info->special_update_version = 0; /* 0 in HotSpot Express VM */
4484 4554