}
}
// Optimize some core class method calls for constant values
else if (iop.isCall()) {
val = null;
CallInstr call = (CallInstr) i;
Operand r = call.getReceiver();
// SSS FIXME: r can be null for ruby/jruby internal call instructions!
// Cannot optimize them as of now.
if (r != null) {
// If 'r' is not a constant, it could actually be a compound value!
// Look in our value map to see if we have a simplified value for the receiver.
if (!r.isConstant()) {
Operand v = valueMap.get(r);
if (v != null)
r = v;
}
// Check if we can optimize this call based on the receiving method and receiver type
// Use the simplified receiver!
IRMethod rm = call.getTargetMethodWithReceiver(r);
if (rm != null) {
IRModule rc = rm.getDefiningIRModule();
if (rc != null) { // TODO: I am fairly sure I am wallpapering
if (rc.isCoreClass("Fixnum")) {
Operand[] args = call.getOperands();
if (args[2].isConstant()) {
addMethodGuard(rm, deoptLabel, versionMap, instrs);
val = ((Fixnum) r).computeValue(rm.getName(), (Constant) args[2]);
}
} else if (rc.isCoreClass("Float")) {
Operand[] args = call.getOperands();
if (args[2].isConstant()) {
addMethodGuard(rm, deoptLabel, versionMap, instrs);
val = ((Float) r).computeValue(rm.getName(), (Constant) args[2]);
}
} else if (rc.isCoreClass("Array")) {
Operand[] args = call.getOperands();
if (args[2] instanceof Fixnum && (rm.getName() == "[]")) {
addMethodGuard(rm, deoptLabel, versionMap, instrs);
val = ((Array) r).fetchCompileTimeArrayElement(((Fixnum) args[2]).value.intValue(), false);
}
}