Package joust.utils.data

Examples of joust.utils.data.SymbolSet


            return this;
        }

        EffectSet unioned = new EffectSet(effectTypes | (unionee.effectTypes & ESCAPING_ONLY));

        unioned.readInternal = new SymbolSet(readInternal);
        unioned.writeInternal = new SymbolSet(writeInternal);
        unioned.readEscaping = SymbolSet.union(readEscaping, unionee.readEscaping);
        unioned.writeEscaping = SymbolSet.union(writeEscaping, unionee.writeEscaping);

        return unioned;
    }
View Full Code Here


    }

    public EffectSet dropUnescaping() {
        EffectSet unioned = new EffectSet(effectTypes & ESCAPING_ONLY);

        unioned.readInternal = new SymbolSet();
        unioned.writeInternal = new SymbolSet();
        unioned.readEscaping = new SymbolSet(readEscaping);
        unioned.writeEscaping = new SymbolSet(writeEscaping);

        return unioned;
    }
View Full Code Here

        if (effectSets == null || effectSets.length == 0) {
            return this;
        }

        int newMask = effectTypes;
        SymbolSet riSyms = new SymbolSet(readInternal);
        SymbolSet wiSyms = new SymbolSet(writeInternal);
        SymbolSet reSyms = new SymbolSet(readEscaping);
        SymbolSet weSyms = new SymbolSet(writeEscaping);


        for (int i = 0; i < effectSets.length; i++) {
            EffectSet unionee = effectSets[i];

            newMask |= unionee.effectTypes;

            // Add the symbols from the new unionee...
            riSyms.addAll(unionee.readInternal);
            wiSyms.addAll(unionee.writeInternal);
            reSyms.addAll(unionee.readEscaping);
            weSyms.addAll(unionee.writeEscaping);
        }

        EffectSet unioned = new EffectSet(newMask);

        unioned.readInternal = riSyms;
View Full Code Here

        if (effect == null) {
            return this;
        }

        EffectSet newEffectSet = new EffectSet(effectTypes | effect.maskValue);
        newEffectSet.readInternal = new SymbolSet(readInternal);
        newEffectSet.writeInternal = new SymbolSet(writeInternal);
        newEffectSet.readEscaping = new SymbolSet(readEscaping);
        newEffectSet.writeEscaping = new SymbolSet(writeEscaping);

        return newEffectSet;
    }
View Full Code Here

        log.debug("Invar for: {}", loop);

        EffectSet loopEffects = loop.effects.getEffectSet();

        // The local variables written by the loop. Expressions that depend on these aren't loop invariants. (Usually)
        SymbolSet writtenInLoop = loopEffects.writeInternal;
        SymbolSet readInLoop = loopEffects.readInternal;

        InvariantExpressionFinder invariantFinder = new InvariantExpressionFinder(writtenInLoop, readInLoop);
        invariantFinder.visitTree(loop);

        log.debug("Invariant expressions: {}", Arrays.toString(invariantFinder.invariantExpressions.keySet().toArray()));
