-
Enhancement
-
Resolution: Fixed
-
P4
-
11, 17, 19, 20
-
b07
If you profile this test:
$ CONF=linux-x86_64-server-fastdebug make test TEST=java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
The hotpath is in the method below, where we have `ResourceMark` that is needed for possible call to `name_and_sig_as_C_string()`:
```
bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
...
#ifdef ASSERT
ResourceMark rm;
bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
if (class_access_flags.is_interface()) {
assert(is_nonv == is_static() || is_nonv == is_private(),
"nonvirtual unexpected for non-static, non-private: %s",
name_and_sig_as_C_string());
}
#endif
...
}
```
...but we end up doing `ResourceMark` destruction all the time on all paths, which includes `ZapResourceArea` code, which zaps the entirety of *untouched* `ResourceArea` chunk.
We can move `ResourceMark` so that it is only used when we are about to fire the error.
$ CONF=linux-x86_64-server-fastdebug make test TEST=java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java
The hotpath is in the method below, where we have `ResourceMark` that is needed for possible call to `name_and_sig_as_C_string()`:
```
bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
...
#ifdef ASSERT
ResourceMark rm;
bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
if (class_access_flags.is_interface()) {
assert(is_nonv == is_static() || is_nonv == is_private(),
"nonvirtual unexpected for non-static, non-private: %s",
name_and_sig_as_C_string());
}
#endif
...
}
```
...but we end up doing `ResourceMark` destruction all the time on all paths, which includes `ZapResourceArea` code, which zaps the entirety of *untouched* `ResourceArea` chunk.
We can move `ResourceMark` so that it is only used when we are about to fire the error.
- relates to
-
JDK-8290464 Optimize ResourceArea zapping on ResourceMark release
- Resolved