Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/oops/Method.java @ 10105:aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
Summary: Allocate the method's profiling related metadata until they are needed.
Reviewed-by: coleenp, roland
author | jiangli |
---|---|
date | Tue, 09 Apr 2013 17:17:41 -0400 |
parents | fd74228fd5ca |
children | cbfe859bd244 |
comparison
equal
deleted
inserted
replaced
9055:dcdeb150988c | 10105:aeaca88565e6 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
47 | 47 |
48 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | 48 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
49 Type type = db.lookupType("Method"); | 49 Type type = db.lookupType("Method"); |
50 constMethod = type.getAddressField("_constMethod"); | 50 constMethod = type.getAddressField("_constMethod"); |
51 methodData = type.getAddressField("_method_data"); | 51 methodData = type.getAddressField("_method_data"); |
52 methodCounters = type.getAddressField("_method_counters"); | |
52 methodSize = new CIntField(type.getCIntegerField("_method_size"), 0); | 53 methodSize = new CIntField(type.getCIntegerField("_method_size"), 0); |
53 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); | 54 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); |
54 code = type.getAddressField("_code"); | 55 code = type.getAddressField("_code"); |
55 vtableIndex = new CIntField(type.getCIntegerField("_vtable_index"), 0); | 56 vtableIndex = new CIntField(type.getCIntegerField("_vtable_index"), 0); |
56 if (!VM.getVM().isCore()) { | |
57 invocationCounter = new CIntField(type.getCIntegerField("_invocation_counter"), 0); | |
58 backedgeCounter = new CIntField(type.getCIntegerField("_backedge_counter"), 0); | |
59 } | |
60 bytecodeOffset = type.getSize(); | 57 bytecodeOffset = type.getSize(); |
61 | |
62 interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0); | |
63 interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0); | |
64 | 58 |
65 /* | 59 /* |
66 interpreterEntry = type.getAddressField("_interpreter_entry"); | 60 interpreterEntry = type.getAddressField("_interpreter_entry"); |
67 fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point"); | 61 fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point"); |
68 | 62 |
78 public boolean isMethod() { return true; } | 72 public boolean isMethod() { return true; } |
79 | 73 |
80 // Fields | 74 // Fields |
81 private static AddressField constMethod; | 75 private static AddressField constMethod; |
82 private static AddressField methodData; | 76 private static AddressField methodData; |
77 private static AddressField methodCounters; | |
83 private static CIntField methodSize; | 78 private static CIntField methodSize; |
84 private static CIntField accessFlags; | 79 private static CIntField accessFlags; |
85 private static CIntField vtableIndex; | 80 private static CIntField vtableIndex; |
86 private static CIntField invocationCounter; | |
87 private static CIntField backedgeCounter; | |
88 private static long bytecodeOffset; | 81 private static long bytecodeOffset; |
89 | 82 |
90 private static AddressField code; | 83 private static AddressField code; |
91 | |
92 private static CIntField interpreterThrowoutCountField; | |
93 private static CIntField interpreterInvocationCountField; | |
94 | 84 |
95 // constant method names - <init>, <clinit> | 85 // constant method names - <init>, <clinit> |
96 // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable | 86 // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable |
97 private static Symbol objectInitializerName; | 87 private static Symbol objectInitializerName; |
98 private static Symbol classInitializerName; | 88 private static Symbol classInitializerName; |
124 return getConstMethod().getConstants(); | 114 return getConstMethod().getConstants(); |
125 } | 115 } |
126 public MethodData getMethodData() { | 116 public MethodData getMethodData() { |
127 Address addr = methodData.getValue(getAddress()); | 117 Address addr = methodData.getValue(getAddress()); |
128 return (MethodData) VMObjectFactory.newObject(MethodData.class, addr); | 118 return (MethodData) VMObjectFactory.newObject(MethodData.class, addr); |
119 } | |
120 public MethodCounters getMethodCounters() { | |
121 Address addr = methodCounters.getValue(getAddress()); | |
122 return (MethodCounters) VMObjectFactory.newObject(MethodCounters.class, addr); | |
129 } | 123 } |
130 /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */ | 124 /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */ |
131 public long getMethodSize() { return methodSize.getValue(this); } | 125 public long getMethodSize() { return methodSize.getValue(this); } |
132 public long getMaxStack() { return getConstMethod().getMaxStack(); } | 126 public long getMaxStack() { return getConstMethod().getMaxStack(); } |
133 public long getMaxLocals() { return getConstMethod().getMaxLocals(); } | 127 public long getMaxLocals() { return getConstMethod().getMaxLocals(); } |
137 public long getGenericSignatureIndex() { return getConstMethod().getGenericSignatureIndex(); } | 131 public long getGenericSignatureIndex() { return getConstMethod().getGenericSignatureIndex(); } |
138 public long getAccessFlags() { return accessFlags.getValue(this); } | 132 public long getAccessFlags() { return accessFlags.getValue(this); } |
139 public long getCodeSize() { return getConstMethod().getCodeSize(); } | 133 public long getCodeSize() { return getConstMethod().getCodeSize(); } |
140 public long getVtableIndex() { return vtableIndex.getValue(this); } | 134 public long getVtableIndex() { return vtableIndex.getValue(this); } |
141 public long getInvocationCounter() { | 135 public long getInvocationCounter() { |
142 if (Assert.ASSERTS_ENABLED) { | 136 return getMethodCounters().getInvocationCounter(); |
143 Assert.that(!VM.getVM().isCore(), "must not be used in core build"); | |
144 } | |
145 return invocationCounter.getValue(this); | |
146 } | 137 } |
147 public long getBackedgeCounter() { | 138 public long getBackedgeCounter() { |
148 if (Assert.ASSERTS_ENABLED) { | 139 return getMethodCounters().getBackedgeCounter(); |
149 Assert.that(!VM.getVM().isCore(), "must not be used in core build"); | |
150 } | |
151 return backedgeCounter.getValue(this); | |
152 } | 140 } |
153 | 141 |
154 // get associated compiled native method, if available, else return null. | 142 // get associated compiled native method, if available, else return null. |
155 public NMethod getNativeMethod() { | 143 public NMethod getNativeMethod() { |
156 Address addr = code.getValue(getAddress()); | 144 Address addr = code.getValue(getAddress()); |
367 interpreterThrowoutCount() + " " + | 355 interpreterThrowoutCount() + " " + |
368 code_size); | 356 code_size); |
369 } | 357 } |
370 | 358 |
371 public int interpreterThrowoutCount() { | 359 public int interpreterThrowoutCount() { |
372 return (int) interpreterThrowoutCountField.getValue(this); | 360 return getMethodCounters().interpreterThrowoutCount(); |
373 } | 361 } |
374 | 362 |
375 public int interpreterInvocationCount() { | 363 public int interpreterInvocationCount() { |
376 return (int) interpreterInvocationCountField.getValue(this); | 364 return getMethodCounters().interpreterInvocationCount(); |
377 } | 365 } |
378 } | 366 } |