This implementation comes at a relatively high cost per invocation. It should not be called repeatedly when it is
clear that the value did not change. Currently this is only truly used to realize certain higher-level tests.
190088
@Override
	public int size() {

		if (allElementsInCache) {
			return orderedCache.size();
		} else {
			int count = 0;
			try (final RocksBytesIterator iterator = orderedBytesIterator()) {
				while (iterator.hasNext()) {
					iterator.next();
					++count;
				}
			}
			return count;
		}
	}
694613
private void incrementCurrentValue() {
    currentValues[currentValues.length - 1]++;
    int i = currentValues.length - 1;
    while (i > 0 &&
        currentValues[i] > finalValues[i]) {
      currentValues[i] = 0;
      currentValues[i - 1]++;
      i--;
    }
  }
1328860
@Override
  public void process(Node externs, Node root) {
    progress = 0.0;
    progressStep = 0.0;
    if (progressRange != null) {
      progressStep = (progressRange.maxValue - progressRange.initialValue)
          / passes.size();
      progress = progressRange.initialValue;
    }

    // When looking at this code, one can mistakenly think that the instance of
    // PhaseOptimizer keeps all compiler passes live. This would be undesirable. A pass can
    // create large data structures that are only useful to the pass, and we shouldn't
    // retain them until the end of the compilation. But if you look at
    // NamedPass#process, the actual pass is created and immediately executed, and no
    // reference to it is retained in PhaseOptimizer:
    //   factory.create(compiler).process(externs, root);
    for (CompilerPass pass : passes) {
      if (Thread.interrupted()) {
        throw new RuntimeException(new InterruptedException());
      }
      pass.process(externs, root);
      if (hasHaltingErrors()) {
        return;
      }
    }
  }
442305
private static boolean meetsThresholdRequirement(long timeTaken) {
        final P6LogLoadableOptions opts = P6LogOptions.getActiveInstance();
        long executionThreshold = null != opts ? opts.getExecutionThreshold() : 0;
    
    return executionThreshold <= 0 || TimeUnit.NANOSECONDS.toMillis(timeTaken) > executionThreshold;
  }
