# HG changeset patch # User Lukas Stadler # Date 1330350610 -3600 # Node ID 27397872945fef4b3ad35426ad4d7e8649ea71ec # Parent 351b9054b49d6855717e6fe8363f6bb8edff063f fix "integer overflow when computing constant displacement" by introducing a temp variable for large constant indexes diff -r 351b9054b49d -r 27397872945f graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Feb 27 14:45:10 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java Mon Feb 27 14:50:10 2012 +0100 @@ -153,15 +153,20 @@ scale = target().sizeInBytes(location.getValueKind()); } if (isConstant(index)) { - displacement += asConstant(index).asLong() * scale; - index = CiValue.IllegalValue; + long newDisplacement = displacement + asConstant(index).asLong() * scale; + // only use the constant index if the resulting displacement fits into a 32 bit offset + if (NumUtil.isInt(newDisplacement)) { + displacement = newDisplacement; + index = CiValue.IllegalValue; + } else { + // create a temporary variable for the index, the pointer load cannot handle a constant index + CiValue newIndex = newVariable(CiKind.Long); + emitMove(index, newIndex); + index = newIndex; + } } } - if (!NumUtil.isInt(displacement)) { - // Currently it's not worth handling this case. - throw new CiBailout("integer overflow when computing constant displacement"); - } return new CiAddress(location.getValueKind(), base, index, CiAddress.Scale.fromInt(scale), (int) displacement); }