10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #ifndef SHARE_GC_Z_ZBARRIER_HPP
25 #define SHARE_GC_Z_ZBARRIER_HPP
26
27 #include "gc/z/zAddress.hpp"
28 #include "memory/allStatic.hpp"
29 #include "memory/iterator.hpp"
30
31 // == Shift based load barrier ==
32 //
33 // The load barriers of ZGC check if a loaded value is safe to expose or not, and
34 // then shifts the pointer to remove metadata bits, such that it points to mapped
35 // memory.
36 //
37 // A pointer is safe to expose if it does not have any load-bad bits set in its
38 // metadata bits. In the C++ code and non-nmethod generated code, that is checked
39 // by testing the pointer value against a load-bad mask, checking that no bad bit
40 // is set, followed by a shift, removing the metadata bits if they were good.
41 // However, for nmethod code, the test + shift sequence is optimized in such
42 // a way that the shift both tests if the pointer is exposable or not, and removes
43 // the metadata bits, with the same instruction. This is a speculative optimization
44 // that assumes that the loaded pointer is frequently going to be load-good or null
45 // when checked. Therefore, the nmethod load barriers just apply the shift with the
46 // current "good" shift (which is patched with nmethod entry barriers for each GC
47 // phase). If the result of that shift was a raw null value, then the ZF flag is set.
48 // If the result is a good pointer, then the very last bit that was removed by the
49 // shift, must have been a 1, which would have set the CF flag. Therefore, the "above"
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #ifndef SHARE_GC_Z_ZBARRIER_HPP
25 #define SHARE_GC_Z_ZBARRIER_HPP
26
27 #include "gc/z/zAddress.hpp"
28 #include "memory/allStatic.hpp"
29 #include "memory/iterator.hpp"
30 #include "oops/inlineKlass.hpp"
31
32 // == Shift based load barrier ==
33 //
34 // The load barriers of ZGC check if a loaded value is safe to expose or not, and
35 // then shifts the pointer to remove metadata bits, such that it points to mapped
36 // memory.
37 //
38 // A pointer is safe to expose if it does not have any load-bad bits set in its
39 // metadata bits. In the C++ code and non-nmethod generated code, that is checked
40 // by testing the pointer value against a load-bad mask, checking that no bad bit
41 // is set, followed by a shift, removing the metadata bits if they were good.
42 // However, for nmethod code, the test + shift sequence is optimized in such
43 // a way that the shift both tests if the pointer is exposable or not, and removes
44 // the metadata bits, with the same instruction. This is a speculative optimization
45 // that assumes that the loaded pointer is frequently going to be load-good or null
46 // when checked. Therefore, the nmethod load barriers just apply the shift with the
47 // current "good" shift (which is patched with nmethod entry barriers for each GC
48 // phase). If the result of that shift was a raw null value, then the ZF flag is set.
49 // If the result is a good pointer, then the very last bit that was removed by the
50 // shift, must have been a 1, which would have set the CF flag. Therefore, the "above"
|