/** @see org.jnode.vm.x86.compiler.l1a.Item#push(EmitterContext) */ final void push(EmitterContext ec) { final X86Assembler os = ec.getStream(); final VirtualStack stack = ec.getVStack(); final X86CompilerHelper helper = ec.getHelper(); switch (getKind()) { case Kind.GPR: os.writePUSH(gpr); break; case Kind.LOCAL: os.writePUSH(helper.BP, getOffsetToFP(ec)); break; case Kind.CONSTANT: pushConstant(ec, os); break; case Kind.FPUSTACK: // Make sure this item is on top of the FPU stack final FPUStack fpuStack = stack.fpuStack; FPUHelper.fxch(os, fpuStack, this); stack.fpuStack.pop(this); // Convert & move to new space on normal stack os.writeLEA(helper.SP, helper.SP, -helper.SLOTSIZE); popFromFPU(os, helper.SP, 0); break; case Kind.STACK: // nothing to do if (VirtualStack.checkOperandStack) { // the item is not really pushed and popped // but this checks that it is really the top // element stack.operandStack.pop(this); } break; default: throw new IllegalArgumentException("Invalid item kind"); } cleanup(ec); setKind(Kind.STACK); if (VirtualStack.checkOperandStack) { stack.operandStack.push(this); } }
/** @see org.jnode.vm.x86.compiler.l1a.Item#pushToFPU(EmitterContext) */ final void pushToFPU(EmitterContext ec) { final X86Assembler os = ec.getStream(); final VirtualStack stack = ec.getVStack(); final X86CompilerHelper helper = ec.getHelper(); switch (getKind()) { case Kind.GPR: os.writePUSH(gpr); pushToFPU(os, helper.SP, 0); os.writeLEA(helper.SP, helper.SP, helper.SLOTSIZE); break; case Kind.LOCAL: pushToFPU(os, helper.BP, getOffsetToFP(ec)); break; case Kind.CONSTANT: pushConstant(ec, os); pushToFPU(os, helper.SP, 0); os.writeLEA(helper.SP, helper.SP, helper.SLOTSIZE); break; case Kind.FPUSTACK: // Assert this item is at the top of the stack stack.fpuStack.pop(this); stack.fpuStack.push(this); return; // break; case Kind.STACK: if (VirtualStack.checkOperandStack) { stack.operandStack.pop(this); } pushToFPU(os, helper.SP, 0); os.writeLEA(helper.SP, helper.SP, helper.SLOTSIZE); break; default: throw new IllegalArgumentException("Invalid item kind"); } cleanup(ec); setKind(Kind.FPUSTACK); stack.fpuStack.push(this); }