Package org.vmmagic.unboxed

Examples of org.vmmagic.unboxed.Address


            offset = Offset.fromIntZeroExtend(f.getSharedStaticsIndex() << 2);
        } else {
            staticsTable = VmMagic.currentProcessor().getIsolatedStaticsTable();
            offset = Offset.fromIntZeroExtend(f.getIsolatedStaticsIndex() << 2);
        }
        final Address ptr = VmMagic.getArrayData(staticsTable);
        ptr.store(ObjectReference.fromObject(value), offset);
    }
View Full Code Here


     *
     * @param address
     * @return True if address is between start and end, false otherwise
     */
    public boolean isInScope(Address address) {
        final Address start = Address.fromAddress(startPtr);
        final Address end = Address.fromAddress(endPtr);

        return address.GE(start) && address.LT(end);
    }
View Full Code Here

        memScan = new MemoryScannerImpl();
    }

    protected static ResourceManager initialize() {
        try {
            final Address kernelStart = Unsafe.getKernelStart();
            final Address kernelEnd = Unsafe.getKernelEnd();
            final Extent kernelSize = kernelEnd.toWord().sub(kernelStart.toWord()).toExtent();
            MemoryResourceImpl
                .claimMemoryResource(new SimpleResourceOwner("kernel"), kernelStart, kernelSize, MEMMODE_NORMAL);

            final Address bootHeapStart = Unsafe.getBootHeapStart();
            final Address bootHeapEnd = Unsafe.getBootHeapEnd();
            final Extent bootHeapSize = bootHeapEnd.toWord().sub(bootHeapStart.toWord()).toExtent();
            MemoryResourceImpl
                .claimMemoryResource(new SimpleResourceOwner("bootheap"), bootHeapStart, bootHeapSize, MEMMODE_NORMAL);

            ResourceManager rm = new ResourceManagerImpl();
            InitialNaming.bind(NAME, rm);
View Full Code Here

        VmThread vmThread = ThreadHelper.getVmThread(thread);

        final int stackSize = vmThread.getStackSize();
        final Object stack = invoke("getStack", VmThread.class, vmThread);
        if (stack != null) {
            final Address stackBottom = ObjectReference.fromObject(stack).toAddress();
            final Address stackTop = stackBottom.add(stackSize);
            final Address stackEnd;
            if (vmThread == VmThread.currentThread()) {
                stackEnd = stackBottom;
            } else {
                stackEnd = ((VmX86Thread) vmThread).getStackPointer();
            }
            final int slotSize = (Integer) invoke("getReferenceSize", VmX86Thread.class, vmThread);
            Address stackFrame = vmThread.getStackFrame();
            System.out.println("Stack start:    " + NumberUtils.hex(stackTop.toInt()));
            System.out.println("Stack end  :    " + NumberUtils.hex(stackEnd.toInt()));

            System.out.println("Raw stack:");
            Address ptr = stackTop;


            while (ptr.GE(stackEnd)) {
                final Address child = ptr.loadAddress();
                if (child != null) {
                    System.out.print(NumberUtils.hex(ptr.toInt()) + " ");
                    if (VmUtils.getVm().getHeapManager().isObject(child)) {
                        System.out.println(child);
                    } else {
                        System.out.println(NumberUtils.hex(child.toInt()));
                    }
                }
                ptr = ptr.sub(slotSize);
            }

            System.out.println("Stack frames:");
            VmX86StackReader sr = new VmX86StackReader(slotSize);
            Address currFrame = stackFrame;

            //Address prevFrame = null;
            do {
                ptr = currFrame;
                //ccid
                ptr = ptr.add(Offset.fromIntSignExtend(VmX86StackReader.METHOD_ID_OFFSET * slotSize));
                int ccid = ptr.loadInt();
                if (ccid == 0) {
                    //invalid farme, exit
                    break;
                }

                System.out.println("--------------------------------------------------------------------------");
                System.out.println("Stack frame:    " + NumberUtils.hex(stackFrame.toInt()));

                VmCompiledCode cc = VmUtils.getVm().getCompiledMethods().get(ccid);
                VmMethod vmMethod = cc.getMethod();
                int noArguments = vmMethod.getNoArguments();
                VmType[] args = new VmType[noArguments];
                for (int i = 0; i < noArguments; i++) {
                    args[i] = vmMethod.getArgumentType(i);
                }
                System.out.print(NumberUtils.hex(ptr.toInt()) + " ");
                System.out.println(vmMethod.getDeclaringClass().getName() + "." + vmMethod.getName() +
                    Signature.toSignature(vmMethod.getReturnType(), args));

                ptr = ptr.sub(Offset.fromIntSignExtend(VmX86StackReader.METHOD_ID_OFFSET * slotSize));

                //old EBP
                System.out.println("Previous frame");
                ptr = ptr.add(Offset.fromIntSignExtend(VmX86StackReader.PREVIOUS_OFFSET * slotSize));
                System.out.print(NumberUtils.hex(ptr.toInt()) + " ");
                System.out.println(NumberUtils.hex(ptr.loadInt()));

                ptr = ptr.sub(Offset.fromIntSignExtend(VmX86StackReader.PREVIOUS_OFFSET * slotSize));

                //return Address
                System.out.println("Return address");
                ptr = ptr.add(Offset.fromIntSignExtend(VmX86StackReader.RETURNADDRESS_OFFSET * slotSize));
                System.out.print(NumberUtils.hex(ptr.toInt()) + " ");
                System.out.println(NumberUtils.hex(ptr.loadInt()));

                //method argumants
                int sc = vmMethod.getArgSlotCount();
                System.out.println("Method arguments: " + sc);
                for (int i = 0; i < sc; i++) {
                    ptr = ptr.add(slotSize);
                    System.out.print(NumberUtils.hex(ptr.toInt()) + " Arg" + (i + 1) + " = ");
                    Address child = ptr.loadAddress();
                    if (VmUtils.getVm().getHeapManager().isObject(child)) {
                        System.out.println("Class: " + child.getClass() + " Value: " + child);
                    } else {
                        System.out.println(NumberUtils.hex(child.toInt()));
                    }
                    //System.out.println(NumberUtils.hex(ptr.loadInt()));
                }
            } while ((currFrame = sr.getPrevious(currFrame)) != null);

View Full Code Here

            } finally {
                proc.enableReschedule(false);
            }
            inSystemException = true;
        } else if (current == proc.getCurrentThread()) {
            final Address curFrame = VmMagic.getCurrentFrame();
            mt = reader.getVmStackTrace(reader.getPrevious(curFrame), reader
                .getReturnAddress(curFrame), STACKTRACE_LIMIT);
        } else {
            proc.disableReschedule(false);
            try {
View Full Code Here

                return true;
            } else {
                return false;
            }
        } else {
            final Address valuePtr = ObjectReference.fromObject(value).toAddress();
            if (slotLength == 1) {
                statics[idx] = valuePtr.toInt();
            } else {
                final long lvalue = valuePtr.toLong();
                if (lsbFirst) {
                    statics[idx + 0] = (int) (lvalue & 0xFFFFFFFFL);
                    statics[idx + 1] = (int) ((lvalue >>> 32) & 0xFFFFFFFFL);
                } else {
                    statics[idx + 1] = (int) (lvalue & 0xFFFFFFFFL);
View Full Code Here

    private final Object getRawObject(int idx) {
        if (objects != null) {
            return objects[idx];
        } else {
            final Address ptr;
            if (slotLength == 1) {
                ptr = Address.fromIntZeroExtend(statics[idx]);
            } else {
                final long lsb;
                final long msb;
                if (lsbFirst) {
                    lsb = statics[idx + 0] & 0xFFFFFFFFL;
                    msb = statics[idx + 1] & 0xFFFFFFFFL;
                } else {
                    lsb = statics[idx + 1] & 0xFFFFFFFFL;
                    msb = statics[idx + 0] & 0xFFFFFFFFL;
                }
                ptr = Address.fromLong(lsb | (msb << 32));
            }
            return ptr.toObjectReference().toObject();
        }
    }
View Full Code Here

    /**
     * Show the current stacktrace using Screen.debug.
     */
    @KernelSpace
    public final void debugStackTrace(int max) {
        Address f = VmMagic.getCurrentFrame();
        Unsafe.debug("\nDebug stacktrace: ");
        boolean first = true;
        while (isValid(f) && (max > 0)) {
            if (first) {
                first = false;
View Full Code Here

    /**
     * Show the stacktrace of the given thread using Screen.debug.
     */
    @KernelSpace
    public final void debugStackTrace(VmThread thread) {
        Address f = thread.getStackFrame();
        Unsafe.debug("Debug stacktrace: ");
        boolean first = true;
        int max = 20;
        while (isValid(f) && (max > 0)) {
            if (first) {
View Full Code Here

     * {@inheritDoc}
     */
    public final Object clone(Cloneable object) {
        testInited();
        final VmClassType<?> objectClass = VmMagic.getObjectType(object);
        final Address objectPtr = ObjectReference.fromObject(object)
            .toAddress();
        final int size;
        if (objectClass.isArray()) {
            final int slotSize = getCurrentProcessor().getArchitecture()
                .getReferenceSize();
            final VmArrayClass<?> arrayClass = (VmArrayClass<?>) objectClass;
            final int length = objectPtr.loadInt(Offset
                .fromIntSignExtend(VmArray.LENGTH_OFFSET * slotSize));
            final int elemSize = arrayClass.getComponentType().getTypeSize();
            size = (VmArray.DATA_OFFSET * slotSize) + (length * elemSize);
        } else {
            final VmNormalClass<?> normalClass = (VmNormalClass<?>) objectClass;
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.