public static ReadRegisterFixedNode forIsolateThread() { return new ReadRegisterFixedNode(SubstrateRegisterConfig::getThreadRegister); }
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { b.addPush(JavaKind.Object, ReadRegisterFixedNode.forHeapBase()); return true; } });
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { if (SubstrateOptions.MultiThreaded.getValue()) { b.addPush(JavaKind.Object, ReadRegisterFixedNode.forIsolateThread()); } else if (SubstrateOptions.SpawnIsolates.getValue()) { ValueNode heapBase = b.add(ReadRegisterFixedNode.forHeapBase()); ConstantNode addend = b.add(ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND)); b.addPush(JavaKind.Object, new AddNode(heapBase, addend)); } else { b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_THREAD_SENTINEL.rawValue())); } return true; } });
private static ValueNode currentThread(GraphBuilderContext b, boolean usedForAddress) { /* * A floating node to access the VMThread is more efficient: it allows value numbering of * multiple accesses, and it does not copy the VMThread from the fixed register into a * virtual register. But for deoptimization target methods, we must not do value numbering * because the VMThread is not part of the FrameState and therefore not restored during * deoptimization. And when computing the address of a VMThreadLocal, we must not have the * VMThread in a fixed register because the it can end up in a FrameState (and a FrameState * must not directly reference a fixed register). */ boolean isDeoptTarget = b.getMethod() instanceof SharedMethod && ((SharedMethod) b.getMethod()).isDeoptTarget(); if (isDeoptTarget || usedForAddress) { return b.add(ReadRegisterFixedNode.forIsolateThread()); } else { return b.add(ReadRegisterFloatingNode.forIsolateThread()); } }
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { if (SubstrateOptions.SpawnIsolates.getValue()) { b.addPush(JavaKind.Object, ReadRegisterFixedNode.forHeapBase()); } else { b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_SENTINEL.rawValue())); } return true; } });
public static ReadRegisterFixedNode forHeapBase() { return new ReadRegisterFixedNode(SubstrateRegisterConfig::getHeapBaseRegister); }