# HG changeset patch # User Lukas Stadler # Date 1427716928 -7200 # Node ID 126ab00f859cd64fcfabb9aa4e5ef43317e66225 # Parent 405257253e59f55952b710fd81e1a6147d85bf17 refactor PrimitiveValueProfile to omit object equality comparison in the profiled case diff -r 405257253e59 -r 126ab00f859c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java Mon Mar 30 14:01:04 2015 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java Mon Mar 30 14:02:08 2015 +0200 @@ -53,27 +53,42 @@ public Object profile(Object value) { Object snapshot = this.cachedValue; if (snapshot != GENERIC) { - if (snapshot instanceof Byte && value instanceof Byte && (byte) snapshot == (byte) value) { - return snapshot; - } else if (snapshot instanceof Short && value instanceof Short && (short) snapshot == (short) value) { - return snapshot; - } else if (snapshot instanceof Integer && value instanceof Integer && (int) snapshot == (int) value) { - return snapshot; - } else if (snapshot instanceof Long && value instanceof Long && (long) snapshot == (long) value) { - return snapshot; - } else if (snapshot instanceof Float && value instanceof Float && exactCompare((float) snapshot, (float) value)) { - return snapshot; - } else if (snapshot instanceof Double && value instanceof Double && exactCompare((double) snapshot, (double) value)) { - return snapshot; - } else if (snapshot instanceof Boolean && value instanceof Boolean && (boolean) snapshot == (boolean) value) { - return snapshot; - } else if (snapshot instanceof Character && value instanceof Character && (char) snapshot == (char) value) { - return snapshot; + if (snapshot instanceof Byte) { + if (value instanceof Byte && (byte) snapshot == (byte) value) { + return snapshot; + } + } else if (snapshot instanceof Short) { + if (value instanceof Short && (short) snapshot == (short) value) { + return snapshot; + } + } else if (snapshot instanceof Integer) { + if (value instanceof Integer && (int) snapshot == (int) value) { + return snapshot; + } + } else if (snapshot instanceof Long) { + if (value instanceof Long && (long) snapshot == (long) value) { + return snapshot; + } + } else if (snapshot instanceof Float) { + if (value instanceof Float && exactCompare((float) snapshot, (float) value)) { + return snapshot; + } + } else if (snapshot instanceof Double) { + if (value instanceof Double && exactCompare((double) snapshot, (double) value)) { + return snapshot; + } + } else if (snapshot instanceof Boolean) { + if (value instanceof Boolean && (boolean) snapshot == (boolean) value) { + return snapshot; + } + } else if (snapshot instanceof Character) { + if (value instanceof Character && (char) snapshot == (char) value) { + return snapshot; + } } else if (snapshot == value) { return snapshot; - } else { - cacheMiss(value); } + cacheMiss(value); } return value; }