From fbbe1436bb33148cf280147e286ac162f882a50c Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 22 May 2026 15:58:32 -0700 Subject: [PATCH] 8382377: [lworld] The JvmtiHeapwalkObject(obj) set incorrect layout --- src/hotspot/share/prims/jvmtiTagMapTable.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiTagMapTable.hpp b/src/hotspot/share/prims/jvmtiTagMapTable.hpp index e1b5a2e9f55..0e10ed32be1 100644 --- a/src/hotspot/share/prims/jvmtiTagMapTable.hpp +++ b/src/hotspot/share/prims/jvmtiTagMapTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 @@ -35,22 +35,27 @@ class JvmtiEnv; // Describes an object which can be tagged during heap walk operation. // - generic heap object: _obj: oop, offset == 0, _inline_klass == nullptr; -// - value heap object: _obj: oop, offset == 0, _inline_klass == _obj.klass(); // - flat value object: _obj: holder object, offset == offset in the holder, _inline_klass == klass of the flattened object; +// - value heap object: _obj: oop, offset == 0, _inline_klass == _obj.klass(); class JvmtiHeapwalkObject { oop _obj; // for flattened value object this is holder object int _offset; // == 0 for heap objects InlineKlass* _inline_klass; // for value object, nullptr otherwise LayoutKind _layout_kind; // layout kind in holder object, used only for flat->heap conversion - static InlineKlass* inline_klass_or_null(oop obj) { - Klass* k = obj->klass(); - return k->is_inline_klass() ? InlineKlass::cast(k) : nullptr; - } public: JvmtiHeapwalkObject(): _obj(nullptr), _offset(0), _inline_klass(nullptr), _layout_kind(LayoutKind::UNKNOWN) {} - JvmtiHeapwalkObject(oop obj): _obj(obj), _offset(0), _inline_klass(inline_klass_or_null(obj)), _layout_kind(LayoutKind::REFERENCE) {} JvmtiHeapwalkObject(oop obj, int offset, InlineKlass* ik, LayoutKind lk): _obj(obj), _offset(offset), _inline_klass(ik), _layout_kind(lk) {} + JvmtiHeapwalkObject(oop obj): _obj(obj), _offset(0) { + Klass* k = obj->klass(); + if (k->is_inline_klass()) { + _inline_klass = InlineKlass::cast(k); + _layout_kind = LayoutKind::BUFFERED; + } else { + _inline_klass = nullptr; + _layout_kind = LayoutKind::REFERENCE; + } + } inline bool is_empty() const { return _obj == nullptr; } inline bool is_value() const { return _inline_klass != nullptr; }