@@ -2885,82 +2885,35 @@ else if(isDirect)
28852885 }
28862886
28872887 public void emitProto (C context , ObjExpr objx , GeneratorAdapter gen ){
2888- Label elseLabel = gen .newLabel ();
2889- Label notSameClassLabel = gen .newLabel ();
2890- Label faultLabel = gen .newLabel ();
2891- Label callLabel = gen .newLabel ();
28922888 Label onLabel = gen .newLabel ();
2889+ Label callLabel = gen .newLabel ();
28932890 Label endLabel = gen .newLabel ();
28942891
28952892 Var v = ((VarExpr )fexpr ).var ;
28962893
28972894 Expr e = (Expr ) args .nth (0 );
28982895 e .emit (C .EXPRESSION , objx , gen );
28992896 gen .dup (); //target, target
2897+ gen .invokeStatic (UTIL_TYPE ,Method .getMethod ("Class classOf(Object)" )); //target,class
2898+ gen .loadThis ();
2899+ gen .getField (objx .objtype , objx .cachedClassName (siteIndex ),CLASS_TYPE ); //target,class,cached-class
2900+ gen .visitJumpInsn (IF_ACMPEQ , callLabel ); //target
29002901 if (protocolOn != null )
29012902 {
2903+ gen .dup (); //target, target
29022904 gen .instanceOf (Type .getType (protocolOn ));
29032905 gen .ifZCmp (GeneratorAdapter .NE , onLabel );
2904- gen .dup ();
29052906 }
2906- gen .invokeStatic (UTIL_TYPE ,Method .getMethod ("Class classOf(Object)" )); //target,class
2907- gen .dup (); //target,class,class
2908- gen .loadThis ();
2909- gen .getField (objx .objtype , objx .cachedClassName (siteIndex ),CLASS_TYPE ); //target,class,class,cached-class
2910- gen .visitJumpInsn (IF_ACMPNE , notSameClassLabel ); //target,class
2911- objx .emitVar (gen , v );
2912- gen .invokeVirtual (VAR_TYPE , Method .getMethod ("Object getRawRoot()" )); //target, class, proto-fn
2913- gen .dup (); //target, class, proto-fn, proto-fn
2914- gen .loadThis ();
2915- gen .getField (objx .objtype , objx .cachedProtoFnName (siteIndex ),AFUNCTION_TYPE ); //target,class, proto-fn,proto-fn,cached-proto-fn
2916- gen .visitJumpInsn (IF_ACMPNE , elseLabel ); //target,class, proto-fn
2917- gen .pop (); //target,class
2918- gen .pop (); //target
2919- gen .loadThis ();
2920- gen .getField (objx .objtype , objx .cachedProtoImplName (siteIndex ),IFN_TYPE ); //target,proto-impl
2921- gen .swap (); //proto-impl, target
2922- gen .goTo (callLabel );
2923-
29242907
2925- gen .mark (notSameClassLabel ); //target,class
2926- gen .dup (); //target,class,class
2908+ gen .mark (callLabel ); //target
2909+ gen .dup (); //target, target
2910+ gen .invokeStatic (UTIL_TYPE ,Method .getMethod ("Class classOf(Object)" )); //target,class
29272911 gen .loadThis ();
29282912 gen .swap ();
2929- gen .putField (objx .objtype , objx .cachedClassName (siteIndex ),CLASS_TYPE ); //target,class
2913+ gen .putField (objx .objtype , objx .cachedClassName (siteIndex ),CLASS_TYPE ); //target
29302914 objx .emitVar (gen , v );
2931- gen .invokeVirtual (VAR_TYPE , Method .getMethod ("Object getRawRoot()" )); //target, class, proto-fn
2932-
2933- gen .mark (elseLabel ); //target, class, proto-fn
2934- gen .checkCast (AFUNCTION_TYPE );
2935- gen .dup (); //target,class,proto-fn,proto-fn
2936- gen .loadThis ();
2937- gen .swap ();
2938- gen .putField (objx .objtype , objx .cachedProtoFnName (siteIndex ),AFUNCTION_TYPE ); //target, class, proto-fn
2939- gen .dupX1 (); //target, proto-fn, class, proto-fn
2940- gen .getField (AFUNCTION_TYPE ,"__methodImplCache" , Type .getType (MethodImplCache .class )); //target,protofn,class,cache
2941- gen .swap (); //target,protofn,cache,class
2942- gen .invokeVirtual (Type .getType (MethodImplCache .class ),Method .getMethod ("clojure.lang.IFn fnFor(Class)" )); //target,protofn,impl
2943- gen .dup (); //target,protofn,impl, impl
2944- gen .ifNull (faultLabel ); //target,protofn,impl
2945- gen .swap (); //target,impl, protofn
2946- gen .pop (); //target, impl
2947- gen .dup (); //target,impl, impl
2948- gen .loadThis ();
2915+ gen .invokeVirtual (VAR_TYPE , Method .getMethod ("Object getRawRoot()" )); //target, proto-fn
29492916 gen .swap ();
2950- gen .putField (objx .objtype , objx .cachedProtoImplName (siteIndex ),IFN_TYPE ); //target,impl
2951- gen .swap (); //impl,target
2952- gen .goTo (callLabel );
2953-
2954- //not in fn table, null out cached fn and use proto-fn itself (which should seed table for next time)
2955- gen .mark (faultLabel ); //target,protofn,null
2956- gen .pop (); //target, protofn
2957- gen .swap (); //protofn, target
2958- gen .loadThis ();
2959- gen .visitInsn (Opcodes .ACONST_NULL );
2960- gen .putField (objx .objtype , objx .cachedProtoFnName (siteIndex ), AFUNCTION_TYPE ); //target, class, proto-fn
2961- gen .goTo (callLabel );
2962-
2963- gen .mark (callLabel ); //impl, target
29642917 emitArgsAndCall (1 , context ,objx ,gen );
29652918 gen .goTo (endLabel );
29662919
@@ -2976,9 +2929,8 @@ public void emitProto(C context, ObjExpr objx, GeneratorAdapter gen){
29762929 Method m = new Method (onMethod .getName (), Type .getReturnType (onMethod ), Type .getArgumentTypes (onMethod ));
29772930 gen .invokeInterface (Type .getType (protocolOn ), m );
29782931 HostExpr .emitBoxReturn (objx , gen , onMethod .getReturnType ());
2979- }
2932+ }
29802933 gen .mark (endLabel );
2981-
29822934 }
29832935
29842936 void emitArgsAndCall (int firstArgToEmit , C context , ObjExpr objx , GeneratorAdapter gen ){
0 commit comments