Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | c18cbe5936b8 |
children | 32f7097f9d8f |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
738 // ik == null for instance fields. | 738 // ik == null for instance fields. |
739 out.writeShort((short) fields.size()); | 739 out.writeShort((short) fields.size()); |
740 for (Iterator itr = fields.iterator(); itr.hasNext();) { | 740 for (Iterator itr = fields.iterator(); itr.hasNext();) { |
741 Field field = (Field) itr.next(); | 741 Field field = (Field) itr.next(); |
742 Symbol name = symTbl.probe(field.getID().getName()); | 742 Symbol name = symTbl.probe(field.getID().getName()); |
743 writeObjectID(name); | 743 writeSymbolID(name); |
744 char typeCode = (char) field.getSignature().getByteAt(0); | 744 char typeCode = (char) field.getSignature().getByteAt(0); |
745 int kind = signatureToHprofKind(typeCode); | 745 int kind = signatureToHprofKind(typeCode); |
746 out.writeByte((byte)kind); | 746 out.writeByte((byte)kind); |
747 if (ik != null) { | 747 if (ik != null) { |
748 // static field | 748 // static field |
850 } | 850 } |
851 | 851 |
852 private void writeSymbol(Symbol sym) throws IOException { | 852 private void writeSymbol(Symbol sym) throws IOException { |
853 byte[] buf = sym.asString().getBytes("UTF-8"); | 853 byte[] buf = sym.asString().getBytes("UTF-8"); |
854 writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE); | 854 writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE); |
855 writeObjectID(sym); | 855 writeSymbolID(sym); |
856 out.write(buf); | 856 out.write(buf); |
857 } | 857 } |
858 | 858 |
859 private void writeClasses() throws IOException { | 859 private void writeClasses() throws IOException { |
860 // write class list (id, name) association | 860 // write class list (id, name) association |
867 Instance clazz = k.getJavaMirror(); | 867 Instance clazz = k.getJavaMirror(); |
868 writeHeader(HPROF_LOAD_CLASS, 2 * (OBJ_ID_SIZE + 4)); | 868 writeHeader(HPROF_LOAD_CLASS, 2 * (OBJ_ID_SIZE + 4)); |
869 out.writeInt(serialNum); | 869 out.writeInt(serialNum); |
870 writeObjectID(clazz); | 870 writeObjectID(clazz); |
871 out.writeInt(DUMMY_STACK_TRACE_ID); | 871 out.writeInt(DUMMY_STACK_TRACE_ID); |
872 writeObjectID(k.getName()); | 872 writeSymbolID(k.getName()); |
873 serialNum++; | 873 serialNum++; |
874 } catch (IOException exp) { | 874 } catch (IOException exp) { |
875 throw new RuntimeException(exp); | 875 throw new RuntimeException(exp); |
876 } | 876 } |
877 } | 877 } |
897 // writes unique ID for an object | 897 // writes unique ID for an object |
898 private void writeObjectID(Oop oop) throws IOException { | 898 private void writeObjectID(Oop oop) throws IOException { |
899 OopHandle handle = (oop != null)? oop.getHandle() : null; | 899 OopHandle handle = (oop != null)? oop.getHandle() : null; |
900 long address = getAddressValue(handle); | 900 long address = getAddressValue(handle); |
901 writeObjectID(address); | 901 writeObjectID(address); |
902 } | |
903 | |
904 private void writeSymbolID(Symbol sym) throws IOException { | |
905 writeObjectID(getAddressValue(sym.getAddress())); | |
902 } | 906 } |
903 | 907 |
904 private void writeObjectID(long address) throws IOException { | 908 private void writeObjectID(long address) throws IOException { |
905 if (OBJ_ID_SIZE == 4) { | 909 if (OBJ_ID_SIZE == 4) { |
906 out.writeInt((int) address); | 910 out.writeInt((int) address); |