--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java Mon Apr 25 21:25:22 2016 +0300
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java Tue Apr 26 10:28:51 2016 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -19,46 +19,42 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
- *
*/
-
package sun.jvm.hotspot.code;
-import java.io.*;
-import java.util.*;
+import sun.jvm.hotspot.compiler.ImmutableOopMap;
+import sun.jvm.hotspot.compiler.ImmutableOopMapSet;
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObject;
+import sun.jvm.hotspot.types.AddressField;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+import sun.jvm.hotspot.utilities.Assert;
-import sun.jvm.hotspot.compiler.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.types.*;
-import sun.jvm.hotspot.utilities.*;
+import java.io.PrintStream;
+import java.util.Observable;
+import java.util.Observer;
public class CodeBlob extends VMObject {
- private static AddressField nameField;
+ private static AddressField nameField;
private static CIntegerField sizeField;
private static CIntegerField headerSizeField;
- private static CIntegerField relocationSizeField;
- private static CIntegerField contentOffsetField;
- private static CIntegerField codeOffsetField;
+ private static AddressField contentBeginField;
+ private static AddressField codeBeginField;
+ private static AddressField codeEndField;
+ private static AddressField dataEndField;
private static CIntegerField frameCompleteOffsetField;
private static CIntegerField dataOffsetField;
private static CIntegerField frameSizeField;
private static AddressField oopMapsField;
- // Only used by server compiler on x86; computed over in SA rather
- // than relying on computation in target VM
- private static final int NOT_YET_COMPUTED = -2;
- private static final int UNDEFINED = -1;
- private int linkOffset = NOT_YET_COMPUTED;
- private static int matcherInterpreterFramePointerReg;
+ public CodeBlob(Address addr) {
+ super(addr);
+ }
- static {
- VM.registerVMInitializedObserver(new Observer() {
- public void update(Observable o, Object data) {
- initialize(VM.getVM().getTypeDataBase());
- }
- });
- }
+ protected static int matcherInterpreterFramePointerReg;
private static void initialize(TypeDataBase db) {
Type type = db.lookupType("CodeBlob");
@@ -66,37 +62,99 @@
nameField = type.getAddressField("_name");
sizeField = type.getCIntegerField("_size");
headerSizeField = type.getCIntegerField("_header_size");
- relocationSizeField = type.getCIntegerField("_relocation_size");
frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
- contentOffsetField = type.getCIntegerField("_content_offset");
- codeOffsetField = type.getCIntegerField("_code_offset");
+ contentBeginField = type.getAddressField("_content_begin");
+ codeBeginField = type.getAddressField("_code_begin");
+ codeEndField = type.getAddressField("_code_end");
+ dataEndField = type.getAddressField("_data_end");
dataOffsetField = type.getCIntegerField("_data_offset");
frameSizeField = type.getCIntegerField("_frame_size");
oopMapsField = type.getAddressField("_oop_maps");
if (VM.getVM().isServerCompiler()) {
matcherInterpreterFramePointerReg =
- db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
+ db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
}
}
- public CodeBlob(Address addr) {
- super(addr);
+ static {
+ VM.registerVMInitializedObserver(new Observer() {
+ public void update(Observable o, Object data) {
+ initialize(VM.getVM().getTypeDataBase());
+ }
+ });
}
+ public Address headerBegin() { return getAddress(); }
+
+ public Address headerEnd() { return getAddress().addOffsetTo(getHeaderSize()); }
+
+ public Address contentBegin() { return contentBeginField.getValue(addr); }
+
+ public Address contentEnd() { return headerBegin().addOffsetTo(getDataOffset()); }
+
+ public Address codeBegin() { return codeBeginField.getValue(addr); }
+
+ public Address codeEnd() { return codeEndField.getValue(addr); }
+
+ public Address dataBegin() { return headerBegin().addOffsetTo(getDataOffset()); }
+
+ public Address dataEnd() { return dataEndField.getValue(addr); }
+
+ public long getFrameCompleteOffset() { return frameCompleteOffsetField.getValue(addr); }
+
+ public int getDataOffset() { return (int) dataOffsetField.getValue(addr); }
+
+ // Sizes
+ public int getSize() { return (int) sizeField.getValue(addr); }
+
+ public int getHeaderSize() { return (int) headerSizeField.getValue(addr); }
+
+ public long getFrameSizeWords() {
+ return (int) frameSizeField.getValue(addr);
+ }
+
+ public String getName() {
+ return getName();
+ }
+
+ /** OopMap for frame; can return null if none available */
+
+ public ImmutableOopMapSet getOopMaps() {
+ Address value = oopMapsField.getValue(addr);
+ if (value == null) {
+ return null;
+ }
+ return new ImmutableOopMapSet(value);
+ }
+
+
// Typing
public boolean isBufferBlob() { return false; }
+
+ public boolean isAOT() { return false; }
+
+ public boolean isCompiled() { return false; }
+
public boolean isNMethod() { return false; }
+
public boolean isRuntimeStub() { return false; }
+
public boolean isDeoptimizationStub() { return false; }
+
public boolean isUncommonTrapStub() { return false; }
+
public boolean isExceptionStub() { return false; }
+
public boolean isSafepointStub() { return false; }
+
public boolean isAdapterBlob() { return false; }
// Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod()
public boolean isJavaMethod() { return false; }
+
public boolean isNativeMethod() { return false; }
+
/** On-Stack Replacement method */
public boolean isOSRMethod() { return false; }
@@ -105,82 +163,33 @@
return null;
}
- // Boundaries
- public Address headerBegin() {
- return addr;
- }
-
- public Address headerEnd() {
- return addr.addOffsetTo(headerSizeField.getValue(addr));
- }
-
- // FIXME: add RelocInfo
- // public RelocInfo relocationBegin();
- // public RelocInfo relocationEnd();
-
- public Address contentBegin() {
- return headerBegin().addOffsetTo(contentOffsetField.getValue(addr));
- }
-
- public Address contentEnd() {
- return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
- }
-
- public Address codeBegin() {
- return headerBegin().addOffsetTo(contentOffsetField.getValue(addr));
- }
-
- public Address codeEnd() {
- return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
- }
-
- public Address dataBegin() {
- return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
- }
-
- public Address dataEnd() {
- return headerBegin().addOffsetTo(sizeField.getValue(addr));
- }
-
- // Offsets
- public int getRelocationOffset() { return (int) headerSizeField .getValue(addr); }
- public int getContentOffset() { return (int) contentOffsetField.getValue(addr); }
- public int getCodeOffset() { return (int) codeOffsetField .getValue(addr); }
- public int getDataOffset() { return (int) dataOffsetField .getValue(addr); }
-
- // Sizes
- public int getSize() { return (int) sizeField .getValue(addr); }
- public int getHeaderSize() { return (int) headerSizeField.getValue(addr); }
// FIXME: add getRelocationSize()
public int getContentSize() { return (int) contentEnd().minus(contentBegin()); }
+
public int getCodeSize() { return (int) codeEnd() .minus(codeBegin()); }
+
public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); }
// Containment
public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); }
+
// FIXME: add relocationContains
public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); }
+
public boolean codeContains(Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); }
+
public boolean dataContains(Address addr) { return dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); }
+
public boolean contains(Address addr) { return contentContains(addr); }
- public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); }
+
+ public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= getFrameCompleteOffset(); }
// Reclamation support (really only used by the nmethods, but in order to get asserts to work
// in the CodeCache they are defined virtual here)
public boolean isZombie() { return false; }
+
public boolean isLockedByVM() { return false; }
- /** OopMap for frame; can return null if none available */
- public ImmutableOopMapSet getOopMaps() {
- Address oopMapsAddr = oopMapsField.getValue(addr);
- if (oopMapsAddr == null) {
- return null;
- }
- return new ImmutableOopMapSet(oopMapsAddr);
- }
- // FIXME: not yet implementable
- // void set_oop_maps(ImmutableOopMapSet* p);
-
public ImmutableOopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) {
Address pc = returnAddress;
if (Assert.ASSERTS_ENABLED) {
@@ -189,25 +198,14 @@
return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging);
}
- // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); }
- // FIXME;
-
/** NOTE: this returns a size in BYTES in this system! */
public long getFrameSize() {
- return VM.getVM().getAddressSize() * frameSizeField.getValue(addr);
+ return VM.getVM().getAddressSize() * getFrameSizeWords();
}
// Returns true, if the next frame is responsible for GC'ing oops passed as arguments
public boolean callerMustGCArguments() { return false; }
- public String getName() {
- return CStringUtilities.getString(nameField.getValue(addr));
- }
-
- // FIXME: NOT FINISHED
-
- // FIXME: add more accessors
-
public void print() {
printOn(System.out);
}