Пример #1
0
// This is the shared initialization code. It sets up the basic pointers,
// and allows enough extra space for a filler object. We call a virtual
// method, "lab_is_valid()" to handle the different asserts the old/young
// labs require.
void PSPromotionLAB::initialize(MemRegion lab) {
  assert(lab_is_valid(lab), "Sanity");

  HeapWord* bottom = lab.start();
  HeapWord* end    = lab.end();

  set_bottom(bottom);
  set_end(end);
  set_top(bottom);

  // Initialize after VM starts up because header_size depends on compressed
  // oops.
  filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));

  // We can be initialized to a zero size!
  if (free() > 0) {
    if (ZapUnusedHeapArea) {
      debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
    }

    // NOTE! We need to allow space for a filler object.
    assert(lab.word_size() >= filler_header_size, "lab is too small");
    end = end - filler_header_size;
    set_end(end);

    _state = needs_flush;
  } else {
    _state = zero_size;
  }

  assert(this->top() <= this->end(), "pointers out of order");
}
Пример #2
0
 Range::Range(const CHARRANGE& range, LONG total_length)
 {
     // Check if this is an invalid range.
     if(range.cpMin==-1 && range.cpMax==-1)
     {
         *this = InvalidRange();
     }
     else
     {
         DCHECK_GE(range.cpMin, 0);
         set_start(range.cpMin);
         // {0,-1} is the "whole range" but that doesn't mean much out of context,
         // so use the |total_length| parameter.
         if(range.cpMax == -1)
         {
             DCHECK_EQ(0, range.cpMin);
             DCHECK_NE(-1, total_length);
             set_end(total_length);
         }
         else
         {
             set_end(range.cpMax);
         }
     }
 }
// This is the shared initialization code. It sets up the basic pointers,
// and allows enough extra space for a filler object. We call a virtual
// method, "lab_is_valid()" to handle the different asserts the old/young
// labs require. 
void PSPromotionLAB::initialize(MemRegion lab) {
  assert(lab_is_valid(lab), "Sanity");

  HeapWord* bottom = lab.start();
  HeapWord* end    = lab.end();

  set_bottom(bottom);
  set_end(end);
  set_top(bottom);

  // We can be initialized to a zero size!
  if (free() > 0) {
    if (ZapUnusedHeapArea) {
      debug_only(Memory::set_words(top(), free()/HeapWordSize, badHeapWord));
    }
    
    // NOTE! We need to allow space for a filler object.
    assert(lab.word_size() >= filler_header_size, "lab is too small");
    end = end - filler_header_size;
    set_end(end);

    _state = needs_flush;
  } else {
    _state = zero_size;
  }

  assert(this->top() <= this->end(), "pointers out of order");
}
// Fill all remaining lab space with an unreachable object.
// The goal is to leave a contiguous parseable span of objects.
void PSPromotionLAB::flush() {
  assert(_state != flushed, "Attempt to flush PLAB twice");
  assert(top() <= end(), "pointers out of order");
  
  // If we were initialized to a zero sized lab, there is
  // nothing to flush
  if (_state == zero_size)
    return;

  // PLAB's never allocate the last aligned_header_size 
  // so they can always fill with an array.
  HeapWord* tlab_end = end() + filler_header_size;
  typeArrayOop filler_oop = (typeArrayOop) top();
  filler_oop->set_mark();
  filler_oop->set_klass(Universe::intArrayKlassObj());
  const size_t array_length =
    pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
  assert( (array_length * (HeapWordSize/sizeof(jint))) < max_jint, "array too big in PSPromotionLAB");
  filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));

#ifdef ASSERT
  // Note that we actually DO NOT want to use the aligned header size!
  HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT);
  Memory::set_words(elt_words, array_length, 0xDEAABABE);
