src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/java.base/share/classes/jdk/internal/misc

src/java.base/share/classes/jdk/internal/misc/Unsafe.java

Print this page
rev 13575 : [mq]: unsafecopyswap
   1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 439      * by the address and length parameters.  If the effective addresses and
 440      * length are all even modulo 8, the transfer takes place in 'long' units.
 441      * If the effective addresses and length are (resp.) even modulo 4 or 2,
 442      * the transfer takes place in units of 'int' or 'short'.
 443      *
 444      * @since 1.7
 445      */
 446     @HotSpotIntrinsicCandidate
 447     public native void copyMemory(Object srcBase, long srcOffset,
 448                                   Object destBase, long destOffset,
 449                                   long bytes);
 450     /**
 451      * Sets all bytes in a given block of memory to a copy of another
 452      * block.  This provides a <em>single-register</em> addressing mode,
 453      * as discussed in {@link #getInt(Object,long)}.
 454      *
 455      * Equivalent to {@code copyMemory(null, srcAddress, null, destAddress, bytes)}.
 456      */
 457     public void copyMemory(long srcAddress, long destAddress, long bytes) {
 458         copyMemory(null, srcAddress, null, destAddress, bytes);




























 459     }
 460 
 461     /**
 462      * Disposes of a block of native memory, as obtained from {@link
 463      * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
 464      * this method may be null, in which case no action is taken.
 465      *
 466      * @see #allocateMemory
 467      */
 468     public native void freeMemory(long address);
 469 
 470     /// random queries
 471 
 472     /**
 473      * This constant differs from all results that will ever be returned from
 474      * {@link #staticFieldOffset}, {@link #objectFieldOffset},
 475      * or {@link #arrayBaseOffset}.
 476      */
 477     public static final int INVALID_FIELD_OFFSET   = -1;
 478 


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 439      * by the address and length parameters.  If the effective addresses and
 440      * length are all even modulo 8, the transfer takes place in 'long' units.
 441      * If the effective addresses and length are (resp.) even modulo 4 or 2,
 442      * the transfer takes place in units of 'int' or 'short'.
 443      *
 444      * @since 1.7
 445      */
 446     @HotSpotIntrinsicCandidate
 447     public native void copyMemory(Object srcBase, long srcOffset,
 448                                   Object destBase, long destOffset,
 449                                   long bytes);
 450     /**
 451      * Sets all bytes in a given block of memory to a copy of another
 452      * block.  This provides a <em>single-register</em> addressing mode,
 453      * as discussed in {@link #getInt(Object,long)}.
 454      *
 455      * Equivalent to {@code copyMemory(null, srcAddress, null, destAddress, bytes)}.
 456      */
 457     public void copyMemory(long srcAddress, long destAddress, long bytes) {
 458         copyMemory(null, srcAddress, null, destAddress, bytes);
 459     }
 460 
 461     /**
 462      * Copies all elements from one block of memory to another block, byte swapping the
 463      * elements on the fly.
 464      *
 465      * <p>This method determines each block's base address by means of two parameters,
 466      * and so it provides (in effect) a <em>double-register</em> addressing mode,
 467      * as discussed in {@link #getInt(Object,long)}.  When the object reference is null,
 468      * the offset supplies an absolute base address.
 469      *
 470      * @since 9
 471      */
 472     public native void copySwapMemory(Object srcBase, long srcOffset,
 473                                       Object destBase, long destOffset,
 474                                       long bytes, long elemSize);
 475 
 476    /**
 477      * Copies all elements from one block of memory to another block, byte swapping the
 478      * elements on the fly.
 479      *
 480      * This provides a <em>single-register</em> addressing mode, as
 481      * discussed in {@link #getInt(Object,long)}.
 482      *
 483      * Equivalent to {@code copySwapMemory(null, srcAddress, null, destAddress, bytes, elemSize)}.
 484      */
 485     public void copySwapMemory(long srcAddress, long destAddress, long bytes, long elemSize) {
 486         copySwapMemory(null, srcAddress, null, destAddress, bytes, elemSize);
 487     }
 488 
 489     /**
 490      * Disposes of a block of native memory, as obtained from {@link
 491      * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
 492      * this method may be null, in which case no action is taken.
 493      *
 494      * @see #allocateMemory
 495      */
 496     public native void freeMemory(long address);
 497 
 498     /// random queries
 499 
 500     /**
 501      * This constant differs from all results that will ever be returned from
 502      * {@link #staticFieldOffset}, {@link #objectFieldOffset},
 503      * or {@link #arrayBaseOffset}.
 504      */
 505     public static final int INVALID_FIELD_OFFSET   = -1;
 506 


src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File