|
1 | 1 | /* |
2 | | - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -86,12 +86,22 @@ class G1CardSetInlinePtr : public StackObj { |
86 | 86 |
|
87 | 87 | uint find(uint const card_idx, uint const bits_per_card, uint start_at, uint num_cards); |
88 | 88 |
|
| 89 | + static ContainerPtr empty_card_set() { |
| 90 | + // Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114573 |
| 91 | + // gcc issues -Wzero-as-null-pointer-constant here, even though |
| 92 | + // ContainerInlinePtr is a *non-literal* constant 0. We cast a non-const |
| 93 | + // copy, and let the compiler's constant propagation optimize into |
| 94 | + // equivalent code. |
| 95 | + static_assert(G1CardSet::ContainerInlinePtr == 0, "unnecessary warning dodge"); |
| 96 | + auto value = G1CardSet::ContainerInlinePtr; |
| 97 | + return reinterpret_cast<ContainerPtr>(value); |
| 98 | + } |
| 99 | + |
89 | 100 | public: |
90 | | - G1CardSetInlinePtr() : _value_addr(nullptr), _value((ContainerPtr)G1CardSet::ContainerInlinePtr) { } |
| 101 | + G1CardSetInlinePtr() : G1CardSetInlinePtr(empty_card_set()) {} |
91 | 102 |
|
92 | | - G1CardSetInlinePtr(ContainerPtr value) : _value_addr(nullptr), _value(value) { |
93 | | - assert(G1CardSet::container_type(_value) == G1CardSet::ContainerInlinePtr, "Value " PTR_FORMAT " is not a valid G1CardSetInlinePtr.", p2i(_value)); |
94 | | - } |
| 103 | + explicit G1CardSetInlinePtr(ContainerPtr value) : |
| 104 | + G1CardSetInlinePtr(nullptr, value) {} |
95 | 105 |
|
96 | 106 | G1CardSetInlinePtr(ContainerPtr volatile* value_addr, ContainerPtr value) : _value_addr(value_addr), _value(value) { |
97 | 107 | assert(G1CardSet::container_type(_value) == G1CardSet::ContainerInlinePtr, "Value " PTR_FORMAT " is not a valid G1CardSetInlinePtr.", p2i(_value)); |
|
0 commit comments