#endif
  
  set_bottom(NULL);
  set_end(NULL);
  set_top(NULL);

  _state = flushed;
}
Пример #5
0
void add_forth_prim(char* name, int immediate, void (*func)())
{
  forth_obj tmp;

  dict[dict_index].name = add_name(name);
  dict[dict_index].immediate = immediate;
  dict[dict_index].thread = forth_thread_code + thread_index;
  dprintf(("add(%s)pointer=%x\n", name, (int)func));

  if(thread_index + 2 >= FORTH_THREAD_SIZE){
    fprintf(stderr, "too few threaded code memory\n");
    exit(1);
  }

  set_prim(&tmp, func);
  forth_thread_code[thread_index] = tmp;
  thread_index++;
  set_end(forth_thread_code + thread_index);
  thread_index++;

  dict_index++;
  if(dict_index >= FORTH_DICT_SIZE){
    fprintf(stderr, "dict over flower\n");
    exit(1);
  }
}
Пример #6
0
oop* oldSpace::expand_and_allocate(int size) {
  int min_size = ReservedSpace::page_align_size(size);
  int expand_size = max(min_size, ObjectHeapExpandSize * K);
  Universe::old_gen.virtual_space.expand(expand_size);
  set_end((oop*) Universe::old_gen.virtual_space.high());
  return allocate(size);
}
Пример #7
0
void HeapRegion::hr_clear(bool par, bool clear_space) {
  _humongous_type = NotHumongous;
  _humongous_start_region = NULL;
  _in_collection_set = false;
  _is_gc_alloc_region = false;

  // Age stuff (if parallel, this will be done separately, since it needs
  // to be sequential).
  G1CollectedHeap* g1h = G1CollectedHeap::heap();

  set_young_index_in_cset(-1);
  uninstall_surv_rate_group();
  set_young_type(NotYoung);

  // In case it had been the start of a humongous sequence, reset its end.
  set_end(_orig_end);

  if (!par) {
    // If this is parallel, this will be done later.
    HeapRegionRemSet* hrrs = rem_set();
    if (hrrs != NULL) hrrs->clear();
    _claimed = InitialClaimValue;
  }
  zero_marked_bytes();
  set_sort_index(-1);

  _offsets.resize(HeapRegion::GrainWords);
  init_top_at_mark_start();
  if (clear_space) clear(SpaceDecorator::Mangle);
}
Пример #8
0
void space::initialize(char* name, oop* bottom, oop* end) {
  assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), "invalid space boundaries");

  set_name(name);
  set_bottom(bottom);
  set_top(bottom);
  set_end(end);
}
void ThreadLocalAllocBuffer::initialize(HeapWord* start,
                                        HeapWord* top,
                                        HeapWord* end) {
  set_start(start);
  set_top(top);
  set_pf_top(top);
  set_end(end);
  invariants();
}
Пример #10
0
// Al llegar al destino se informa al pacth para que comienze la caza
int hunting ()
{
	printf("cazando\n");
	// Indicar al patch que voy a cazar en el
	add_infoHunter_message (get_x(),get_y(),10,get_clans());
	set_end(1);
	
	return 0;
}
Пример #11
0
void Space::initialize(MemRegion mr, bool clear_space) {
  HeapWord* bottom = mr.start();
  HeapWord* end    = mr.end();
  assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end),
         "invalid space boundaries");
  set_bottom(bottom);
  set_end(end);
  if (clear_space) clear();
}
Пример #12
0
void HeapRegion::add_continuingHumongousRegion(HeapRegion* cont) {
  // Must join the blocks of the current H region seq with the block of the
  // added region.
  offsets()->join_blocks(bottom(), cont->bottom());
  arrayOop obj = (arrayOop)(bottom());
  obj->set_length((int) (obj->length() + cont->capacity()/jintSize));
  set_end(cont->end());
  set_top(cont->end());
}
Пример #13
0
 PartialIterator& operator++ ()
 {
     if (ptr_ == &value_) {
         set_end();
     } else {
         ++ it_;
         ptr_ = it_.operator->();
     }
     return *this;
 }
