public void branch(Location location) { mAssembler.branch(location); }
public void checkCast(TypeDesc type) { mAssembler.checkCast(type); }
public void convert(TypeDesc fromType, TypeDesc toType) { mAssembler.convert(fromType, toType); }
params = new LocalVariable[assembler.getParameterCount()]; for (int i=params.length; --i>=0; ) { params[i] = assembler.getParameter(i); if (nextLine != currentLine) { if ((currentLine = nextLine) >= 0) { mAssembler.mapLineNumber(currentLine); assembler.nop(); break; case Opcode.BREAKPOINT: assembler.breakpoint(); break; assembler.loadNull(); break; case Opcode.ICONST_M1: assembler.loadConstant(-1); break; case Opcode.ICONST_0: assembler.loadConstant(0); break; case Opcode.ICONST_1: assembler.loadConstant(1); break; case Opcode.ICONST_2: assembler.loadConstant(2); break; case Opcode.ICONST_3:
final LocalVariable encodedVar = a.createLocalVariable(null, byteArrayType); a.loadConstant(prefix + generationPrefix); a.loadConstant(suffix); params = new TypeDesc[] {byteArrayType, TypeDesc.INT, TypeDesc.INT}; } else { a.invokeStatic(KeyEncoder.class.getName(), "encodeSingleNullableDesc", byteArrayType, params); } else { a.invokeStatic(DataEncoder.class.getName(), "encodeSingleNullable", byteArrayType, params); a.invokeStatic(KeyEncoder.class.getName(), "encodeSingleDesc", byteArrayType, params); } else if (prefix > 0 || generationPrefix > 0 || suffix > 0) { a.invokeStatic(DataEncoder.class.getName(), "encodeSingle", byteArrayType, params); } else { a.storeLocal(encodedVar); LocalVariable propVar = a.createLocalVariable(null, info.getStorageType()); stashedProperties[i] = propVar; a.storeLocal(propVar); a.loadConstant(0); hasStackVar = true;
a.loadLocal(encodedVar); a.loadConstant(prefix + generationPrefix); a.loadConstant(suffix); params = new TypeDesc[] {byteArrayType, TypeDesc.INT, TypeDesc.INT}; } else { a.invokeStatic(KeyDecoder.class.getName(), "decodeSingleNullableDesc", byteArrayType, params); } else { a.invokeStatic(DataDecoder.class.getName(), "decodeSingleNullable", byteArrayType, params); a.invokeStatic(KeyDecoder.class.getName(), "decodeSingleDesc", byteArrayType, params); } else if (prefix > 0 || generationPrefix > 0 || suffix > 0) { a.invokeStatic(DataDecoder.class.getName(), "decodeSingle", byteArrayType, params); } else { a.invokeVirtual(TypeDesc.OBJECT, "clone", TypeDesc.OBJECT, null); a.checkCast(byteArrayType); offsetVar = a.createLocalVariable(null, TypeDesc.INT); a.loadConstant(constantOffset); a.storeLocal(offsetVar); if (stringRefRef[0] == null) { TypeDesc refType = TypeDesc.forClass(String[].class);
LocalVariable temp = a.createLocalVariable(null, storageType); a.storeLocal(temp); a.loadStaticField (TypeDesc.forClass(adapterInstanceClass), fieldName, adapterType); a.loadLocal(temp); a.invoke(info.getFromStorageAdapter()); a.storeField(info.getPropertyName(), type); } else { a.invokeVirtual(info.getWriteMethodName() + '$', null, new TypeDesc[] {storageType}); Label convertLabel = a.createLabel(); Label convertedLabel = a.createLabel(); a.dup(); a.ifNullBranch(convertLabel, false); a.pop(); // pop null off stack loadBlankValue(a, propType); a.branch(convertedLabel); a.convert(type, propType); a.pop2(); } else { a.pop();
LocalVariable actualGeneration = a.createLocalVariable(null, TypeDesc.INT); a.loadLocal(encodedVar); a.loadConstant(offset); a.loadFromArray(TypeDesc.BYTE); a.storeLocal(actualGeneration); a.loadLocal(actualGeneration); Label compareGeneration = a.createLabel(); a.ifZeroComparisonBranch(compareGeneration, ">="); a.loadLocal(actualGeneration); a.loadConstant(24); a.math(Opcode.ISHL); a.loadConstant(0x7fffffff); a.math(Opcode.IAND); for (int i=1; i<4; i++) { a.loadLocal(encodedVar); a.loadConstant(offset + i); a.loadFromArray(TypeDesc.BYTE); a.loadConstant(0xff); a.math(Opcode.IAND); int shift = 8 * (3 - i); if (shift > 0) { a.loadConstant(shift); a.math(Opcode.ISHL); a.math(Opcode.IOR); a.storeLocal(actualGeneration);
TypeDesc adapterType = TypeDesc.forClass (info.getToStorageAdapter().getDeclaringClass()); a.loadStaticField (TypeDesc.forClass(adapterInstanceClass), fieldName, adapterType); a.loadThis(); if (useReadMethod) { info.addInvokeReadMethod(a); a.loadField(info.getPropertyName(), type); } else { a.invokeVirtual(info.getReadMethodName() + '$', storageType, null); a.loadLocal(instanceVar); if (useReadMethod) { info.addInvokeReadMethod(a, instanceVar.getType()); a.loadField(instanceVar.getType(), info.getPropertyName(), type); } else { a.invokeVirtual(instanceVar.getType(), info.getReadMethodName() + '$', storageType, null); a.loadLocal(instanceVar); a.loadConstant(ordinal); if (ordinal > 0 && partialStartVar != null) { a.loadLocal(partialStartVar); a.math(Opcode.ISUB);
/** * @param partialStartVar must not be null */ private Label[] jumpToPartialEntryPoints(CodeAssembler a, LocalVariable partialStartVar, int propertyCount) { // Create all the entry points for offset var, whose locations will be // set later. int[] cases = new int[propertyCount]; Label[] entryPoints = new Label[propertyCount]; for (int i=0; i<propertyCount; i++) { cases[i] = i; entryPoints[i] = a.createLabel(); } // Now jump in! Label errorLoc = a.createLabel(); a.loadLocal(partialStartVar); a.switchBranch(cases, entryPoints, errorLoc); errorLoc.setLocation(); TypeDesc errorType = TypeDesc.forClass(IllegalArgumentException.class); a.newObject(errorType); a.dup(); a.loadConstant("Illegal partial start offset"); a.invokeConstructor(errorType, new TypeDesc[] {TypeDesc.STRING}); a.throwObject(); return entryPoints; }
LocalVariable accumVar = a.createLocalVariable(null, TypeDesc.INT); int accumShift = 8; stateVars.set(stateVarOrdinal, a.createLocalVariable(null, TypeDesc.INT)); a.loadThis(); a.loadField(PROPERTY_STATE_FIELD_NAME + stateVarOrdinal, TypeDesc.INT); a.storeLocal(stateVars.get(stateVarOrdinal)); a.loadLocal(encodedVar); a.loadConstant(offset++); a.loadFromArray(TypeDesc.BYTE); a.loadConstant(0xff); a.math(Opcode.IAND); a.storeLocal(accumVar); accumShift = 0; a.loadLocal(accumVar); a.loadConstant(accumShift - stateShift); a.math(Opcode.IUSHR); } else if (stateShift > accumShift) { a.loadConstant(stateShift - accumShift); a.math(Opcode.ISHL); a.loadConstant(mask); a.math(Opcode.IAND); a.loadLocal(stateVars.get(stateVarOrdinal)); a.loadConstant(~mask); a.math(Opcode.IAND);
LocalVariable stateFieldVar = a.createLocalVariable(null, TypeDesc.INT); int lastFieldOrdinal = -1; LocalVariable accumVar = a.createLocalVariable(null, TypeDesc.INT); int accumShift = 0; a.loadLocal(stateFieldVar); } else { a.loadThis(); a.loadField(PROPERTY_STATE_FIELD_NAME + fieldOrdinal, TypeDesc.INT); a.storeLocal(stateFieldVar); a.loadLocal(stateFieldVar); lastFieldOrdinal = fieldOrdinal; a.loadConstant(mask); a.math(Opcode.IAND); a.loadConstant(accumShift - stateShift); a.math(Opcode.ISHL); } else if (stateShift > accumShift) { a.loadConstant(stateShift - accumShift); a.math(Opcode.IUSHR); a.loadLocal(accumVar); a.math(Opcode.IOR); a.storeLocal(accumVar); a.loadLocal(encodedVar);
a.invokeStatic (KeyDecoder.class.getName(), methodName + "Desc", returnType, params); } else { a.invokeStatic (DataDecoder.class.getName(), methodName, returnType, params); a.convert(returnType, storageType); refType = TypeDesc.forClass(String[].class); if (stringRefRef[0] == null) { stringRefRef[0] = a.createLocalVariable(null, refType); a.loadConstant(1); a.newObject(refType); a.storeLocal(stringRefRef[0]); a.loadLocal(stringRefRef[0]); valueRefRef[0] = stringRefRef[0]; } else if (storageType.toClass() == byte[].class) { refType = TypeDesc.forClass(byte[][].class); if (byteArrayRefRef[0] == null) { byteArrayRefRef[0] = a.createLocalVariable(null, refType); a.loadConstant(1); a.newObject(refType); a.storeLocal(byteArrayRefRef[0]); a.loadLocal(byteArrayRefRef[0]); valueRefRef[0] = byteArrayRefRef[0]; } else if (storageType.toClass() == BigInteger.class) {
/** * Generates code to push RawSupport instance to the stack. RawSupport is * available only in Storable instances. If instanceVar is an Object[], a * SupportException is thrown. * * @param instanceVar Storable instance or array of property values. Null * is storable instance of "this". */ protected void pushRawSupport(CodeAssembler a, LocalVariable instanceVar) throws SupportException { boolean isObjectArrayInstanceVar = instanceVar != null && instanceVar.getType() == TypeDesc.forClass(Object[].class); if (isObjectArrayInstanceVar) { throw new SupportException("Lob properties not supported"); } if (instanceVar == null) { a.loadThis(); } else { a.loadLocal(instanceVar); } a.loadField(SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class)); a.checkCast(TypeDesc.forClass(RawSupport.class)); }
public void invoke(Method method) { mAssembler.invoke(method); }
private void locateLabel() { int labelKey = mAddress; Object labelValue = mLabels.get(labelKey); if (labelValue != null) { if (labelValue instanceof Label) { ((Label)labelValue).setLocation(); } else { labelValue = mAssembler.createLabel().setLocation(); mLabels.put(labelKey, labelValue); } } List<ExceptionHandler> handlers = mCatchLocations.get(labelKey); if (handlers != null) { for (int i=0; i<handlers.size(); i++) { ExceptionHandler handler = handlers.get(i); Label start = getLabel(handler.getStartLocation().getLocation()); Label end = getLabel(handler.getEndLocation().getLocation()); String catchClassName; if (handler.getCatchType() == null) { catchClassName = null; } else { catchClassName = handler.getCatchType().getType().getFullName(); } mAssembler.exceptionHandler(start, end, catchClassName); } } }
public LocalVariable createLocalVariable(String name, TypeDesc type) { return mAssembler.createLocalVariable(name, type); }
public Label createLabel() { return mAssembler.createLabel(); }
public void ifComparisonBranch(Location location, String choice, TypeDesc type) throws IllegalArgumentException { mAssembler.ifComparisonBranch(location, choice, type); }
public void ifZeroComparisonBranch(Location location, String choice) throws IllegalArgumentException { mAssembler.ifZeroComparisonBranch(location, choice); }