Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/ExactClassValueProfile.java @ 20075:405257253e59
ExactClassValueProfile: do not create isInstance check for generic (object) profiles
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Mon, 30 Mar 2015 14:01:04 +0200 |
parents | 1e542561783e |
children |
comparison
equal
deleted
inserted
replaced
20074:a7ee2e1f0d4e | 20075:405257253e59 |
---|---|
38 } | 38 } |
39 | 39 |
40 @SuppressWarnings("unchecked") | 40 @SuppressWarnings("unchecked") |
41 @Override | 41 @Override |
42 public <T> T profile(T value) { | 42 public <T> T profile(T value) { |
43 if (cachedClass != null && cachedClass.isInstance(value)) { | 43 if (cachedClass != Object.class) { |
44 return (T) cachedClass.cast(value); | 44 if (cachedClass != null && cachedClass.isInstance(value)) { |
45 } else { | 45 return (T) cachedClass.cast(value); |
46 CompilerDirectives.transferToInterpreterAndInvalidate(); | |
47 if (cachedClass == null && value != null) { | |
48 cachedClass = value.getClass(); | |
49 } else { | 46 } else { |
50 cachedClass = Object.class; | 47 CompilerDirectives.transferToInterpreterAndInvalidate(); |
48 if (cachedClass == null && value != null) { | |
49 cachedClass = value.getClass(); | |
50 } else { | |
51 cachedClass = Object.class; | |
52 } | |
51 } | 53 } |
52 } | 54 } |
53 return value; | 55 return value; |
54 } | 56 } |
55 | 57 |