src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeArrayTypeWriter.java
equal
deleted
inserted
replaced
29 import static org.graalvm.compiler.core.common.util.TypeConversion.asS4; |
29 import static org.graalvm.compiler.core.common.util.TypeConversion.asS4; |
30 import static org.graalvm.compiler.core.common.util.TypeConversion.asU1; |
30 import static org.graalvm.compiler.core.common.util.TypeConversion.asU1; |
31 import static org.graalvm.compiler.core.common.util.TypeConversion.asU2; |
31 import static org.graalvm.compiler.core.common.util.TypeConversion.asU2; |
32 import static org.graalvm.compiler.core.common.util.TypeConversion.asU4; |
32 import static org.graalvm.compiler.core.common.util.TypeConversion.asU4; |
33 import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe; |
33 import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe; |
|
34 |
|
35 import java.nio.ByteBuffer; |
34 |
36 |
35 import org.graalvm.compiler.core.common.calc.UnsignedMath; |
37 import org.graalvm.compiler.core.common.calc.UnsignedMath; |
36 |
38 |
37 import sun.misc.Unsafe; |
39 import sun.misc.Unsafe; |
38 |
40 |
101 } |
103 } |
102 assert resultIdx == totalSize; |
104 assert resultIdx == totalSize; |
103 return result; |
105 return result; |
104 } |
106 } |
105 |
107 |
|
108 /** Copies the buffer into the provided ByteBuffer at its current position. */ |
|
109 public final ByteBuffer toByteBuffer(ByteBuffer buffer) { |
|
110 assert buffer.remaining() <= totalSize; |
|
111 int initialPos = buffer.position(); |
|
112 for (Chunk cur = firstChunk; cur != null; cur = cur.next) { |
|
113 buffer.put(cur.data, 0, cur.size); |
|
114 } |
|
115 assert buffer.position() - initialPos == totalSize; |
|
116 return buffer; |
|
117 } |
|
118 |
106 @Override |
119 @Override |
107 public final void putS1(long value) { |
120 public final void putS1(long value) { |
108 long offset = writeOffset(Byte.BYTES); |
121 long offset = writeOffset(Byte.BYTES); |
109 UNSAFE.putByte(writeChunk.data, offset, asS1(value)); |
122 UNSAFE.putByte(writeChunk.data, offset, asS1(value)); |
110 } |
123 } |