Skip to content

Commit 2bbcd33

Browse files
Cleanups and Shenandoah-specific changes.
1 parent da0d4fe commit 2bbcd33

File tree

15 files changed

+170
-122
lines changed

15 files changed

+170
-122
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ In some code parts, `Unimplemented()` serves as a placeholder for GC-specific fu
8181
- `src/hotspot/share/gc/shared/hSpaceCounters.cpp`
8282
- `src/hotspot/share/gc/shared/ageTable.cpp`
8383

84-
Besides that, the length of 0 for `GCThreadLocalData` in `src/hotspot/share/gc/shared/gcThreadLocalData.hpp` is a placeholder as well.
84+
Besides that, there are a few places where values are hardcoded at the moment.
85+
Those need to be replaced with the correct GC-specific values:
86+
- the length of `GCThreadLocalData` in `src/hotspot/share/gc/shared/gcThreadLocalData.hpp` is hardcoded to 0
87+
- `log_of_heap_region_grain_bytes` in `src/hotspot/svm/svmToGC.cpp` is hardcoded to 20
8588

8689
## Build
8790

src/hotspot/SubMakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ DEBUG_LEVEL_FILE_SUFFIX.debug := -debug
101101
DEBUG_LEVEL_FILE_SUFFIX := $(DEBUG_LEVEL_FILE_SUFFIX.$(DEBUG_LEVEL))
102102

103103
BUILD_DIR := $(BUILD_ROOT)/$(DEBUG_LEVEL)-$(COMPRESSED_REFERENCES_SUFFIX)$(TARGET_EXT)
104-
TARGET_FILE := $(BUILD_ROOT)/libsvmgc$(DEBUG_LEVEL_FILE_SUFFIX)-$(COMPRESSED_REFERENCES_SUFFIX)$(TARGET_EXT)
104+
TARGET_FILE := $(BUILD_ROOT)/libshenandoahgc$(DEBUG_LEVEL_FILE_SUFFIX)-$(COMPRESSED_REFERENCES_SUFFIX)$(TARGET_EXT)
105105

106106
CPP_FILES_TO_EXCLUDE.amd64 := aarch64
107107
CPP_FILES_TO_EXCLUDE.aarch64 := x86

