当前位置: 首页>>代码示例>>Java>>正文


Java MethodHandleFactory.addDebugPrintout方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.lookup.MethodHandleFactory.addDebugPrintout方法的典型用法代码示例。如果您正苦于以下问题:Java MethodHandleFactory.addDebugPrintout方法的具体用法?Java MethodHandleFactory.addDebugPrintout怎么用?Java MethodHandleFactory.addDebugPrintout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.lookup.MethodHandleFactory的用法示例。


在下文中一共展示了MethodHandleFactory.addDebugPrintout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constantGetter

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入方法依赖的package包/类
private MethodHandle constantGetter(final Object c) {
    final MethodHandle mh = staticConstantGetter(c);
    if (log.isEnabled()) {
        return MethodHandleFactory.addDebugPrintout(log, Level.FINEST, mh, "getting as constant");
    }
    return mh;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:GlobalConstants.java

示例2: debug

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入方法依赖的package包/类
private MethodHandle debug(final MethodHandle mh, final Class<?> forType, final Class<?> type, final String tag) {
    if (DEBUG_FIELDS) {
       return MethodHandleFactory.addDebugPrintout(
           LOG,
           mh,
           tag + " '" + getKey() + "' (property="+ Debug.id(this) + ", forType=" + stripName(forType) + ", type=" + stripName(type) + ')');
    }
    return mh;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:10,代码来源:AccessorProperty.java

示例3: findGetMethod

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入方法依赖的package包/类
/**
 * Try to turn a getter into a MethodHandle.constant, if possible
 *
 * @param find      property lookup
 * @param receiver  receiver
 * @param desc      callsite descriptor
 *
 * @return resulting getter, or null if failed to create constant
 */
GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) {
    // Only use constant getter for fast scope access, because the receiver may change between invocations
    // for slow-scope and non-scope callsites.
    // Also return null for user accessor properties as they may have side effects.
    if (invalidatedForever.get() || !NashornCallSiteDescriptor.isFastScope(desc)
            || (GLOBAL_ONLY && !find.getOwner().isGlobal())
            || find.getProperty() instanceof UserAccessorProperty) {
        return null;
    }

    final boolean  isOptimistic = NashornCallSiteDescriptor.isOptimistic(desc);
    final int      programPoint = isOptimistic ? getProgramPoint(desc) : INVALID_PROGRAM_POINT;
    final Class<?> retType      = desc.getMethodType().returnType();
    final String   name         = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);

    synchronized (this) {
        final Access acc = getOrCreateSwitchPoint(name);

        log.fine("Starting to look up object value " + name);
        final Object c = find.getObjectValue();

        if (log.isEnabled()) {
            log.fine("Trying to link constant GETTER " + acc + " value = " + c);
        }

        if (acc.hasBeenInvalidated() || acc.guardFailed() || invalidatedForever.get()) {
            if (log.isEnabled()) {
                log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation());
            }
            return null;
        }

        final MethodHandle cmh = constantGetter(c);

        MethodHandle mh;
        MethodHandle guard;

        if (isOptimistic) {
            if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) {
                //widen return type - this is pessimistic, so it will always work
                mh = MH.asType(cmh, cmh.type().changeReturnType(retType));
            } else {
                //immediately invalidate - we asked for a too wide constant as a narrower one
                mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class);
            }
        } else {
            //pessimistic return type filter
            mh = Lookup.filterReturnType(cmh, retType);
        }

        if (find.getOwner().isGlobal()) {
            guard = null;
        } else {
            guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver);
        }

        if (log.isEnabled()) {
            log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint());
            mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc);
        }

        return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:74,代码来源:GlobalConstants.java

示例4: findGetMethod

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入方法依赖的package包/类
/**
 * Try to turn a getter into a MethodHandle.constant, if possible
 *
 * @param find      property lookup
 * @param receiver  receiver
 * @param desc      callsite descriptor
 *
 * @return resulting getter, or null if failed to create constant
 */
GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) {
    // Only use constant getter for fast scope access, because the receiver may change between invocations
    // for slow-scope and non-scope callsites.
    // Also return null for user accessor properties as they may have side effects.
    if (invalidatedForever.get() || !NashornCallSiteDescriptor.isFastScope(desc)
            || (GLOBAL_ONLY && !find.getOwner().isGlobal())
            || find.getProperty() instanceof UserAccessorProperty) {
        return null;
    }

    final boolean  isOptimistic = NashornCallSiteDescriptor.isOptimistic(desc);
    final int      programPoint = isOptimistic ? getProgramPoint(desc) : INVALID_PROGRAM_POINT;
    final Class<?> retType      = desc.getMethodType().returnType();
    final String   name         = NashornCallSiteDescriptor.getOperand(desc);

    synchronized (this) {
        final Access acc = getOrCreateSwitchPoint(name);

        log.fine("Starting to look up object value " + name);
        final Object c = find.getObjectValue();

        if (log.isEnabled()) {
            log.fine("Trying to link constant GETTER " + acc + " value = " + c);
        }

        if (acc.hasBeenInvalidated() || acc.guardFailed() || invalidatedForever.get()) {
            if (log.isEnabled()) {
                log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation());
            }
            return null;
        }

        final MethodHandle cmh = constantGetter(c);

        MethodHandle mh;
        MethodHandle guard;

        if (isOptimistic) {
            if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) {
                //widen return type - this is pessimistic, so it will always work
                mh = MH.asType(cmh, cmh.type().changeReturnType(retType));
            } else {
                //immediately invalidate - we asked for a too wide constant as a narrower one
                mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class);
            }
        } else {
            //pessimistic return type filter
            mh = Lookup.filterReturnType(cmh, retType);
        }

        if (find.getOwner().isGlobal()) {
            guard = null;
        } else {
            guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver);
        }

        if (log.isEnabled()) {
            log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint());
            mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc);
        }

        return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:74,代码来源:GlobalConstants.java

示例5: addLoggingToHandle

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入方法依赖的package包/类
/**
 * Given a Loggable class, weave debug info info a method handle for that logger.
 *
 * @param clazz            loggable
 * @param level            log level
 * @param mh               method handle
 * @param paramStart       first parameter to print
 * @param printReturnValue should we print the return vaulue?
 * @param text             debug printout to add
 *
 * @return instrumented method handle, or null if logger not enabled
 */
public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Supplier<String> text) {
    final DebugLogger log = getLogger(clazz);
    if (log.isEnabled()) {
        return MethodHandleFactory.addDebugPrintout(log, level, mh, paramStart, printReturnValue, text.get());
    }
    return mh;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Context.java

示例6: addLoggingToHandle

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入方法依赖的package包/类
/**
 * Given a Loggable class, weave debug info info a method handle for that logger.
 *
 * @param clazz            loggable
 * @param level            log level
 * @param mh               method handle
 * @param paramStart       first parameter to print
 * @param printReturnValue should we print the return value?
 * @param text             debug printout to add
 *
 * @return instrumented method handle, or null if logger not enabled
 */
public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Supplier<String> text) {
    final DebugLogger log = getLogger(clazz);
    if (log.isEnabled()) {
        return MethodHandleFactory.addDebugPrintout(log, level, mh, paramStart, printReturnValue, text.get());
    }
    return mh;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Context.java


注:本文中的jdk.nashorn.internal.lookup.MethodHandleFactory.addDebugPrintout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。