/** * Gets the must reaching definition of a given node. The node must be one of the control flow * graph nodes. * * @param name name of the variable. It can only be names of local variable that are not function * parameters, escaped variables or variables declared in catch. * @param useNode the location of the use where the definition reaches. */ Node getDef(String name, Node useNode) { Preconditions.checkArgument(getCfg().hasNode(useNode)); GraphNode<Node, Branch> n = getCfg().getNode(useNode); FlowState<MustDef> state = n.getAnnotation(); Definition def = state.getIn().reachingDef.get(jsScope.getVar(name)); if (def == null) { return null; } else { return def.node; } }
@Override public void initialInboundWindowSize(int newWindowSize) throws Http2Exception { int deltaWindowSize = newWindowSize - initialWindowSize; initialWindowSize = newWindowSize; // Apply the delta to all of the windows. connectionState.addAndGet(deltaWindowSize); for (FlowState window : streamStates.values()) { window.updatedInitialWindowSize(deltaWindowSize); } }
boolean dependsOnOuterScopeVars(String name, Node useNode) { Preconditions.checkArgument(getCfg().hasNode(useNode)); GraphNode<Node, Branch> n = getCfg().getNode(useNode); FlowState<MustDef> state = n.getAnnotation(); Definition def = state.getIn().reachingDef.get(jsScope.getVar(name)); for (Var s : def.depends) { if (s.scope != jsScope) { return true; } } return false; }
/** Apply connection-wide flow control to the incoming data frame. */ private void applyConnectionFlowControl(int dataLength, FrameWriter frameWriter) throws Http2Exception { // Remove the data length from the available window size. Throw if the lower bound // was exceeded. connectionState.addAndGet(-dataLength); // If less than the window update threshold remains, restore the window size // to the initial value and send a window update to the remote endpoint indicating // the new window size. if (connectionState.windowSize() <= getWindowUpdateThreshold()) { connectionState.updateWindow(frameWriter); } }
/** Apply stream-based flow control to the incoming data frame. */ private void applyStreamFlowControl( int streamId, int dataLength, boolean endOfStream, FrameWriter frameWriter) throws Http2Exception { // Remove the data length from the available window size. Throw if the lower bound // was exceeded. FlowState state = getStateOrFail(streamId); state.addAndGet(-dataLength); // If less than the window update threshold remains, restore the window size // to the initial value and send a window update to the remote endpoint indicating // the new window size. if (state.windowSize() <= getWindowUpdateThreshold() && !endOfStream) { state.updateWindow(frameWriter); } }