Package org.vmmagic.unboxed

Examples of org.vmmagic.unboxed.Offset


                    .debugStackTrace();
        }

        final int align = ObjectLayout.OBJECT_ALIGN;
        final Word headerSize = Word.fromIntZeroExtend(this.headerSize);
        final Offset tibOffset = Offset.fromIntSignExtend(this.tibOffset);
        final Offset flagsOffset = Offset.fromIntSignExtend(this.flagsOffset);
        int allocator = BasePlan.ALLOC_DEFAULT;

        final int refSize = VmUtils.getVm().getArch().getReferenceSize();
        allocator = checkAllocator(size, align, allocator);
View Full Code Here


        }
        if (align <= 0) {
            throw new IllegalArgumentException("Align must be >= 1");
        }

        Offset offset = Offset.zero();
        final Word alignMask = Word.fromIntZeroExtend(align - 1);
        while (true) {
            final Address addr = this.start.add(offset);
            final MemoryResourceImpl child = new MemoryResourceImpl(this, getOwner(), addr, size);
            final MemoryResourceImpl existingChild = (MemoryResourceImpl) get(this.children, child);
            if (existingChild == null) {
                // We found a free region
                this.children = (MemoryResourceImpl) add(this.children, child);
                return child;
            }
            // We found an existing child, skip over that.
            offset = existingChild.getOffset().add(existingChild.getSize());

            // Align the new offset
            if (!offset.toWord().and(alignMask).isZero()) {
                offset = offset.toWord().add(alignMask).and(alignMask.not()).toOffset();
            }

            // Do we have space left?
            if (offset.toWord().add(size).GT(this.size.toWord())) {
                throw new ResourceNotFreeException();
            }
        }
    }
View Full Code Here

            throw new IndexOutOfBoundsException("length < 0");
        }

        final int slotSize = VmProcessor.current().getArchitecture()
            .getReferenceSize();
        final Offset lengthOffset = Offset
            .fromIntSignExtend(VmArray.LENGTH_OFFSET * slotSize);
        final int dataOffset = VmArray.DATA_OFFSET * slotSize;

        final Address srcAddr = ObjectReference.fromObject(src).toAddress();
        final Address dstAddr = ObjectReference.fromObject(dst).toAddress();
View Full Code Here

    public static void setStaticField(Class<?> clazz, String fieldName,
                                      Object value) {
        final VmStaticField f = (VmStaticField) VmType.fromClass((Class<?>) clazz).getField(
            fieldName);
        final Object staticsTable;
        final Offset offset;
        if (f.isShared()) {
            staticsTable = VmMagic.currentProcessor().getSharedStaticsTable();
            offset = Offset.fromIntZeroExtend(f.getSharedStaticsIndex() << 2);
        } else {
            staticsTable = VmMagic.currentProcessor().getIsolatedStaticsTable();
View Full Code Here

            this.deviceRam =
                    rm.claimMemoryResource(device, Address.fromIntZeroExtend(fbBase), memSize,
                            ResourceManager.MEMMODE_NORMAL);

            // Map MMIO block 0, first test for 8Mb framebuffers.
            Offset block0Ofs = Offset.fromIntZeroExtend(0x7ffc00);
            Extent mmioSize = Extent.fromIntZeroExtend(1024); // 1K
            MemoryResource mmio0 = deviceRam.claimChildResource(block0Ofs, mmioSize, false);
            Mach64VgaIO io = new Mach64VgaIO(deviceRam, mmio0);
            if ((io.getReg32(CONFIG_CHIP_ID) & CFG_CHIP_TYPE) != pciCfg.getDeviceID()) {
                // Try for 4Mb framebuffers.
View Full Code Here

            return false;
        }

        final int offset = addr.toWord().sub(start.toWord()).toInt();
        int bit = offset / ObjectLayout.OBJECT_ALIGN;
        final Offset idx = Offset.fromIntZeroExtend(bit / 8);
        final int mask = 1 << (bit & 7);
        final Address bitmapPtr = this.allocationBitmapPtr;
        final int value = bitmapPtr.loadByte(idx);
        return ((value & mask) == mask);
    }
View Full Code Here

            return;
        }

        final int offset = addr.toWord().sub(start.toWord()).toInt();
        final int bit = offset / ObjectLayout.OBJECT_ALIGN;
        final Offset idx = Offset.fromIntZeroExtend(bit / 8);
        final int mask = 1 << (bit & 7);
        final Address bitmapPtr = this.allocationBitmapPtr;
        int value = bitmapPtr.loadByte(idx);
        if (on) {
            value |= mask;
View Full Code Here

     */
    protected static VmDefaultHeap setupHeap(HeapHelper helper, Address start,
                                             VmNormalClass<VmDefaultHeap> heapClass, int slotSize) {
        final int headerSize = ObjectLayout
            .objectAlign((ObjectLayout.HEADER_SLOTS + 1) * slotSize);
        final Offset vmtOffset = Offset.fromIntSignExtend(ObjectLayout.TIB_SLOT * slotSize);
        final Offset sizeOffset = Offset.fromIntSignExtend(-((ObjectLayout.HEADER_SLOTS + 1) * slotSize));
        final Offset flagsOffset = Offset.fromIntSignExtend(ObjectLayout.FLAGS_SLOT * slotSize);

        // Setup a heap object, so the heap can initialize itself.
        final Address heapPtr = start.add(headerSize);
        final Word heapObjSize = Word.fromIntZeroExtend(ObjectLayout.objectAlign(heapClass
            .getObjectSize()));
View Full Code Here

        if (nextFreePtr.EQ(Address.zero())) { /* This heap is full */
            return null;
        }

        final Offset tibOffset = this.tibOffset;
        final Word headerSize = Word.fromIntZeroExtend(this.headerSize);
        final Offset flagsOffset = this.flagsOffset;
        final Offset sizeOffset = this.sizeOffset;

        Word alignedSizeW = Word.fromIntZeroExtend(alignedSize);
        final Word totalSize = alignedSizeW.add(headerSize);
        final Object tib = vmClass.getTIB();
        if (tib == null) {
View Full Code Here

     */
    protected final void defragment() throws UninterruptiblePragma {
        final Word size = Word.fromIntZeroExtend(getSize());
        final Word headerSize = Word.fromIntZeroExtend(this.headerSize);
        Word offset = headerSize;
        final Offset sizeOffset = this.sizeOffset;
        final Offset tibOffset = this.tibOffset;


        lock();
        try {
            Address firstFreePtr = Address.zero();
View Full Code Here

TOP

Related Classes of org.vmmagic.unboxed.Offset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.