Permalink
Browse files

Intergrate kilim-1.0/asm-4.0

  • Loading branch information...
1 parent 075ff45 commit 3ba242ef95ec60f3572813c238e1c37705761427 @krestenkrab krestenkrab committed Aug 16, 2013
View
@@ -6,7 +6,8 @@
<path id="erjang.classpath">
<pathelement location="target/classes/" />
<pathelement location="lib/js.jar" />
- <pathelement location="lib/kilim-0.6-krab.jar" />
+ <pathelement location="lib/kilim.jar" />
+ <pathelement location="lib/asm-all-4.1.jar" />
<pathelement location="lib/OtpErlang.jar" />
<pathelement location="lib/junit.jar" />
<pathelement location="lib/clj-ds.jar" />
View
Binary file not shown.
@@ -219,7 +219,7 @@ private static String erlangNameOfMethod(Method method) {
String self_type = EFUN_TYPE.getInternalName() + arity;
- ClassWriter cw = new ClassWriter(true);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT,
self_type, null, EFUN_TYPE.getInternalName(), null);
@@ -273,6 +273,7 @@ private static String erlangNameOfMethod(Method method) {
static final Pattern JAVA_ID = Pattern.compile("([a-z]|[A-Z]|$|_|[0-9])*"); // valid java identifier
public static EFun get_fun_with_handler(String module, String function, int arity, EFunHandler handler, ClassLoader loader) {
+
String signature = module + function + arity;
Constructor<? extends EFun> h = handlers.get(signature);
@@ -287,7 +288,7 @@ public static EFun get_fun_with_handler(String module, String function, int arit
.append(safe_module).append(safe_function)
.append("Handler").append(arity).toString();
- ClassWriter cw = new ClassWriter(true);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
String super_class_name = EFUN_TYPE.getInternalName() + arity;
cw.visit(Opcodes.V1_4, ACC_PUBLIC, self_type, null,
super_class_name, null);
@@ -555,7 +556,7 @@ private static String make_valid_java_id(CharSequence seq) {
String super_type = EFUN_TYPE.getInternalName() + arity;
String self_type = super_type + "Exported";
- ClassWriter cw = new ClassWriter(true);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT,
self_type, null, super_type, null);
@@ -633,6 +634,7 @@ private static void push_int(MethodVisitor mv, int i) {
public static byte[] weave(byte[] data) {
ClassWeaver w = new ClassWeaver(data, new Compiler.ErjangDetector("/xx/", (Set<String>)Collections.EMPTY_SET));
+ w.weave();
for (ClassInfo ci : w.getClassInfos()) {
// ETuple.dump(ci.className, ci.bytes);
@@ -203,6 +203,8 @@ public EInternalPID self_handle() {
public int midx = 0;
+ private int priority = 2;
+
protected void link_failure(EHandle h) throws Pausable {
if (trap_exit == ERT.TRUE || h.testLocalHandle()==null) {
send_exit(h, ERT.am_noproc, false);
@@ -439,6 +441,14 @@ public EObject process_flag(EAtom flag, EObject value) {
throw new NotImplemented("process_flag flag="+flag+", value="+value);
}
+ private int getPriority() {
+ return this.priority;
+ }
+
+ private void setPriority(int i) {
+ this.priority = i;
+ }
+
@Override
public void execute() throws Pausable {
Throwable death = null;
@@ -25,7 +25,7 @@
import java.util.Map;
import java.util.Set;
-import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
@@ -204,7 +204,7 @@ static public Class get_tuple_class(int num_cells) {
}
static byte[] make_tuple_class_data(int num_cells) {
- ClassWriter cww = new ClassWriter(true);
+ ClassWriter cww = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
CheckClassAdapter cw = new CheckClassAdapter(cww);
@@ -247,7 +247,7 @@ static public Class get_tuple_class(int num_cells) {
return data;
}
- private static void create_tuple_copy(int i, ClassAdapter cw,
+ private static void create_tuple_copy(int i, ClassVisitor cw,
String this_class_name, String super_class_name) {
MethodVisitor mv;
make_blank_bridge(cw, this_class_name, super_class_name);
@@ -266,7 +266,7 @@ private static void create_tuple_copy(int i, ClassAdapter cw,
mv.visitEnd();
}
- private static void make_blank_bridge(ClassAdapter cw,
+ private static void make_blank_bridge(ClassVisitor cw,
String this_class_name, String super_class_name) {
MethodVisitor mv;
mv = cw.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC
@@ -281,7 +281,7 @@ private static void make_blank_bridge(ClassAdapter cw,
mv.visitEnd();
}
- private static void create_tuple_nth(int n_cells, ClassAdapter cw,
+ private static void create_tuple_nth(int n_cells, ClassVisitor cw,
String this_class_name) {
MethodVisitor mv;
mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "elm", "(I)"
@@ -321,7 +321,7 @@ private static void create_tuple_nth(int n_cells, ClassAdapter cw,
mv.visitEnd();
}
- private static void create_tuple_set(int n_cells, ClassAdapter cw,
+ private static void create_tuple_set(int n_cells, ClassVisitor cw,
String this_class_name) {
MethodVisitor mv;
mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "set", "(I"
@@ -368,7 +368,7 @@ protected final EObject bad_nth(int i) {
throw ERT.badarg(this);
}
- private static void create_count(ClassAdapter cw, int n) {
+ private static void create_count(ClassVisitor cw, int n) {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "arity", "()I",
null, null);
mv.visitCode();
@@ -383,7 +383,7 @@ private static void create_count(ClassAdapter cw, int n) {
mv.visitEnd();
}
- private static void create_cast(ClassAdapter cw, int n) {
+ private static void create_cast(ClassVisitor cw, int n) {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC
| Opcodes.ACC_STATIC, "cast", "(L" + ETUPLE_NAME + ";)L"
+ ETUPLE_NAME + n + ";", null, null);
@@ -414,7 +414,7 @@ private static void create_cast(ClassAdapter cw, int n) {
}
- private static void create_cast2(ClassAdapter cw, int n) {
+ private static void create_cast2(ClassVisitor cw, int n) {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC
| Opcodes.ACC_STATIC, "cast", "(L" + Type.getInternalName(EObject.class) + ";)L"
+ ETUPLE_NAME + n + ";", null, null);
@@ -439,7 +439,7 @@ private static void create_cast2(ClassAdapter cw, int n) {
mv.visitEnd();
}
- private static void create_constructor(ClassAdapter cw,
+ private static void create_constructor(ClassVisitor cw,
String super_class_name) {
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V",
null, null);
@@ -452,7 +452,7 @@ private static void create_constructor(ClassAdapter cw,
mv.visitEnd();
}
- static void dump(String name, byte[] data) {
+ public static void dump(String name, byte[] data) {
String pkg = name.substring(0, name.lastIndexOf('/'));
@@ -32,7 +32,7 @@
import kilim.analysis.ClassInfo;
import kilim.analysis.ClassWeaver;
-import kilim.analysis.Detector;
+import kilim.mirrors.Detector;
import kilim.mirrors.ClassMirrorNotFoundException;
import kilim.mirrors.Mirrors;
@@ -70,7 +70,7 @@ public static void compile(BeamFileData data, ClassRepo repo) throws IOException
ClassWeaver.reset();
// class writer, phase 4
- ClassWriter cw = new ClassWriter(true);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
// class checker, optional phase
//CheckClassAdapter ca = new CheckClassAdapter(cw);
@@ -102,6 +102,7 @@ public static void compile(BeamFileData data, ClassRepo repo) throws IOException
boolean written = false;
ClassWeaver cwe = new ClassWeaver(byteArray, new ErjangDetector(
cv.getInternalClassName(), cv.non_pausable_methods));
+ cwe.weave();
for (ClassInfo ci : cwe.getClassInfos()) {
String name = ci.className;
byte[] bytes = ci.bytes;
@@ -137,7 +138,7 @@ public void compile(File file, BeamLoader beam_parser) throws IOException {
* @param mirrors
*/
public ErjangDetector(String className, Set<String> nonPausableMethods) {
- super(Mirrors.getRuntimeMirrors());
+ super(Detector.DEFAULT.mirrors);
this.className = className;
this.nonPausableMethods = nonPausableMethods;
}
@@ -682,6 +682,7 @@ public void visitEnd() {
ClassWeaver w = new ClassWeaver(data, new Compiler.ErjangDetector(
self_type.getInternalName(), non_pausable_methods));
+ w.weave();
if (w.getClassInfos().size() == 0) { // Class did not need weaving
try {
classRepo.store(full_inner_name, data);
@@ -3119,7 +3120,7 @@ public Lambda get_lambda_freevars(EAtom fun, int arity_plus) {
String inner_name = "FN_" + mname;
String full_inner_name = outer_name + "$" + inner_name;
- ClassWriter cw = new ClassWriter(true);
+ ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
int residual_arity = arity - freevars;
String super_class_name = EFUN_NAME + residual_arity +
(exported ? "Exported" : "");
@@ -18,6 +18,8 @@
package erjang.beam;
+import java.util.Collection;
+
/**
*
*/

0 comments on commit 3ba242e

Please sign in to comment.