750084
@Override
    public void sawOpcode(int seen) {
        try {
            stack.precomputation(this);

            int pc = getPC();
            if ((loopEnd != -1) && (pc > loopEnd)) {
                loopStart = -1;
                loopEnd = -1;
                regValueType.clear();
            }

            if (OpcodeUtils.isALoad(seen)) {
                int reg = RegisterUtils.getALoadReg(this, seen);
                State type = regValueType.get(Integer.valueOf(reg));
                if (type == null) {
                    state = State.SEEN_NOTHING;
                } else {
                    state = type;
                }
                return;
            }
            if (OpcodeUtils.isAStore(seen)) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    int reg = RegisterUtils.getAStoreReg(this, seen);
                    regValueType.put(Integer.valueOf(reg), (State) item.getUserValue());
                }
                state = State.SEEN_NOTHING;
                return;
            }
            if (OpcodeUtils.isILoad(seen)) {
                int reg = RegisterUtils.getLoadReg(this, seen);
                State type = regValueType.get(Integer.valueOf(reg));
                if (type == null) {
                    state = State.SEEN_NOTHING;
                } else {
                    state = type;
                }
                return;
            }
            if (OpcodeUtils.isIStore(seen)) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    int reg = RegisterUtils.getStoreReg(this, seen);
                    regValueType.put(Integer.valueOf(reg), (State) item.getUserValue());
                }
                state = State.SEEN_NOTHING;
                return;
            }

            switch (state) {
                case SEEN_NOTHING:
                    if ((seen == Const.INVOKESPECIAL) && "java/util/StringTokenizer".equals(getClassConstantOperand())
                            && Values.CONSTRUCTOR.equals(getNameConstantOperand())
                            && SignatureBuilder.SIG_TWO_STRINGS_TO_VOID.equals(getSigConstantOperand())) {
                        state = State.SEEN_STRINGTOKENIZER;
                    }
                break;

                case SEEN_STRINGTOKENIZER:
                    if (seen == Const.INVOKEVIRTUAL) {
                        String methodName = getNameConstantOperand();
                        String signature = getSigConstantOperand();
                        if ("countTokens".equals(methodName) && SignatureBuilder.SIG_VOID_TO_INT.equals(signature))
                            state = State.SEEN_COUNTTOKENS;
                        else if ("hasMoreTokens".equals(methodName) || "hasMoreElements".equals(methodName))
                            state = State.SEEN_HASMORE;
                        else if ("nextToken".equals(methodName) || "nextElement".equals(methodName)) {
                            if ((pc < loopStart) || (pc > loopEnd))
                                regValueType.clear();
                            else
                                state = State.SEEN_NEXT;
                        }
                    }
                break;

                case SEEN_COUNTTOKENS:
                    if (seen == Const.ANEWARRAY)
                        state = State.SEEN_NEWARRAY;
                    else if (seen == Const.IF_ICMPGE) {
                        int target = getBranchTarget() - 3;// sizeof goto
                        byte[] code = getCode().getCode();
                        if ((code[target] & 0x000000FF) == Const.GOTO) {
                            int offset = (code[target + 1] << 1) + code[target + 2];
                            int gotoTarget = target + offset + 3;
                            if (gotoTarget < getPC()) {
                                loopStart = gotoTarget;
                                loopEnd = target;
                            }
                        }
                    }
                break;

                case SEEN_HASMORE:
                    if (seen == Const.IFEQ) {
                        int target = getBranchTarget() - 3;// sizeof goto
                        byte[] code = getCode().getCode();
                        if ((code[target] & 0x000000FF) == Const.GOTO) {
                            int offset = (code[target + 1] << 1) + code[target + 2];
                            int gotoTarget = target + offset + 3;
                            if (gotoTarget < getPC()) {
                                loopStart = gotoTarget;
                                loopEnd = target;
                            }
                        }
                    }
                    state = State.SEEN_NOTHING;
                break;

                case SEEN_NEXT:
                    if ((seen == Const.AASTORE) && (pc > loopStart) && (pc < loopEnd) && (stack.getStackDepth() > 2)) {
                        OpcodeStack.Item arrayItem = stack.getStackItem(2);
                        State arrayType = (State) arrayItem.getUserValue();
                        OpcodeStack.Item elemItem = stack.getStackItem(0);
                        State elemType = (State) elemItem.getUserValue();
                        if ((arrayType == State.SEEN_NEWARRAY) && (elemType == State.SEEN_NEXT)) {
                            bugReporter.reportBug(new BugInstance(this, BugType.USS_USE_STRING_SPLIT.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
                                    .addSourceLine(this));
                        }
                    }
                    state = State.SEEN_NOTHING;
                break;

                case SEEN_ARRAYSTORE:
                case SEEN_NEWARRAY:
                break;
            }
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if ((state != State.SEEN_NOTHING) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                item.setUserValue(state);
            }
        }
    }
910128
private T retain0(T instance, final int increment, final int rawIncrement) {
        int oldRef = updater().getAndAdd(instance, rawIncrement);
        if (oldRef != 2 && oldRef != 4 && (oldRef & 1) != 0) {
            throw new IllegalReferenceCountException(0, increment);
        }
        // don't pass 0!
        if ((oldRef <= 0 && oldRef + rawIncrement >= 0)
                || (oldRef >= 0 && oldRef + rawIncrement < oldRef)) {
            // overflow case
            updater().getAndAdd(instance, -rawIncrement);
            throw new IllegalReferenceCountException(realRefCnt(oldRef), increment);
        }
        return instance;
    }
