use of com.oracle.truffle.espresso.impl.ArrayKlass in project graal by oracle.
the class BytecodeNode method allocateMultiArray.
// endregion Class/Method/Field resolution
// region Instance/array allocation
@ExplodeLoop
private int allocateMultiArray(VirtualFrame frame, int top, Klass klass, int allocatedDimensions) {
assert klass.isArray();
CompilerAsserts.partialEvaluationConstant(allocatedDimensions);
CompilerAsserts.partialEvaluationConstant(klass);
int[] dimensions = new int[allocatedDimensions];
for (int i = 0; i < allocatedDimensions; ++i) {
dimensions[i] = popInt(frame, top - allocatedDimensions + i);
}
putObject(frame, top - allocatedDimensions, getInterpreterToVM().newMultiArray(((ArrayKlass) klass).getComponentType(), dimensions));
// Does not include the created (pushed) array.
return -allocatedDimensions;
}
use of com.oracle.truffle.espresso.impl.ArrayKlass in project graal by oracle.
the class Target_sun_misc_Unsafe method arrayBaseOffset.
/**
* Report the offset of the first element in the storage allocation of a given array class. If
* {@link #arrayIndexScale} returns a non-zero value for the same class, you may use that scale
* factor, together with this base offset, to form new offsets to access elements of arrays of
* the given class.
*
* @see #getInt
* @see #putInt
*/
@Substitution(hasReceiver = true, nameProvider = SharedUnsafeAppend0.class)
public static int arrayBaseOffset(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Class.class) StaticObject clazz, @Inject Meta meta) {
Unsafe unsafe = UnsafeAccess.getIfAllowed(meta);
Klass klass = clazz.getMirrorKlass();
assert klass.isArray();
if (((ArrayKlass) klass).getComponentType().isPrimitive()) {
Class<?> hostPrimitive = ((ArrayKlass) klass).getComponentType().getJavaKind().toJavaClass();
return unsafe.arrayBaseOffset(Array.newInstance(hostPrimitive, 0).getClass());
} else {
// Just a reference type.
return unsafe.arrayBaseOffset(Object[].class);
}
}
Aggregations