Mercurial > hg > truffle
annotate test/serviceability/dcmd/DcmdUtil.java @ 14495:cd5d10655495
8027754: Enable loop optimizations for loops with MathExact inside
Reviewed-by: kvn, iveresov
author | rbackman |
---|---|
date | Thu, 23 Jan 2014 12:08:28 +0100 |
parents | afa21611f918 |
children |
rev | line source |
---|---|
14246
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
1 /* |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
4 * |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
8 * |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
13 * accompanied this code). |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
14 * |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
18 * |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
21 * questions. |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
22 */ |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
23 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
24 import sun.management.ManagementFactoryHelper; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
25 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
26 import com.sun.management.DiagnosticCommandMBean; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
27 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
28 public class DcmdUtil |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
29 { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
30 public static String executeDcmd(String cmd, String ... args) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
31 DiagnosticCommandMBean dcmd = ManagementFactoryHelper.getDiagnosticCommandMBean(); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
32 Object[] dcmdArgs = {args}; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
33 String[] signature = {String[].class.getName()}; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
34 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
35 try { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
36 System.out.print("> " + cmd + " "); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
37 for (String s : args) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
38 System.out.print(s + " "); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
39 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
40 System.out.println(":"); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
41 String result = (String) dcmd.invoke(transform(cmd), dcmdArgs, signature); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
42 System.out.println(result); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
43 return result; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
44 } catch(Exception ex) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
45 ex.printStackTrace(); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
46 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
47 return null; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
48 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
49 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
50 private static String transform(String name) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
51 StringBuilder sb = new StringBuilder(); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
52 boolean toLower = true; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
53 boolean toUpper = false; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
54 for (int i = 0; i < name.length(); i++) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
55 char c = name.charAt(i); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
56 if (c == '.' || c == '_') { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
57 toLower = false; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
58 toUpper = true; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
59 } else { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
60 if (toUpper) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
61 toUpper = false; |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
62 sb.append(Character.toUpperCase(c)); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
63 } else if(toLower) { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
64 sb.append(Character.toLowerCase(c)); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
65 } else { |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
66 sb.append(c); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
67 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
68 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
69 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
70 return sb.toString(); |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
71 } |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
72 |
afa21611f918
8031304: Add dcmd to print all loaded dynamic libraries.
farvidsson
parents:
diff
changeset
|
73 } |