Пример #14
0
oldSpace::oldSpace(char *name, int &size) {
  next_space= NULL;

  offset_array = NEW_C_HEAP_ARRAY(u_char, Universe::old_gen.virtual_space.reserved_size()/card_size);
  set_name(name);
  set_bottom((oop*) Universe::old_gen.virtual_space.low());
  set_top((oop*)    Universe::old_gen.virtual_space.low());
  set_end((oop*)    Universe::old_gen.virtual_space.high());
  initialize_threshold();
}
Пример #15
0
/*
* Note!
* Argument @Pth - not thread safe!
* if @Pth use of multiple thread, then  copy this string to temp local buffer before call.
* This not doing in func for improve performance.
*/
static LqHttpPth* LqHttpPthGetByAddressSubdirCheck
(
	LqHttp* Http,
	const char* Domain,
	char* Path,
	int* DeepSubDirs
) {
	int k = 0;
	char c, c2;
	LqHttpDmnPtr DefaultDmn = &EmptyDmn, Dmn = &EmptyDmn;
	auto& Dmns = LqHttpGetHttpData(Http)->Dmns;

	{
		auto Interator = Dmns.search(Domain);
		if(!Interator.is_end())
			Dmn = *Interator;
	}
	if(LqHttpGetHttpData(Http)->UseDefaultDmn) {
		auto Interator = Dmns.search("*");
		if(!Interator.is_end())
			DefaultDmn = *Interator;
	}
	auto Pth = Dmn->Pths.search(Path);
	if(Pth.is_end())
		Pth = DefaultDmn->Pths.search(Path);
	if(!Pth.is_end()) {
		LqHttpPthAssign(Pth->Get());
		*DeepSubDirs = k;
		return Pth->Get();
	}
	for(intptr_t l = LqStrLen(Path) - 1; l >= 0; l--)
		if(Path[l] == '/') {
			k++;
			c = Path[l + 1];
			Path[l + 1] = '?';
			c2 = Path[l + 2];
			Path[l + 2] = '\0';
			Pth = Dmn->Pths.search(Path);
			if(Pth.is_end())
				Pth = DefaultDmn->Pths.search(Path);
			Path[l + 1] = c;
			Path[l + 2] = c2;
			if(!Pth.is_end()) {
				if((k > 1) && !((*Pth)->Type & LQHTTPPTH_FLAG_SUBDIR)) {
					Pth.set_end();
				} else {
					LqHttpPthAssign(Pth->Get());
					*DeepSubDirs = k;
					return Pth->Get();
				}
			}
		}
	return nullptr;
}
Пример #16
0
void Basic_block::apply_scheduling(list <Node_dfg*> *new_order){
   list <Node_dfg*>::iterator it=new_order->begin();
   Instruction *inst=(*it)->get_instruction();
   Line *n=_head, *prevn=NULL;
   Line *end_next = _end->get_next();
   if(!n){
      cout<<"wrong bb : cannot apply"<<endl;
      return;
   }
   
   while(!n->isInst()){
     prevn=n;
     n=n->get_next();
     if(n==_end){
       cout<<"wrong bb : cannot apply"<<endl;
       return;
     }
   }
   
   //y'a des instructions, on sait pas si c'est le bon BB, mais on va supposer que oui
   inst->set_index(0);
   inst->set_prev(NULL);
   _firstInst = inst;
   n = inst;
   
   if(prevn){
     prevn->set_next(n);
     n->set_prev(prevn);
   }
   else{
     set_head(n);
   }

   int i;
   it++;
   for(i=1; it!=new_order->end(); it++, i++){

     inst->set_link_succ_pred((*it)->get_instruction());
     
     inst=(*it)->get_instruction();
     inst->set_index(i);
     prevn = n;
     n = inst;
     prevn->set_next(n);
     n->set_prev(prevn);
     }
   inst->set_next(NULL);
   _lastInst = inst;
   set_end(n);
   n->set_next(end_next);
   return;
}
Пример #17
0
void forth_compile_in(forth_obj exp)
{
  dprintf(("compile(%4x)type=%d\n",
	   ((int)exp.num & ~TYPE_MASK), get_type(exp)));
  forth_thread_code[thread_index] = exp;
  thread_index++;
  set_end(forth_thread_code + thread_index);

  if(thread_index >= FORTH_THREAD_SIZE){
    fprintf(stderr, "threaded code over flower\n");
    exit(1);
  }
}
Пример #18
0
void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) {
  assert(!isHumongous(), "sanity / pre-condition");
  assert(end() == _orig_end,
         "Should be normal before the humongous object allocation");
  assert(top() == bottom(), "should be empty");
  assert(bottom() <= new_top && new_top <= new_end, "pre-condition");

  _humongous_type = StartsHumongous;
  _humongous_start_region = this;

  set_end(new_end);
  _offsets.set_for_starts_humongous(new_top);
}
Пример #19
0
static void set_object(void* S)
{
  fprintf(stdout, 
      "\t__set__ -> {\n"
      "\t  object=>0x%p,\n"
      "\t  size=>%d,\n"
      "\t  empty=>'%s',\n"
      "\t  begin=>0x%p,\n"
      "\t  end=>0x%p,\n"
      "\t}\n", 
      S, set_size(S), (set_empty(S) ? "yes" : "no"), 
      set_begin(S), set_end(S)
      );
}
// Fills the current tlab with a dummy filler array to create
// an illusion of a contiguous Eden and optionally retires the tlab.
// Waste accounting should be done in caller as appropriate; see,
// for example, clear_before_allocation().
void ThreadLocalAllocBuffer::make_parsable(bool retire) {
  if (end() != NULL) {
    invariants();
    CollectedHeap::fill_with_object(top(), hard_end());

    if (retire || ZeroTLAB) {  // "Reset" the TLAB
      set_start(NULL);
      set_top(NULL);
      set_pf_top(NULL);
      set_end(NULL);
    }
  }
  assert(!(retire || ZeroTLAB)  ||
         (start() == NULL && end() == NULL && top() == NULL),
         "TLAB must be reset");
}
Пример #21
0
inline iterator2 set_end2( container *C )
{
    iterator		it = set_end(C);
    iterator2		it2;

    it2.node = it.node;
    it2.valid = it.valid;
    it2.next = _set_previous2;
    it2.get_key = _set_get_key;
    it2.get_value = _set_get_value;
    it2.compare_keys = _set_compare_keys;
    it2.C = C;
    it2.insert = _set_insert;

    return it2;
}
Пример #22
0
int get_numGuanacos()
{
	int guanacos =0;
	// Recive num of guanacos
	printf("preguntando\n");
	START_INFOGUANACOS_MESSAGE_LOOP
		guanacos = infoGuanacos_message->amount;
	FINISH_INFOGUANACOS_MESSAGE_LOOP
	// si hay guanacos comenzar la caza
	if (guanacos > 0)
		set_start(1);
	// Sino y se ha llegado al destino, acabar la caza
	else if (get_arrive() == 1 )
		set_end(1);

	return 0;
}
Пример #23
0
void HeapRegion::clear_humongous() {
  assert(isHumongous(), "pre-condition");

  if (startsHumongous()) {
    assert(top() <= end(), "pre-condition");
    set_end(_orig_end);
    if (top() > end()) {
      // at least one "continues humongous" region after it
      set_top(end());
    }
  } else {
    // continues humongous
    assert(end() == _orig_end, "sanity");
  }

  assert(capacity() == HeapRegion::GrainBytes, "pre-condition");
  _humongous_start_region = NULL;
}
Пример #24
0
void F_create(void)
{
  forth_obj tmp;
  dprintf(("create! thread=(%p)\n", forth_thread_code + thread_index));
  thread_index++;

  dict[dict_index].name = "";
  dict[dict_index].immediate = FALSE;
  dict[dict_index].thread = forth_thread_code + thread_index;

  set_thread(&tmp, forth_thread_code + thread_index + 2);
  forth_compile_in(tmp);
  thread_index++;
  set_end(forth_thread_code + thread_index);

  dict_index++;
  if(dict_index >= FORTH_DICT_SIZE){
    fprintf(stderr, "dict over flower\n");
    exit(1);
  }
  pc++;
}
Пример #25
0
static int append_record(struct stats_file *file,
				struct stats_record *rec)
{
	struct stats_record *cur, *next;
	int err;

