Mercurial > hg > graal-compiler
changeset 20822:8ad82587f08d
Allow scaling factors in integer options; add support for Long values in addition to Integer values
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 08 Apr 2015 21:59:42 -0700 |
parents | 1bfa14fd1275 |
children | 3c1f872f280e |
files | graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionUtils.java |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionUtils.java Wed Apr 08 21:58:46 2015 -0700 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionUtils.java Wed Apr 08 21:59:42 2015 -0700 @@ -91,7 +91,9 @@ } else if (optionType == Double.class) { value = Double.parseDouble(valueString); } else if (optionType == Integer.class) { - value = Integer.parseInt(valueString); + value = Integer.valueOf((int) parseLong(valueString)); + } else if (optionType == Long.class) { + value = Long.valueOf(parseLong(valueString)); } else if (optionType == String.class) { value = valueString; } @@ -118,6 +120,27 @@ return true; } + private static long parseLong(String v) { + String valueString = v.toLowerCase(); + long scale = 1; + if (valueString.endsWith("k")) { + scale = 1024L; + } else if (valueString.endsWith("m")) { + scale = 1024L * 1024L; + } else if (valueString.endsWith("g")) { + scale = 1024L * 1024L * 1024L; + } else if (valueString.endsWith("t")) { + scale = 1024L * 1024L * 1024L * 1024L; + } + + if (scale != 1) { + /* Remove trailing scale character. */ + valueString = valueString.substring(0, valueString.length() - 1); + } + + return Long.parseLong(valueString) * scale; + } + public static void printNoMatchMessage(SortedMap<String, OptionDescriptor> options, String optionName, String prefix) { OptionDescriptor desc = options.get(optionName); if (desc != null) {