37815
@Override
    public void sawOpcode(int seen) {
        Integer tosIsPriority = null;
        try {
            stack.precomputation(this);

            switch (seen) {
                case Const.GETFIELD:
                    tosIsPriority = OWNED;
                break;

                case Const.ALOAD:
                case Const.ALOAD_0:
                case Const.ALOAD_1:
                case Const.ALOAD_2:
                case Const.ALOAD_3: {
                    int reg = RegisterUtils.getALoadReg(this, seen);
                    if ((reg == 0) && getMethod().isStatic()) {
                        tosIsPriority = Values.LOW_BUG_PRIORITY;
                    } else {
                        tosIsPriority = regPriorities.get(Integer.valueOf(reg));
                        if (tosIsPriority == null) {
                            tosIsPriority = Values.NORMAL_BUG_PRIORITY;
                        }
                    }
                }
                break;

                case Const.ASTORE:
                case Const.ASTORE_0:
                case Const.ASTORE_1:
                case Const.ASTORE_2:
                case Const.ASTORE_3: {
                    if (stack.getStackDepth() > 0) {
                        OpcodeStack.Item item = stack.getStackItem(0);
                        Integer priority = (Integer) item.getUserValue();
                        regPriorities.put(Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)), priority);
                    }
                }
                break;

                case Const.INVOKEVIRTUAL:
                case Const.INVOKEINTERFACE: {
                    String sig = getSigConstantOperand();
                    if (SignatureUtils.getReturnSignature(sig).startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
                        int parmCnt = SignatureUtils.getNumParameters(sig);
                        if (stack.getStackDepth() > parmCnt) {
                            OpcodeStack.Item itm = stack.getStackItem(parmCnt);
                            Integer priority = (Integer) itm.getUserValue();
                            if ((priority != null) && OWNED.equals(priority)) {
                                tosIsPriority = OWNED;
                            } else {
                                int reg = itm.getRegisterNumber();
                                if (reg > 0) {
                                    tosIsPriority = regPriorities.get(Integer.valueOf(reg));
                                } else {
                                    tosIsPriority = OWNED;
                                }
                            }
                        }
                    }
                }
                break;

                case Const.INVOKESTATIC: {
                    String sig = getSigConstantOperand();
                    if (SignatureUtils.getReturnSignature(sig).startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
                        tosIsPriority = OWNED; // can't be sure
                    }
                }
                break;

                case Const.INVOKESPECIAL: {
                    String name = getNameConstantOperand();
                    if (Values.CONSTRUCTOR.equals(name)) {
                        tosIsPriority = OWNED;
                    }
                }
                break;

                case Const.MONITORENTER: {
                    if (stack.getStackDepth() > 0) {
                        OpcodeStack.Item itm = stack.getStackItem(0);
                        Integer priority = (Integer) itm.getUserValue();
                        if ((priority != null) && (!priority.equals(OWNED))) {
                            bugReporter.reportBug(new BugInstance(this, BugType.NOS_NON_OWNED_SYNCHRONIZATION.name(), priority.intValue()).addClass(this)
                                    .addMethod(this).addSourceLine(this));
                        }
                    }
                }
                break;
                default:
                break;
            }
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if ((tosIsPriority != null) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                itm.setUserValue(tosIsPriority);
            }
        }
    }
937990
private boolean setCaseChain(int varIndex, int choiceIndex) {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "setCaseChain", new Object[]{Integer.valueOf(varIndex), Integer.valueOf(choiceIndex)});

    if (choiceCache[varIndex] == choiceIndex) {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "setCaseChain", Boolean.FALSE);
      return false;
    }

    int prevChoiceIndex = choiceCache[varIndex];
    choiceCache[varIndex] = choiceIndex;

    boolean dominated = setDominatingCases(variants[varIndex]);

    // We know we've changed a variant case, so we'll normally return 'true'
    // to signal the caller to check their caches. Howver if we set the
    // initial state of a variant that is not dominated by any other
    // variants the change cannot have any effect on anything already
    // cached, so we can return 'false'.
    boolean result = (dominated || (prevChoiceIndex != -1));

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "setCaseChain", Boolean.valueOf(result));
    return result;
  }
295657
private boolean isRetryException(final Throwable th) {
        Throwable current = th;
        boolean res = false;
        while (current != null) {
            if (current instanceof ONeedRetryException) {
                res = true;
                break;
            }
            current = current.getCause();
        }
        return res;
    }
162577
protected boolean sameValue(Object newValue, Object currentValue) {
        if (newValue == NOT_FOUND) {
            return true;
        }
        if (currentValue == NOT_FOUND) {
            currentValue = Undefined.instance;
        }
        // Special rules for numbers: NaN is considered the same value,
        // while zeroes with different signs are considered different.
        if (currentValue instanceof Number && newValue instanceof Number) {
            double d1 = ((Number)currentValue).doubleValue();
            double d2 = ((Number)newValue).doubleValue();
            if (Double.isNaN(d1) && Double.isNaN(d2)) {
                return true;
            }
            if (d1 == 0.0 && Double.doubleToLongBits(d1) != Double.doubleToLongBits(d2)) {
                return false;
            }
        }
        return ScriptRuntime.shallowEq(currentValue, newValue);
    }
