< prev index next >

src/share/vm/classfile/classLoaderData.cpp

Print this page
rev 8961 : [mq]: diff-shenandoah.patch


 225   objArrayHandle last_handle(THREAD, last);
 226 
 227   // Create a new dependency node with fields for (class_loader or mirror, next)
 228   objArrayOop deps = oopFactory::new_objectArray(2, CHECK);
 229   deps->obj_at_put(0, dependency());
 230 
 231   // Must handle over GC points
 232   objArrayHandle new_dependency(THREAD, deps);
 233 
 234   // Add the dependency under lock
 235   locked_add(last_handle, new_dependency, THREAD);
 236 }
 237 
 238 void ClassLoaderData::Dependencies::locked_add(objArrayHandle last_handle,
 239                                                objArrayHandle new_dependency,
 240                                                Thread* THREAD) {
 241 
 242   // Have to lock and put the new dependency on the end of the dependency
 243   // array so the card mark for CMS sees that this dependency is new.
 244   // Can probably do this lock free with some effort.
 245   ObjectLocker ol(Handle(THREAD, _list_head), THREAD);
 246 
 247   oop loader_or_mirror = new_dependency->obj_at(0);
 248 
 249   // Since the dependencies are only added, add to the end.
 250   objArrayOop end = last_handle();
 251   objArrayOop last = NULL;
 252   while (end != NULL) {
 253     last = end;
 254     // check again if another thread added it to the end.
 255     if (end->obj_at(0) == loader_or_mirror) {
 256       // Don't need to add it
 257       return;
 258     }
 259     end = (objArrayOop)end->obj_at(1);
 260   }
 261   assert (last != NULL, "dependencies should be initialized");
 262   // fill in the first element with the oop in new_dependency.
 263   if (last->obj_at(0) == NULL) {
 264     last->obj_at_put(0, new_dependency->obj_at(0));
 265   } else {




 225   objArrayHandle last_handle(THREAD, last);
 226 
 227   // Create a new dependency node with fields for (class_loader or mirror, next)
 228   objArrayOop deps = oopFactory::new_objectArray(2, CHECK);
 229   deps->obj_at_put(0, dependency());
 230 
 231   // Must handle over GC points
 232   objArrayHandle new_dependency(THREAD, deps);
 233 
 234   // Add the dependency under lock
 235   locked_add(last_handle, new_dependency, THREAD);
 236 }
 237 
 238 void ClassLoaderData::Dependencies::locked_add(objArrayHandle last_handle,
 239                                                objArrayHandle new_dependency,
 240                                                Thread* THREAD) {
 241 
 242   // Have to lock and put the new dependency on the end of the dependency
 243   // array so the card mark for CMS sees that this dependency is new.
 244   // Can probably do this lock free with some effort.
 245   ObjectLocker ol(Handle(THREAD, oopDesc::bs()->resolve_and_maybe_copy_oop(_list_head)), THREAD);
 246 
 247   oop loader_or_mirror = new_dependency->obj_at(0);
 248 
 249   // Since the dependencies are only added, add to the end.
 250   objArrayOop end = last_handle();
 251   objArrayOop last = NULL;
 252   while (end != NULL) {
 253     last = end;
 254     // check again if another thread added it to the end.
 255     if (end->obj_at(0) == loader_or_mirror) {
 256       // Don't need to add it
 257       return;
 258     }
 259     end = (objArrayOop)end->obj_at(1);
 260   }
 261   assert (last != NULL, "dependencies should be initialized");
 262   // fill in the first element with the oop in new_dependency.
 263   if (last->obj_at(0) == NULL) {
 264     last->obj_at_put(0, new_dependency->obj_at(0));
 265   } else {


< prev index next >