jdk.nashorn.internal.runtime.CodeInstaller的实例源码

项目:Openjsharp    文件Compiler.java   
private static String safeSourceName(final ScriptEnvironment env,final CodeInstaller<ScriptEnvironment> installer,final Source source) {
    String baseName = new File(source.getName()).getName();

    final int index = baseName.lastIndexOf(".js");
    if (index != -1) {
        baseName = baseName.substring(0,index);
    }

    baseName = baseName.replace('.','_').replace('-','_');
    if (!env._loader_per_compile) {
        baseName = baseName + installer.getUniqueScriptId();
    }

    // ASM's bytecode verifier does not allow JVM allowed safe escapes using '\' as escape char.
    // While ASM accepts such escapes for method names,field names,it enforces Java identifier
    // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_'
    // rather than safe encoding using '\'.
    final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName);
    return mangled != null ? mangled : baseName;
}
项目:openjdk-jdk10    文件Compiler.java   
/**
 * Creates a compiler for an on-demand compilation job.
 *
 * @param installer                code installer
 * @param source                   source to compile
 * @param isstrict                 is this a strict compilation
 * @param compiledFunction         compiled function,if any
 * @param types                    parameter and return value type information,if any is kNown
 * @param invalidatedProgramPoints invalidated program points for recompilation
 * @param typeinformationFile      descriptor of the location where type information is persisted
 * @param continuationEntryPoints  continuation entry points for restof method
 * @param runtimeScope             runtime scope for recompilation type lookup in {@code TypeEvaluator}
 * @return a new compiler
 */
public static Compiler forondemandCompilation(
        final CodeInstaller installer,final Source source,final boolean isstrict,final RecompilableScriptFunctionData compiledFunction,final TypeMap types,final Map<Integer,Type> invalidatedProgramPoints,final Object typeinformationFile,final int[] continuationEntryPoints,final ScriptObject runtimeScope) {
    final Context context = installer.getContext();
    return new Compiler(context,installer,source,context.getErrorManager(),isstrict,true,compiledFunction,types,invalidatedProgramPoints,typeinformationFile,continuationEntryPoints,runtimeScope);
}
项目:openjdk9    文件Compiler.java   
/**
 * Creates a compiler for an on-demand compilation job.
 *
 * @param installer                code installer
 * @param source                   source to compile
 * @param isstrict                 is this a strict compilation
 * @param compiledFunction         compiled function,runtimeScope);
}
项目:kaziranga    文件Compiler.java   
private static String safeSourceName(final ScriptEnvironment env,it enforces Java identifier
    // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_'
    // rather than safe encoding using '\'.
    final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName);
    return mangled != null ? mangled : baseName;
}
项目:lookaside_java-1.8.0-openjdk    文件Compiler.java   
/**
 * Creates a compiler for an on-demand compilation job.
 *
 * @param installer                code installer
 * @param source                   source to compile
 * @param isstrict                 is this a strict compilation
 * @param compiledFunction         compiled function,runtimeScope);
}
项目:jdk8u_nashorn    文件Compiler.java   
/**
 * Creates a compiler for an on-demand compilation job.
 *
 * @param installer                code installer
 * @param source                   source to compile
 * @param isstrict                 is this a strict compilation
 * @param compiledFunction         compiled function,runtimeScope);
}
项目:infobip-open-jdk-8    文件Compiler.java   
private static String safeSourceName(final ScriptEnvironment env,it enforces Java identifier
    // for class names. Workaround that ASM bug here by replacing JVM 'dangerous' chars with '_'
    // rather than safe encoding using '\'.
    final String mangled = env._verify_code? replaceDangerChars(baseName) : NameCodec.encode(baseName);
    return mangled != null ? mangled : baseName;
}
项目:Openjsharp    文件Compiler.java   
/**
 * Constructor
 *
 * @param context                  context
 * @param env                      script environment
 * @param installer                code installer
 * @param source                   source to compile
 * @param errors                   error manager
 * @param isstrict                 is this a strict compilation
 * @param isondemand               is this an on demand compilation
 * @param compiledFunction         compiled function,if any is kNown
 * @param invalidatedProgramPoints invalidated program points for recompilation
 * @param typeinformationFile      descriptor of the location where type information is persisted
 * @param continuationEntryPoints  continuation entry points for restof method
 * @param runtimeScope             runtime scope for recompilation type lookup in {@code TypeEvaluator}
 */