1148666
public void valueHasChanged(DCache cache, Object id, long expirationTime, int inactivity) {  // CPF-Inactivity
        //final String methodName = "valueHasChanged()";
        if (expirationTime <= 0 && inactivity <=0 ) { // CPF-Inactivity
            throw new IllegalArgumentException("expirationTime or inactivity must be positive");
        }
        if ( UNIT_TEST_INACTIVITY ) {
            System.out.println(" valueHasChanged() - entry");
            System.out.println(" expirationTime="+expirationTime);
            System.out.println(" inactivity="+inactivity);
        }
        // CPF-Inactivity
        //-----------------------------------------------------------
        // Force an expriationTime if we have an inactivity timer
        //-----------------------------------------------------------
        boolean isInactivityTimeOut = false;
        if ( inactivity > 0 ) {
            // For 7.0, use QuickApproxTime.getRef.getApproxTime()
            long adjustedExpirationTime = System.currentTimeMillis() + ( inactivity * 1000 );
            if ( adjustedExpirationTime < expirationTime ||
                 expirationTime <= 0 ) {
                expirationTime = adjustedExpirationTime;
                isInactivityTimeOut = true;
            }
        }
        ExpirationMetaData expirationMetaData = (ExpirationMetaData)cacheInstancesTable.get(cache);
        // Just make sure expirationMetaData is NOT NULL in case of an internal-error condition
        if (expirationMetaData == null) {
            return;
        }
        synchronized (expirationMetaData) {
            InvalidationTask it = (InvalidationTask) expirationMetaData.expirationTable.get(id);
            if (it == null) {
                it = (InvalidationTask) taskPool.remove();
                it.id = id;
                expirationMetaData.expirationTable.put(id, it);
            } else {
                expirationMetaData.timeLimitHeap.delete(it);
            }
            it.expirationTime = expirationTime;
            it.isInactivityTimeOut = isInactivityTimeOut;
            expirationMetaData.timeLimitHeap.insert(it);
            //ccount++;
            //traceDebug(methodName, "cacheName=" + cache.getCacheName() + " id=" + id + " expirationTableSize=" + expirationMetaData.expirationTable.size() + " timeLimitHeapSize=" + expirationMetaData.timeLimitHeap.size() + " count=" + ccount);
        }
    }
