Skip to content

Commit 63d3e10

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents b968b89 + 6ae5e5b commit 63d3e10

File tree

5 files changed

+454
-196
lines changed

5 files changed

+454
-196
lines changed

src/hotspot/share/opto/indexSet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2020, 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
@@ -241,7 +241,7 @@ IndexSet::IndexSet (IndexSet *set) {
241241
set_block(i, &_empty_block);
242242
} else {
243243
BitBlock *new_block = alloc_block();
244-
memcpy(new_block->words(), block->words(), sizeof(uint32_t) * words_per_block);
244+
memcpy(new_block->words(), block->words(), sizeof(uintptr_t) * words_per_block);
245245
set_block(i, new_block);
246246
}
247247
}

src/hotspot/share/opto/indexSet.hpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2020, 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
@@ -60,9 +60,12 @@ class IndexSet : public ResourceObj {
6060
// membership of the element in the set.
6161

6262
// The lengths of the index bitfields
63-
enum { bit_index_length = 5,
64-
word_index_length = 3,
65-
block_index_length = 8 // not used
63+
enum {
64+
// Each block consists of 256 bits
65+
block_index_length = 8,
66+
// Split over 4 or 8 words depending on bitness
67+
word_index_length = block_index_length - LogBitsPerWord,
68+
bit_index_length = block_index_length - word_index_length,
6669
};
6770

6871
// Derived constants used for manipulating the index bitfields
@@ -88,7 +91,7 @@ class IndexSet : public ResourceObj {
8891
return mask_bits(element >> word_index_offset,word_index_mask);
8992
}
9093
static uint get_bit_index(uint element) {
91-
return mask_bits(element,bit_index_mask);
94+
return mask_bits(element, bit_index_mask);
9295
}
9396

9497
//------------------------------ class BitBlock ----------------------------
@@ -102,17 +105,17 @@ class IndexSet : public ResourceObj {
102105
// All of BitBlocks fields and methods are declared private. We limit
103106
// access to IndexSet and IndexSetIterator.
104107

105-
// A BitBlock is composed of some number of 32 bit words. When a BitBlock
108+
// A BitBlock is composed of some number of 32- or 64-bit words. When a BitBlock
106109
// is not in use by any IndexSet, it is stored on a free list. The next field
107-
// is used by IndexSet to mainting this free list.
110+
// is used by IndexSet to maintain this free list.
108111

109112
union {
110-
uint32_t _words[words_per_block];
113+
uintptr_t _words[words_per_block];
111114
BitBlock *_next;
112115
} _data;
113116

114117
// accessors
115-
uint32_t* words() { return _data._words; }
118+
uintptr_t* words() { return _data._words; }
116119
void set_next(BitBlock *next) { _data._next = next; }
117120
BitBlock *next() { return _data._next; }
118121

@@ -121,32 +124,32 @@ class IndexSet : public ResourceObj {
121124
// not assume that the block index has been masked out.
122125

123126
void clear() {
124-
memset(words(), 0, sizeof(uint32_t) * words_per_block);
127+
memset(words(), 0, sizeof(uintptr_t) * words_per_block);
125128
}
126129

127130
bool member(uint element) {
128131
uint word_index = IndexSet::get_word_index(element);
129-
uint bit_index = IndexSet::get_bit_index(element);
132+
uintptr_t bit_index = IndexSet::get_bit_index(element);
130133

131-
return ((words()[word_index] & (uint32_t)(0x1 << bit_index)) != 0);
134+
return ((words()[word_index] & (uintptr_t(1) << bit_index)) != 0);
132135
}
133136

134137
bool insert(uint element) {
135138
uint word_index = IndexSet::get_word_index(element);
136-
uint bit_index = IndexSet::get_bit_index(element);
139+
uintptr_t bit_index = IndexSet::get_bit_index(element);
137140

138-
uint32_t bit = (0x1 << bit_index);
139-
uint32_t before = words()[word_index];
141+
uintptr_t bit = uintptr_t(1) << bit_index;
142+
uintptr_t before = words()[word_index];
140143
words()[word_index] = before | bit;
141144
return ((before & bit) != 0);
142145
}
143146

144147
bool remove(uint element) {
145148
uint word_index = IndexSet::get_word_index(element);
146-
uint bit_index = IndexSet::get_bit_index(element);
149+
uintptr_t bit_index = IndexSet::get_bit_index(element);
147150

148-
uint32_t bit = (0x1 << bit_index);
149-
uint32_t before = words()[word_index];
151+
uintptr_t bit = uintptr_t(1) << bit_index;
152+
uintptr_t before = words()[word_index];
150153
words()[word_index] = before & ~bit;
151154
return ((before & bit) != 0);
152155
}
@@ -376,7 +379,7 @@ class IndexSetIterator {
376379

377380
private:
378381
// The current word we are inspecting
379-
uint32_t _current;
382+
uintptr_t _current;
380383

381384
// What element number are we currently on?
382385
uint _value;
@@ -391,7 +394,7 @@ class IndexSetIterator {
391394
uint _max_blocks;
392395

393396
// A pointer to the contents of the current block
394-
uint32_t *_words;
397+
uintptr_t* _words;
395398

396399
// A pointer to the blocks in our set
397400
IndexSet::BitBlock **_blocks;
@@ -447,7 +450,7 @@ class IndexSetIterator {
447450

448451
// Return the next element of the set.
449452
uint next_value() {
450-
uint current = _current;
453+
uintptr_t current = _current;
451454
assert(current != 0, "sanity");
452455
uint advance = count_trailing_zeros(current);
453456
assert(((current >> advance) & 0x1) == 1, "sanity");

0 commit comments

Comments
 (0)