Mercurial > hg > truffle
changeset 20076:126ab00f859c
refactor PrimitiveValueProfile to omit object equality comparison in the profiled case
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Mon, 30 Mar 2015 14:02:08 +0200 |
parents | 405257253e59 |
children | a8b979f7dcef |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java |
diffstat | 1 files changed, 33 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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; }