comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2521:2f271a85d104

Removed intrinsic-related instructions
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 16:40:09 +0200
parents f6125fb5bfbc
children c480605ef068
comparison
equal deleted inserted replaced
2520:99307021e3f5 2521:2f271a85d104
1432 return true; 1432 return true;
1433 } 1433 }
1434 } 1434 }
1435 } 1435 }
1436 return false; 1436 return false;
1437 }
1438
1439 private Instruction genArrayClone(RiMethod target, Value[] args) {
1440 FrameState state = curState.immutableCopy(bci());
1441 Value array = args[0];
1442 RiType type = array.declaredType();
1443 assert type != null && type.isResolved() && type.isArrayClass();
1444 Value newLength = args[1];
1445
1446 Value oldLength = append(new ArrayLength(array, state));
1447 Value newArray = append(new NewObjectArrayClone(newLength, array, state));
1448 Value copyLength = append(new IfOp(newLength, Condition.LT, oldLength, newLength, oldLength));
1449 append(new ArrayCopy(array, Constant.forInt(0), newArray, Constant.forInt(0), copyLength, null, null));
1450 return (Instruction) newArray;
1451 }
1452
1453 private Instruction genArrayCopy(RiMethod target, Value[] args) {
1454 FrameState state = curState.immutableCopy(bci());
1455 Instruction result;
1456 Value src = args[0];
1457 Value srcPos = args[1];
1458 Value dest = args[2];
1459 Value destPos = args[3];
1460 Value length = args[4];
1461
1462 // Check src start pos.
1463 Value srcLength = append(new ArrayLength(src, state));
1464
1465 // Check dest start pos.
1466 Value destLength = srcLength;
1467 if (src != dest) {
1468 destLength = append(new ArrayLength(dest, state));
1469 }
1470
1471 // Check src end pos.
1472 Value srcEndPos = append(new ArithmeticOp(IADD, CiKind.Int, srcPos, length, false, null));
1473 append(new BoundsCheck(srcEndPos, srcLength, state, Condition.LE));
1474
1475 // Check dest end pos.
1476 Value destEndPos = srcEndPos;
1477 if (destPos != srcPos) {
1478 destEndPos = append(new ArithmeticOp(IADD, CiKind.Int, destPos, length, false, null));
1479 }
1480 append(new BoundsCheck(destEndPos, destLength, state, Condition.LE));
1481
1482 Value zero = append(Constant.forInt(0));
1483 append(new BoundsCheck(length, zero, state, Condition.GE));
1484 append(new BoundsCheck(srcPos, zero, state, Condition.GE));
1485 append(new BoundsCheck(destPos, zero, state, Condition.GE));
1486
1487 result = new ArrayCopy(src, srcPos, dest, destPos, length, target, state);
1488 return result;
1489 } 1437 }
1490 1438
1491 private boolean tryFoldable(RiMethod target, Value[] args) { 1439 private boolean tryFoldable(RiMethod target, Value[] args) {
1492 CiConstant result = Canonicalizer.foldInvocation(compilation.runtime, target, args); 1440 CiConstant result = Canonicalizer.foldInvocation(compilation.runtime, target, args);
1493 if (result != null) { 1441 if (result != null) {