Package org.vmmagic.unboxed

Examples of org.vmmagic.unboxed.Address


        }
        if (srcOfs + length > src.length) {
            throw new IndexOutOfBoundsException("srcOfs + length > src.length");
        }
        testMemPtr(dstPtr, length * 8);
        final Address srcPtr = VmMagic.getArrayData(src).add(srcOfs * 8);
        final Extent size = Extent.fromIntZeroExtend(length * 8);
        Unsafe.copy(srcPtr, start.add(dstPtr), size);
    }
View Full Code Here


        }

        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);
View Full Code Here

            throw new IndexOutOfBoundsException("MemoryResource is released");
        }
        if (offset.toWord().add(size).GT(this.size.toWord())) {
            throw new IndexOutOfBoundsException("Offset + size > this.size");
        }
        final Address addr = this.start.add(offset);
        final MemoryResourceImpl child = new MemoryResourceImpl(this, getOwner(), addr, size);
        synchronized (this) {
            // Re-test released flag
            if (released) {
                throw new IndexOutOfBoundsException("MemoryResource is released");
View Full Code Here

     */
    @NoInline
    private final void enterSlowPath() {
        // No yet owner, try to obtain the lock
        boolean loop = true;
        final Address lcAddr = getLCAddress();
        while (loop) {
            // Get current thread
            final VmThread current = VmMagic.currentProcessor().getCurrentThread();
            // Try to claim this monitor
            if (lcAddr.attempt(0, 1)) {
                loop = false;
                dropFromOwner();
                this.owner = current;
                addToOwner();
            } else {
View Full Code Here

     * @see #monitorLock
     */
    @Inline
    private final void lock() {
        //final VmProcessor proc = VmProcessor.current();
        final Address mlAddr = ObjectReference.fromObject(this).toAddress().add(4);
        while (!mlAddr.attempt(0, 1)) {
            //proc.yield(true); // Yield breaks the Uninterruptible idea, so don't use it!
        }
    }
View Full Code Here

     * @see #unlock()
     * @see #monitorLock
     */
    @Inline
    private final boolean lockNoWait() {
        final Address mlAddr = ObjectReference.fromObject(this).toAddress().add(4);
        return mlAddr.attempt(0, 1);
    }
View Full Code Here

            Unsafe.debugStackTrace();
            Unsafe.die("Deadlock in SpinLock#lock");
        }

        // Do the spinlock
        final Address mlAddr = ObjectReference.fromObject(this).toAddress();
        while (!mlAddr.attempt(0, 1)) {
            current.yield(true);
        }
        this.owner = current;
    }
View Full Code Here

     * @param rm the resource manager
     * @return The initial jarfile resource, or null if no initial jarfile is
     *         available.
     */
    private static MemoryResource loadInitJar(ResourceManager rm) {
        final Address start = Unsafe.getInitJarStart();
        final Address end = Unsafe.getInitJarEnd();
        final Extent size = end.toWord().sub(start.toWord()).toExtent();
        if (size.toWord().isZero()) {
            // No initial jarfile
            BootLogInstance.get().info("No initial jarfile found");
            return null;
        } else {
View Full Code Here

     */
    protected static VmClassLoader getContextClassLoader() {
        final VmStackReader reader = VmProcessor.current().getArchitecture()
            .getStackReader();
        final VmSystemClassLoader systemLoader = VmSystem.systemLoader;
        Address f = VmMagic.getCurrentFrame();
        while (reader.isValid(f)) {
            final VmMethod method = reader.getMethod(f);
            final VmClassLoader loader = method.getDeclaringClass().getLoader();
            if ((loader != null) && (loader != systemLoader)) {
                return loader;
View Full Code Here

            .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();

        final int srcLen = srcAddr.loadInt(lengthOffset);
        final int dstLen = dstAddr.loadInt(lengthOffset);

        // Calc end index (if overflow, then will be < 0 )
        final int srcEnd = srcPos + length;
        final int dstEnd = dstPos + length;

        if ((srcEnd > srcLen) || (srcEnd < 0)) {
            throw new IndexOutOfBoundsException("srcPos+length > src.length ("
                + srcPos + '+' + length + " > " + srcLen + ')');
        }
        if ((dstEnd > dstLen) || (dstEnd < 0)) {
            throw new IndexOutOfBoundsException("dstPos+length > dst.length");
        }

        final int elemsize;
        final boolean isObjectArray;
        switch (src_type) {
            case 'Z':
                // Boolean
            case 'B':
                // Byte
                elemsize = 1;
                isObjectArray = false;
                break;
            case 'C':
                // Character
            case 'S':
                // Short
                elemsize = 2;
                isObjectArray = false;
                break;
            case 'I':
                // Integer
            case 'F':
                // Float
                elemsize = 4;
                isObjectArray = false;
                break;
            case 'L':
                // Object
                elemsize = slotSize;
                isObjectArray = true;
                break;
            case 'J':
                // Long
            case 'D':
                // Double
                elemsize = 8;
                isObjectArray = false;
                break;
            default:
                // Unsafe.debug("uat:");
                // Unsafe.debug(src_type);
                // Unsafe.debug(src_name);
                throw new ArrayStoreException("Unknown array type");
        }

        final Address srcPtr = srcAddr.add(dataOffset + (srcPos * elemsize));
        final Address dstPtr = dstAddr.add(dataOffset + (dstPos * elemsize));
        final Extent size = Extent.fromIntZeroExtend(length * elemsize);


        if (isObjectArray) {
            Class dst_comp_class = dst_class.getComponentType();
View Full Code Here

TOP

Related Classes of org.vmmagic.unboxed.Address

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.