	if (file->last == get_end(file)) {
		err = stats_file_remap(file, file->len +
					sysconf(_SC_PAGESIZE));
		if (err < 0)
			return err;

		stats_file_update_cache(file);
	}

	cur = get_end(file);
	next = get_next(file, cur);

	memcpy(next, rec, sizeof(struct stats_record));

	set_end(file, next);

	return 0;
}
Пример #26
0
static int stats_create(struct stats_file *file, unsigned int nr,
			unsigned int interval, time_t start_ts,
			struct stats_record *start)
{
	unsigned int i;
	int err;
	struct stats_record *cur, *next;
	struct stats_file_header *hdr;
	unsigned int pkt;
	unsigned int step_ts;
	unsigned int roaming = FALSE;

	hdr = get_hdr(file);

	hdr->magic = MAGIC;
	hdr->begin = sizeof(struct stats_file_header);
	hdr->end = sizeof(struct stats_file_header);
	hdr->home = UINT_MAX;
	hdr->roaming = UINT_MAX;

	stats_file_update_cache(file);

	if (start) {
		struct stats_record *rec;

		rec = get_end(file);
		memcpy(rec, start, sizeof(struct stats_record));
	} else {
		get_end(file)->ts = start_ts;
	}

	for (i = 0; i < nr; i++) {
		if (file->last == get_end(file)) {
			err = stats_file_remap(file, file->len +
						sysconf(_SC_PAGESIZE));
			if (err < 0)
				return err;

			stats_file_update_cache(file);
		}
		cur = get_end(file);
		next = get_next(file, cur);

		step_ts = (rand() % interval);
		if (step_ts == 0)
			step_ts = 1;

		next->ts = cur->ts + step_ts;
		next->roaming = roaming;
		next->data.time = cur->data.time + step_ts;

		next->data.rx_packets = cur->data.rx_packets;
		next->data.rx_bytes = cur->data.rx_bytes;

		if (rand() % 3 == 0) {
			pkt = rand() % 5;
			next->data.rx_packets += pkt;
			next->data.rx_bytes += pkt * (rand() % 1500);
		}

		next->data.tx_packets = cur->data.tx_packets;
		next->data.tx_bytes = cur->data.tx_bytes;

		if (rand() % 3 == 0) {
			pkt = rand() % 5;
			next->data.tx_packets += pkt;
			next->data.tx_bytes += pkt * (rand() % 1500);
		}

		set_end(file, next);

		if ((rand() % 50) == 0)
			roaming = roaming ? FALSE : TRUE;

	}

