diff --git a/gen/main.go b/gen/main.go index ec0b004..f82c120 100644 --- a/gen/main.go +++ b/gen/main.go @@ -210,11 +210,11 @@ func generate(typ *def.Class, opt options) string { } if opt.cpool { - res += emitReadI32() + res += emitReadU64() if opt.doNotKeepData { } else { - res += fmt.Sprintf("id := %s(v32_)\n", refName(typ)) + res += fmt.Sprintf("id := %s(v64_)\n", refName(typ)) } } diff --git a/parser/testdata/cpool-uint64-constant-index.jfr.gz b/parser/testdata/cpool-uint64-constant-index.jfr.gz new file mode 100644 index 0000000..c4523f7 Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index.jfr.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_0_block_contentions__count delay__nanoseconds_expected.txt.gz b/parser/testdata/cpool-uint64-constant-index_0_block_contentions__count delay__nanoseconds_expected.txt.gz new file mode 100644 index 0000000..392f3be Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_0_block_contentions__count delay__nanoseconds_expected.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_0_block_contentions__count delay__nanoseconds_expected_collapsed.txt.gz b/parser/testdata/cpool-uint64-constant-index_0_block_contentions__count delay__nanoseconds_expected_collapsed.txt.gz new file mode 100644 index 0000000..576490b Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_0_block_contentions__count delay__nanoseconds_expected_collapsed.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_1_memory_alloc_in_new_tlab_objects__count alloc_in_new_tlab_bytes__bytes_expected.txt.gz b/parser/testdata/cpool-uint64-constant-index_1_memory_alloc_in_new_tlab_objects__count alloc_in_new_tlab_bytes__bytes_expected.txt.gz new file mode 100644 index 0000000..9fa5049 Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_1_memory_alloc_in_new_tlab_objects__count alloc_in_new_tlab_bytes__bytes_expected.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_1_memory_alloc_in_new_tlab_objects__count alloc_in_new_tlab_bytes__bytes_expected_collapsed.txt.gz b/parser/testdata/cpool-uint64-constant-index_1_memory_alloc_in_new_tlab_objects__count alloc_in_new_tlab_bytes__bytes_expected_collapsed.txt.gz new file mode 100644 index 0000000..a5ef2d5 Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_1_memory_alloc_in_new_tlab_objects__count alloc_in_new_tlab_bytes__bytes_expected_collapsed.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_2_memory_alloc_outside_tlab_objects__count alloc_outside_tlab_bytes__bytes_expected.txt.gz b/parser/testdata/cpool-uint64-constant-index_2_memory_alloc_outside_tlab_objects__count alloc_outside_tlab_bytes__bytes_expected.txt.gz new file mode 100644 index 0000000..86c065a Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_2_memory_alloc_outside_tlab_objects__count alloc_outside_tlab_bytes__bytes_expected.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_2_memory_alloc_outside_tlab_objects__count alloc_outside_tlab_bytes__bytes_expected_collapsed.txt.gz b/parser/testdata/cpool-uint64-constant-index_2_memory_alloc_outside_tlab_objects__count alloc_outside_tlab_bytes__bytes_expected_collapsed.txt.gz new file mode 100644 index 0000000..ef765cc Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_2_memory_alloc_outside_tlab_objects__count alloc_outside_tlab_bytes__bytes_expected_collapsed.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_3_process_cpu_cpu__nanoseconds_expected.txt.gz b/parser/testdata/cpool-uint64-constant-index_3_process_cpu_cpu__nanoseconds_expected.txt.gz new file mode 100644 index 0000000..b545f51 Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_3_process_cpu_cpu__nanoseconds_expected.txt.gz differ diff --git a/parser/testdata/cpool-uint64-constant-index_3_process_cpu_cpu__nanoseconds_expected_collapsed.txt.gz b/parser/testdata/cpool-uint64-constant-index_3_process_cpu_cpu__nanoseconds_expected_collapsed.txt.gz new file mode 100644 index 0000000..7f35399 Binary files /dev/null and b/parser/testdata/cpool-uint64-constant-index_3_process_cpu_cpu__nanoseconds_expected_collapsed.txt.gz differ diff --git a/parser/types/class.go b/parser/types/class.go index 46b805c..72b2302 100644 --- a/parser/types/class.go +++ b/parser/types/class.go @@ -90,22 +90,24 @@ func (this *ClassList) Parse(data []byte, bind *BindClass, typeMap *def.TypeMap) this.IDMap = make(map[ClassRef]uint32, n) this.Class = make([]Class, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := ClassRef(v32_) + id := ClassRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/classloader.go b/parser/types/classloader.go index 7668e9e..0f5ee84 100644 --- a/parser/types/classloader.go +++ b/parser/types/classloader.go @@ -86,22 +86,24 @@ func (this *ClassLoaderList) Parse(data []byte, bind *BindClassLoader, typeMap * this.IDMap = make(map[ClassLoaderRef]uint32, n) this.ClassLoader = make([]ClassLoader, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := ClassLoaderRef(v32_) + id := ClassLoaderRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/frametype.go b/parser/types/frametype.go index 48dd699..9d1afda 100644 --- a/parser/types/frametype.go +++ b/parser/types/frametype.go @@ -78,22 +78,24 @@ func (this *FrameTypeList) Parse(data []byte, bind *BindFrameType, typeMap *def. this.IDMap = make(map[FrameTypeRef]uint32, n) this.FrameType = make([]FrameType, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := FrameTypeRef(v32_) + id := FrameTypeRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/loglevel.go b/parser/types/loglevel.go index 26ba820..3ba3149 100644 --- a/parser/types/loglevel.go +++ b/parser/types/loglevel.go @@ -78,22 +78,24 @@ func (this *LogLevelList) Parse(data []byte, bind *BindLogLevel, typeMap *def.Ty this.IDMap = make(map[LogLevelRef]uint32, n) this.LogLevel = make([]LogLevel, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := LogLevelRef(v32_) + id := LogLevelRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/method.go b/parser/types/method.go index 6fd375a..4706f62 100644 --- a/parser/types/method.go +++ b/parser/types/method.go @@ -97,22 +97,24 @@ func (this *MethodList) Parse(data []byte, bind *BindMethod, typeMap *def.TypeMa this.IDMap = NewIDMap[MethodRef](n) this.Method = make([]Method, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := MethodRef(v32_) + id := MethodRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/package.go b/parser/types/package.go index d061ede..b78b2ae 100644 --- a/parser/types/package.go +++ b/parser/types/package.go @@ -78,22 +78,24 @@ func (this *PackageList) Parse(data []byte, bind *BindPackage, typeMap *def.Type this.IDMap = make(map[PackageRef]uint32, n) this.Package = make([]Package, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := PackageRef(v32_) + id := PackageRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/skipper.go b/parser/types/skipper.go index 701fe1b..3651e3d 100644 --- a/parser/types/skipper.go +++ b/parser/types/skipper.go @@ -66,19 +66,21 @@ func (this *SkipConstantPoolList) Parse(data []byte, bind *BindSkipConstantPool, } n := int(v32_) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { diff --git a/parser/types/stacktrace.go b/parser/types/stacktrace.go index 38a0caf..3b7cd42 100644 --- a/parser/types/stacktrace.go +++ b/parser/types/stacktrace.go @@ -86,22 +86,24 @@ func (this *StackTraceList) Parse(data []byte, bind *BindStackTrace, bindStackFr this.IDMap = make(map[StackTraceRef]uint32, n) this.StackTrace = make([]StackTrace, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := StackTraceRef(v32_) + id := StackTraceRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/symbol.go b/parser/types/symbol.go index dbab2bd..cc69892 100644 --- a/parser/types/symbol.go +++ b/parser/types/symbol.go @@ -78,22 +78,24 @@ func (this *SymbolList) Parse(data []byte, bind *BindSymbol, typeMap *def.TypeMa this.IDMap = make(map[SymbolRef]uint32, n) this.Symbol = make([]Symbol, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := SymbolRef(v32_) + id := SymbolRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/thread.go b/parser/types/thread.go index 75a3220..b2ee7c0 100644 --- a/parser/types/thread.go +++ b/parser/types/thread.go @@ -100,22 +100,24 @@ func (this *ThreadList) Parse(data []byte, bind *BindThread, typeMap *def.TypeMa this.IDMap = make(map[ThreadRef]uint32, n) this.Thread = make([]Thread, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := ThreadRef(v32_) + id := ThreadRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/parser/types/threadstate.go b/parser/types/threadstate.go index 0c533e2..7d46519 100644 --- a/parser/types/threadstate.go +++ b/parser/types/threadstate.go @@ -78,22 +78,24 @@ func (this *ThreadStateList) Parse(data []byte, bind *BindThreadState, typeMap * this.IDMap = make(map[ThreadStateRef]uint32, n) this.ThreadState = make([]ThreadState, n) for i := 0; i < n; i++ { - v32_ = uint32(0) - for shift = uint(0); ; shift += 7 { - if shift >= 32 { - return 0, def.ErrIntOverflow - } + v64_ = 0 + for shift = uint(0); shift <= 56; shift += 7 { if pos >= l { return 0, io.ErrUnexpectedEOF } b_ = data[pos] pos++ - v32_ |= uint32(b_&0x7F) << shift - if b_ < 0x80 { + if shift == 56 { + v64_ |= uint64(b_&0xFF) << shift break + } else { + v64_ |= uint64(b_&0x7F) << shift + if b_ < 0x80 { + break + } } } - id := ThreadStateRef(v32_) + id := ThreadStateRef(v64_) for bindFieldIndex := 0; bindFieldIndex < len(bind.Fields); bindFieldIndex++ { bindArraySize := 1 if bind.Fields[bindFieldIndex].Field.Array { diff --git a/pprof/parser_test.go b/pprof/parser_test.go index 4607e4f..60d00e7 100644 --- a/pprof/parser_test.go +++ b/pprof/parser_test.go @@ -44,6 +44,7 @@ var testfiles = []testdata{ {"dump1", "dump1.labels.pb.gz", 1}, {"dump2", "dump2.labels.pb.gz", 4}, {"dd-trace-java", "", 4}, + {"cpool-uint64-constant-index", "", 4}, } type gprofile struct {