mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Unsafe code for AtomicReference
This commit is contained in:
parent
3f5cb135e5
commit
588c9563f6
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2022 Volker Berlin (i-net software)
|
* Copyright 2023 Volker Berlin (i-net software)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,6 +24,7 @@ import de.inetsoftware.jwebassembly.WasmException;
|
|||||||
import de.inetsoftware.jwebassembly.module.StackInspector.StackValue;
|
import de.inetsoftware.jwebassembly.module.StackInspector.StackValue;
|
||||||
import de.inetsoftware.jwebassembly.module.WasmInstruction.Type;
|
import de.inetsoftware.jwebassembly.module.WasmInstruction.Type;
|
||||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||||
|
import de.inetsoftware.jwebassembly.wasm.ValueType;
|
||||||
import de.inetsoftware.jwebassembly.wasm.VariableOperator;
|
import de.inetsoftware.jwebassembly.wasm.VariableOperator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,6 +153,7 @@ class UnsafeManager {
|
|||||||
case "sun/misc/Unsafe.putOrderedLong(Ljava/lang/Object;JJ)V":
|
case "sun/misc/Unsafe.putOrderedLong(Ljava/lang/Object;JJ)V":
|
||||||
case "sun/misc/Unsafe.getObjectVolatile(Ljava/lang/Object;J)Ljava/lang/Object;":
|
case "sun/misc/Unsafe.getObjectVolatile(Ljava/lang/Object;J)Ljava/lang/Object;":
|
||||||
case "sun/misc/Unsafe.putOrderedObject(Ljava/lang/Object;JLjava/lang/Object;)V":
|
case "sun/misc/Unsafe.putOrderedObject(Ljava/lang/Object;JLjava/lang/Object;)V":
|
||||||
|
case "sun/misc/Unsafe.getAndSetObject(Ljava/lang/Object;JLjava/lang/Object;)Ljava/lang/Object;":
|
||||||
case "jdk/internal/misc/Unsafe.getAndAddInt(Ljava/lang/Object;JI)I":
|
case "jdk/internal/misc/Unsafe.getAndAddInt(Ljava/lang/Object;JI)I":
|
||||||
case "jdk/internal/misc/Unsafe.getAndSetInt(Ljava/lang/Object;JI)I":
|
case "jdk/internal/misc/Unsafe.getAndSetInt(Ljava/lang/Object;JI)I":
|
||||||
case "jdk/internal/misc/Unsafe.putIntRelease(Ljava/lang/Object;JI)V":
|
case "jdk/internal/misc/Unsafe.putIntRelease(Ljava/lang/Object;JI)V":
|
||||||
@ -432,10 +434,15 @@ class UnsafeManager {
|
|||||||
switch( name.methodName ) {
|
switch( name.methodName ) {
|
||||||
case "compareAndSwapInt":
|
case "compareAndSwapInt":
|
||||||
case "compareAndSwapLong":
|
case "compareAndSwapLong":
|
||||||
|
case "compareAndSwapObject":
|
||||||
|
AnyType type = paramTypes[3];
|
||||||
|
if( type.isRefType() ) {
|
||||||
|
type = ValueType.ref;
|
||||||
|
}
|
||||||
return "local.get 0" // THIS
|
return "local.get 0" // THIS
|
||||||
+ " struct.get " + state.typeName + ' ' + state.fieldName //
|
+ " struct.get " + state.typeName + ' ' + state.fieldName //
|
||||||
+ " local.get 2 " // expected
|
+ " local.get 2 " // expected
|
||||||
+ paramTypes[3] + ".eq" //
|
+ type + ".eq" //
|
||||||
+ " if" //
|
+ " if" //
|
||||||
+ " local.get 0" // THIS
|
+ " local.get 0" // THIS
|
||||||
+ " local.get 3" // update
|
+ " local.get 3" // update
|
||||||
@ -460,6 +467,7 @@ class UnsafeManager {
|
|||||||
|
|
||||||
case "getAndSetInt":
|
case "getAndSetInt":
|
||||||
case "getAndSetLong":
|
case "getAndSetLong":
|
||||||
|
case "getAndSetObject":
|
||||||
return "local.get 0" // THIS
|
return "local.get 0" // THIS
|
||||||
+ " struct.get " + state.typeName + ' ' + state.fieldName //
|
+ " struct.get " + state.typeName + ' ' + state.fieldName //
|
||||||
+ " local.get 0" // THIS
|
+ " local.get 0" // THIS
|
||||||
@ -469,6 +477,7 @@ class UnsafeManager {
|
|||||||
|
|
||||||
case "putOrderedInt":
|
case "putOrderedInt":
|
||||||
case "putOrderedLong":
|
case "putOrderedLong":
|
||||||
|
case "putOrderedObject":
|
||||||
return "local.get 0" // THIS
|
return "local.get 0" // THIS
|
||||||
+ " local.get 2" // x
|
+ " local.get 2" // x
|
||||||
+ " struct.set " + state.typeName + ' ' + state.fieldName;
|
+ " struct.set " + state.typeName + ' ' + state.fieldName;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 - 2022 Volker Berlin (i-net software)
|
Copyright 2018 - 2023 Volker Berlin (i-net software)
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -227,6 +227,9 @@ public class WatParser extends WasmCodeBuilder {
|
|||||||
case "ref.is_null":
|
case "ref.is_null":
|
||||||
addNumericInstruction( NumericOperator.ifnull, ValueType.i32, javaCodePos, lineNumber );
|
addNumericInstruction( NumericOperator.ifnull, ValueType.i32, javaCodePos, lineNumber );
|
||||||
break;
|
break;
|
||||||
|
case "ref.eq":
|
||||||
|
addNumericInstruction( NumericOperator.ref_eq, ValueType.i32, javaCodePos, lineNumber );
|
||||||
|
break;
|
||||||
case "table.get":
|
case "table.get":
|
||||||
addTableInstruction( true, getInt( tokens, ++i), javaCodePos, lineNumber );
|
addTableInstruction( true, getInt( tokens, ++i), javaCodePos, lineNumber );
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user