8307147: [x86] Dangling pointer warning for Assembler::_attributes
Reviewed-by: dholmes, aph
This commit is contained in:
parent
64ac9a05e8
commit
3599448ad8
src/hotspot
cpu/x86
share/utilities
@ -217,6 +217,17 @@ void Assembler::init_attributes(void) {
|
||||
_attributes = nullptr;
|
||||
}
|
||||
|
||||
void Assembler::set_attributes(InstructionAttr* attributes) {
|
||||
// Record the assembler in the attributes, so the attributes destructor can
|
||||
// clear the assembler's attributes, cleaning up the otherwise dangling
|
||||
// pointer. gcc13 has a false positive warning, because it doesn't tie that
|
||||
// cleanup to the assignment of _attributes here.
|
||||
attributes->set_current_assembler(this);
|
||||
PRAGMA_DIAG_PUSH
|
||||
PRAGMA_DANGLING_POINTER_IGNORED
|
||||
_attributes = attributes;
|
||||
PRAGMA_DIAG_POP
|
||||
}
|
||||
|
||||
void Assembler::membar(Membar_mask_bits order_constraint) {
|
||||
// We only have to handle StoreLoad
|
||||
@ -11442,7 +11453,6 @@ void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix
|
||||
vex_x = adr.index_needs_rex();
|
||||
}
|
||||
set_attributes(attributes);
|
||||
attributes->set_current_assembler(this);
|
||||
|
||||
// For EVEX instruction (which is not marked as pure EVEX instruction) check and see if this instruction
|
||||
// is allowed in legacy mode and has resources which will fit in it.
|
||||
@ -11489,7 +11499,6 @@ int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexS
|
||||
bool vex_b = (src_enc & 8) == 8;
|
||||
bool vex_x = false;
|
||||
set_attributes(attributes);
|
||||
attributes->set_current_assembler(this);
|
||||
|
||||
// For EVEX instruction (which is not marked as pure EVEX instruction) check and see if this instruction
|
||||
// is allowed in legacy mode and has resources which will fit in it.
|
||||
|
@ -678,7 +678,8 @@ private:
|
||||
bool _legacy_mode_vlbw;
|
||||
NOT_LP64(bool _is_managed;)
|
||||
|
||||
class InstructionAttr *_attributes;
|
||||
InstructionAttr *_attributes;
|
||||
void set_attributes(InstructionAttr* attributes);
|
||||
|
||||
// 64bit prefixes
|
||||
void prefix(Register reg);
|
||||
@ -917,8 +918,6 @@ private:
|
||||
// belong in macro assembler but there is no need for both varieties to exist
|
||||
|
||||
void init_attributes(void);
|
||||
|
||||
void set_attributes(InstructionAttr *attributes) { _attributes = attributes; }
|
||||
void clear_attributes(void) { _attributes = nullptr; }
|
||||
|
||||
void set_managed(void) { NOT_LP64(_is_managed = true;) }
|
||||
@ -2892,7 +2891,6 @@ public:
|
||||
if (_current_assembler != nullptr) {
|
||||
_current_assembler->clear_attributes();
|
||||
}
|
||||
_current_assembler = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,6 +55,10 @@
|
||||
#define ATTRIBUTE_SCANF(fmt, vargs)
|
||||
#endif
|
||||
|
||||
#ifndef PRAGMA_DANGLING_POINTER_IGNORED
|
||||
#define PRAGMA_DANGLING_POINTER_IGNORED
|
||||
#endif
|
||||
|
||||
#ifndef PRAGMA_FORMAT_NONLITERAL_IGNORED
|
||||
#define PRAGMA_FORMAT_NONLITERAL_IGNORED
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,6 +39,11 @@
|
||||
#define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push")
|
||||
#define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop")
|
||||
|
||||
// Disable -Wdangling-pointer which is introduced in GCC 12.
|
||||
#if !defined(__clang_major__) && (__GNUC__ >= 12)
|
||||
#define PRAGMA_DANGLING_POINTER_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wdangling-pointer")
|
||||
#endif
|
||||
|
||||
#define PRAGMA_FORMAT_NONLITERAL_IGNORED \
|
||||
PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \
|
||||
PRAGMA_DISABLE_GCC_WARNING("-Wformat-security")
|
||||
|
Loading…
x
Reference in New Issue
Block a user