public Namespace(String name, Namespace parent) { this.functionName = name; this.parent = parent; this.frameDescriptor = new FrameDescriptor(); }
public FrameSlot findOrAddFrameSlot(Object identifier) { FrameSlot result = findFrameSlot(identifier); if (result != null) { return result; } return addFrameSlot(identifier); }
DefaultVirtualFrame(FrameDescriptor descriptor, Object[] arguments) { this.descriptor = descriptor; this.arguments = arguments; this.locals = new Object[descriptor.getSize()]; Arrays.fill(locals, descriptor.getDefaultValue()); this.tags = new byte[descriptor.getSize()]; }
public FrameDescriptor copy() { FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue); for (int i = 0; i < this.getSlots().size(); i++) { Object identifier = this.getSlots().get(i).getIdentifier(); clonedFrameDescriptor.addFrameSlot(identifier); } return clonedFrameDescriptor; }
/** * Deeper copy of the descriptor. Copies all slots in the descriptor, but only their * {@linkplain FrameSlot#getIdentifier() identifier} and {@linkplain FrameSlot#getInfo() info} * but not their {@linkplain FrameSlot#getKind() kind}! * * @return new instance of a descriptor with copies of values from this one * @since 0.8 or earlier */ public FrameDescriptor copy() { FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue); for (int i = 0; i < slots.size(); i++) { FrameSlot slot = slots.get(i); clonedFrameDescriptor.addFrameSlot(slot.getIdentifier(), slot.getInfo(), FrameSlotKind.Illegal); } return clonedFrameDescriptor; }
public FrameSlot addFrameSlot(Object identifier, FrameSlotKind kind) { return addFrameSlot(identifier, null, kind); }
@Override protected void innerOnDispose(EventContext context, VirtualFrame frame) { Lock lock = getLock(); lock.lock(); try { if (inputSlots != null) { FrameSlot[] slots = inputSlots; inputSlots = null; RootNode rootNode = context.getInstrumentedNode().getRootNode(); if (rootNode == null) { return; } FrameDescriptor descriptor = rootNode.getFrameDescriptor(); assert descriptor != null; for (FrameSlot slot : slots) { FrameSlot resolvedSlot = descriptor.findFrameSlot(slot.getIdentifier()); if (resolvedSlot != null) { descriptor.removeFrameSlot(slot.getIdentifier()); } else { // slot might be shared and already removed by another event provider // node. } } } } finally { lock.unlock(); } super.innerOnDispose(context, frame); }
public FrameSlot addFrameSlot(Object identifier, Object info, FrameSlotKind kind) { CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); assert !identifierToSlotMap.containsKey(identifier); FrameSlot slot = new FrameSlot(this, identifier, info, slots.size(), kind); slots.add(slot); identifierToSlotMap.put(identifier, slot); updateVersion(); invalidateNotInFrameAssumption(identifier); return slot; }
public void removeFrameSlot(Object identifier) { CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); assert identifierToSlotMap.containsKey(identifier); slots.remove(identifierToSlotMap.get(identifier)); identifierToSlotMap.remove(identifier); updateVersion(); getNotInFrameAssumption(identifier); }
private static void clearFrame(MaterializedFrame frame) { FrameDescriptor descriptor = frame.getFrameDescriptor(); Object value = descriptor.getDefaultValue(); for (FrameSlot slot : descriptor.getSlots()) { frame.setObject(slot, value); } }
private LuaNode declareLocalVariable(String name, LuaExpressionNode value) { return LuaWriteLocalVariableNodeFactory.create(value, frameDescriptor.findOrAddFrameSlot(name)); }
private Object visitName(Name name) { final FrameSlot frameSlot = frameDescriptor.findFrameSlot(name.name); if (frameSlot == null) { return visitGlobalName(name); } return LuaReadLocalVariableNodeFactory.create(frameSlot); }
@Override protected void onDispose(VirtualFrame frame) { FrameDescriptor frameDescriptor = context.getInstrumentedNode().getRootNode().getFrameDescriptor(); if (frameDescriptor.getIdentifiers().contains(KEY_TIME_STARTED)) { frameDescriptor.removeFrameSlot(KEY_TIME_STARTED); } if (frameDescriptor.getIdentifiers().contains(KEY_PARENT_COUNTER)) { frameDescriptor.removeFrameSlot(KEY_PARENT_COUNTER); } }
private TRegexDFAExecutorProperties createExecutorProperties(NFA nfaArg, boolean forward, boolean searching, boolean trackCaptureGroups) { FrameDescriptor frameDescriptor = new FrameDescriptor(); FrameSlot inputFS = frameDescriptor.addFrameSlot("input", FrameSlotKind.Object); FrameSlot fromIndexFS = frameDescriptor.addFrameSlot("fromIndex", FrameSlotKind.Int); FrameSlot indexFS = frameDescriptor.addFrameSlot("index", FrameSlotKind.Int); FrameSlot maxIndexFS = frameDescriptor.addFrameSlot("maxIndex", FrameSlotKind.Int); FrameSlot curMaxIndexFS = frameDescriptor.addFrameSlot("curMaxIndex", FrameSlotKind.Int); FrameSlot successorIndexFS = frameDescriptor.addFrameSlot("successorIndex", FrameSlotKind.Int); FrameSlot resultFS = frameDescriptor.addFrameSlot("result", FrameSlotKind.Int); FrameSlot captureGroupResultFS = frameDescriptor.addFrameSlot("captureGroupResult", FrameSlotKind.Object); FrameSlot lastTransitionFS = frameDescriptor.addFrameSlot("lastTransition", FrameSlotKind.Int); FrameSlot cgDataFS = frameDescriptor.addFrameSlot("cgData", FrameSlotKind.Object); return new TRegexDFAExecutorProperties( frameDescriptor,
public FrameSlot addFrameSlot(Object identifier) { return addFrameSlot(identifier, null, FrameSlotKind.Illegal); }
@Override protected void innerOnDispose(EventContext context, VirtualFrame frame) { Lock lock = getLock(); lock.lock(); try { if (inputSlots != null) { FrameSlot[] slots = inputSlots; inputSlots = null; RootNode rootNode = context.getInstrumentedNode().getRootNode(); if (rootNode == null) { return; } FrameDescriptor descriptor = rootNode.getFrameDescriptor(); assert descriptor != null; for (FrameSlot slot : slots) { FrameSlot resolvedSlot = descriptor.findFrameSlot(slot.getIdentifier()); if (resolvedSlot != null) { descriptor.removeFrameSlot(slot.getIdentifier()); } else { // slot might be shared and already removed by another event provider // node. } } } } finally { lock.unlock(); } super.innerOnDispose(context, frame); }
/** * Adds new frame slot to {@link #getSlots()} list. This is a slow operation that switches to * interpreter mode. * * @param identifier key for the slot - must not be {@code null} and needs proper * {@link #equals(java.lang.Object)} and {@link Object#hashCode()} implementations * @param info additional {@linkplain FrameSlot#getInfo() information for the slot}, may be null * @param kind the kind of the new slot * @return the newly created slot * @throws IllegalArgumentException if a frame slot with the same identifier exists * @throws NullPointerException if {@code identifier} or {@code kind} is {@code null} * @since 0.8 or earlier */ public FrameSlot addFrameSlot(Object identifier, Object info, FrameSlotKind kind) { CompilerAsserts.neverPartOfCompilation(NEVER_PART_OF_COMPILATION_MESSAGE); Objects.requireNonNull(identifier, "identifier"); Objects.requireNonNull(kind, "kind"); if (identifierToSlotMap.containsKey(identifier)) { throw new IllegalArgumentException("duplicate frame slot: " + identifier); } FrameSlot slot = new FrameSlot(this, identifier, info, kind, slots.size()); slots.add(slot); identifierToSlotMap.put(identifier, slot); updateVersion(); invalidateNotInFrameAssumption(identifier); return slot; }
/** * Removes a slot. If the identifier is found, its slot is removed from this descriptor. This is * a slow operation. * * @param identifier identifies the slot to remove * @throws IllegalArgumentException if no such frame slot exists * @since 0.8 or earlier */ public void removeFrameSlot(Object identifier) { CompilerAsserts.neverPartOfCompilation(NEVER_PART_OF_COMPILATION_MESSAGE); synchronized (lock) { FrameSlot slot = identifierToSlotMap.get(identifier); if (slot == null) { throw new IllegalArgumentException("no such frame slot: " + identifier); } slots.remove(slot); identifierToSlotMap.removeKey(identifier); updateVersion(); getNotInFrameAssumption(identifier); } }
private static void clearFrame(RootNode root, MaterializedFrame frame) { FrameDescriptor descriptor = frame.getFrameDescriptor(); if (root.getFrameDescriptor() == descriptor) { // Clear only those frames that correspond to the current root Object value = descriptor.getDefaultValue(); for (FrameSlot slot : descriptor.getSlots()) { frame.setObject(slot, value); } } }