comparison src/share/vm/gc_implementation/g1/g1RemSet.hpp @ 4839:b4ebad3520bb

7133038: G1: Some small profile based optimizations Summary: Some minor profile based optimizations. Reduce the number of branches and branch mispredicts by removing some virtual calls, through closure specalization, and refactoring some conditional statements. Reviewed-by: brutisso, tonyp
author johnc
date Thu, 26 Jan 2012 14:14:55 -0800
parents 441e946dc1af
children d2a62e0f25eb
comparison
equal deleted inserted replaced
4838:a5244e07b761 4839:b4ebad3520bb
1 /* 1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
189 189
190 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 190 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
191 virtual void do_oop( oop* p) { do_oop_work(p); } 191 virtual void do_oop( oop* p) { do_oop_work(p); }
192 }; 192 };
193 193
194 class UpdateRSOrPushRefOopClosure: public OopClosure {
195 G1CollectedHeap* _g1;
196 G1RemSet* _g1_rem_set;
197 HeapRegion* _from;
198 OopsInHeapRegionClosure* _push_ref_cl;
199 bool _record_refs_into_cset;
200 int _worker_i;
201
202 template <class T> void do_oop_work(T* p);
203
204 public:
205 UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
206 G1RemSet* rs,
207 OopsInHeapRegionClosure* push_ref_cl,
208 bool record_refs_into_cset,
209 int worker_i = 0) :
210 _g1(g1h),
211 _g1_rem_set(rs),
212 _from(NULL),
213 _record_refs_into_cset(record_refs_into_cset),
214 _push_ref_cl(push_ref_cl),
215 _worker_i(worker_i) { }
216
217 void set_from(HeapRegion* from) {
218 assert(from != NULL, "from region must be non-NULL");
219 _from = from;
220 }
221
222 bool self_forwarded(oop obj) {
223 bool result = (obj->is_forwarded() && (obj->forwardee()== obj));
224 return result;
225 }
226
227 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
228 virtual void do_oop(oop* p) { do_oop_work(p); }
229
230 bool apply_to_weak_ref_discovered_field() { return true; }
231 };
232
233 194
234 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP 195 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_HPP