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
项目: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
项目:jdk8u_nashorn
文件:Compiler.java
项目: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;
}
/**
* 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
项目: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
项目: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<>();
}
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;
}
项目: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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。