os.writePUSH(SoftByteCodes.EX_CLASSCAST); os.writePUSH(0); invokeJavaMethod(context.getSystemExceptionMethod()); final RefItem exi = vstack.popRef(); assertCondition(exi.uses(EAX), "item must be in eax"); exi.release(eContext);   helper.writeJumpTableCALL(X86JumpTable.VM_ATHROW_OFS);
invokeJavaMethod(context.getClassCastFailedMethod());
    public final void visit_checkcast(VmConstClass classRef) {    	// Resolve classRef    	classRef.resolve(loader);    	final VmType resolvedType = classRef.getResolvedVmClass();    	    	if (resolvedType.isInterface() || resolvedType.isArray()) {        		// ClassRef is an interface or array, do the slow test    		    		// Pre-claim ECX    		L1AHelper.requestRegister(eContext, EAX);    		    		// check that top item is a reference    		final RefItem ref = vstack.popRef();    		    		// Load the ref    		ref.load(eContext);    		final Register refr = ref.getRegister();    		final Register classr = EAX;    		final Register cntr = L1AHelper.requestRegister(eContext, JvmType.INT,    				false);    		final Register tmpr = L1AHelper.requestRegister(eContext, JvmType.INT,    				false);    		    		// Resolve the class    		writeResolveAndLoadClassToReg(classRef, classr);    		    		final Label okLabel = new Label(this.curInstrLabel + "cc-ok");    		    		/* Is objectref null? */    		os.writeTEST(refr, refr);    		os.writeJCC(okLabel, X86Constants.JZ);    		/* Is instanceof? */    		instanceOf(refr, classr, tmpr, cntr, okLabel, true);    		/* Not instanceof */    		    		// Release temp registers here, so invokeJavaMethod can use it    		L1AHelper.releaseRegister(eContext, cntr);    		L1AHelper.releaseRegister(eContext, classr);    		L1AHelper.releaseRegister(eContext, tmpr);    		    		// Call SoftByteCodes.systemException    		os.writePUSH(SoftByteCodes.EX_CLASSCAST);    		os.writePUSH(0);    		invokeJavaMethod(context.getSystemExceptionMethod());    		final RefItem exi = vstack.popRef();    		assertCondition(exi.uses(EAX), "item must be in eax");    		exi.release(eContext);    		    		/* Exception in EAX, throw it */    		helper.writeJumpTableCALL(X86JumpTable.VM_ATHROW_OFS);    		    		/* Normal exit */    		os.setObjectRef(okLabel);    		    		// Leave ref on stack    		vstack.push(ref);    	} else {			// classRef is a class, do the fast test    		    		// Pre-claim EAX    		L1AHelper.requestRegister(eContext, EAX);    		    		// check that top item is a reference    		final RefItem ref = vstack.popRef();    		    		// Load the ref    		ref.load(eContext);    		final Register refr = ref.getRegister();    		final Register tmpr = L1AHelper.requestRegister(eContext, JvmType.INT,    				false);    		    		final Label okLabel = new Label(this.curInstrLabel + "cc-ok");    		    		// Is objectref null?    		os.writeTEST(refr, refr);    		os.writeJCC(okLabel, X86Constants.JZ);    		// Is instanceof?    		instanceOfClass(refr, (VmClassType)resolvedType, tmpr, null, okLabel, true);    		// Not instanceof     		    		// Release temp registers here, so invokeJavaMethod can use it    		L1AHelper.releaseRegister(eContext, EAX);    		L1AHelper.releaseRegister(eContext, tmpr);    		    		// Call SoftByteCodes.systemException    		os.writePUSH(SoftByteCodes.EX_CLASSCAST);    		os.writePUSH(0);    		invokeJavaMethod(context.getSystemExceptionMethod());    		final RefItem exi = vstack.popRef();    		assertCondition(exi.uses(EAX), "item must be in eax");    		exi.release(eContext);    		    		/* Exception in EAX, throw it */    		helper.writeJumpTableCALL(X86JumpTable.VM_ATHROW_OFS);    		    		/* Normal exit */    		os.setObjectRef(okLabel);    		    		// Leave ref on stack    		vstack.push(ref);					}    }