View Full Code Here

     * General visitor method for handling updates - strips from the availableExpressions map anything invalidated by
     * this tree. (Using effect information).
     */
    private void visitUpdate(AJCEffectAnnotatedTree tree) {
        EffectSet effects = tree.effects.getEffectSet();
        SymbolSet internalWrites = effects.writeInternal;

        // If this tree writes anything that is read by an availableExpression, it has to go.
        // TODO: Make this more efficient.
        Set<AJCComparableExpressionTree> keysCopy = new HashSet<AJCComparableExpressionTree>(availableExpressions.keySet());
        for (AJCComparableExpressionTree t : keysCopy) {
            if (t.wrappedNode instanceof AJCEffectAnnotatedTree) {
                AJCEffectAnnotatedTree effectTree = (AJCEffectAnnotatedTree) t.wrappedNode;

                EffectSet availEffects = effectTree.effects.getEffectSet();
                for (Symbol.VarSymbol sym : availEffects.readInternal) {
                    if (internalWrites.contains(sym)) {
                        log.debug("Dropping {} because {} wrote {}", t, tree, sym);
                        finaliseAvailableExpression(availableExpressions.get(t));
                        availableExpressions.remove(t);
                        break;
                    }
View Full Code Here

            return;
        }

        if (exprEffects.contains(EffectSet.EffectType.READ_INTERNAL)) {
            // Determine if this expression reads any symbols that are written in the loop.
            SymbolSet readSymbols = new SymbolSet(exprEffects.readInternal);

            log.debug("ReadSymbols: {}", readSymbols);
            readSymbols.retainAll(writtenInLoop);
            log.debug("After dropping: {}", readSymbols);

            if (!readSymbols.isEmpty()) {
                log.debug("No good - reads symbols written in the loop.");
                return;
            }
        }

        if (exprEffects.contains(EffectSet.EffectType.WRITE_INTERNAL)) {
            // Determine if this expression writes any symbols that are read in the loop.
            SymbolSet writeSymbols = new SymbolSet(exprEffects.writeInternal);

            log.debug("ReadSymbols: {}", writeSymbols);
            writeSymbols.retainAll(readInLoop);
            log.debug("After dropping: {}", writeSymbols);

            if (!writeSymbols.isEmpty()) {
                log.debug("No good - writes symbols read in the loop.");
                return;
            }
        }
View Full Code Here

    public void visitForLoop(AJCForLoop tree) {
        super.visitForLoop(tree);
        log.debug("unroll consideration for {}", tree);

        EffectSet condEffects = tree.cond.effects.getEffectSet();
        SymbolSet condReads = condEffects.readInternal;
        SymbolSet condWrites = condEffects.writeInternal;

        // Find the effects for the statements in the repeat steps...
        SymbolSet repeatReads = new SymbolSet();
        SymbolSet repeatWrites = new SymbolSet();
        for (AJCExpressionStatement stat : tree.step) {
            EffectSet stepEffects = stat.effects.getEffectSet();
            repeatReads.addAll(stepEffects.readInternal);
            repeatWrites.addAll(stepEffects.writeInternal);
        }

        // Determine if any of the symbols depended on by the condition or repeat are global.
        if (containsGlobal(condReads) || containsGlobal(condWrites)
         || containsGlobal(repeatReads) || containsGlobal(repeatWrites)) {
            log.debug("Aborting unrolling - global symbol deps!");
            return;
        }

        EffectSet bodyEffects = tree.body.effects.getEffectSet();
        // If the body writes anything read by the cond or repeat, abort. (That shit's complicated.).
        SymbolSet bodyWrites = bodyEffects.writeInternal;

        // TODO: can *sometimes* deal with this. Sort of tricky, and implies very retarded code.
        if (!bodyWrites.intersect(condReads).isEmpty() || !bodyWrites.intersect(repeatReads).isEmpty()) {
            log.debug("Aborting unrolling - body writes to condition/repeat deps!");
            return;
        }

        // Attempt to evaluate the loop management code ahead of time.
View Full Code Here

        everLive.add(referenced);
    }

    private void markLive(AJCEffectAnnotatedTree tree) {
        // TODO: Datastructure-fu to enable portions of this map to be shared...
        tree.liveVariables = new SymbolSet(currentlyLive);
    }
View Full Code Here

        byte isUniversalSet = input.readByte();
        if (isUniversalSet == (byte) 1) {
            return SymbolSet.UNIVERSAL_SET;
        }

        SymbolSet ret = new SymbolSet();
        int len = input.readInt();

        for (int i = 0; i < len; i++) {
            String symbolHash = input.readString();
            //log.info("Got symbol hash: {}", symbolHash);

            // Determine if this is a symbol we care about...
            if (JOUSTCache.varSymbolTable.containsKey(symbolHash)) {
                VarSymbol symGot = JOUSTCache.varSymbolTable.get(symbolHash);
               // log.info("Obtained concrete symbol: {}", symGot);
                ret.add(symGot);
            } else {
                //log.info("Discarded.");
            }
        }
View Full Code Here

TOP

Related Classes of joust.utils.data.SymbolSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.