mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
more Java 11 Unsafe replacements
This commit is contained in:
parent
577d2883c9
commit
579288d663
@ -163,8 +163,15 @@ class UnsafeManager {
|
|||||||
case "jdk/internal/misc/Unsafe.isBigEndian()Z":
|
case "jdk/internal/misc/Unsafe.isBigEndian()Z":
|
||||||
patch_isBigEndian( instructions, idx, callInst );
|
patch_isBigEndian( instructions, idx, callInst );
|
||||||
break;
|
break;
|
||||||
|
case "jdk/internal/misc/Unsafe.shouldBeInitialized(Ljava/lang/Class;)Z":
|
||||||
|
replaceWithConstNumber( instructions, idx, callInst, 2, 0 );
|
||||||
|
break;
|
||||||
case "jdk/internal/misc/Unsafe.storeFence()V":
|
case "jdk/internal/misc/Unsafe.storeFence()V":
|
||||||
remove( instructions, idx, callInst );
|
remove( instructions, idx, callInst, 1 );
|
||||||
|
break;
|
||||||
|
case "jdk/internal/misc/Unsafe.ensureClassInitialized(Ljava/lang/Class;)V":
|
||||||
|
case "jdk/internal/misc/Unsafe.unpark(Ljava/lang/Object;)V":
|
||||||
|
remove( instructions, idx, callInst, 2 );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new WasmException( "Unsupported Unsafe method: " + name.signatureName, -1 );
|
throw new WasmException( "Unsupported Unsafe method: " + name.signatureName, -1 );
|
||||||
@ -495,9 +502,28 @@ class UnsafeManager {
|
|||||||
* @param callInst
|
* @param callInst
|
||||||
* the method call to Unsafe
|
* the method call to Unsafe
|
||||||
*/
|
*/
|
||||||
private void remove( List<WasmInstruction> instructions, int idx, final WasmCallInstruction callInst ) {
|
private void replaceWithConstNumber( List<WasmInstruction> instructions, int idx, final WasmCallInstruction callInst, int paramCount, int number ) {
|
||||||
int from = StackInspector.findInstructionThatPushValue( instructions.subList( 0, idx ), 1, callInst.getCodePosition() ).idx;
|
int from = StackInspector.findInstructionThatPushValue( instructions.subList( 0, idx ), 1, callInst.getCodePosition() ).idx;
|
||||||
|
|
||||||
|
nop( instructions, from, idx );
|
||||||
|
|
||||||
|
// on x86 use little endian
|
||||||
|
instructions.set( idx, new WasmConstNumberInstruction( number, callInst.getCodePosition(), callInst.getLineNumber() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch an unsafe function that access a field
|
||||||
|
*
|
||||||
|
* @param instructions
|
||||||
|
* the instruction list
|
||||||
|
* @param idx
|
||||||
|
* the index in the instructions
|
||||||
|
* @param callInst
|
||||||
|
* the method call to Unsafe
|
||||||
|
*/
|
||||||
|
private void remove( List<WasmInstruction> instructions, int idx, final WasmCallInstruction callInst, int paramCount ) {
|
||||||
|
int from = StackInspector.findInstructionThatPushValue( instructions.subList( 0, idx ), paramCount, callInst.getCodePosition() ).idx;
|
||||||
|
|
||||||
nop( instructions, from, idx + 1 );
|
nop( instructions, from, idx + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +335,14 @@ class ReplacementForClass<T> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the declaring class
|
||||||
|
* @return the declaring class for this class
|
||||||
|
*/
|
||||||
|
private Class<?> getDeclaringClass0() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement of the Java method getSimpleName()
|
* Replacement of the Java method getSimpleName()
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user