1001432
@Override
    public void sawOpcode(int seen) {
        int reg = -1;
        Object uValue = null;
        boolean sawAlias = false;
        boolean sawLoad = false;
        boolean sawNewArray = false;

        try {
            stack.precomputation(this);

            if (seen == Const.INVOKEINTERFACE) {
                String methodName = getNameConstantOperand();
                String signature = getSigConstantOperand();
                if ("size".equals(methodName) && SignatureBuilder.SIG_VOID_TO_INT.equals(signature)) {
                    if (stack.getStackDepth() > 0) {
                        OpcodeStack.Item itm = stack.getStackItem(0);
                        reg = isLocalCollection(itm);
                        if (reg >= 0) {
                            sawAlias = true;
                        }
                    }
                } else if ("get".equals(methodName) && SignatureBuilder.SIG_INT_TO_OBJECT.equals(signature)) {
                    if (stack.getStackDepth() > 1) {
                        OpcodeStack.Item itm = stack.getStackItem(1);
                        reg = isLocalCollection(itm);
                        if (reg >= 0) {
                            sawAlias = true;
                        }
                    }
                } else if (("keySet".equals(methodName) || "values".equals(methodName) || "iterator".equals(methodName) || "next".equals(methodName))
                        && (stack.getStackDepth() > 0)) {
                    OpcodeStack.Item itm = stack.getStackItem(0);
                    reg = isLocalCollection(itm);
                    if (reg >= 0) {
                        sawAlias = true;
                    }
                }
            } else if (OpcodeUtils.isIStore(seen) || OpcodeUtils.isAStore(seen)) {
                if (stack.getStackDepth() > 0) {
                    uValue = stack.getStackItem(0).getUserValue();
                    userValues.put(Integer.valueOf(RegisterUtils.getStoreReg(this, seen)), uValue);
                }
            } else if (OpcodeUtils.isILoad(seen) || OpcodeUtils.isALoad(seen)) {
                sawLoad = true;
            } else if (seen == Const.ANEWARRAY) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item itm = stack.getStackItem(0);
                    uValue = itm.getUserValue();
                    sawNewArray = true;
                }
            } else if (seen == Const.IF_ICMPGE) {
                if (stack.getStackDepth() > 1) {
                    OpcodeStack.Item itm1 = stack.getStackItem(1);
                    OpcodeStack.Item itm2 = stack.getStackItem(0);
                    reg = itm1.getRegisterNumber();
                    if ((reg >= 0) && (itm1.couldBeZero())) {
                        uValue = itm2.getUserValue();
                        if (uValue != null) {
                            userValues.put(Integer.valueOf(reg), uValue);
                        }
                    }
                }
            } else if ((seen >= Const.IASTORE) && (seen <= Const.SASTORE)) {
                if (stack.getStackDepth() > 2) {
                    OpcodeStack.Item arItem = stack.getStackItem(2);
                    OpcodeStack.Item idxItem = stack.getStackItem(1);
                    OpcodeStack.Item valueItem = stack.getStackItem(0);
                    reg = isLocalCollection(arItem);
                    if ((reg >= 0) && (idxItem.getUserValue() != null) && (valueItem.getUserValue() != null)) {
                        bugReporter.reportBug(
                                new BugInstance(this, BugType.UTA_USE_TO_ARRAY.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
                    }
                }
            } else if ((seen == Const.CHECKCAST) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                uValue = itm.getUserValue();
                if (uValue instanceof Integer) {
                    reg = ((Integer) uValue).intValue();
                    sawAlias = true;
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if (sawAlias) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item itm = stack.getStackItem(0);
                    itm.setUserValue(Integer.valueOf(reg));
                }
            } else if (sawLoad) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item itm = stack.getStackItem(0);
                    reg = itm.getRegisterNumber();
                    if (reg >= 0) {
                        uValue = userValues.get(Integer.valueOf(reg));
                        itm.setUserValue(uValue);
                    }
                }
            } else if (sawNewArray && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item itm = stack.getStackItem(0);
                itm.setUserValue(uValue);
            }
        }
    }
815111
private void simpleIncrement(TensorBase other, double multiplier) {
    Preconditions.checkArgument(Arrays.equals(other.getDimensionNumbers(), getDimensionNumbers()));
    if (other instanceof DenseTensorBase) {
      double[] otherTensorValues = ((DenseTensorBase) other).values;
      Preconditions.checkArgument(otherTensorValues.length == values.length);
      int length = values.length;
      for (int i = 0; i < length; i++) {
        values[i] += otherTensorValues[i] * multiplier;
      }
    } else {
      int otherSize = other.size();
      for (int i = 0; i < otherSize; i++) {
        long keyNum = other.indexToKeyNum(i);
        double value = other.getByIndex(i);
        values[keyNumToIndex(keyNum)] += value * multiplier;
      }
    }
  }
974914
@Override
	protected String initValuesImpl(final FieldCase ca) {
		if (ca == FieldCase.NULL || ca == FieldCase.BLANK) {
			return null;
		}
		String s = super.initValuesImpl(ca);
		int counter = 10000;
		while (set.contains(s) && counter > 0) {
			s = super.initValuesImpl(ca);
			counter--;
		}
		if (counter == 0) {
			throw new IllegalStateException("Could not generate unique value");
		}
		set.add(s);
		return s;
	}
752858
@Override
  public void increment(double coord, double value) {
    // Store in cache
    if (cachefill >= 0) {
      if (cachefill < cachec.length) {
        cachec[cachefill] = coord;
        cachev[cachefill] = value;
        cachefill ++;
        return;
      } else {
        materialize();
        // But continue below!
      }
    }
    // Check if we need to resample to accomodate this bin.
    testResample(coord);
    // super class will handle histogram resizing / shifting
    super.increment(coord, value);
  }
469952
private boolean canPrependValueLength(int value, int index) {
    if (index < this.nbrruns) {
      int nextValue = toIntUnsigned(getValue(index));
      if (nextValue == value + 1) {
        return true;
      }
    }
    return false;
  }
1142972
public long getPerInstanceUniqueValue()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getPerInstanceUniqueValue");

        long retval;

        synchronized(_instanceUniqueLock)
        {
            retval = _instanceUnique--;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getPerInstanceUniqueValue", "return="+retval);
        return retval;
    }