Skip to content

Commit

Permalink
update jvm.hotspot.code.CodeBlob class
Browse files Browse the repository at this point in the history
  • Loading branch information
bulasevich committed Nov 18, 2024
1 parent c401e77 commit 0c70bd2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@
nonstatic_field(CodeBlob, _frame_size, int) \
nonstatic_field(CodeBlob, _oop_maps, ImmutableOopMapSet*) \
nonstatic_field(CodeBlob, _caller_must_gc_arguments, bool) \
nonstatic_field(CodeBlob, _mutable_data, address) \
nonstatic_field(CodeBlob, _mutable_data_size, int) \
\
nonstatic_field(DeoptimizationBlob, _unpack_offset, int) \
\
Expand Down Expand Up @@ -592,8 +594,6 @@
nonstatic_field(nmethod, _osr_entry_point, address) \
nonstatic_field(nmethod, _immutable_data, address) \
nonstatic_field(nmethod, _immutable_data_size, int) \
nonstatic_field(nmethod, _mutable_data, address) \
nonstatic_field(nmethod, _mutable_data_size, int) \
nonstatic_field(nmethod, _compile_id, int) \
nonstatic_field(nmethod, _comp_level, CompLevel) \
volatile_nonstatic_field(nmethod, _exception_cache, ExceptionCache*) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public class CodeBlob extends VMObject {
private static CIntField headerSizeField;
private static CIntegerField contentOffsetField;
private static CIntegerField codeOffsetField;
private static CIntegerField codeEndOffsetField;
private static CIntField frameCompleteOffsetField;
private static CIntegerField dataOffsetField;
private static CIntegerField frameSizeField;
private static AddressField oopMapsField;
private static AddressField mutableDataField;
private static CIntegerField mutableDataSizeField;

public CodeBlob(Address addr) {
super(addr);
Expand All @@ -68,9 +70,11 @@ private static void initialize(TypeDataBase db) {
contentOffsetField = type.getCIntegerField("_content_offset");
codeOffsetField = type.getCIntegerField("_code_offset");
frameCompleteOffsetField = new CIntField(type.getCIntegerField("_frame_complete_offset"), 0);
dataOffsetField = type.getCIntegerField("_data_offset");
codeEndOffsetField = type.getCIntegerField("_code_end_offset");
frameSizeField = type.getCIntegerField("_frame_size");
oopMapsField = type.getAddressField("_oop_maps");
mutableDataField = type.getAddressField("_mutable_data");
mutableDataSizeField = type.getCIntegerField("_mutable_data_size");

if (VM.getVM().isServerCompiler()) {
matcherInterpreterFramePointerReg =
Expand All @@ -92,15 +96,16 @@ public void update(Observable o, Object data) {

public Address contentBegin() { return headerBegin().addOffsetTo(getContentOffset()); }

public Address contentEnd() { return headerBegin().addOffsetTo(getDataOffset()); }
public Address contentEnd() { return headerBegin().addOffsetTo(getCodeEndOffset()); }

public Address codeBegin() { return headerBegin().addOffsetTo(getCodeOffset()); }

public Address codeEnd() { return headerBegin().addOffsetTo(getDataOffset()); }
public Address codeEnd() { return headerBegin().addOffsetTo(getCodeEndOffset()); }

public Address dataBegin() { return headerBegin().addOffsetTo(getDataOffset()); }
public Address dataBegin() { return mutableDataField.getValue(addr); }

public Address dataEnd() { return headerBegin().addOffsetTo(getSize()); }
public Address dataEnd() { return (dataBegin() == null) ? dataBegin() :
dataBegin().addOffsetTo(mutableDataSizeField.getValue(addr)); }

// Offsets
public int getContentOffset() { return (int) contentOffsetField.getValue(addr); }
Expand All @@ -109,7 +114,7 @@ public void update(Observable o, Object data) {

public long getFrameCompleteOffset() { return frameCompleteOffsetField.getValue(addr); }

public int getDataOffset() { return (int) dataOffsetField.getValue(addr); }
public int getCodeEndOffset() { return (int) codeEndOffsetField.getValue(addr); }

// Sizes
public int getSize() { return (int) sizeField.getValue(addr); }
Expand Down Expand Up @@ -176,14 +181,15 @@ public NMethod asNMethodOrNull() {
public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); }

// Containment
public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); }
public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && codeEnd() .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 dataContains(Address addr) { return (dataBegin() == null) ? false :
dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); }

public boolean contains(Address addr) { return contentContains(addr); }

Expand Down

0 comments on commit 0c70bd2

Please sign in to comment.