@SuppressWarnings("unused")
public Compiler(
        final Context context,final ScriptEnvironment env,final ErrorManager errors,final boolean isondemand,final ScriptObject runtimeScope) {
    this.context                  = context;
    this.env                      = env;
    this.installer                = installer;
    this.constantData             = new ConstantData();
    this.compileUnits             = CompileUnit.createCompileUnitSet();
    this.bytecode                 = new LinkedHashMap<>();
    this.log                      = initLogger(context);
    this.source                   = source;
    this.errors                   = errors;
    this.sourceName               = FunctionNode.getSourceName(source);
    this.ondemand                 = isondemand;
    this.compiledFunction         = compiledFunction;
    this.types                    = types;
    this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new HashMap<Integer,Type>() : invalidatedProgramPoints;
    this.typeinformationFile      = typeinformationFile;
    this.continuationEntryPoints  = continuationEntryPoints == null ? null: continuationEntryPoints.clone();
    this.typeEvaluator            = new TypeEvaluator(this,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:openjdk-jdk10    文件Compiler.java   
/**
 * Convenience constructor for non on-demand compiler instances.
 */
private Compiler(
        final Context context,final CodeInstaller installer,final boolean isstrict) {
    this(context,errors,false,null,null);
}
项目:openjdk-jdk10    文件Compiler.java   
private Compiler(
        final Context context,final ScriptObject runtimeScope) {
    this.context                  = context;
    this.env                      = context.getEnv();
    this.installer                = installer;
    this.constantData             = new ConstantData();
    this.compileUnits             = CompileUnit.createCompileUnitSet();
    this.bytecode                 = new LinkedHashMap<>();
    this.log                      = initLogger(context);
    this.source                   = source;
    this.errors                   = errors;
    this.sourceName               = FunctionNode.getSourceName(source);
    this.ondemand                 = isondemand;
    this.compiledFunction         = compiledFunction;
    this.types                    = types;
    this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new HashMap<>() : invalidatedProgramPoints;
    this.typeinformationFile      = typeinformationFile;
    this.continuationEntryPoints  = continuationEntryPoints == null ? null: continuationEntryPoints.clone();
    this.typeEvaluator            = new TypeEvaluator(this,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:openjdk9    文件Compiler.java   
/**
 * Convenience constructor for non on-demand compiler instances.
 */
private Compiler(
        final Context context,null);
}
项目:openjdk9    文件Compiler.java   
private Compiler(
        final Context context,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:kaziranga    文件Compiler.java   
/**
 * Constructor
 *
 * @param context                  context
 * @param env                      script environment
 * @param installer                code installer
 * @param source                   source to compile
 * @param errors                   error manager
 * @param isstrict                 is this a strict compilation
 * @param isondemand               is this an on demand compilation
 * @param compiledFunction         compiled function,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:lookaside_java-1.8.0-openjdk    文件Compiler.java   
/**
 * Convenience constructor for non on-demand compiler instances.
 */
private Compiler(
        final Context context,null);
}
项目:lookaside_java-1.8.0-openjdk    文件Compiler.java   
private Compiler(
        final Context context,final ScriptObject runtimeScope) {
    this.context                  = context;
    this.env                      = context.getEnv();
    this.installer                = installer;
    this.constantData             = new ConstantData();
    this.compileUnits             = CompileUnit.createCompileUnitSet();
    this.bytecode                 = new LinkedHashMap<>();
    this.log                      = initLogger(context);
    this.source                   = source;
    this.errors                   = errors;
    this.sourceName               = FunctionNode.getSourceName(source);
    this.ondemand                 = isondemand;
    this.compiledFunction         = compiledFunction;
    this.types                    = types;
    this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new HashMap<Integer,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:jdk8u_nashorn    文件Compiler.java   
/**
 * Convenience constructor for non on-demand compiler instances.
 */
private Compiler(
        final Context context,null);
}
项目:jdk8u_nashorn    文件Compiler.java   
private Compiler(
        final Context context,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:infobip-open-jdk-8    文件Compiler.java   
/**
 * Constructor
 *
 * @param context                  context
 * @param env                      script environment
 * @param installer                code installer
 * @param source                   source to compile
 * @param errors                   error manager
 * @param isstrict                 is this a strict compilation
 * @param isondemand               is this an on demand compilation
 * @param compiledFunction         compiled function,runtimeScope);
    this.firstCompileUnitName     = firstCompileUnitName();
    this.strict                   = isstrict;

    this.optimistic = env._optimistic_types;
}
项目:OLD-OpenJDK8    文件Compiler.java   
/**
 * Constructor
 *
 * @param env          script environment
 * @param installer    code installer
 * @param sequence     {@link Compiler.CompilationSequence} of {@link CompilationPhase}s to apply as this compilation
 * @param strict       should this compilation use strict mode semantics
 */
//Todo support an array of FunctionNodes for batch lazy compilation
Compiler(final ScriptEnvironment env,final CompilationSequence sequence,final boolean strict) {
    this.env           = env;
    this.sequence      = sequence;
    this.installer     = installer;
    this.constantData  = new ConstantData();
    this.compileUnits  = new TreeSet<>();
    this.bytecode      = new LinkedHashMap<>();
}
项目:nashorn-backport    文件Compiler.java   
/**
 * Constructor
 *
 * @param env          script environment
 * @param installer    code installer
 * @param sequence     {@link Compiler.CompilationSequence} of {@link CompilationPhase}s to apply as this compilation
 * @param strict       should this compilation use strict mode semantics
 */
//Todo support an array of FunctionNodes for batch lazy compilation
Compiler(final ScriptEnvironment env,final boolean strict) {
    this.env           = env;
    this.sequence      = sequence;
    this.installer     = installer;
    this.constantData  = new ConstantData();
    this.compileUnits  = new HashSet<>();
    this.bytecode      = new HashMap<>();
}
项目:nashorn    文件Compiler.java   
/**
 * Constructor
 *
 * @param env          script environment
 * @param installer    code installer
 * @param sequence     {@link Compiler.CompilationSequence} of {@link CompilationPhase}s to apply as this compilation
 * @param strict       should this compilation use strict mode semantics
 */
//Todo support an array of FunctionNodes for batch lazy compilation
Compiler(final ScriptEnvironment env,final boolean strict) {
    this.env           = env;
    this.sequence      = sequence;
    this.installer     = installer;
    this.constantData  = new ConstantData();
    this.compileUnits  = new HashSet<>();
    this.bytecode      = new HashMap<>();
}
项目:Openjsharp    文件Compiler.java   
CodeInstaller<ScriptEnvironment> getCodeInstaller() {
    return installer;
}
项目:openjdk-jdk10    文件CompilationPhase.java   
@Override
FunctionNode transform(final Compiler compiler,final CompilationPhases phases,final FunctionNode fn) {
    final DebugLogger log = compiler.getLogger();

    final Map<String,Class<?>> installedClasses = new LinkedHashMap<>();

    boolean first = true;
    Class<?> rootClass = null;
    long length = 0L;

    final CodeInstaller origCodeInstaller = compiler.getCodeInstaller();
    final Map<String,byte[]> bytecode = compiler.getBytecode();
    final CodeInstaller codeInstaller = bytecode.size() > 1 ? origCodeInstaller.getMultiClassCodeInstaller() : origCodeInstaller;

    for (final Entry<String,byte[]> entry : bytecode.entrySet()) {
        final String className = entry.getKey();
        //assert !first || className.equals(compiler.getFirstCompileUnit().getUnitClassName()) : "first=" + first + " className=" + className + " != " + compiler.getFirstCompileUnit().getUnitClassName();
        final byte[] code = entry.getValue();
        length += code.length;

        final Class<?> clazz = codeInstaller.install(className,code);
        if (first) {
            rootClass = clazz;
            first = false;
        }
        installedClasses.put(className,clazz);
    }

    if (rootClass == null) {
        throw new CompilationException("Internal compiler error: root class not found!");
    }

    final Object[] constants = compiler.getConstantData().toArray();
    codeInstaller.initialize(installedClasses.values(),compiler.getSource(),constants);

    // initialize transient fields on recompilable script function data
    for (final Object constant: constants) {
        if (constant instanceof RecompilableScriptFunctionData) {
            ((RecompilableScriptFunctionData)constant).initTransients(compiler.getSource(),codeInstaller);
        }
    }

    // initialize function in the compile units
    for (final CompileUnit unit : compiler.getCompileUnits()) {
        if (!unit.isUsed()) {
            continue;
        }
        unit.setCode(installedClasses.get(unit.getUnitClassName()));
        unit.initializefunctionsCode();
    }

    if (log.isEnabled()) {
        final StringBuilder sb = new StringBuilder();

        sb.append("Installed class '").
            append(rootClass.getSimpleName()).
            append('\'').
            append(" [").
            append(rootClass.getName()).
            append(",size=").
            append(length).
            append(" bytes,").
            append(compiler.getCompileUnits().size()).
            append(" compile unit(s)]");

        log.fine(sb.toString());
    }

    return fn.setRootClass(null,rootClass);
}
项目:openjdk-jdk10    文件Compiler.java   
CodeInstaller getCodeInstaller() {
    return installer;
}
项目:openjdk9    文件CompilationPhase.java   
@Override
FunctionNode transform(final Compiler compiler,rootClass);
}
项目:openjdk9    文件Compiler.java   
CodeInstaller getCodeInstaller() {
    return installer;
}
项目:kaziranga    文件Compiler.java   
CodeInstaller<ScriptEnvironment> getCodeInstaller() {
    return installer;
}
项目:lookaside_java-1.8.0-openjdk    文件CompilationPhase.java   
@Override
FunctionNode transform(final Compiler compiler,Class<?>> installedClasses = new LinkedHashMap<>();

    boolean first = true;
    Class<?> rootClass = null;
    long length = 0L;

    final CodeInstaller       codeInstaller = compiler.getCodeInstaller();
    final Map<String,byte[]> bytecode      = compiler.getBytecode();

    for (final Entry<String,rootClass);
}
项目:lookaside_java-1.8.0-openjdk    文件Compiler.java   
CodeInstaller getCodeInstaller() {
    return installer;
}
项目:jdk8u_nashorn    文件CompilationPhase.java   
@Override
FunctionNode transform(final Compiler compiler,rootClass);
}
项目:jdk8u_nashorn    文件Compiler.java   
CodeInstaller getCodeInstaller() {
    return installer;
}
项目:infobip-open-jdk-8    文件Compiler.java   
CodeInstaller<ScriptEnvironment> getCodeInstaller() {
    return installer;
}
项目:OLD-OpenJDK8    文件Lower.java   
/**
 * Constructor.
 */
Lower(final CodeInstaller<?> installer) {
    super(new BlockLexicalContext() {

        @Override
        public List<Statement> popStatements() {
            final List<Statement> newStatements = new ArrayList<>();
            boolean terminated = false;

            final List<Statement> statements = super.popStatements();
            for (final Statement statement : statements) {
                if (!terminated) {
                    newStatements.add(statement);
                    if (statement.isTerminal() || statement instanceof BreakNode || statement instanceof ContinueNode) { //Todo hasGoto? But some Loops are hasGoto too - why?
                        terminated = true;
                    }
                } else {
                    statement.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
                        @Override
                        public boolean enterVarNode(final VarNode varNode) {
                            newStatements.add(varNode.setinit(null));
                            return false;
                        }
                    });
                }
            }
            return newStatements;
        }

        @Override
        protected Block afterSetStatements(final Block block) {
            final List<Statement> stmts = block.getStatements();
            for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevIoUs();) {
                final Statement stmt = li.prevIoUs();
                // popStatements() guarantees that the only thing after a terminal statement are uninitialized
                // VarNodes. We skip past those,and set the terminal state of the block to the value of the
                // terminal state of the first statement that is not an uninitialized VarNode.
                if(!(stmt instanceof VarNode && ((VarNode)stmt).getinit() == null)) {
                    return block.setIsTerminal(this,stmt.isTerminal());
                }
            }
            return block.setIsTerminal(this,false);
        }
    });
    this.installer = installer;
}
项目:OLD-OpenJDK8    文件Compiler.java   
CodeInstaller<ScriptEnvironment> getCodeInstaller() {
    return installer;
}
项目:nashorn-backport    文件Compiler.java   
CodeInstaller<ScriptEnvironment> getCodeInstaller() {
    return installer;
}
项目:nashorn    文件Compiler.java   
CodeInstaller<ScriptEnvironment> getCodeInstaller() {
    return installer;
}
项目:Openjsharp    文件Compiler.java   
/**
 * Constructor
 *
 * @param context   context
 * @param env       script environment
 * @param installer code installer
 * @param source    source to compile
 * @param errors    error manager
 * @param isstrict  is this a strict compilation
 */
public Compiler(
        final Context context,env,null);
}
项目:openjdk-jdk10    文件Compiler.java   
/**
 * Creates a new compiler instance for initial compilation of a script.
 *
 * @param installer code installer
 * @param source    source to compile
 * @param errors    error manager
 * @param isstrict  is this a strict compilation
 * @return a new compiler
 */
public static Compiler forInitialCompilation(
        final CodeInstaller installer,final boolean isstrict) {
    return new Compiler(installer.getContext(),isstrict);
}
项目:openjdk9    文件Compiler.java   
/**
 * Creates a new compiler instance for initial compilation of a script.
 *
 * @param installer code installer
 * @param source    source to compile
 * @param errors    error manager
 * @param isstrict  is this a strict compilation
 * @return a new compiler
 */
public static Compiler forInitialCompilation(
        final CodeInstaller installer,isstrict);
}
项目:kaziranga    文件Compiler.java   
/**
 * Constructor
 *
 * @param context   context
 * @param env       script environment
 * @param installer code installer
 * @param source    source to compile
 * @param errors    error manager
 * @param isstrict  is this a strict compilation
 */
public Compiler(
        final Context context,null);
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...