	return 0;
}
Пример #27
0
static void stats_convert(struct stats_file *file)
{
	struct stats_file temp_file;
	int err;

	DBG("converting data file %s", file->name);

	stats_file_update_cache32(file);

	bzero(&temp_file, sizeof(struct stats_file));

	err = stats_open_temp(&temp_file);
	if (err < 0) {
		connman_error("failed to open temporary file during data conversion");
		return;
	}
	stats_file_setup(&temp_file);

	struct stats_iter32 data_iter;
	struct stats_record32 *record;

	data_iter.file = file;
	data_iter.begin = get_iterator_begin32(data_iter.file);
	data_iter.end = get_iterator_end32(data_iter.file);
	data_iter.it = data_iter.begin;

	record = get_next_record32(&data_iter);
	while (record) {
		struct stats_record *next;

		if (temp_file.last == get_end(&temp_file)) {
			err = stats_file_remap(&temp_file, temp_file.len + sysconf(_SC_PAGESIZE));
			if (err < 0) {
				connman_error("failed to extend file %s", temp_file.name);
				unlink(temp_file.name);
				stats_file_unmap(&temp_file);
				TFR(close(temp_file.fd));
				stats_file_cleanup(&temp_file);
				return;
			}

			stats_file_update_cache(&temp_file);
		}

		next = get_next(&temp_file, get_end(&temp_file));
		if (next == get_begin(&temp_file)) {
			connman_error("ring buffer is full");
			unlink(temp_file.name);
            stats_file_unmap(&temp_file);
			TFR(close(temp_file.fd));
			stats_file_cleanup(&temp_file);
			return;
		}

		next->ts = record->ts;
		next->roaming = record->roaming;
		next->data.rx_packets = record->data.rx_packets;
		next->data.tx_packets = record->data.tx_packets;
		next->data.rx_bytes = record->data.rx_bytes;
		next->data.tx_bytes = record->data.tx_bytes;
		next->data.rx_errors = record->data.rx_errors;
		next->data.tx_errors = record->data.tx_errors;
		next->data.rx_dropped = record->data.rx_dropped;
		next->data.tx_dropped = record->data.tx_dropped;
		next->data.time = record->data.time;

		if (next->roaming)
			set_roaming(&temp_file, next);
		else
			set_home(&temp_file, next);

		set_end(&temp_file, next);

		record = get_next_record32(&data_iter);
	}

	// close and swap
	stats_file_unmap(file);
	TFR(close(file->fd));
	err = rename(temp_file.name, file->name);
	if (err < 0)
		connman_error("failed to rename converted data file %s to %s", temp_file.name, file->name);

	g_free(temp_file.name);
	temp_file.name = file->name;

	memcpy(file, &temp_file, sizeof(struct stats_file));
}