Skip to content
Browse files

reduce protocol callsite overhead

  • Loading branch information...
1 parent 469005f commit 0b73494c3c855e54b1da591eeb687f24f608f346 @richhickey richhickey committed
Showing with 5 additions and 17 deletions.
  1. +1 −0 clojure.iml
  2. +4 −17 src/jvm/clojure/lang/Compiler.java
View
1 clojure.iml
@@ -11,6 +11,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/clj" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/jvm" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
View
21 src/jvm/clojure/lang/Compiler.java
@@ -3502,8 +3502,7 @@ public void emitProto(C context, ObjExpr objx, GeneratorAdapter gen){
e.emit(C.EXPRESSION, objx, gen);
gen.dup(); //target, target
gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class
- gen.loadThis();
- gen.getField(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target,class,cached-class
+ gen.getStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target,class,cached-class
gen.visitJumpInsn(IF_ACMPEQ, callLabel); //target
if(protocolOn != null)
{
@@ -3514,9 +3513,7 @@ public void emitProto(C context, ObjExpr objx, GeneratorAdapter gen){
gen.dup(); //target, target
gen.invokeStatic(UTIL_TYPE,Method.getMethod("Class classOf(Object)")); //target,class
- gen.loadThis();
- gen.swap();
- gen.putField(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target
+ gen.putStatic(objx.objtype, objx.cachedClassName(siteIndex),CLASS_TYPE); //target
gen.mark(callLabel); //target
objx.emitVar(gen, v);
@@ -4154,12 +4151,10 @@ void compile(String superName, String[] interfaceNames, boolean oneTimeUse) thro
}
}
- //instance fields for callsites and thunks
+ //static fields for callsites and thunks
for(int i=0;i<protocolCallsites.count();i++)
{
- cv.visitField(ACC_PRIVATE, cachedClassName(i), CLASS_TYPE.getDescriptor(), null, null);
- cv.visitField(ACC_PRIVATE, cachedProtoFnName(i), AFUNCTION_TYPE.getDescriptor(), null, null);
- cv.visitField(ACC_PRIVATE, cachedProtoImplName(i), IFN_TYPE.getDescriptor(), null, null);
+ cv.visitField(ACC_PRIVATE + ACC_STATIC, cachedClassName(i), CLASS_TYPE.getDescriptor(), null, null);
}
//ctor that takes closed-overs and inits base + fields
@@ -4922,14 +4917,6 @@ String cachedVarName(int n){
return "__cached_var__" + n;
}
- String cachedProtoFnName(int n){
- return "__cached_proto_fn__" + n;
- }
-
- String cachedProtoImplName(int n){
- return "__cached_proto_impl__" + n;
- }
-
String varCallsiteName(int n){
return "__var__callsite__" + n;
}

0 comments on commit 0b73494

Please sign in to comment.
Something went wrong with that request. Please try again.