mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 14:35:58 +00:00
Added support for NV_path_rendering.
Made MappedObjectUnsafe package private.
This commit is contained in:
parent
d3d14b6f3c
commit
83c2208aa0
9 changed files with 730 additions and 98 deletions
|
|
@ -31,11 +31,12 @@
|
|||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import static org.lwjgl.opengl.ARBBufferObject.*;
|
||||
import static org.lwjgl.opengl.ATIVertexArrayObject.*;
|
||||
import static org.lwjgl.opengl.EXTAbgr.*;
|
||||
|
|
@ -43,6 +44,7 @@ import static org.lwjgl.opengl.EXTBgra.*;
|
|||
import static org.lwjgl.opengl.EXTDirectStateAccess.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.NVPathRendering.*;
|
||||
|
||||
/**
|
||||
* A class to check buffer boundaries in GL methods. Many GL
|
||||
|
|
@ -55,7 +57,7 @@ import static org.lwjgl.opengl.GL15.*;
|
|||
*
|
||||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
* $Id$
|
||||
* $Id$
|
||||
*/
|
||||
class GLChecks {
|
||||
|
||||
|
|
@ -81,25 +83,25 @@ class GLChecks {
|
|||
|
||||
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOdisabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOenabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureElementVBOdisabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureElementVBOenabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
|
|
@ -209,10 +211,10 @@ class GLChecks {
|
|||
case GL_FLOAT:
|
||||
bpe = 4;
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
// TODO: Add more types (like the GL12 types GL_UNSIGNED_INT_8_8_8_8
|
||||
return 0;
|
||||
// throw new IllegalArgumentException("Unknown type " + type);
|
||||
// throw new IllegalArgumentException("Unknown type " + type);
|
||||
}
|
||||
int epp;
|
||||
switch ( format ) {
|
||||
|
|
@ -233,7 +235,7 @@ class GLChecks {
|
|||
case GL_BGRA_EXT:
|
||||
epp = 4;
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
// TODO: Add more formats. Assuming 4 is too wasteful on buffer sizes where e.g. 1 is enough (like GL_DEPTH_COMPONENT)
|
||||
return 0;
|
||||
/* // Assume 4 elements per pixel
|
||||
|
|
@ -242,4 +244,116 @@ class GLChecks {
|
|||
|
||||
return bpe * epp;
|
||||
}
|
||||
}
|
||||
|
||||
// NV_path_rendering checks
|
||||
|
||||
static int calculateBytesPerCharCode(int type) {
|
||||
switch ( type ) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
case GL_UTF8_NV:
|
||||
return 1;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
case GL_2_BYTES:
|
||||
case GL_UTF16_NV:
|
||||
return 2;
|
||||
case GL_3_BYTES:
|
||||
return 3;
|
||||
case GL_4_BYTES:
|
||||
return 4;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported charcode type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
static int calculateBytesPerPathName(int pathNameType) {
|
||||
switch ( pathNameType ) {
|
||||
case GL_BYTE:
|
||||
case GL_UNSIGNED_BYTE:
|
||||
case GL_UTF8_NV:
|
||||
return 1;
|
||||
case GL_SHORT:
|
||||
case GL_UNSIGNED_SHORT:
|
||||
case GL_2_BYTES:
|
||||
case GL_UTF16_NV:
|
||||
return 2;
|
||||
case GL_3_BYTES:
|
||||
return 3;
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
case GL_FLOAT:
|
||||
case GL_4_BYTES:
|
||||
return 4;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported path name type: " + pathNameType);
|
||||
}
|
||||
}
|
||||
|
||||
static int calculateTransformPathValues(int transformType) {
|
||||
switch ( transformType ) {
|
||||
case GL_NONE:
|
||||
return 0;
|
||||
case GL_TRANSLATE_X_NV:
|
||||
case GL_TRANSLATE_Y_NV:
|
||||
return 1;
|
||||
case GL_TRANSLATE_2D_NV:
|
||||
return 2;
|
||||
case GL_TRANSLATE_3D_NV:
|
||||
return 3;
|
||||
case GL_AFFINE_2D_NV:
|
||||
case GL_TRANSPOSE_AFFINE_2D_NV:
|
||||
return 6;
|
||||
case GL_AFFINE_3D_NV:
|
||||
case GL_TRANSPOSE_AFFINE_3D_NV:
|
||||
return 12;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported transform type: " + transformType);
|
||||
}
|
||||
}
|
||||
|
||||
static int calculatePathColorGenCoeffsCount(int genMode, int colorFormat) {
|
||||
final int coeffsPerComponent = calculatePathGenCoeffsPerComponent(genMode);
|
||||
|
||||
switch ( colorFormat ) {
|
||||
case GL_RGB:
|
||||
return 3 * coeffsPerComponent;
|
||||
case GL_RGBA:
|
||||
return 4 * coeffsPerComponent;
|
||||
default:
|
||||
return coeffsPerComponent;
|
||||
}
|
||||
}
|
||||
|
||||
static int calculatePathTextGenCoeffsPerComponent(FloatBuffer coeffs, int genMode) {
|
||||
if ( genMode == GL_NONE )
|
||||
return 0;
|
||||
|
||||
return coeffs.remaining() / calculatePathGenCoeffsPerComponent(genMode);
|
||||
}
|
||||
|
||||
private static int calculatePathGenCoeffsPerComponent(int genMode) {
|
||||
switch ( genMode ) {
|
||||
case GL_NONE:
|
||||
return 0;
|
||||
case GL_OBJECT_LINEAR:
|
||||
case GL_PATH_OBJECT_BOUNDING_BOX_NV:
|
||||
return 3;
|
||||
case GL_EYE_LINEAR:
|
||||
return 4;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported gen mode: " + genMode);
|
||||
}
|
||||
}
|
||||
|
||||
static int calculateMetricsSize(int metricQueryMask, int stride) {
|
||||
if ( LWJGLUtil.DEBUG && (stride < 0 || (stride % 4) != 0) )
|
||||
throw new IllegalArgumentException("Invalid stride value: " + stride);
|
||||
|
||||
final int metrics = Integer.bitCount(metricQueryMask);
|
||||
|
||||
if ( LWJGLUtil.DEBUG && (stride >> 2) < metrics )
|
||||
throw new IllegalArgumentException("The queried metrics do not fit in the specified stride: " + stride);
|
||||
|
||||
return stride == 0 ? metrics : (stride >> 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@
|
|||
package org.lwjgl.test.mapped;
|
||||
|
||||
import org.lwjgl.MemoryUtil;
|
||||
import org.lwjgl.util.mapped.MappedObjectUnsafe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ package org.lwjgl.test.mapped;
|
|||
|
||||
import org.lwjgl.MemoryUtil;
|
||||
import org.lwjgl.util.mapped.MappedHelper;
|
||||
import org.lwjgl.util.mapped.MappedObjectUnsafe;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import java.lang.annotation.ElementType;
|
|||
public @interface AutoSize {
|
||||
String value(); // The name of the Buffer parameter
|
||||
String expression() default ""; // This value is added after the argument
|
||||
boolean useExpression() default false; // When this is true, the expression result will be used directly.
|
||||
boolean canBeNull() default false; // When this is true and the Buffer parameter is null, 0 will be used.
|
||||
boolean isNative() default false; // When this is true, auto-sizing will be performed in native code.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,24 +458,26 @@ public class JavaMethodsGenerator {
|
|||
writer.print(auto_type);
|
||||
} else if (AutoSize.class.equals(param_type)) {
|
||||
final AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class);
|
||||
final String auto_parameter_name = auto_size_annotation.value();
|
||||
final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
|
||||
final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
|
||||
final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
|
||||
int shifting = 0;
|
||||
if ( shift_remaining ) {
|
||||
shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
|
||||
if ( shifting > 0 )
|
||||
writer.print("(");
|
||||
}
|
||||
if ( auto_size_annotation.canBeNull() )
|
||||
writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
|
||||
else
|
||||
writer.print(auto_parameter_name + ".remaining()");
|
||||
// Shift the remaining if the target parameter is multityped and there's no AutoType to track type
|
||||
if (shift_remaining && shifting > 0) {
|
||||
writer.print(" << " + shifting);
|
||||
writer.print(")");
|
||||
if ( !auto_size_annotation.useExpression() ) {
|
||||
final String auto_parameter_name = auto_size_annotation.value();
|
||||
final ParameterDeclaration auto_target_param = Utils.findParameter(method, auto_parameter_name);
|
||||
final TypeInfo auto_target_type_info = typeinfos_instance.get(auto_target_param);
|
||||
final boolean shift_remaining = !hasAnyParameterAutoTypeAnnotation(method, auto_target_param) && Utils.isParameterMultiTyped(auto_target_param);
|
||||
int shifting = 0;
|
||||
if ( shift_remaining ) {
|
||||
shifting = getBufferElementSizeExponent(auto_target_type_info.getType());
|
||||
if ( shifting > 0 )
|
||||
writer.print("(");
|
||||
}
|
||||
if ( auto_size_annotation.canBeNull() )
|
||||
writer.print("(" + auto_parameter_name + " == null ? 0 : " + auto_parameter_name + ".remaining())");
|
||||
else
|
||||
writer.print(auto_parameter_name + ".remaining()");
|
||||
// Shift the remaining if the target parameter is multityped and there's no AutoType to track type
|
||||
if (shift_remaining && shifting > 0) {
|
||||
writer.print(" << " + shifting);
|
||||
writer.print(")");
|
||||
}
|
||||
}
|
||||
writer.print(auto_size_annotation.expression());
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ import org.lwjgl.MemoryUtil;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static org.lwjgl.util.mapped.MappedObjectUnsafe.*;
|
||||
|
||||
/**
|
||||
* [INTERNAL USE ONLY]
|
||||
* <p/>
|
||||
|
|
@ -122,7 +124,7 @@ public class MappedHelper {
|
|||
dst.checkRange(bytes);
|
||||
}
|
||||
|
||||
MappedObjectUnsafe.INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
|
||||
INSTANCE.copyMemory(src.viewAddress, dst.viewAddress, bytes);
|
||||
}
|
||||
|
||||
public static ByteBuffer newBuffer(long address, int capacity) {
|
||||
|
|
@ -134,257 +136,257 @@ public class MappedHelper {
|
|||
// byte
|
||||
|
||||
public static void bput(byte value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putByte(addr, value);
|
||||
INSTANCE.putByte(addr, value);
|
||||
}
|
||||
|
||||
public static void bput(MappedObject mapped, byte value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putByte(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putByte(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static byte bget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getByte(addr);
|
||||
return INSTANCE.getByte(addr);
|
||||
}
|
||||
|
||||
public static byte bget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getByte(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getByte(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void bvput(byte value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putByteVolatile(null, addr, value);
|
||||
INSTANCE.putByteVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void bvput(MappedObject mapped, byte value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putByteVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static byte bvget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, addr);
|
||||
return INSTANCE.getByteVolatile(null, addr);
|
||||
}
|
||||
|
||||
public static byte bvget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getByteVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// short
|
||||
|
||||
public static void sput(short value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putShort(addr, value);
|
||||
INSTANCE.putShort(addr, value);
|
||||
}
|
||||
|
||||
public static void sput(MappedObject mapped, short value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putShort(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putShort(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static short sget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getShort(addr);
|
||||
return INSTANCE.getShort(addr);
|
||||
}
|
||||
|
||||
public static short sget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getShort(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getShort(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void svput(short value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putShortVolatile(null, addr, value);
|
||||
INSTANCE.putShortVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void svput(MappedObject mapped, short value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putShortVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static short svget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, addr);
|
||||
return INSTANCE.getShortVolatile(null, addr);
|
||||
}
|
||||
|
||||
public static short svget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getShortVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// char
|
||||
|
||||
public static void cput(char value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putChar(addr, value);
|
||||
INSTANCE.putChar(addr, value);
|
||||
}
|
||||
|
||||
public static void cput(MappedObject mapped, char value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putChar(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putChar(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static char cget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getChar(addr);
|
||||
return INSTANCE.getChar(addr);
|
||||
}
|
||||
|
||||
public static char cget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getChar(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getChar(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void cvput(char value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putCharVolatile(null, addr, value);
|
||||
INSTANCE.putCharVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void cvput(MappedObject mapped, char value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putCharVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static char cvget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, addr);
|
||||
return INSTANCE.getCharVolatile(null, addr);
|
||||
}
|
||||
|
||||
public static char cvget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getCharVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// int
|
||||
|
||||
public static void iput(int value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putInt(addr, value);
|
||||
INSTANCE.putInt(addr, value);
|
||||
}
|
||||
|
||||
public static void iput(MappedObject mapped, int value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putInt(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putInt(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static int iget(long address) {
|
||||
return MappedObjectUnsafe.INSTANCE.getInt(address);
|
||||
return INSTANCE.getInt(address);
|
||||
}
|
||||
|
||||
public static int iget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getInt(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getInt(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void ivput(int value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putIntVolatile(null, addr, value);
|
||||
INSTANCE.putIntVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void ivput(MappedObject mapped, int value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putIntVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static int ivget(long address) {
|
||||
return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, address);
|
||||
return INSTANCE.getIntVolatile(null, address);
|
||||
}
|
||||
|
||||
public static int ivget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getIntVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// float
|
||||
|
||||
public static void fput(float value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putFloat(addr, value);
|
||||
INSTANCE.putFloat(addr, value);
|
||||
}
|
||||
|
||||
public static void fput(MappedObject mapped, float value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putFloat(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static float fget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getFloat(addr);
|
||||
return INSTANCE.getFloat(addr);
|
||||
}
|
||||
|
||||
public static float fget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getFloat(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void fvput(float value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, addr, value);
|
||||
INSTANCE.putFloatVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void fvput(MappedObject mapped, float value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putFloatVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static float fvget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, addr);
|
||||
return INSTANCE.getFloatVolatile(null, addr);
|
||||
}
|
||||
|
||||
public static float fvget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getFloatVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// long
|
||||
|
||||
public static void jput(long value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putLong(addr, value);
|
||||
INSTANCE.putLong(addr, value);
|
||||
}
|
||||
|
||||
public static void jput(MappedObject mapped, long value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putLong(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putLong(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static long jget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getLong(addr);
|
||||
return INSTANCE.getLong(addr);
|
||||
}
|
||||
|
||||
public static long lget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getLong(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getLong(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void jvput(long value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putLongVolatile(null, addr, value);
|
||||
INSTANCE.putLongVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void jvput(MappedObject mapped, long value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putLongVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static long jvget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, addr);
|
||||
return INSTANCE.getLongVolatile(null, addr);
|
||||
}
|
||||
|
||||
public static long lvget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getLongVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// address
|
||||
|
||||
public static void aput(long value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putAddress(addr, value);
|
||||
INSTANCE.putAddress(addr, value);
|
||||
}
|
||||
|
||||
public static void aput(MappedObject mapped, long value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putAddress(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static long aget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getAddress(addr);
|
||||
return INSTANCE.getAddress(addr);
|
||||
}
|
||||
|
||||
public static long aget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getAddress(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getAddress(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
// double
|
||||
|
||||
public static void dput(double value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putDouble(addr, value);
|
||||
INSTANCE.putDouble(addr, value);
|
||||
}
|
||||
|
||||
public static void dput(MappedObject mapped, double value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putDouble(mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static double dget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getDouble(addr);
|
||||
return INSTANCE.getDouble(addr);
|
||||
}
|
||||
|
||||
public static double dget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getDouble(mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
public static void dvput(double value, long addr) {
|
||||
MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, addr, value);
|
||||
INSTANCE.putDoubleVolatile(null, addr, value);
|
||||
}
|
||||
|
||||
public static void dvput(MappedObject mapped, double value, int fieldOffset) {
|
||||
MappedObjectUnsafe.INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
INSTANCE.putDoubleVolatile(null, mapped.viewAddress + fieldOffset, value);
|
||||
}
|
||||
|
||||
public static double dvget(long addr) {
|
||||
return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, addr);
|
||||
return INSTANCE.getDoubleVolatile(null, addr);
|
||||
}
|
||||
|
||||
public static double dvget(MappedObject mapped, int fieldOffset) {
|
||||
return MappedObjectUnsafe.INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
return INSTANCE.getDoubleVolatile(null, mapped.viewAddress + fieldOffset);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -549,10 +549,10 @@ public class MappedObjectTransformer {
|
|||
final Map<Integer, MappedSubtypeInfo> arrayVars = new HashMap<Integer, MappedSubtypeInfo>();
|
||||
|
||||
/*
|
||||
We need this map because we insert/remove instructions from the stream and we need a way
|
||||
to match each original instruction with the corresponding frame.
|
||||
TODO: Can we keep track of everything more efficiently without a map?
|
||||
*/
|
||||
We need this map because we insert/remove instructions from the stream and we need a way
|
||||
to match each original instruction with the corresponding frame.
|
||||
TODO: Can we keep track of everything more efficiently without a map?
|
||||
*/
|
||||
final Map<AbstractInsnNode, Frame<BasicValue>> frameMap = new HashMap<AbstractInsnNode, Frame<BasicValue>>();
|
||||
for ( int i = 0; i < frames.length; i++ )
|
||||
frameMap.put(instructions.get(i), frames[i]);
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ import sun.misc.Unsafe;
|
|||
*
|
||||
* @author Riven
|
||||
*/
|
||||
public class MappedObjectUnsafe {
|
||||
final class MappedObjectUnsafe {
|
||||
|
||||
public static final Unsafe INSTANCE = getUnsafeInstance();
|
||||
static final Unsafe INSTANCE = getUnsafeInstance();
|
||||
|
||||
private static final long BUFFER_ADDRESS_OFFSET = getObjectFieldOffset(ByteBuffer.class, "address");
|
||||
private static final long BUFFER_CAPACITY_OFFSET = getObjectFieldOffset(ByteBuffer.class, "capacity");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue