public static int getStackRootCount(Address stackFrame) { return stackFrame.getInt(); }
public static Address getStackRootPointer(Address stackFrame) { int size = stackFrame.getInt(); return stackFrame.add(-size * 4); }
private static Address getExceptionHandlerPtr(Address stackFrame) { int size = stackFrame.getInt(); return stackFrame.add(-size * 4 - 4); }
public static int getCallSiteId(Address stackFrame) { return getExceptionHandlerPtr(stackFrame).getInt(); }
public static Address getNextStackFrame(Address stackFrame) { int size = stackFrame.getInt() + 2; Address result = stackFrame.add(-size * 4); if (result == initStack()) { result = null; } return result; }
private static int resourceMapSize(Address map) { int result = 0; int sz = map.getInt(); Address data = contentStart(map); for (int i = 0; i < sz; ++i) { if (data.getAddress() != null) { result++; } data = data.add(Address.sizeOf() * 2); } return result; }
@Unmanaged public static RuntimeArray allocateMultiArray(RuntimeClass tag, Address dimensions, int dimensionCount) { int size = dimensions.getInt(); RuntimeArray array = allocateArray(tag, dimensions.getInt()).toStructure(); if (dimensionCount > 1) { Address arrayData = Structure.add(RuntimeArray.class, array, 1).toAddress(); arrayData = Address.align(arrayData, Address.sizeOf()); for (int i = 0; i < size; ++i) { RuntimeArray innerArray = allocateMultiArray(tag.itemType, dimensions.add(4), dimensionCount - 1); arrayData.putAddress(innerArray.toAddress()); arrayData = arrayData.add(Address.sizeOf()); } } return array; }
private static void fillResourceMapKeys(Address map, String[] target) { int sz = map.getInt(); Address data = contentStart(map); Address targetData = Address.ofData(target); for (int i = 0; i < sz; ++i) { Address entry = data.getAddress(); if (entry != null) { targetData.putAddress(entry); targetData = targetData.add(Address.sizeOf()); } data = data.add(Address.sizeOf()); } }
public static Address lookupResource(Address map, String string) { RuntimeString runtimeString = Address.ofObject(string).toStructure(); int hashCode = hashCode(runtimeString); int sz = map.getInt(); Address content = contentStart(map); for (int i = 0; i < sz; ++i) { int index = (hashCode + i) % sz; if (index < 0) { index += sz; } Address entry = content.add(index * Address.sizeOf() * 2); Address key = entry.getAddress(); if (key == null) { return null; } if (equals(key.toStructure(), runtimeString)) { return entry; } } return null; }
private static void mark() { Allocator.fillZero(regionsAddress().toAddress(), regionMaxCount() * Structure.sizeOf(Region.class)); Address staticRoots = Mutator.getStaticGCRoots(); int staticCount = staticRoots.getInt(); staticRoots = staticRoots.add(Address.sizeOf()); while (staticCount-- > 0) { RuntimeObject object = staticRoots.getAddress().getAddress().toStructure(); if (object != null) { mark(object); } staticRoots = staticRoots.add(Address.sizeOf()); } for (Address stackRoots = ShadowStack.getStackTop(); stackRoots != null; stackRoots = ShadowStack.getNextStackFrame(stackRoots)) { int count = ShadowStack.getStackRootCount(stackRoots); Address stackRootsPtr = ShadowStack.getStackRootPointer(stackRoots); while (count-- > 0) { RuntimeObject obj = stackRootsPtr.getAddress().toStructure(); mark(obj); stackRootsPtr = stackRootsPtr.add(Address.sizeOf()); } } }
switch (source.toInt() - alignedSourceStart.toInt()) { case 0: alignedTargetStart.putInt(alignedSourceStart.getInt()); break; case 1: alignedTargetStart.putInt(alignedSourceStart.getInt()); alignedSourceStart = alignedSourceStart.add(4); alignedTargetStart = alignedTargetStart.add(4); alignedSourceEnd = alignedSourceEnd.add(-4); alignedTargetEnd = alignedTargetEnd.add(-4); alignedTargetEnd.putInt(alignedSourceEnd.getInt());
public static int getStackRootCount(Address stackFrame) { return stackFrame.getInt(); }
public static Address getStackRootPointer(Address stackFrame) { int size = stackFrame.getInt(); return stackFrame.add(-size * 4); }
private static Address getExceptionHandlerPtr(Address stackFrame) { int size = stackFrame.getInt(); return stackFrame.add(-size * 4 - 4); }
public static int getCallSiteId(Address stackFrame) { return getExceptionHandlerPtr(stackFrame).getInt(); }
public static Address getNextStackFrame(Address stackFrame) { int size = stackFrame.getInt() + 2; Address result = stackFrame.add(-size * 4); if (result == initStack()) { result = null; } return result; }
public static RuntimeArray allocateMultiArray(RuntimeClass tag, Address dimensions, int dimensionCount) { int size = dimensions.getInt(); RuntimeArray array = allocateArray(tag, dimensions.getInt()).toStructure(); if (dimensionCount > 1) { Address arrayData = Structure.add(RuntimeArray.class, array, 1).toAddress(); arrayData = Address.align(arrayData, Address.sizeOf()); for (int i = 0; i < size; ++i) { RuntimeArray innerArray = allocateMultiArray(tag.itemType, dimensions.add(4), dimensionCount - 1); arrayData.putAddress(innerArray.toAddress()); arrayData = arrayData.add(Address.sizeOf()); } } return array; }
private static void mark() { Allocator.fillZero(regionsAddress().toAddress(), regionMaxCount() * Structure.sizeOf(Region.class)); Address staticRoots = Mutator.getStaticGCRoots(); int staticCount = staticRoots.getInt(); staticRoots = staticRoots.add(8); while (staticCount-- > 0) { RuntimeObject object = staticRoots.getAddress().getAddress().toStructure(); if (object != null) { mark(object); } staticRoots = staticRoots.add(Address.sizeOf()); } for (Address stackRoots = ShadowStack.getStackTop(); stackRoots != null; stackRoots = ShadowStack.getNextStackFrame(stackRoots)) { int count = ShadowStack.getStackRootCount(stackRoots); Address stackRootsPtr = ShadowStack.getStackRootPointer(stackRoots); while (count-- > 0) { RuntimeObject obj = stackRootsPtr.getAddress().toStructure(); mark(obj); stackRootsPtr = stackRootsPtr.add(Address.sizeOf()); } } }
switch (source.toInt() - alignedSourceStart.toInt()) { case 0: alignedTargetStart.putInt(alignedSourceStart.getInt()); break; case 1: alignedTargetStart.putInt(alignedSourceStart.getInt()); alignedSourceStart = alignedSourceStart.add(4); alignedTargetStart = alignedTargetStart.add(4); alignedTargetEnd.putInt(alignedSourceEnd.getInt()); alignedSourceEnd = alignedSourceEnd.add(-4); alignedTargetEnd = alignedTargetEnd.add(-4); alignedTargetStart.putInt(alignedSourceStart.getInt()); break; case 1: