changeset 20835:220ecaa0cc9b

Use native byte order on UnsafeArrayTypeReader
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Thu, 09 Apr 2015 16:13:32 +0200
parents a9e55baaa3cc
children aff67777d2ea d2ce468854b4
files graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/UnsafeArrayTypeReader.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/UnsafeArrayTypeWriter.java
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/UnsafeArrayTypeReader.java	Thu Apr 09 15:46:14 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/UnsafeArrayTypeReader.java	Thu Apr 09 16:13:32 2015 +0200
@@ -46,7 +46,7 @@
         if (byteIndex % Short.BYTES == 0) {
             return UnsafeAccess.unsafe.getShort(data, readOffset(data, byteIndex, Short.BYTES));
         } else {
-            ByteBuffer buf = ByteBuffer.wrap(new byte[Short.BYTES]);
+            ByteBuffer buf = ByteBuffer.wrap(new byte[Short.BYTES]).order(ByteOrder.nativeOrder());
             buf.put((byte) getU1(data, byteIndex));
             buf.put((byte) getU1(data, byteIndex + Byte.BYTES));
             return buf.getShort(0);
@@ -61,7 +61,7 @@
         if (byteIndex % Integer.BYTES == 0) {
             return UnsafeAccess.unsafe.getInt(data, readOffset(data, byteIndex, Integer.BYTES));
         } else {
-            ByteBuffer buf = ByteBuffer.wrap(new byte[Integer.BYTES]);
+            ByteBuffer buf = ByteBuffer.wrap(new byte[Integer.BYTES]).order(ByteOrder.nativeOrder());
             buf.putShort((short) getS2(data, byteIndex));
             buf.putShort((short) getS2(data, byteIndex + Short.BYTES));
             return buf.getInt(0);
@@ -76,7 +76,7 @@
         if (byteIndex % Long.BYTES == 0) {
             return UnsafeAccess.unsafe.getLong(data, readOffset(data, byteIndex, Long.BYTES));
         } else {
-            ByteBuffer buf = ByteBuffer.wrap(new byte[Long.BYTES]);
+            ByteBuffer buf = ByteBuffer.wrap(new byte[Long.BYTES]).order(ByteOrder.nativeOrder());
             buf.putInt(getS4(data, byteIndex));
             buf.putInt(getS4(data, byteIndex + Integer.BYTES));
             return buf.getLong(0);
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/UnsafeArrayTypeWriter.java	Thu Apr 09 15:46:14 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/util/UnsafeArrayTypeWriter.java	Thu Apr 09 16:13:32 2015 +0200
@@ -94,7 +94,7 @@
             UnsafeAccess.unsafe.putShort(writeChunk.data, offset, asS2(value));
             commitWrite(Short.BYTES);
         } else {
-            ByteBuffer buf = ByteBuffer.wrap(new byte[Short.BYTES]);
+            ByteBuffer buf = ByteBuffer.wrap(new byte[Short.BYTES]).order(ByteOrder.nativeOrder());
             buf.putShort(asS2(value));
             putS1(buf.get(0));
             putS1(buf.get(Byte.BYTES));
@@ -113,7 +113,7 @@
             UnsafeAccess.unsafe.putInt(writeChunk.data, offset, asS4(value));
             commitWrite(Integer.BYTES);
         } else {
-            ByteBuffer buf = ByteBuffer.wrap(new byte[Integer.BYTES]);
+            ByteBuffer buf = ByteBuffer.wrap(new byte[Integer.BYTES]).order(ByteOrder.nativeOrder());
             buf.putInt(asS4(value));
             if (offset % Short.BYTES == 0) {
                 putS2(buf.getShort(0));
@@ -138,7 +138,7 @@
             UnsafeAccess.unsafe.putLong(writeChunk.data, offset, value);
             commitWrite(Long.BYTES);
         } else {
-            ByteBuffer buf = ByteBuffer.wrap(new byte[Long.BYTES]);
+            ByteBuffer buf = ByteBuffer.wrap(new byte[Long.BYTES]).order(ByteOrder.nativeOrder());
             buf.putLong(value);
             if (offset % Integer.BYTES == 0) {
                 putS4(buf.getInt(0));