當前位置: 首頁>>代碼示例>>Java>>正文


Java Translator.BY_SUITE屬性代碼示例

本文整理匯總了Java中com.sun.squawk.translator.Translator.BY_SUITE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Translator.BY_SUITE屬性的具體用法?Java Translator.BY_SUITE怎麽用?Java Translator.BY_SUITE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.sun.squawk.translator.Translator的用法示例。


在下文中一共展示了Translator.BY_SUITE屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transform

/**
 * Do the transformations to the IR.
 */
public void transform(Translator translator) {
    boolean recordCalls = translator.getTranslationStrategy() >= Translator.BY_SUITE;

    /*
     * Pass 0 - Count the uses of every stack producer.
     */
    new IRUseCounter().count(ir);

    /*
     * Pass 1 - Iterate over the instructions to insert loads for stack values that must be spilt.
     */
    MethodDB.Entry callerEntry = null;
    if (recordCalls) {
        callerEntry = translator.methodDB.lookupMethodEntry(method);
    }
    Instruction instruction = ir.getHead();
    while (instruction != null) {
        oneOrMoreOperandsSpilt = false;
        instruction.visit(this);

        /*
         * The filling for reversing parameters is done here instead of doOperand.
         */
        if (instructionNeedParametersReversed(instruction)) {
            Invoke invoke = (Invoke)instruction;
            StackProducer[] parameters = invoke.getParameters();
            for (int i = parameters.length - 1; i >= 0; --i) {
                fillReversedParameters(invoke, parameters[i]);
            }
        }

        /*
         * Record method calls
         */
        if (recordCalls && instruction instanceof Invoke) {
            Invoke inv = (Invoke)instruction;
            translator.methodDB.recordMethodCall(callerEntry, inv.getMethod());
        }

        instruction = instruction.getNext();
    }

    /*
     * Pass 2 - Iterate over all the instructions to spill stack
     * values for the loads which were inserted in the previous pass.
     */
    for (instruction = ir.getHead() ; instruction != null ; instruction = instruction.getNext()) {

        /*
         * Spill the instruction's result if necessary.
         */
        if (instruction instanceof StackProducer) {
            StackProducer producer = (StackProducer)instruction;
            if (producer.isSpilt()) {
                Local local = producer.getSpillLocal();
                Assert.that(local != null);

                /*
                 * If the current instruction is the fill corresponding to the pending
                 * spill and the spill was not due to a dup or a phi merge, then
                 * cancel the spill and remove the fill
                 */
                if (!producer.isDuped() && !(producer instanceof StackMerge) && producer.getNext() instanceof LoadLocal) {
                    LoadLocal load = (LoadLocal)instruction.getNext();
                    if (load.getLocal() == local) {
                        ir.remove(load);
                        continue;
                    }
                }

                Instruction store = new StoreLocal(local, producer);
                ir.insertAfter(store, instruction);
                instruction = store;
            }
        }
    }

}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:81,代碼來源:IRTransformer.java


注:本文中的com.sun.squawk.translator.Translator.BY_SUITE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。