Mercurial > hg > graal-compiler
changeset 15825:4fd787b04c92
Recompute probability only when number of types in profile changed
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 20 May 2014 18:51:54 -0700 |
parents | 8b4c360cd2fe |
children | 1891bac562d8 |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java |
diffstat | 1 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Tue May 20 18:51:16 2014 -0700 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Tue May 20 18:51:54 2014 -0700 @@ -109,14 +109,20 @@ if (result.size() == 0) { return new JavaTypeProfile(newNullSeen, 1.0, EMPTY_ARRAY); } - double probabilitySum = 0.0; - for (int i = 0; i < result.size(); i++) { - probabilitySum += result.get(i).getProbability(); + double factor; + if (result.size() == this.getItems().length) { + /* List of types did not change, no need to recompute probabilities. */ + factor = 1.0; + } else { + double probabilitySum = 0.0; + for (int i = 0; i < result.size(); i++) { + probabilitySum += result.get(i).getProbability(); + } + probabilitySum += newNotRecorded; + + factor = 1.0 / probabilitySum; // Normalize to 1.0 + assert factor >= 1.0; } - probabilitySum += newNotRecorded; - - double factor = 1.0 / probabilitySum; // Normalize to 1.0 - assert factor >= 1.0; ProfiledType[] newResult = new ProfiledType[result.size()]; for (int i = 0; i < newResult.length; ++i) { ProfiledType curType = result.get(i);