|
| 1 | +/* |
| 2 | + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 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 | + |
| 25 | +#ifndef SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP |
| 26 | +#define SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP |
| 27 | + |
| 28 | +#include "gc/parallel/psScavenge.hpp" |
| 29 | +#include "gc/shared/stringdedup/stringDedup.hpp" |
| 30 | +#include "memory/allStatic.hpp" |
| 31 | +#include "oops/oopsHierarchy.hpp" |
| 32 | + |
| 33 | +class psStringDedup : AllStatic { |
| 34 | +public: |
| 35 | + static bool is_candidate_from_mark(oop java_string) { |
| 36 | + // Candidate if string is being evacuated from young to old but has not |
| 37 | + // reached the deduplication age threshold, i.e. has not previously been a |
| 38 | + // candidate during its life in the young generation. |
| 39 | + return PSScavenge::is_obj_in_young(java_string) && |
| 40 | + StringDedup::is_below_threshold_age(java_string->age()); |
| 41 | + } |
| 42 | + |
| 43 | + static bool is_candidate_from_evacuation(oop obj, |
| 44 | + bool obj_is_tenured) { |
| 45 | + return obj_is_tenured ? |
| 46 | + StringDedup::is_below_threshold_age(obj->age()) : |
| 47 | + StringDedup::is_threshold_age(obj->age()); |
| 48 | + } |
| 49 | +}; |
| 50 | +#endif // SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP |
0 commit comments