---
Problem:
Hotspot headers override C++ language keywords as follows:
"""
#define bool jint
#define true v_true
#define false v_false
"""
---
Symptoms:
1) If headers are not included in a very specific order, subtle data
alignment problems occur, which are extremely expensive to debug.
2) The same subtle alignment problems occur whenever we link with code
that is not part of the Sun's Hotspot distribution and does not
include Sun headers before other headers.
3) Including standard C++ headers is impossible. Some of these
standard headers (which we have no way of modifying) assume that bool is
a different type from integer and cause compiler errors if we attempt to
redefine bool.
4) Writing assembly that accesses runtime data structures is confusing
and bug prone. One would think they are accessing a 'bool' field, but
it is in fact an 'int' with a different size.
5) Overriding the language keywords eliminates the type checking
normally enforced by the language and defeats the purpose of using the
keywords in the first place.
6) Optimizing the size of C++ data structures by using the language's
smaller built-in bool type is now impossible.
7) Sun's serviceability agent requires unwanted specialization.
Fixing the original problem would be easier than maintaining this
specialization.
---
Fix:
Although the fix for this problem requires modifying one of the main
headers, it would be extremely easy to implement.
Remove all macro definitions that override a language keyword.
Remove the specialization in the Serviceability Agent.
Some fields are declared 'bool' in the C++ runtime and accessed by
assembly code generated by Hotspot. For example,
JavaThread::_is_throwing_null_ptr_exception. For each such field,
select one of the following two fixes:
1) Modify the field declaration giving it a type with a specific
width, such as 'jint'.
OR
2) For each instruction emitted by the Hotspot assembler instruction
that accesses the field, replace the hard-coded field size with an
field size that is computed by the native C++ compiler. Computing the
field size can be done trivially with the following logic:
"""
if( sizeof(bool)==1 )
return T_BYTE;
else {
assert( sizeof(bool) == 4, "bad size for C++ bool type" );
return T_INT;
}
""
Problem:
Hotspot headers override C++ language keywords as follows:
"""
#define bool jint
#define true v_true
#define false v_false
"""
---
Symptoms:
1) If headers are not included in a very specific order, subtle data
alignment problems occur, which are extremely expensive to debug.
2) The same subtle alignment problems occur whenever we link with code
that is not part of the Sun's Hotspot distribution and does not
include Sun headers before other headers.
3) Including standard C++ headers is impossible. Some of these
standard headers (which we have no way of modifying) assume that bool is
a different type from integer and cause compiler errors if we attempt to
redefine bool.
4) Writing assembly that accesses runtime data structures is confusing
and bug prone. One would think they are accessing a 'bool' field, but
it is in fact an 'int' with a different size.
5) Overriding the language keywords eliminates the type checking
normally enforced by the language and defeats the purpose of using the
keywords in the first place.
6) Optimizing the size of C++ data structures by using the language's
smaller built-in bool type is now impossible.
7) Sun's serviceability agent requires unwanted specialization.
Fixing the original problem would be easier than maintaining this
specialization.
---
Fix:
Although the fix for this problem requires modifying one of the main
headers, it would be extremely easy to implement.
Remove all macro definitions that override a language keyword.
Remove the specialization in the Serviceability Agent.
Some fields are declared 'bool' in the C++ runtime and accessed by
assembly code generated by Hotspot. For example,
JavaThread::_is_throwing_null_ptr_exception. For each such field,
select one of the following two fixes:
1) Modify the field declaration giving it a type with a specific
width, such as 'jint'.
OR
2) For each instruction emitted by the Hotspot assembler instruction
that accesses the field, replace the hard-coded field size with an
field size that is computed by the native C++ compiler. Computing the
field size can be done trivially with the following logic:
"""
if( sizeof(bool)==1 )
return T_BYTE;
else {
assert( sizeof(bool) == 4, "bad size for C++ bool type" );
return T_INT;
}
""
- relates to
-
JDK-6296159 SA: Handling C++ bool fields
-
- Resolved
-
-
JDK-6288120 Need portable bool accessors for C1/C2
-
- Closed
-