2015-09-04 09:47:35 +02:00
/*
2017-02-23 10:19:05 +01:00
* Copyright ( c ) 2015 , 2017 , Oracle and / or its affiliates . All rights reserved .
2015-09-04 09:47:35 +02:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
*
* This code is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License version 2 only , as
* published by the Free Software Foundation .
*
* This code is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License
* version 2 for more details ( a copy is included in the LICENSE file that
* accompanied this code ) .
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work ; if not , write to the Free Software Foundation ,
* Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 USA .
*
* Please contact Oracle , 500 Oracle Parkway , Redwood Shores , CA 94065 USA
* or visit www . oracle . com if you need additional information or have any
* questions .
*
*/
# include "precompiled.hpp"
# include "code/nmethod.hpp"
# include "gc/g1/g1CodeBlobClosure.hpp"
# include "gc/g1/g1CollectedHeap.inline.hpp"
# include "gc/g1/heapRegion.hpp"
# include "gc/g1/heapRegionRemSet.hpp"
2018-03-15 21:24:10 +01:00
# include "oops/access.inline.hpp"
# include "oops/compressedOops.inline.hpp"
2015-09-04 09:47:35 +02:00
# include "oops/oop.inline.hpp"
template < typename T >
void G1CodeBlobClosure : : HeapRegionGatheringOopClosure : : do_oop_work ( T * p ) {
_work - > do_oop ( p ) ;
2018-03-15 21:24:10 +01:00
T oop_or_narrowoop = RawAccess < > : : oop_load ( p ) ;
if ( ! CompressedOops : : is_null ( oop_or_narrowoop ) ) {
oop o = CompressedOops : : decode_not_null ( oop_or_narrowoop ) ;
2015-11-09 09:19:39 +01:00
HeapRegion * hr = _g1h - > heap_region_containing ( o ) ;
2017-02-23 10:19:05 +01:00
assert ( ! _g1h - > is_in_cset ( o ) | | hr - > rem_set ( ) - > strong_code_roots_list_contains ( _nm ) , " if o still in collection set then evacuation failed and nm must already be in the remset " ) ;
2015-09-04 09:47:35 +02:00
hr - > add_strong_code_root ( _nm ) ;
}
}
void G1CodeBlobClosure : : HeapRegionGatheringOopClosure : : do_oop ( oop * o ) {
do_oop_work ( o ) ;
}
void G1CodeBlobClosure : : HeapRegionGatheringOopClosure : : do_oop ( narrowOop * o ) {
do_oop_work ( o ) ;
}
void G1CodeBlobClosure : : do_code_blob ( CodeBlob * cb ) {
nmethod * nm = cb - > as_nmethod_or_null ( ) ;
if ( nm ! = NULL ) {
if ( ! nm - > test_set_oops_do_mark ( ) ) {
_oc . set_nm ( nm ) ;
nm - > oops_do ( & _oc ) ;
nm - > fix_oop_relocations ( ) ;
}
}
}