Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java @ 3939:f6f3bb0ee072
7088955: add C2 IR support to the SA
Reviewed-by: kvn
author | never |
---|---|
date | Sun, 11 Sep 2011 14:48:24 -0700 |
parents | 63997f575155 |
children | cfa2c82f4c04 |
comparison
equal
deleted
inserted
replaced
3938:e6b1331a51d2 | 3939:f6f3bb0ee072 |
---|---|
110 buf.append(charArray.getCharAt(i)); | 110 buf.append(charArray.getCharAt(i)); |
111 } | 111 } |
112 return buf.toString(); | 112 return buf.toString(); |
113 } | 113 } |
114 | 114 |
115 public static String escapeString(String s) { | |
116 StringBuilder sb = null; | |
117 for (int index = 0; index < s.length(); index++) { | |
118 char value = s.charAt(index); | |
119 if (value >= 32 && value < 127 || value == '\'' || value == '\\') { | |
120 if (sb != null) { | |
121 sb.append(value); | |
122 } | |
123 } else { | |
124 if (sb == null) { | |
125 sb = new StringBuilder(s.length() * 2); | |
126 sb.append(s, 0, index); | |
127 } | |
128 sb.append("\\u"); | |
129 if (value < 0x10) sb.append("000"); | |
130 else if (value < 0x100) sb.append("00"); | |
131 else if (value < 0x1000) sb.append("0"); | |
132 sb.append(Integer.toHexString(value)); | |
133 } | |
134 } | |
135 if (sb != null) { | |
136 return sb.toString(); | |
137 } | |
138 return s; | |
139 } | |
140 | |
115 public static String stringOopToString(Oop stringOop) { | 141 public static String stringOopToString(Oop stringOop) { |
116 if (offsetField == null) { | 142 if (offsetField == null) { |
117 InstanceKlass k = (InstanceKlass) stringOop.getKlass(); | 143 InstanceKlass k = (InstanceKlass) stringOop.getKlass(); |
118 offsetField = (IntField) k.findField("offset", "I"); | 144 offsetField = (IntField) k.findField("offset", "I"); |
119 countField = (IntField) k.findField("count", "I"); | 145 countField = (IntField) k.findField("count", "I"); |
125 } | 151 } |
126 } | 152 } |
127 return charArrayToString((TypeArray) valueField.getValue(stringOop), | 153 return charArrayToString((TypeArray) valueField.getValue(stringOop), |
128 offsetField.getValue(stringOop), | 154 offsetField.getValue(stringOop), |
129 countField.getValue(stringOop)); | 155 countField.getValue(stringOop)); |
156 } | |
157 | |
158 public static String stringOopToEscapedString(Oop stringOop) { | |
159 return escapeString(stringOopToString(stringOop)); | |
130 } | 160 } |
131 | 161 |
132 private static void initThreadGroupFields() { | 162 private static void initThreadGroupFields() { |
133 if (threadGroupParentField == null) { | 163 if (threadGroupParentField == null) { |
134 SystemDictionary sysDict = VM.getVM().getSystemDictionary(); | 164 SystemDictionary sysDict = VM.getVM().getSystemDictionary(); |