Exemplo n.º 1
0
void JvmtiBreakpoint::each_method_version_do(method_action meth_act) {
  ((methodOopDesc*)_method->*meth_act)(_bci);

  // add/remove breakpoint to/from versions of the method that
  // are EMCP. Directly or transitively obsolete methods are
  // not saved in the PreviousVersionInfo.
  Thread *thread = Thread::current();
  instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder());
  Symbol* m_name = _method->name();
  Symbol* m_signature = _method->signature();

  {
    ResourceMark rm(thread);
    // PreviousVersionInfo objects returned via PreviousVersionWalker
    // contain a GrowableArray of handles. We have to clean up the
    // GrowableArray _after_ the PreviousVersionWalker destructor
    // has destroyed the handles.
    {
      // search previous versions if they exist
      PreviousVersionWalker pvw((instanceKlass *)ikh()->klass_part());
      for (PreviousVersionInfo * pv_info = pvw.next_previous_version();
           pv_info != NULL; pv_info = pvw.next_previous_version()) {
        GrowableArray<methodHandle>* methods =
          pv_info->prev_EMCP_method_handles();

        if (methods == NULL) {
          // We have run into a PreviousVersion generation where
          // all methods were made obsolete during that generation's
          // RedefineClasses() operation. At the time of that
          // operation, all EMCP methods were flushed so we don't
          // have to go back any further.
          //
          // A NULL methods array is different than an empty methods
          // array. We cannot infer any optimizations about older
          // generations from an empty methods array for the current
          // generation.
          break;
        }

        for (int i = methods->length() - 1; i >= 0; i--) {
          methodHandle method = methods->at(i);
          if (method->name() == m_name && method->signature() == m_signature) {
            RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)",
              meth_act == &methodOopDesc::set_breakpoint ? "sett" : "clear",
              method->name()->as_C_string(),
              method->signature()->as_C_string()));
            assert(!method->is_obsolete(), "only EMCP methods here");

            ((methodOopDesc*)method()->*meth_act)(_bci);
            break;
          }
        }
      }
    } // pvw is cleaned up
  } // rm is cleaned up
}
Exemplo n.º 2
0
void JvmtiBreakpoint::each_method_version_do(method_action meth_act) {
  ((Method*)_method->*meth_act)(_bci);

  // add/remove breakpoint to/from versions of the method that
  // are EMCP. Directly or transitively obsolete methods are
  // not saved in the PreviousVersionNodes.
  Thread *thread = Thread::current();
  instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder());
  Symbol* m_name = _method->name();
  Symbol* m_signature = _method->signature();

  // search previous versions if they exist
  PreviousVersionWalker pvw(thread, (InstanceKlass *)ikh());
  for (PreviousVersionNode * pv_node = pvw.next_previous_version();
       pv_node != NULL; pv_node = pvw.next_previous_version()) {
    GrowableArray<Method*>* methods = pv_node->prev_EMCP_methods();

    if (methods == NULL) {
      // We have run into a PreviousVersion generation where
      // all methods were made obsolete during that generation's
      // RedefineClasses() operation. At the time of that
      // operation, all EMCP methods were flushed so we don't
      // have to go back any further.
      //
      // A NULL methods array is different than an empty methods
      // array. We cannot infer any optimizations about older
      // generations from an empty methods array for the current
      // generation.
      break;
    }

    for (int i = methods->length() - 1; i >= 0; i--) {
      Method* method = methods->at(i);
      // obsolete methods that are running are not deleted from
      // previous version array, but they are skipped here.
      if (!method->is_obsolete() &&
          method->name() == m_name &&
          method->signature() == m_signature) {
        RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)",
          meth_act == &Method::set_breakpoint ? "sett" : "clear",
          method->name()->as_C_string(),
          method->signature()->as_C_string()));

        (method->*meth_act)(_bci);
        break;
      }
    }
  }
}
void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) {
  assert(obj->is_klass(), "must be klass");
  instanceKlass* ik = instanceKlass::cast(klassOop(obj));
  klassKlass::oop_print_on(obj, st);

  st->print(BULLET"instance size:     %d", ik->size_helper());                        st->cr();
  st->print(BULLET"klass size:        %d", ik->object_size());                        st->cr();
  st->print(BULLET"access:            "); ik->access_flags().print_on(st);            st->cr();
  st->print(BULLET"state:             "); st->print_cr(state_names[ik->_init_state]);
  st->print(BULLET"name:              "); ik->name()->print_value_on(st);             st->cr();
  st->print(BULLET"super:             "); ik->super()->print_value_on(st);            st->cr();
  st->print(BULLET"sub:               ");
  Klass* sub = ik->subklass();
  int n;
  for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) {
    if (n < MaxSubklassPrintSize) {
      sub->as_klassOop()->print_value_on(st);
      st->print("   ");
    }
  }
  if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize);
  st->cr();

  if (ik->is_interface()) {
    st->print_cr(BULLET"nof implementors:  %d", ik->nof_implementors());
    if (ik->nof_implementors() == 1) {
      st->print_cr(BULLET"implementor:    ");
      st->print("   ");
      ik->implementor()->print_value_on(st);
      st->cr();
    }
  }

  st->print(BULLET"arrays:            "); ik->array_klasses()->print_value_on(st);     st->cr();
  st->print(BULLET"methods:           "); ik->methods()->print_value_on(st);           st->cr();
  if (Verbose) {
    objArrayOop methods = ik->methods();
    for(int i = 0; i < methods->length(); i++) {
      tty->print("%d : ", i); methods->obj_at(i)->print_value(); tty->cr();
    }
  }
  st->print(BULLET"method ordering:   "); ik->method_ordering()->print_value_on(st);       st->cr();
  st->print(BULLET"local interfaces:  "); ik->local_interfaces()->print_value_on(st);      st->cr();
  st->print(BULLET"trans. interfaces: "); ik->transitive_interfaces()->print_value_on(st); st->cr();
  st->print(BULLET"constants:         "); ik->constants()->print_value_on(st);         st->cr();
  st->print(BULLET"class loader:      "); ik->class_loader()->print_value_on(st);      st->cr();
  st->print(BULLET"protection domain: "); ik->protection_domain()->print_value_on(st); st->cr();
  if (ik->host_klass() != NULL) {
    st->print(BULLET"host class:        "); ik->host_klass()->print_value_on(st);        st->cr();
  }
  st->print(BULLET"signers:           "); ik->signers()->print_value_on(st);           st->cr();
  if (ik->source_file_name() != NULL) {
    st->print(BULLET"source file:       ");
    ik->source_file_name()->print_value_on(st);
    st->cr();
  }
  if (ik->source_debug_extension() != NULL) {
    st->print(BULLET"source debug extension:       ");
    st->print_cr("%s", ik->source_debug_extension());
    st->cr();
  }

  {
    ResourceMark rm;
    // PreviousVersionInfo objects returned via PreviousVersionWalker
    // contain a GrowableArray of handles. We have to clean up the
    // GrowableArray _after_ the PreviousVersionWalker destructor
    // has destroyed the handles.
    {
      bool have_pv = false;
      PreviousVersionWalker pvw(ik);
      for (PreviousVersionInfo * pv_info = pvw.next_previous_version();
           pv_info != NULL; pv_info = pvw.next_previous_version()) {
        if (!have_pv)
          st->print(BULLET"previous version:  ");
        have_pv = true;
        pv_info->prev_constant_pool_handle()()->print_value_on(st);
      }
      if (have_pv)  st->cr();
    } // pvw is cleaned up
  } // rm is cleaned up

  if (ik->generic_signature() != NULL) {
    st->print(BULLET"generic signature: ");
    ik->generic_signature()->print_value_on(st);
    st->cr();
  }
  st->print(BULLET"inner classes:     "); ik->inner_classes()->print_value_on(st);     st->cr();
  st->print(BULLET"java mirror:       "); ik->java_mirror()->print_value_on(st);       st->cr();
  st->print(BULLET"vtable length      %d  (start addr: " INTPTR_FORMAT ")", ik->vtable_length(), ik->start_of_vtable());  st->cr();
  st->print(BULLET"itable length      %d (start addr: " INTPTR_FORMAT ")", ik->itable_length(), ik->start_of_itable()); st->cr();
  st->print_cr(BULLET"---- static fields (%d words):", ik->static_field_size());
  FieldPrinter print_static_field(st);
  ik->do_local_static_fields(&print_static_field);
  st->print_cr(BULLET"---- non-static fields (%d words):", ik->nonstatic_field_size());
  FieldPrinter print_nonstatic_field(st);
  ik->do_nonstatic_fields(&print_nonstatic_field);

  st->print(BULLET"non-static oop maps: ");
  OopMapBlock* map     = ik->start_of_nonstatic_oop_maps();
  OopMapBlock* end_map = map + ik->nonstatic_oop_map_count();
  while (map < end_map) {
    st->print("%d-%d ", map->offset(), map->offset() + heapOopSize*(map->count() - 1));
    map++;
  }
  st->cr();
}
vector< vector<double> > calc_delta_slim(Graph& G, v_size_t diam)
{


  //Variable initializations
  const vector<double> zero_dist(diam+2,0);
  double maxDelta = 0;


  // for(tie(vit,vite)=vertices(G); vit!=vite; vit++)
  //   {
  //     Vert v =*vit;
  //     vert_vec.push_back(v);
  //   }


  vector< vector<double> > delta(diam,zero_dist);



#pragma omp parallel shared(delta,maxDelta,diam)
  {

    //Variable assignements,
    //Notation: puv = "Path indices on side uv"
    //           uv = "Vertices on side uv"
    //vertex iterators
    graph_traits<Graph>::vertex_iterator vit, vite;
  
    //Property maps
    property_map<Graph,vertex_index_t>::type index = get(vertex_index,G);

    vector<Vert> vert_vec;
    vector< vector<v_size_t> > d;

    for(tie(vit,vite) = vertices(G); vit!= vite; ++vit)
      {
	Vert v = *vit;
	vert_vec.push_back(v);
	d.push_back(G[v].distances);
      }

    const size_t size = vert_vec.size();

    vector<unsigned int> dummy;
    vector< vector<unsigned int> > puv(size,dummy);
    vector< vector<unsigned int> > puw(size,dummy);
    vector< vector<unsigned int> > pvw(size,dummy);

    vector<path_node> node_stack;
    node_stack.reserve(CHUNKSIZE);

    for(size_t i=0;i<size;i++)
      {
    	puv[i].reserve(CHUNKSIZE);
    	puw[i].reserve(CHUNKSIZE);
    	pvw[i].reserve(CHUNKSIZE);
	
      }
    
    vector<unsigned int> delta_v;
    vector<unsigned int> k1;
    vector<unsigned int> k2;

    delta_v.reserve(diam+1);
    k1.reserve(CHUNKSIZE);
    k2.reserve(CHUNKSIZE);

    vector<Vert> uv,uw,vw;
    vector<bool> on_path;
    queue<Vert> Q;

    on_path.reserve(size);
    uv.reserve(diam+1);
    uw.reserve(diam+1);
    vw.reserve(diam+1);

    vector<vector<Vert> > vPredecessors;
    vector<vector<Vert> > uPredecessors;

    vector< vector<double> > delta_loc(diam,zero_dist);
    double maxDelta_loc = 0;

    double uvDelta, uwDelta, vwDelta, currDelta;
    unsigned int nuv, nuw, nvw;
    
    //distribute outer for loops
#pragma omp for schedule(dynamic,1)
    for(size_t i=0;i<size;i++)
      {
	const Vert u = vert_vec[i];
	const v_size_t ui = index[u];
	
#pragma omp single nowait
	{
	  cerr<<"Vertex: "<<u<<"\n";
	}

	uPredecessors = G[u].predecessors;
	//cerr<<"Vertex: "<<u<<"\n";

	for(size_t j=i+1;j<size;++j)
	  {
	    const Vert v = vert_vec[j];
	    const v_size_t vi = index[v];
	    const v_size_t uvd = d[ui][vi];
	  
	    vPredecessors = G[v].predecessors;
	    form_path(u,v,G,uPredecessors, uv, Q, on_path, index);

	    // if(j==(size-1))
	    //   {
	    // 	for(size_t k=0;k<size;k++)
	    // 	  {
	    // 	    puv[k].clear();
	    // 	    puw[k].clear();
	    // 	    pvw[k].clear();
		    
	    // 	    uv_meta[k][1] = 0;
	    // 	    uw_meta[k][1] = 0;
	    // 	    vw_meta[k][1] = 0;
	    // 	  }
	    //   }
	    
	    for(size_t k=j+1;k<size;++k)
	      {
		const Vert w = vert_vec[k];
		const v_size_t wi = index[w];

		const v_size_t uwd = d[ui][wi];
		const v_size_t vwd = d[vi][wi];

		v_size_t maxSide = uvd;

		if(uwd>maxSide)
		  maxSide = uwd;

		if(vwd>maxSide)
		  maxSide = vwd;
		
		  form_path(u,w,G,uPredecessors,uw,Q,on_path,index);
		  form_path(v,w,G,vPredecessors,vw,Q,on_path,index);
		
		//**Code commented out for BFS (less memory, MUCH slower version)**
		//BFS_two_target(u,v,w,G,uv,uw,predecessors);
	      
		// vector< vector<unsigned int> > puv;
		// vector< vector<unsigned int> > puw;
		// vector< vector<unsigned int> > pvw;


		  //#pragma omp parallel sections num_threads(3)
		    //{
		  //#pragma omp section
		  nuv = index_paths(u,v,index,size,uPredecessors,puv,node_stack);
		  //#pragma omp section		
		  nuw = index_paths(u,w,index,size,uPredecessors,puw,node_stack);
		  //#pragma omp section		
		  nvw = index_paths(v,w,index,size,vPredecessors,pvw,node_stack);	      
		  //}
		//**Debugging commented out**
		// cout<<"u: "<<u<<" v: "<<v<<"\n";
		// for(int l=0;l<uv.size();l++)
		// 	{
		// 	  Vert c = uv[l];
		// 	  v_size_t ci = index[c];
		// 	  cout<<c<<"\nOn Paths: ";
		// 	  for(int z=0;z<puv[ci].size();z++)
		// 	    {
		// 	      cout<<puv[ci][z]<<" ";
		// 	    }
		// 	  cout<<"\n";
		// 	}
		// char a;
		// cin>>a;	  
  
		//**Again, BFS code**
		//BFS_source_target(v,w,G,vw,predecessors);


		//Calculates delta for each side, ie returns the maximum minimum distance for 
		//any vertex on a shortest path between the pair 

		  //#pragma omp parallel sections shared(uvDelta,uwDelta,vwDelta) num_threads(3)
		    //{
		  //#pragma omp section
		  uvDelta = pair_delta(d,uv,uw,vw,puw,pvw,nuw,nvw,index,delta_v,k1,k2,size);
		  //#pragma omp section
		  uwDelta = pair_delta(d,uw,uv,vw,puv,pvw,nuv,nvw,index,delta_v,k1,k2,size);
		  //#pragma omp section
		  vwDelta = pair_delta(d,vw,uv,uw,puv,puw,nuv,nuw,index,delta_v,k1,k2,size);
		  //}
		//The worst of all pairs is the delta of that triplet
		currDelta = uvDelta;
		if(uwDelta>currDelta)
		  currDelta = uwDelta;
		if(vwDelta>currDelta)
		  currDelta = vwDelta;

		++delta_loc[maxSide-1][currDelta+1];
		if(currDelta>maxDelta_loc)
		  maxDelta_loc = currDelta;

		++delta_loc[maxSide-1][0]; 
	      }
	  }
      }

    #pragma omp critical
    {
      //cout<<delta_loc.size()<<"\n";
      for(size_t i=0;i<delta_loc.size();++i)
	for(size_t j=0;j<delta_loc[i].size();++j)
	  {
	    //cout<<i<<" "<<j<<"\n";
	    delta[i][j] += delta_loc[i][j];
	  }

      if(maxDelta_loc > maxDelta)
	maxDelta = maxDelta_loc;      
    }

  }
  for(int i=0;i<diam;++i)
    {
      delta[i].erase(delta[i].begin()+maxDelta+2,delta[i].end());
    }

  return(delta);
}