Mercurial > hg > graal-compiler
diff 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 |
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Thu Apr 04 21:15:43 2013 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Tue Apr 09 17:17:41 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,19 +49,13 @@ Type type = db.lookupType("Method"); constMethod = type.getAddressField("_constMethod"); methodData = type.getAddressField("_method_data"); + methodCounters = type.getAddressField("_method_counters"); methodSize = new CIntField(type.getCIntegerField("_method_size"), 0); accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); code = type.getAddressField("_code"); vtableIndex = new CIntField(type.getCIntegerField("_vtable_index"), 0); - if (!VM.getVM().isCore()) { - invocationCounter = new CIntField(type.getCIntegerField("_invocation_counter"), 0); - backedgeCounter = new CIntField(type.getCIntegerField("_backedge_counter"), 0); - } bytecodeOffset = type.getSize(); - interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0); - interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0); - /* interpreterEntry = type.getAddressField("_interpreter_entry"); fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point"); @@ -80,18 +74,14 @@ // Fields private static AddressField constMethod; private static AddressField methodData; + private static AddressField methodCounters; private static CIntField methodSize; private static CIntField accessFlags; private static CIntField vtableIndex; - private static CIntField invocationCounter; - private static CIntField backedgeCounter; private static long bytecodeOffset; private static AddressField code; - private static CIntField interpreterThrowoutCountField; - private static CIntField interpreterInvocationCountField; - // constant method names - <init>, <clinit> // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable private static Symbol objectInitializerName; @@ -127,6 +117,10 @@ Address addr = methodData.getValue(getAddress()); return (MethodData) VMObjectFactory.newObject(MethodData.class, addr); } + public MethodCounters getMethodCounters() { + Address addr = methodCounters.getValue(getAddress()); + return (MethodCounters) VMObjectFactory.newObject(MethodCounters.class, addr); + } /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */ public long getMethodSize() { return methodSize.getValue(this); } public long getMaxStack() { return getConstMethod().getMaxStack(); } @@ -139,16 +133,10 @@ public long getCodeSize() { return getConstMethod().getCodeSize(); } public long getVtableIndex() { return vtableIndex.getValue(this); } public long getInvocationCounter() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(!VM.getVM().isCore(), "must not be used in core build"); - } - return invocationCounter.getValue(this); + return getMethodCounters().getInvocationCounter(); } public long getBackedgeCounter() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(!VM.getVM().isCore(), "must not be used in core build"); - } - return backedgeCounter.getValue(this); + return getMethodCounters().getBackedgeCounter(); } // get associated compiled native method, if available, else return null. @@ -369,10 +357,10 @@ } public int interpreterThrowoutCount() { - return (int) interpreterThrowoutCountField.getValue(this); + return getMethodCounters().interpreterThrowoutCount(); } public int interpreterInvocationCount() { - return (int) interpreterInvocationCountField.getValue(this); + return getMethodCounters().interpreterInvocationCount(); } }