src/hotspot/share/runtime/mutex.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ void Mutex::lock_contended(Thread* self) {
119119
if (thread->has_status_vm()) {
120120
while (true) {
121121
// do a transition to native thread status so that we can safely block below without preventing a safepoint
122-
SVMGlobalData::_transition_vm_to_native(heap_base, thread);
122+
SVMGlobalData::_transition_vm_to_native(thread);
123123

124124
_lock.lock();
125125

126126
// do a transition back to VM state so that this thread can be sure that no safepoints are happening concurrently
127127
assert(thread->has_status_native_or_safepoint(), "must be");
128-
if (SVMGlobalData::_try_fast_transition_native_to_vm(heap_base, thread)) {
128+
if (SVMGlobalData::_try_fast_transition_native_to_vm(thread)) {
129129
// The fast path succeeded, so we have the lock and we are back in VM state.
130130
assert(thread->has_status_vm(), "must be");
131131
break;
@@ -134,7 +134,7 @@ void Mutex::lock_contended(Thread* self) {
134134
// try to lock it again after the safepoint ends. Otherwise, we could end up with a deadlock between this thread
135135
// and the VM thread.
136136
_lock.unlock();
137-
SVMGlobalData::_slow_transition_native_to_vm(heap_base, thread);
137+
SVMGlobalData::_slow_transition_native_to_vm(thread);
138138
assert(thread->has_status_vm(), "must be");
139139
}
140140
}

src/hotspot/share/runtime/thread.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#endif
4646
#ifdef SVM
4747
#include "svmIsolateThread.hpp"
48-
#include "exports/sharedGCStructs.hpp"
48+
#include "exports/sharedGCStructs.h"
4949
#endif // SVM
5050

5151

src/hotspot/svm/exports/sharedGCStructs.hpp renamed to src/hotspot/svm/exports/sharedGCStructs.h

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,18 @@
2323
* questions.
2424
*/
2525

26-
#ifndef SVM_SHARED_STRUCTS_HPP
27-
#define SVM_SHARED_STRUCTS_HPP
26+
#ifndef SVM_SHARED_GC_STRUCTS_HPP
27+
#define SVM_SHARED_GC_STRUCTS_HPP
2828

2929
#include <sys/types.h>
30-
// forward declarations
3130

3231
#ifdef __cplusplus
33-
namespace svm_gc {
32+
namespace svm_gc {
3433
#endif
3534

35+
// forward declarations
3636
typedef struct CodeInfo CodeInfo;
3737

38-
struct HeapOptions {
39-
size_t max_heap_size;
40-
size_t heap_address_space_size;
41-
size_t physical_memory_size;
42-
};
43-
44-
struct GCConstants {
45-
void* card_table_address;
46-
void* gc_total_collections_address;
47-
int tlab_top_offset;
48-
int tlab_end_offset;
49-
int card_table_shift;
50-
int java_thread_size;
51-
int vm_operation_data_size;
52-
int vm_operation_wrapper_data_size;
53-
char dirty_card_value;
54-
};
55-
56-
struct GCInternalState {
57-
unsigned int total_collections;
58-
unsigned int full_collections;
59-
60-
void* card_table_start;
61-
size_t card_table_size;
62-
63-
void* block_offset_table_start;
64-
size_t block_offset_table_size;
65-
};
66-
6738
// data structures for frames that are currently on the stack
6839
struct StackFrame {
6940
u_char *stack_pointer;
@@ -92,9 +63,8 @@ struct CodeInfosPerThread {
9263
struct CodeInfos *threads[0]; // variable-sized array
9364
};
9465

95-
9666
#ifdef __cplusplus
97-
} // namespace svm_gc
67+
} // namespace svm_gc
9868
#endif
9969

100-
#endif // SVM_SHARED_STRUCTS_HPP
70+
#endif // SVM_SHARED_GC_STRUCTS_HPP
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#ifndef SVM_SHENANDOAH_GC_STRUCTS_H
27+
#define SVM_SHENANDOAH_GC_STRUCTS_H
28+
29+
#include <sys/types.h>
30+
31+
#ifdef __cplusplus
32+
namespace svm_gc {
33+
#endif
34+
35+
struct ShenandoahHeapOptions {
36+
size_t max_heap_size;
37+
size_t heap_address_space_size;
38+
size_t physical_memory_size;
39+
};
40+
41+
struct ShenandoahInitState {
42+
void* card_table_address;
43+
int tlab_top_offset;
44+
int tlab_end_offset;
45+
int card_table_shift;
46+
int log_of_heap_region_grain_bytes;
47+
int java_thread_size;
48+
int vm_operation_data_size;
49+
int vm_operation_wrapper_data_size;
50+
char dirty_card_value;
51+
};
52+
53+
struct ShenandoahRegionBoundaries {
54+
u_char *bottom;
55+
u_char *top;
56+
};
57+
58+
struct ShenandoahRegionInfo {
59+
u_char *bottom;
60+
u_char *top;
61+
u_char *end;
62+
char region_type;
63+
};
64+
65+
struct ShenandoahInternalState {
66+
unsigned int total_collections;
67+
unsigned int full_collections;
68+
69+
void* card_table_start;
70+
size_t card_table_size;
71+
};
72+
73+
#ifdef __cplusplus
74+
} // namespace svm_gc
75+
#endif
76+
77+
#endif // SVM_SHENANDOAH_GC_STRUCTS_H
78+

src/hotspot/svm/share/oops/stackChunkOop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "runtime/smallRegisterMap.inline.hpp"
3838
#include "runtime/stackChunkFrameStream.inline.hpp"
3939
#ifdef SVM
40-
#include "exports/sharedGCStructs.hpp"
40+
#include "exports/sharedGCStructs.h"
4141
#include "svmCodeReferenceMapDecoder.hpp"
4242
#endif // SVM
4343

src/hotspot/svm/share/runtime/vmOperation.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace svm_gc {
6262

6363
class VM_Operation;
6464

65-
// The layout of this class must match the NativeVMOperationData on the Java-side.
65+
// The layout of this class must match the NativeGCVMOperationData on the Java-side.
6666
// It must always be allocated as a part of a VM_Operation (i.e., it must never exist on its own)
6767
// and it must not contain a vtable. The blackbox fields are only accessed on native-image side.
6868
class VM_OperationData {

src/hotspot/svm/share/runtime/vmThread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void VMThread::execute(VM_Operation* op) {
104104

105105
assert(isolate_thread == nullptr || isolate_thread->has_status_vm(), "isolate thread must be in VM state");
106106
if (isolate_thread != nullptr && !current_thread->is_VM_thread()) {
107-
SVMGlobalData::_transition_vm_to_native(heap_base, isolate_thread);
107+
SVMGlobalData::_transition_vm_to_native(isolate_thread);
108108
}
109109

110110
VM_OperationData *op_data = op->data();
@@ -131,7 +131,7 @@ void VMThread::execute(VM_Operation* op) {
131131

132132
if (isolate_thread != nullptr) {
133133
// The fast transition is always possible because no one can request a safepoint while the VM operation thread is blocked.
134-
bool in_vm = SVMGlobalData::_try_fast_transition_native_to_vm(heap_base, isolate_thread);
134+
bool in_vm = SVMGlobalData::_try_fast_transition_native_to_vm(isolate_thread);
135135
assert(in_vm && isolate_thread->has_status_vm(), "must be back in VM state");
136136
}
137137

@@ -141,7 +141,7 @@ void VMThread::execute(VM_Operation* op) {
141141
} else {
142142
if (isolate_thread != nullptr) {
143143
// The fast transition is always possible because no one can request a safepoint while the VM operation thread is blocked.
144-
bool in_vm = SVMGlobalData::_try_fast_transition_native_to_vm(heap_base, isolate_thread);
144+
bool in_vm = SVMGlobalData::_try_fast_transition_native_to_vm(isolate_thread);
145145
assert(in_vm && isolate_thread->has_status_vm(), "must be back in VM state");
146146
}
147147

src/hotspot/svm/svmCodeReferenceMapDecoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "code/compressedStream.hpp"
2727
#include "compiler/oopMap.hpp"
28-
#include "exports/sharedGCStructs.hpp"
28+
#include "exports/sharedGCStructs.h"
2929
#include "svmCodeReferenceMapDecoder.hpp"
3030

3131
/**

0 commit comments

Comments
 (0)