Permalink
Browse files

Upgrade to final release of Asm 4.0

  • Loading branch information...
1 parent 264c113 commit 1cd1a4f67eba47464add6b229f8d08aad95b3b1e @olabini olabini committed Nov 10, 2011
View
@@ -1,2 +1,31 @@
-- Generate structural types on the fly instead
+- Pass arguments to the bootstrap method instead of pushing on the stack all the time.
+- Make Seph not need SephObject interface anymore
+- See if it's possible to find a way to not do all that crap for lazy methods
+- see if it's possible to bind native calls directly in to their implementation. use folding or something like it to evaluate arguments where needed
+- Implement dynalink
+- Classy implementation
+ - Notes about impl of classy
+ - Compilation of names uses names or indexes: get:index:32
+ - If slot can't be found for the current object, instead get the prototype from the layout and combine with getFromPrototype
+ - The actual ScriptableObject keeps the prototype information in the layout
+ - Had simple static getters and setters that cast to Struct4 or Struct8 etc
+- See if I can generate the structures on the fly
+ - See if it's possible to use Johns classy layout for it
+- Each object has an instance of a layout that describes the mapping from a name to a field on a structured implementation
+- Getting from a specific Object should return a MethodHandle that can get it from any object with that specific layout
+- Invocation with arguments HAVE to be invocable. We can make that into a separate operation probably.
+- Macros:
+ use same way of declaring things. Add a asMacro() to the interface
+ define:
+ if = #(cond, then, else,
+ if(cond evaluateOn(surroundingContext),
+ then evaluateOn(surroundingContext),
+ else evaluateOn(surroundingContext))) asMacro
+ we will make surroundingContext available to all method invocations to make it easy.
+ or maybe not. Maybe asMacro can take information on where to put data in the argument list to make it easier:
+ if = #(cond, then, else, surroundingContext,
+ if(cond evaluateOn(surroundingContext),
+ then evaluateOn(surroundingContext),
+ else evaluateOn(surroundingContext))) asMacro(withSurroundingContext: 3)
+ this makes it possible for macros to get lots of useful things, without necessarily having to degrade performance as much
View
Binary file not shown.
@@ -23,6 +23,7 @@
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Label;
import org.objectweb.asm.Type;
+import org.objectweb.asm.Handle;
import static org.objectweb.asm.Opcodes.*;
import static seph.lang.compiler.CompilationHelpers.*;
import static seph.lang.ActivationHelpers.*;
@@ -40,7 +41,7 @@
public class AbstractionCompiler {
public static boolean PRINT_COMPILE = false;
- private final static org.objectweb.asm.MethodHandle BOOTSTRAP_METHOD = new org.objectweb.asm.MethodHandle(MH_INVOKESTATIC, "seph/lang/compiler/SephCallSite", "bootstrap", BOOTSTRAP_SIGNATURE_DESC);
+ private final static Handle BOOTSTRAP_METHOD = new Handle(H_INVOKESTATIC, "seph/lang/compiler/SephCallSite", "bootstrap", BOOTSTRAP_SIGNATURE_DESC);
private final static AtomicInteger compiledCount = new AtomicInteger(0);
@@ -373,7 +374,7 @@ private void compileAssignment(MethodAdapter ma, Assignment current, int[] layou
currentAssignment = oldAssignment;
}
- private void compileArgument(Message argument, int currentMessageIndex, int argIndex, List<ArgumentEntry> currentArguments, Message last, List<org.objectweb.asm.MethodHandle> mhsAndAsts) {
+ private void compileArgument(Message argument, int currentMessageIndex, int argIndex, List<ArgumentEntry> currentArguments, Message last, List<Handle> mhsAndAsts) {
// printThisClass = true;
String keyword = null;
Message argumentToCompile = argument;
@@ -387,8 +388,8 @@ private void compileArgument(Message argument, int currentMessageIndex, int argI
final String handleName = "handle_arg_" + currentMessageIndex + "_" + argIndex;
final String methodName = "argument_" + currentMessageIndex + "_" + argIndex;
ArgumentEntry ae = new ArgumentEntry(codeName, handleName, methodName, argument, keyword);
- mhsAndAsts.add(new org.objectweb.asm.MethodHandle(MH_INVOKESTATIC, className, methodName, sig(SephObject.class, LexicalScope.class, SThread.class, LexicalScope.class, boolean.class, boolean.class)));
- mhsAndAsts.add(new org.objectweb.asm.MethodHandle(MH_GETSTATIC, className, codeName, c(SephObject.class)));
+ mhsAndAsts.add(new Handle(H_INVOKESTATIC, className, methodName, sig(SephObject.class, LexicalScope.class, SThread.class, LexicalScope.class, boolean.class, boolean.class)));
+ mhsAndAsts.add(new Handle(H_GETSTATIC, className, codeName, c(SephObject.class)));
arguments.add(ae);
currentArguments.add(ae);
@@ -475,15 +476,15 @@ private Arity countArguments(IPersistentList arguments) {
return new Arity(arity - keywordArgs, keywordArgs);
}
- private org.objectweb.asm.MethodHandle[] compileArguments(MethodAdapter ma, IPersistentList arguments, int[] layout, Message last) {
+ private Handle[] compileArguments(MethodAdapter ma, IPersistentList arguments, int[] layout, Message last) {
int num = 0;
final int currentMessageIndex = messageIndex++;
final int arity = RT.count(arguments);
final List<ArgumentEntry> currentArguments = new ArrayList<>();
final List<Message> keywordArguments = new LinkedList<>();
final List<String> keywordArgumentNames = new LinkedList<>();
- final List<org.objectweb.asm.MethodHandle> mhsAndAsts = new LinkedList<>();
+ final List<Handle> mhsAndAsts = new LinkedList<>();
for(ISeq seq = arguments.seq(); seq != null; seq = seq.next()) {
@@ -552,7 +553,7 @@ private Arity countArguments(IPersistentList arguments) {
}
}
- return mhsAndAsts.toArray(new org.objectweb.asm.MethodHandle[0]);
+ return mhsAndAsts.toArray(new Handle[0]);
}
@@ -800,7 +801,7 @@ private void compileRegularMessageSend(MethodAdapter ma, Message current, int[]
ma.loadLocal(layout[THREAD_IDX]);
ma.loadLocal(layout[METHOD_SCOPE_IDX]);
- org.objectweb.asm.MethodHandle[] argMHrefs = compileArguments(ma, current.arguments(), layout, last);
+ Handle[] argMHrefs = compileArguments(ma, current.arguments(), layout, last);
if(first && se != null) {
// [recv, value, thread, scope, arg0, arg1]
@@ -1091,8 +1092,8 @@ private void activateWithMethod() {
private void activationForMethod() {
MethodAdapter ma = new MethodAdapter(cw.visitMethod(ACC_PUBLIC, "activationFor", sig(MethodHandle.class, int.class, boolean.class), null, null));
- org.objectweb.asm.MethodHandle specific = new org.objectweb.asm.MethodHandle(MH_INVOKEVIRTUAL, className, encode(abstractionName), sig(SephObject.class, argumentClassesFor(argNames.size(), false)));
- org.objectweb.asm.MethodHandle generic = new org.objectweb.asm.MethodHandle(MH_INVOKEVIRTUAL, className, encode(abstractionName), sig(SephObject.class, argumentClassesFor(-1, false)));
+ Handle specific = new Handle(H_INVOKEVIRTUAL, className, encode(abstractionName), sig(SephObject.class, argumentClassesFor(argNames.size(), false)));
+ Handle generic = new Handle(H_INVOKEVIRTUAL, className, encode(abstractionName), sig(SephObject.class, argumentClassesFor(-1, false)));
ma.loadThis();
ma.loadLocalInt(1);
@@ -8,6 +8,7 @@
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.Type;
+import org.objectweb.asm.Handle;
import static org.objectweb.asm.Opcodes.*;
import static seph.lang.compiler.CompilationHelpers.*;
@@ -363,7 +364,7 @@ public void interfaceCall(String on, String name, String s) {
}
public final static Object[] EMPTY = new Object[0];
- public void dynamicCall(String name, String sig, org.objectweb.asm.MethodHandle bootstrap, org.objectweb.asm.MethodHandle... arguments) {
+ public void dynamicCall(String name, String sig, Handle bootstrap, Handle... arguments) {
op();
if(TRACE) System.err.println("INVOKEDYNAMIC " + name + " " + sig + " " + bootstrap);
mv.visitInvokeDynamicInsn(name, sig, bootstrap, arguments);

0 comments on commit 1cd1a4f

Please sign in to comment.