Search in sources :

Example 31 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class MemoryManagerTest method allocateArrayTestOverflowToNegative.

@Test(expected = OutOfMemoryError.class)
public void allocateArrayTestOverflowToNegative() {
    int size = 1 << 29;
    RVMArray arrayType = RVMArray.IntArray;
    int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
    int align = ObjectModel.getAlignment(arrayType);
    int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
    int width = arrayType.getLogElementSize();
    TIB arrayTib = arrayType.getTypeInformationBlock();
    int[] test = (int[]) MemoryManager.allocateArray(size, width, headerSize, arrayTib, ALLOC_NON_MOVING, align, offset, DEFAULT_SITE);
    fail("FAIL! Created array with length " + test.length);
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Test(org.junit.Test)

Example 32 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class MemoryManagerTest method allocateArrayTestNegative.

@Test(expected = OutOfMemoryError.class)
public void allocateArrayTestNegative() {
    int size = -5;
    RVMArray arrayType = RVMArray.IntArray;
    int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
    int align = ObjectModel.getAlignment(arrayType);
    int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
    int width = arrayType.getLogElementSize();
    TIB arrayTib = arrayType.getTypeInformationBlock();
    int[] test = (int[]) MemoryManager.allocateArray(size, width, headerSize, arrayTib, ALLOC_NON_MOVING, align, offset, DEFAULT_SITE);
    fail("FAIL! Created array with length " + test.length);
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Test(org.junit.Test)

Aggregations

RVMArray (org.jikesrvm.classloader.RVMArray)32 TIB (org.jikesrvm.objectmodel.TIB)14 Entrypoint (org.vmmagic.pragma.Entrypoint)14 RVMType (org.jikesrvm.classloader.RVMType)11 RVMClass (org.jikesrvm.classloader.RVMClass)9 NoInline (org.vmmagic.pragma.NoInline)8 TypeReference (org.jikesrvm.classloader.TypeReference)7 Interruptible (org.vmmagic.pragma.Interruptible)7 RVMMethod (org.jikesrvm.classloader.RVMMethod)6 Address (org.vmmagic.unboxed.Address)6 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)4 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)4 Test (org.junit.Test)4 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)3 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)3 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)3 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)3 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)3 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)3 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)3