Skip to content

Commit dd49879

Browse files
author
Kim Barrett
committed
8340524: Remove NarrowPtrStruct
Reviewed-by: shade, jwaters
1 parent ab06a87 commit dd49879

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

src/hotspot/share/oops/compressedOops.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2024, 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
@@ -35,8 +35,10 @@
3535
#include "runtime/globals.hpp"
3636

3737
// For UseCompressedOops.
38-
NarrowPtrStruct CompressedOops::_narrow_oop = { nullptr, 0, true };
39-
MemRegion CompressedOops::_heap_address_range;
38+
address CompressedOops::_base = nullptr;
39+
int CompressedOops::_shift = 0;
40+
bool CompressedOops::_use_implicit_null_checks = true;
41+
MemRegion CompressedOops::_heap_address_range;
4042

4143
// Choose the heap base address and oop encoding mode
4244
// when compressed oops are used:
@@ -88,16 +90,16 @@ void CompressedOops::initialize(const ReservedHeapSpace& heap_space) {
8890

8991
void CompressedOops::set_base(address base) {
9092
assert(UseCompressedOops, "no compressed oops?");
91-
_narrow_oop._base = base;
93+
_base = base;
9294
}
9395

9496
void CompressedOops::set_shift(int shift) {
95-
_narrow_oop._shift = shift;
97+
_shift = shift;
9698
}
9799

98100
void CompressedOops::set_use_implicit_null_checks(bool use) {
99101
assert(UseCompressedOops, "no compressed ptrs?");
100-
_narrow_oop._use_implicit_null_checks = use;
102+
_use_implicit_null_checks = use;
101103
}
102104

103105
bool CompressedOops::is_in(void* addr) {
@@ -148,14 +150,14 @@ bool CompressedOops::is_disjoint_heap_base_address(address addr) {
148150

149151
// Check for disjoint base compressed oops.
150152
bool CompressedOops::base_disjoint() {
151-
return _narrow_oop._base != nullptr && is_disjoint_heap_base_address(_narrow_oop._base);
153+
return _base != nullptr && is_disjoint_heap_base_address(_base);
152154
}
153155

154156
// Check for real heapbased compressed oops.
155157
// We must subtract the base as the bits overlap.
156158
// If we negate above function, we also get unscaled and zerobased.
157159
bool CompressedOops::base_overlaps() {
158-
return _narrow_oop._base != nullptr && !is_disjoint_heap_base_address(_narrow_oop._base);
160+
return _base != nullptr && !is_disjoint_heap_base_address(_base);
159161
}
160162

161163
void CompressedOops::print_mode(outputStream* st) {

src/hotspot/share/oops/compressedOops.hpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,18 @@
3434
class outputStream;
3535
class ReservedHeapSpace;
3636

37-
struct NarrowPtrStruct {
37+
class CompressedOops : public AllStatic {
38+
friend class VMStructs;
39+
3840
// Base address for oop-within-java-object materialization.
3941
// null if using wide oops or zero based narrow oops.
40-
address _base;
42+
static address _base;
4143
// Number of shift bits for encoding/decoding narrow ptrs.
42-
// 0 if using wide ptrs or zero based unscaled narrow ptrs,
44+
// 0 if using wide oops or zero based unscaled narrow oops,
4345
// LogMinObjAlignmentInBytes otherwise.
44-
int _shift;
45-
// Generate code with implicit null checks for narrow ptrs.
46-
bool _use_implicit_null_checks;
47-
};
48-
49-
class CompressedOops : public AllStatic {
50-
friend class VMStructs;
51-
52-
// For UseCompressedOops.
53-
static NarrowPtrStruct _narrow_oop;
46+
static int _shift;
47+
// Generate code with implicit null checks for narrow oops.
48+
static bool _use_implicit_null_checks;
5449

5550
// The address range of the heap
5651
static MemRegion _heap_address_range;
@@ -86,13 +81,13 @@ class CompressedOops : public AllStatic {
8681
static void set_shift(int shift);
8782
static void set_use_implicit_null_checks(bool use);
8883

89-
static address base() { return _narrow_oop._base; }
90-
static address base_addr() { return (address)&_narrow_oop._base; }
84+
static address base() { return _base; }
85+
static address base_addr() { return (address)&_base; }
9186
static address begin() { return (address)_heap_address_range.start(); }
9287
static address end() { return (address)_heap_address_range.end(); }
9388
static bool is_base(void* addr) { return (base() == (address)addr); }
94-
static int shift() { return _narrow_oop._shift; }
95-
static bool use_implicit_null_checks() { return _narrow_oop._use_implicit_null_checks; }
89+
static int shift() { return _shift; }
90+
static bool use_implicit_null_checks() { return _use_implicit_null_checks; }
9691

9792
static bool is_in(void* addr);
9893
static bool is_in(MemRegion mr);

src/hotspot/share/runtime/vmStructs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@
373373
/* CompressedOops */ \
374374
/******************/ \
375375
\
376-
static_field(CompressedOops, _narrow_oop._base, address) \
377-
static_field(CompressedOops, _narrow_oop._shift, int) \
378-
static_field(CompressedOops, _narrow_oop._use_implicit_null_checks, bool) \
376+
static_field(CompressedOops, _base, address) \
377+
static_field(CompressedOops, _shift, int) \
378+
static_field(CompressedOops, _use_implicit_null_checks, bool) \
379379
\
380380
/***************************/ \
381381
/* CompressedKlassPointers */ \

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CompressedOops.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, 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
@@ -64,8 +64,8 @@ private static boolean typeExists(TypeDataBase db, String type) {
6464
private static synchronized void initialize(TypeDataBase db) {
6565
Type type = db.lookupType("CompressedOops");
6666

67-
baseField = type.getAddressField("_narrow_oop._base");
68-
shiftField = type.getCIntegerField("_narrow_oop._shift");
67+
baseField = type.getAddressField("_base");
68+
shiftField = type.getCIntegerField("_shift");
6969
}
7070

7171
public CompressedOops() {

0 commit comments

Comments
 (0)