Search in sources :

Example 1 with Fence

use of org.robovm.compiler.llvm.Fence in project robovm by robovm.

the class ClassCompiler method createFieldSetter.

static Function createFieldSetter(Function fn, SootField field, List<SootField> classFields, StructureType classType, List<SootField> instanceFields, StructureType instanceType) {
    Value fieldPtr = null;
    Value value = null;
    if (field.isStatic()) {
        fieldPtr = getClassFieldPtr(fn, field, classFields, classType);
        value = fn.getParameterRef(1);
    } else {
        fieldPtr = getInstanceFieldPtr(fn, fn.getParameterRef(1), field, instanceFields, instanceType);
        value = fn.getParameterRef(2);
    }
    if (Modifier.isVolatile(field.getModifiers()) || !field.isStatic() && Modifier.isFinal(field.getModifiers())) {
        if (LongType.v().equals(field.getType())) {
            fn.add(new Store(value, fieldPtr, false, Ordering.unordered, 8));
        } else {
            fn.add(new Store(value, fieldPtr));
        }
        fn.add(new Fence(Ordering.seq_cst));
    } else {
        fn.add(new Store(value, fieldPtr));
    }
    fn.add(new Ret());
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Value(org.robovm.compiler.llvm.Value) Store(org.robovm.compiler.llvm.Store) Fence(org.robovm.compiler.llvm.Fence)

Example 2 with Fence

use of org.robovm.compiler.llvm.Fence in project robovm by robovm.

the class ClassCompiler method createFieldGetter.

static Function createFieldGetter(Function fn, SootField field, List<SootField> classFields, StructureType classType, List<SootField> instanceFields, StructureType instanceType) {
    Value fieldPtr = null;
    if (field.isStatic()) {
        fieldPtr = getClassFieldPtr(fn, field, classFields, classType);
    } else {
        fieldPtr = getInstanceFieldPtr(fn, fn.getParameterRef(1), field, instanceFields, instanceType);
    }
    Variable result = fn.newVariable(getType(field.getType()));
    if (Modifier.isVolatile(field.getModifiers())) {
        fn.add(new Fence(Ordering.seq_cst));
        if (LongType.v().equals(field.getType())) {
            fn.add(new Load(result, fieldPtr, false, Ordering.unordered, 8));
        } else {
            fn.add(new Load(result, fieldPtr));
        }
    } else {
        fn.add(new Load(result, fieldPtr));
    }
    fn.add(new Ret(new VariableRef(result)));
    return fn;
}
Also used : Ret(org.robovm.compiler.llvm.Ret) Load(org.robovm.compiler.llvm.Load) VariableRef(org.robovm.compiler.llvm.VariableRef) Variable(org.robovm.compiler.llvm.Variable) Value(org.robovm.compiler.llvm.Value) Fence(org.robovm.compiler.llvm.Fence)

Aggregations

Fence (org.robovm.compiler.llvm.Fence)2 Ret (org.robovm.compiler.llvm.Ret)2 Value (org.robovm.compiler.llvm.Value)2 Load (org.robovm.compiler.llvm.Load)1 Store (org.robovm.compiler.llvm.Store)1 Variable (org.robovm.compiler.llvm.Variable)1 VariableRef (org.robovm.compiler.llvm.VariableRef)1