Search in sources :

Example 6 with Property

use of com.oracle.truffle.api.object.Property in project graal by oracle.

the class ShapeImpl method getPropertyList.

/**
 * @since 0.17 or earlier
 */
@TruffleBoundary
@Override
public final List<Property> getPropertyList() {
    Property[] props = new Property[getPropertyCount()];
    int i = props.length;
    for (Iterator<Property> it = this.propertyMap.reverseOrderedValueIterator(); it.hasNext(); ) {
        Property currentProperty = it.next();
        if (!currentProperty.isHidden()) {
            props[--i] = currentProperty;
        }
    }
    return Arrays.asList(props);
}
Also used : Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 7 with Property

use of com.oracle.truffle.api.object.Property in project graal by oracle.

the class ShapeImpl method createFactory.

/**
 * @since 0.17 or earlier
 */
@Override
public final DynamicObjectFactory createFactory() {
    List<Property> properties = getPropertyListInternal(true);
    List<Property> filtered = null;
    for (ListIterator<Property> iterator = properties.listIterator(); iterator.hasNext(); ) {
        Property property = iterator.next();
        // skip non-instance fields
        assert property.getLocation() != layout.getPrimitiveArrayLocation();
        if (property.getLocation() instanceof ValueLocation) {
            if (filtered == null) {
                filtered = new ArrayList<>();
                filtered.addAll(properties.subList(0, iterator.previousIndex()));
            }
        } else if (filtered != null) {
            filtered.add(property);
        }
    }
    if (filtered != null) {
        properties = filtered;
    }
    return new DynamicObjectFactoryImpl(this, properties);
}
Also used : Property(com.oracle.truffle.api.object.Property) ValueLocation(com.oracle.truffle.object.Locations.ValueLocation)

Example 8 with Property

use of com.oracle.truffle.api.object.Property in project graal by oracle.

the class ShapeImpl method getKeyList.

/**
 * @since 0.17 or earlier
 */
@TruffleBoundary
@Override
public final List<Object> getKeyList() {
    Object[] props = new Object[getPropertyCount()];
    int i = props.length;
    for (Iterator<Property> it = this.propertyMap.reverseOrderedValueIterator(); it.hasNext(); ) {
        Property currentProperty = it.next();
        if (!currentProperty.isHidden()) {
            props[--i] = currentProperty.getKey();
        }
    }
    return Arrays.asList(props);
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 9 with Property

use of com.oracle.truffle.api.object.Property in project graal by oracle.

the class ShapeImpl method getPropertyListInternal.

/**
 * Returns all (also hidden) Property objects in this shape.
 *
 * @param ascending desired order
 * @since 0.17 or earlier
 */
@TruffleBoundary
@Override
public final List<Property> getPropertyListInternal(boolean ascending) {
    Property[] props = new Property[this.propertyMap.size()];
    int i = ascending ? props.length : 0;
    for (Iterator<Property> it = this.propertyMap.reverseOrderedValueIterator(); it.hasNext(); ) {
        Property current = it.next();
        if (ascending) {
            props[--i] = current;
        } else {
            props[i++] = current;
        }
    }
    return Arrays.asList(props);
}
Also used : Property(com.oracle.truffle.api.object.Property) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 10 with Property

use of com.oracle.truffle.api.object.Property in project graal by oracle.

the class ShapeImpl method makeShapeWithAddedProperty.

/**
 * Create a new shape that adds a property to the parent shape.
 *
 * @since 0.17 or earlier
 */
protected static ShapeImpl makeShapeWithAddedProperty(ShapeImpl parent, AddPropertyTransition addTransition) {
    Property addend = addTransition.getProperty();
    BaseAllocator allocator = parent.allocator().addLocation(addend.getLocation());
    PropertyMap newPropertyMap = parent.propertyMap.putCopy(addend);
    ShapeImpl newShape = parent.createShape(parent.layout, parent.sharedData, parent, parent.objectType, newPropertyMap, addTransition, allocator, parent.id);
    assert ((LocationImpl) addend.getLocation()).primitiveArrayCount() == 0 || newShape.hasPrimitiveArray;
    assert newShape.depth == allocator.depth;
    return newShape;
}
Also used : Property(com.oracle.truffle.api.object.Property)

Aggregations

Property (com.oracle.truffle.api.object.Property)31 DynamicObject (com.oracle.truffle.api.object.DynamicObject)8 Test (org.junit.Test)7 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)6 IncompatibleLocationException (com.oracle.truffle.api.object.IncompatibleLocationException)4 Location (com.oracle.truffle.api.object.Location)4 ArrayDeque (java.util.ArrayDeque)3 FinalLocationException (com.oracle.truffle.api.object.FinalLocationException)2 ObjectLocation (com.oracle.truffle.api.object.ObjectLocation)2 DeclaredLocation (com.oracle.truffle.object.Locations.DeclaredLocation)2 Layout (com.oracle.truffle.api.object.Layout)1 Shape (com.oracle.truffle.api.object.Shape)1 ValueLocation (com.oracle.truffle.object.Locations.ValueLocation)1 PropertyMap (com.oracle.truffle.object.PropertyMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Random (java.util.Random)1