Skip to content

Commit bdf6e63

Browse files
committedJan 15, 2025
8347431: Update ObjectMonitor comments
Reviewed-by: dholmes, pchilanomate
1 parent 764d70b commit bdf6e63

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed
 

‎src/hotspot/share/runtime/objectMonitor.hpp

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -84,12 +84,9 @@ class ObjectWaiter : public CHeapObj<mtThread> {
8484
//
8585
// ObjectMonitor Layout Overview/Highlights/Restrictions:
8686
//
87-
// - The _metadata field must be at offset 0 because the displaced header
88-
// from markWord is stored there. We do not want markWord.hpp to include
89-
// ObjectMonitor.hpp to avoid exposing ObjectMonitor everywhere. This
90-
// means that ObjectMonitor cannot inherit from any other class nor can
91-
// it use any virtual member functions. This restriction is critical to
92-
// the proper functioning of the VM.
87+
// - For performance reasons we ensure the _metadata field is located at offset 0,
88+
// which in turn means that ObjectMonitor can't inherit from any other class nor use
89+
// any virtual member functions.
9390
// - The _metadata and _owner fields should be separated by enough space
9491
// to avoid false sharing due to parallel access by different threads.
9592
// This is an advisory recommendation.
@@ -117,11 +114,7 @@ class ObjectWaiter : public CHeapObj<mtThread> {
117114
//
118115
// - See TEST_VM(ObjectMonitor, sanity) gtest for how critical restrictions are
119116
// enforced.
120-
// - Adjacent ObjectMonitors should be separated by enough space to avoid
121-
// false sharing. This is handled by the ObjectMonitor allocation code
122-
// in synchronizer.cpp. Also see TEST_VM(SynchronizerTest, sanity) gtest.
123117
//
124-
// Futures notes:
125118
// - Separating _owner from the <remaining_fields> by enough space to
126119
// avoid false sharing might be profitable. Given that the CAS in
127120
// monitorenter will invalidate the line underlying _owner. We want
@@ -132,7 +125,7 @@ class ObjectWaiter : public CHeapObj<mtThread> {
132125
// would make them immune to CAS-based invalidation from the _owner
133126
// field.
134127
//
135-
// - The _recursions field should be of type int, or int32_t but not
128+
// - TODO: The _recursions field should be of type int, or int32_t but not
136129
// intptr_t. There's no reason to use a 64-bit type for this field
137130
// in a 64-bit JVM.
138131

@@ -151,7 +144,7 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
151144
// ParkEvent of unblocker thread.
152145
static ParkEvent* _vthread_unparker_ParkEvent;
153146

154-
// The sync code expects the metadata field to be at offset zero (0).
147+
// Because of frequent access, the the metadata field is at offset zero (0).
155148
// Enforced by the assert() in metadata_addr().
156149
// * LM_LIGHTWEIGHT with UseObjectMonitorTable:
157150
// Contains the _object's hashCode.

0 commit comments

Comments
 (0)
Please sign in to comment.