java.lang.Object
com.yasuenag.ffmasm.CodeSegment
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class to register calling close() as Cleaner action.static final record
Holder for method information. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Default size of code segment. -
Constructor Summary
ConstructorsConstructorDescriptionAllocate memory for this code segment with default size (4096 bytes).CodeSegment
(long size) Allocate memory for this code segment. -
Method Summary
Modifier and TypeMethodDescriptionaddMethodInfo
(String name, long address, int size) Add method info.void
Align the tail to 16 bytesvoid
close()
Release memory for this code segment.void
Disable perf map dumpervoid
enablePerfMapDumper
(Path path) Enable perf map dumper at shutdown hook for dumping all of functions in this CodeSegment.getAddr()
Get MemorySegment which relates to this segment.long
getTail()
Get the tail of this segment.Get slice of this segment from the tail.void
incTail
(long size) Increment the tail with given size.
-
Field Details
-
DEFAULT_CODE_SEGMENT_SIZE
public static final long DEFAULT_CODE_SEGMENT_SIZEDefault size of code segment.- See Also:
-
-
Constructor Details
-
CodeSegment
Allocate memory for this code segment with default size (4096 bytes).- Throws:
PlatformException
- thrown when native function call failed.UnsupportedPlatformException
- thrown when the platform is not supported.
-
CodeSegment
Allocate memory for this code segment.- Parameters:
size
- size of code segment.- Throws:
PlatformException
- thrown when native function call failed.UnsupportedPlatformException
- thrown when the platform is not supported.
-
-
Method Details
-
close
Release memory for this code segment.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
getTailOfMemorySegment
Get slice of this segment from the tail.- Returns:
- Slice of this segment from the tail.
-
alignTo16Bytes
public void alignTo16Bytes()Align the tail to 16 bytes -
getTail
public long getTail()Get the tail of this segment.- Returns:
- the tail of this segment.
-
incTail
public void incTail(long size) Increment the tail with given size.- Parameters:
size
- value to increment
-
getAddr
Get MemorySegment which relates to this segment.- Returns:
- MemorySegment of this segment.
-
addMethodInfo
Add method info. It will be dumped to perf map as related method of this CodeSegment.- Parameters:
name
- Method nameaddress
- Address of the methodsize
- Size of the method (machine code)- Returns:
- MethodInfo of the method info.
- Throws:
IllegalArgumentException
- if the address is out of range from this CodeSegment.
-
enablePerfMapDumper
Enable perf map dumper at shutdown hook for dumping all of functions in this CodeSegment.- Parameters:
path
- Path to dumpfile
-
disablePerfMapDumper
public void disablePerfMapDumper()Disable perf map dumper- Throws:
IllegalStateException
- if enablePerfMapDumper() is not called before.
-