hotspot/src/share/vm/prims/unsafe.cpp
changeset 36086 f70e100d3195
parent 35135 dd2ce9021031
child 36316 7a83de7aabca
equal deleted inserted replaced
36085:222ab7d1a9bf 36086:f70e100d3195
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2016, 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.
   658   void* src = index_oop_from_field_offset_long(srcp, srcOffset);
   658   void* src = index_oop_from_field_offset_long(srcp, srcOffset);
   659   void* dst = index_oop_from_field_offset_long(dstp, dstOffset);
   659   void* dst = index_oop_from_field_offset_long(dstp, dstOffset);
   660   Copy::conjoint_memory_atomic(src, dst, sz);
   660   Copy::conjoint_memory_atomic(src, dst, sz);
   661 UNSAFE_END
   661 UNSAFE_END
   662 
   662 
       
   663 // This function is a leaf since if the source and destination are both in native memory
       
   664 // the copy may potentially be very large, and we don't want to disable GC if we can avoid it.
       
   665 // If either source or destination (or both) are on the heap, the function will enter VM using
       
   666 // JVM_ENTRY_FROM_LEAF
       
   667 JVM_LEAF(void, Unsafe_CopySwapMemory0(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size, jlong elemSize)) {
       
   668   UnsafeWrapper("Unsafe_CopySwapMemory0");
       
   669 
       
   670   size_t sz = (size_t)size;
       
   671   size_t esz = (size_t)elemSize;
       
   672 
       
   673   if (srcObj == NULL && dstObj == NULL) {
       
   674     // Both src & dst are in native memory
       
   675     address src = (address)srcOffset;
       
   676     address dst = (address)dstOffset;
       
   677 
       
   678     Copy::conjoint_swap(src, dst, sz, esz);
       
   679   } else {
       
   680     // At least one of src/dst are on heap, transition to VM to access raw pointers
       
   681 
       
   682     JVM_ENTRY_FROM_LEAF(env, void, Unsafe_CopySwapMemory0) {
       
   683       oop srcp = JNIHandles::resolve(srcObj);
       
   684       oop dstp = JNIHandles::resolve(dstObj);
       
   685 
       
   686       address src = (address)index_oop_from_field_offset_long(srcp, srcOffset);
       
   687       address dst = (address)index_oop_from_field_offset_long(dstp, dstOffset);
       
   688 
       
   689       Copy::conjoint_swap(src, dst, sz, esz);
       
   690     } JVM_END
       
   691   }
       
   692 } JVM_END
   663 
   693 
   664 ////// Random queries
   694 ////// Random queries
   665 
   695 
   666 // See comment at file start about UNSAFE_LEAF
   696 // See comment at file start about UNSAFE_LEAF
   667 //UNSAFE_LEAF(jint, Unsafe_AddressSize())
   697 //UNSAFE_LEAF(jint, Unsafe_AddressSize())
  1361     {CC "unpark",             CC "(" OBJ ")V",           FN_PTR(Unsafe_Unpark)},
  1391     {CC "unpark",             CC "(" OBJ ")V",           FN_PTR(Unsafe_Unpark)},
  1362 
  1392 
  1363     {CC "getLoadAverage",     CC "([DI)I",               FN_PTR(Unsafe_Loadavg)},
  1393     {CC "getLoadAverage",     CC "([DI)I",               FN_PTR(Unsafe_Loadavg)},
  1364 
  1394 
  1365     {CC "copyMemory",         CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory)},
  1395     {CC "copyMemory",         CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory)},
       
  1396     {CC "copySwapMemory0",    CC "(" OBJ "J" OBJ "JJJ)V", FN_PTR(Unsafe_CopySwapMemory0)},
  1366     {CC "setMemory",          CC "(" OBJ "JJB)V",        FN_PTR(Unsafe_SetMemory)},
  1397     {CC "setMemory",          CC "(" OBJ "JJB)V",        FN_PTR(Unsafe_SetMemory)},
  1367 
  1398 
  1368     {CC "defineAnonymousClass", CC "(" DAC_Args ")" CLS, FN_PTR(Unsafe_DefineAnonymousClass)},
  1399     {CC "defineAnonymousClass", CC "(" DAC_Args ")" CLS, FN_PTR(Unsafe_DefineAnonymousClass)},
  1369 
  1400 
  1370     {CC "shouldBeInitialized",CC "(" CLS ")Z",           FN_PTR(Unsafe_ShouldBeInitialized)},
  1401     {CC "shouldBeInitialized",CC "(" CLS ")Z",           FN_PTR(Unsafe_ShouldBeInitialized)},