# HG changeset patch # User Doug Simon # Date 1335811240 -7200 # Node ID 7ceb3f3671b9df5b288643066e252415b85299ef # Parent e4e02131c58b11e74ef5245ea206ae1bc39a21ae removed XIR support for arraycopy diff -r e4e02131c58b -r 7ceb3f3671b9 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java Mon Apr 30 20:28:49 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotXirGenerator.java Mon Apr 30 20:40:40 2012 +0200 @@ -645,166 +645,6 @@ } }; - private KindTemplates arrayCopyTemplates = new KindTemplates() { - - @Override - protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { - asm.restart(CiKind.Void); - XirParameter src = asm.createInputParameter("src", CiKind.Object); - XirParameter srcPos = asm.createInputParameter("srcPos", CiKind.Int, true); - XirParameter dest = asm.createInputParameter("dest", CiKind.Object); - XirParameter destPos = asm.createInputParameter("destPos", CiKind.Int, true); - XirParameter length = asm.createInputParameter("length", CiKind.Int, true); - - XirOperand tempSrc = asm.createTemp("tempSrc", target.wordKind); - XirOperand tempDest = asm.createTemp("tempDest", target.wordKind); - XirOperand lengthOperand = asm.createRegisterTemp("lengthOperand", CiKind.Int, AMD64.rax); - - XirOperand compHub = null; - XirOperand valueHub = null; - XirOperand temp = null; - XirLabel store = null; - XirLabel slowStoreCheck = null; - - if (is(STORE_CHECK, flags) && kind == CiKind.Object) { - valueHub = asm.createRegisterTemp("valueHub", target.wordKind, AMD64.rdi); - compHub = asm.createRegisterTemp("compHub", target.wordKind, AMD64.rsi); - temp = asm.createRegisterTemp("temp", target.wordKind, AMD64.r10); - } - - // Calculate the factor for the repeat move instruction. - int elementSize = target.sizeInBytes(kind); - int factor; - boolean wordSize; - if (elementSize >= target.wordSize) { - assert elementSize % target.wordSize == 0; - wordSize = true; - factor = elementSize / target.wordSize; - } else { - factor = elementSize; - wordSize = false; - } - - // Adjust the length if the factor is not 1. - if (factor != 1) { - asm.shl(lengthOperand, length, asm.i(CiUtil.log2(factor))); - } else { - asm.mov(lengthOperand, length); - } - - // Set the start and the end pointer. - asm.lea(tempSrc, src, srcPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); - asm.lea(tempDest, dest, destPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); - - XirLabel reverse = null; - XirLabel normal = null; - - if (is(STORE_CHECK, flags)) { - reverse = asm.createInlineLabel("reverse"); - asm.jneq(reverse, src, dest); - } - - if (!is(STORE_CHECK, flags) && !is(INPUTS_DIFFERENT, flags) && !is(INPUTS_SAME, flags)) { - normal = asm.createInlineLabel("normal"); - asm.jneq(normal, src, dest); - } - - if (!is(INPUTS_DIFFERENT, flags)) { - if (reverse == null) { - reverse = asm.createInlineLabel("reverse"); - } - asm.jlt(reverse, srcPos, destPos); - } - - if (!is(STORE_CHECK, flags) && !is(INPUTS_DIFFERENT, flags) && !is(INPUTS_SAME, flags)) { - asm.bindInline(normal); - } - - // Everything set up => repeat mov. - if (wordSize) { - asm.repmov(tempSrc, tempDest, lengthOperand); - } else { - asm.repmovb(tempSrc, tempDest, lengthOperand); - } - - if (!is(INPUTS_DIFFERENT, flags) || is(STORE_CHECK, flags)) { - - XirLabel end = asm.createInlineLabel("end"); - asm.jmp(end); - - // Implement reverse copy, because srcPos < destPos and src == dest. - asm.bindInline(reverse); - - if (is(STORE_CHECK, flags)) { - asm.pload(CiKind.Object, compHub, dest, asm.i(config.hubOffset), false); - asm.pload(CiKind.Object, compHub, compHub, asm.i(config.arrayClassElementOffset), false); - } - - CiKind copyKind = wordSize ? CiKind.Object : CiKind.Byte; - XirOperand tempValue = asm.createTemp("tempValue", copyKind); - XirLabel start = asm.createInlineLabel("start"); - asm.bindInline(start); - asm.sub(lengthOperand, lengthOperand, asm.i(1)); - asm.jlt(end, lengthOperand, asm.i(0)); - - Scale scale = wordSize ? Scale.fromInt(target.wordSize) : Scale.Times1; - asm.pload(copyKind, tempValue, tempSrc, lengthOperand, 0, scale, false); - - if (is(STORE_CHECK, flags)) { - slowStoreCheck = asm.createOutOfLineLabel("slowStoreCheck"); - store = asm.createInlineLabel("store"); - asm.jeq(store, tempValue, asm.o(null)); // first check if value is null - asm.pload(CiKind.Object, valueHub, tempValue, asm.i(config.hubOffset), false); - asm.jneq(slowStoreCheck, compHub, valueHub); // then check component hub matches value hub - asm.bindInline(store); - } - - asm.pstore(copyKind, tempDest, lengthOperand, tempValue, 0, scale, false); - - asm.jmp(start); - asm.bindInline(end); - } - - if (kind == CiKind.Object) { - // Do write barriers - asm.lea(tempDest, dest, destPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); - asm.shr(tempDest, tempDest, asm.i(config.cardtableShift)); - asm.pstore(CiKind.Boolean, wordConst(asm, config.cardtableStartAddress), tempDest, asm.b(false), false); - - XirOperand tempDestEnd = tempSrc; // Reuse src temp - asm.lea(tempDestEnd, dest, destPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); - asm.add(tempDestEnd, tempDestEnd, length); - asm.shr(tempDestEnd, tempDestEnd, asm.i(config.cardtableShift)); - - // Jump to out-of-line write barrier loop if the array is big. - XirLabel writeBarrierLoop = asm.createOutOfLineLabel("writeBarrierLoop"); - asm.jneq(writeBarrierLoop, tempDest, tempSrc); - XirLabel back = asm.createInlineLabel("back"); - asm.bindInline(back); - - asm.bindOutOfLine(writeBarrierLoop); - asm.pstore(CiKind.Boolean, wordConst(asm, config.cardtableStartAddress), tempDestEnd, asm.b(false), false); - asm.sub(tempDestEnd, tempDestEnd, asm.i(1)); - asm.jneq(writeBarrierLoop, tempDestEnd, tempDest); - asm.jmp(back); - } - - if (is(STORE_CHECK, flags)) { - assert kind == CiKind.Object; - useRegisters(asm, AMD64.rax); - asm.bindOutOfLine(slowStoreCheck); - checkSubtype(asm, temp, valueHub, compHub); - asm.jneq(store, temp, wordConst(asm, 0)); - XirOperand scratch = asm.createRegisterTemp("scratch", target.wordKind, AMD64.r10); - asm.mov(scratch, wordConst(asm, compiler.getRuntime().encodeDeoptActionAndReason(RiDeoptAction.None, RiDeoptReason.ClassCastException))); - asm.callRuntime(CiRuntimeCall.Deoptimize, null); - asm.jmp(store); - } - - return asm.finishTemplate("arraycopy<" + kind + ">"); - } - }; - private SimpleTemplates typeCheckTemplates = new SimpleTemplates(NULL_CHECK) { @Override protected XirTemplate create(CiXirAssembler asm, long flags) { @@ -955,23 +795,6 @@ } @Override - public XirSnippet genArrayCopy(XirSite site, XirArgument src, XirArgument srcPos, XirArgument dest, XirArgument destPos, XirArgument length, RiType elementType, boolean inputsSame, boolean inputsDifferent) { - if (elementType == null) { - return null; - } - assert !inputsDifferent || !inputsSame; - XirTemplate template = null; - if (inputsDifferent) { - template = arrayCopyTemplates.get(site, elementType.kind(true), INPUTS_DIFFERENT); - } else if (inputsSame) { - template = arrayCopyTemplates.get(site, elementType.kind(true), INPUTS_SAME); - } else { - template = arrayCopyTemplates.get(site, elementType.kind(true)); - } - return new XirSnippet(template, src, srcPos, dest, destPos, length); - } - - @Override public XirSnippet genTypeBranch(XirSite site, XirArgument thisHub, XirArgument otherHub, RiType type) { assert type instanceof RiResolvedType; return new XirSnippet(typeCheckTemplates.get(site), thisHub, otherHub); diff -r e4e02131c58b -r 7ceb3f3671b9 graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java Mon Apr 30 20:28:49 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java Mon Apr 30 20:40:40 2012 +0200 @@ -55,8 +55,6 @@ XirSnippet genMaterializeInstanceOf(XirSite site, XirArgument receiver, XirArgument hub, XirArgument trueValue, XirArgument falseValue, RiType type, RiResolvedType[] hints, boolean hintsExact); - XirSnippet genArrayCopy(XirSite site, XirArgument src, XirArgument srcPos, XirArgument dest, XirArgument destPos, XirArgument length, RiType elementType, boolean inputsSame, boolean inputsDifferent); - /** * Generates code that checks that the {@linkplain Representation#ObjectHub hub} of * an object is identical to a given hub constant. In pseudo code: