Skip to content

Commit

Permalink
Add ObjectAllocationSample type support
Browse files Browse the repository at this point in the history
  • Loading branch information
sivachandran committed Sep 9, 2024
1 parent c7aebd8 commit a057255
Show file tree
Hide file tree
Showing 32 changed files with 530 additions and 13 deletions.
1 change: 1 addition & 0 deletions gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func main() {
write("types/execution_sample.go", generate(&Type_jdk_ExecutionSample, options{}))
write("types/allocation_in_new_tlab.go", generate(&Type_jdk_ObjectAllocationInNewTLAB, options{}))
write("types/allocation_outside_tlab.go", generate(&Type_jdk_ObjectAllocationOutsideTLAB, options{}))
write("types/allocation_sample.go", generate(&Type_jdk_ObjectAllocationSample, options{}))
write("types/monitor_enter.go", generate(&Type_jdk_JavaMonitorEnter, options{}))
write("types/thread_park.go", generate(&Type_jdk_ThreadPark, options{}))
write("types/live_object.go", generate(&Type_profiler_LiveObject, options{}))
Expand Down
15 changes: 15 additions & 0 deletions gen/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (
T_MEMORY_ADDRESS = def.TypeID(206)
T_UNSIGNED = def.TypeID(207)
T_PERCENTAGE = def.TypeID(208)
T_ALLOC_SAMPLE = def.TypeID(209)
)

func TypeID2Sym(id def.TypeID) string {
Expand Down Expand Up @@ -110,6 +111,8 @@ func TypeID2Sym(id def.TypeID) string {
return "T_ALLOC_IN_NEW_TLAB"
case T_ALLOC_OUTSIDE_TLAB:
return "T_ALLOC_OUTSIDE_TLAB"
case T_ALLOC_SAMPLE:
return "T_ALLOC_SAMPLE"
case T_MONITOR_ENTER:
return "T_MONITOR_ENTER"
case T_THREAD_PARK:
Expand Down Expand Up @@ -330,6 +333,18 @@ var Type_jdk_ObjectAllocationOutsideTLAB = def.Class{
{Name: "contextId", Type: T_LONG, ConstantPool: false},
},
}
var Type_jdk_ObjectAllocationSample = def.Class{
Name: "jdk.ObjectAllocationSample",
ID: T_ALLOC_SAMPLE,
Fields: []def.Field{
{Name: "startTime", Type: T_LONG, ConstantPool: false},
{Name: "eventThread", Type: T_THREAD, ConstantPool: true},
{Name: "stackTrace", Type: T_STACK_TRACE, ConstantPool: true},
{Name: "objectClass", Type: T_CLASS, ConstantPool: true},
{Name: "weight", Type: T_LONG, ConstantPool: false},
{Name: "contextId", Type: T_LONG, ConstantPool: false},
},
}
var Type_jdk_JavaMonitorEnter = def.Class{
Name: "jdk.JavaMonitorEnter",
ID: T_MONITOR_ENTER,
Expand Down
21 changes: 20 additions & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Parser struct {
ExecutionSample types2.ExecutionSample
ObjectAllocationInNewTLAB types2.ObjectAllocationInNewTLAB
ObjectAllocationOutsideTLAB types2.ObjectAllocationOutsideTLAB
ObjectAllocationSample types2.ObjectAllocationSample
JavaMonitorEnter types2.JavaMonitorEnter
ThreadPark types2.ThreadPark
LiveObject types2.LiveObject
Expand Down Expand Up @@ -80,6 +81,7 @@ type Parser struct {

bindAllocInNewTLAB *types2.BindObjectAllocationInNewTLAB
bindAllocOutsideTLAB *types2.BindObjectAllocationOutsideTLAB
bindAllocSample *types2.BindObjectAllocationSample
bindMonitorEnter *types2.BindJavaMonitorEnter
bindThreadPark *types2.BindThreadPark
bindLiveObject *types2.BindLiveObject
Expand Down Expand Up @@ -153,6 +155,16 @@ func (p *Parser) ParseEvent() (def.TypeID, error) {
}
p.pos = pp + int(size)
return ttyp, nil
case p.TypeMap.T_ALLOC_SAMPLE:
if p.bindAllocSample == nil {
p.pos = pp + int(size) // skip
}
_, err := p.ObjectAllocationSample.Parse(p.buf[p.pos:], p.bindAllocSample, &p.TypeMap)
if err != nil {
return 0, err
}
p.pos = pp + int(size)
return ttyp, nil
case p.TypeMap.T_LIVE_OBJECT:
if p.bindLiveObject == nil {
p.pos = pp + int(size) // skip
Expand Down Expand Up @@ -513,6 +525,7 @@ func (p *Parser) checkTypes() error {
typeExecutionSample := p.TypeMap.NameMap["jdk.ExecutionSample"]
typeAllocInNewTLAB := p.TypeMap.NameMap["jdk.ObjectAllocationInNewTLAB"]
typeALlocOutsideTLAB := p.TypeMap.NameMap["jdk.ObjectAllocationOutsideTLAB"]
typeAllocSample := p.TypeMap.NameMap["jdk.ObjectAllocationSample"]
typeMonitorEnter := p.TypeMap.NameMap["jdk.JavaMonitorEnter"]
typeThreadPark := p.TypeMap.NameMap["jdk.ThreadPark"]
typeLiveObject := p.TypeMap.NameMap["profiler.LiveObject"]
Expand Down Expand Up @@ -541,7 +554,13 @@ func (p *Parser) checkTypes() error {
p.TypeMap.T_ALLOC_OUTSIDE_TLAB = -1
p.bindAllocOutsideTLAB = nil
}

if typeAllocSample != nil {
p.TypeMap.T_ALLOC_SAMPLE = typeAllocSample.ID
p.bindAllocSample = types2.NewBindObjectAllocationSample(typeAllocSample, &p.TypeMap)
} else {
p.TypeMap.T_ALLOC_SAMPLE = -1
p.bindAllocSample = nil
}
if typeMonitorEnter != nil {
p.TypeMap.T_MONITOR_ENTER = typeMonitorEnter.ID
p.bindMonitorEnter = types2.NewBindJavaMonitorEnter(typeMonitorEnter, &p.TypeMap)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added parser/testdata/object-allocation-sample.jfr.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit a057255

Please sign in to comment.