Esempio n. 1
0
// RedefineClasses() API support:
// If any entry of this constantPoolCache points to any of
// old_methods, replace it with the corresponding new_method.
void constantPoolCacheOopDesc::adjust_method_entries(methodOop* old_methods, methodOop* new_methods,
                                                     int methods_length, bool * trace_name_printed) {

  if (methods_length == 0) {
    // nothing to do if there are no methods
    return;
  }

  // get shorthand for the interesting class
  klassOop old_holder = old_methods[0]->method_holder();

  for (int i = 0; i < length(); i++) {
    if (!entry_at(i)->is_interesting_method_entry(old_holder)) {
      // skip uninteresting methods
      continue;
    }

    // The constantPoolCache contains entries for several different
    // things, but we only care about methods. In fact, we only care
    // about methods in the same class as the one that contains the
    // old_methods. At this point, we have an interesting entry.

    for (int j = 0; j < methods_length; j++) {
      methodOop old_method = old_methods[j];
      methodOop new_method = new_methods[j];

      if (entry_at(i)->adjust_method_entry(old_method, new_method,
          trace_name_printed)) {
        // current old_method matched this entry and we updated it so
        // break out and get to the next interesting entry if there one
        break;
      }
    }
  }
}
void constantPoolCacheOopDesc::dump_cache() {
  for (int i = 1; i < length(); i++) {
    if (entry_at(i)->is_interesting_method_entry(NULL)) {
      entry_at(i)->print(tty, i);
    }
  }
}
// the constant pool cache should never contain old or obsolete methods
bool constantPoolCacheOopDesc::check_no_old_or_obsolete_entries() {
  for (int i = 1; i < length(); i++) {
    if (entry_at(i)->is_interesting_method_entry(NULL) &&
        !entry_at(i)->check_no_old_or_obsolete_entries()) {
      return false;
    }
  }
  return true;
}
Esempio n. 4
0
void constantPoolCacheOopDesc::adjust_method_entries(objArrayOop old_methods,
						     objArrayOop new_methods) {
  for (int i = 0; i < old_methods->length(); i++) {
    methodOop old_method = (methodOop) old_methods->obj_at(i);
    if (! old_method->is_old_version())
      continue;
    for (int j = 0; j < length(); j++) {
      if (entry_at(j)->is_method_entry()) {
	entry_at(j)->adjust_method_entry(old_method, (methodOop) new_methods->obj_at(i));
      }
    }
  }
}
Esempio n. 5
0
void constantPoolCacheOopDesc::initialize(intArray& inverse_index_map) {
  assert(inverse_index_map.length() == length(), "inverse index map must have same length as cache");
  for (int i = 0; i < length(); i++) {
    ConstantPoolCacheEntry* e = entry_at(i);
    int original_index = inverse_index_map[i];
    if ((original_index & Rewriter::_secondary_entry_tag) != 0) {
      int main_index = (original_index - Rewriter::_secondary_entry_tag);
      assert(!entry_at(main_index)->is_secondary_entry(), "valid main index");
      e->initialize_secondary_entry(main_index);
    } else {
      e->initialize_entry(original_index);
    }
    assert(entry_at(i) == e, "sanity");
  }
}
Esempio n. 6
0
/* paste body of @entry into item */
static int paste_entry(const coord_t * coord /* coord of item */ ,
		       struct cde_entry * entry /* new entry */ ,
		       int pos /* position to insert */ ,
		       reiser4_dir_entry_desc * dir_entry	/* parameters for
								 * new entry */ )
{
	cde_unit_header *header;
	directory_entry_format *dent;
	const char *name;
	int len;

	header = header_at(coord, pos);
	dent = entry_at(coord, pos);

	build_de_id_by_key(&dir_entry->key, &header->hash);
	build_inode_key_id(entry->obj, &dent->id);
	/* AUDIT unsafe strcpy() operation! It should be replaced with
	   much less CPU hungry
	   memcpy( ( char * ) dent -> name, entry -> name -> name , entry -> name -> len );

	   Also a more major thing is that there should be a way to figure out
	   amount of space in dent -> name and be able to check that we are
	   not going to overwrite more than we supposed to */
	name = entry->name->name;
	len = entry->name->len;
	if (is_longname(name, len)) {
		strcpy((unsigned char *)dent->name, name);
		put_unaligned(0, &dent->name[len]);
	}
	return 0;
}
Esempio n. 7
0
/* expand @coord as to accommodate for insertion of @no new entries starting
   from @pos, with total bodies size @size. */
static int expand_item(const coord_t * coord /* coord of item */ ,
		       int pos /* unit position */ , int no	/* number of new
								 * units*/ ,
		       int size /* total size of new units' data */ ,
		       unsigned int data_size	/* free space already reserved
						 * in the item for insertion */ )
{
	int entries;
	cde_unit_header *header;
	char *dent;
	int i;

	assert("nikita-1310", coord != NULL);
	assert("nikita-1311", pos >= 0);
	assert("nikita-1312", no > 0);
	assert("nikita-1313", data_size >= no * sizeof(directory_entry_format));
	assert("nikita-1343",
	       item_length_by_coord(coord) >=
	       (int)(size + data_size + no * sizeof *header));

	entries = units(coord);

	if (pos == entries)
		dent = address(coord, size);
	else
		dent = (char *)entry_at(coord, pos);
	/* place where new header will be in */
	header = header_at(coord, pos);
	/* free space for new entry headers */
	memmove(header + no, header,
		(unsigned)(address(coord, size) - (char *)header));
	/* if adding to the end initialise first new header */
	if (pos == entries) {
		set_offset(coord, pos, (unsigned)size);
	}

	/* adjust entry pointer and size */
	dent = dent + no * sizeof *header;
	size += no * sizeof *header;
	/* free space for new entries */
	memmove(dent + data_size, dent,
		(unsigned)(address(coord, size) - dent));

	/* increase counter */
	entries += no;
	put_unaligned(cpu_to_le16((__u16) entries), &formatted_at(coord)->num_of_entries);

	/* [ 0 ... pos ] entries were shifted by no * ( sizeof *header )
	   bytes.  */
	for (i = 0; i <= pos; ++i)
		adj_offset(coord, i, no * sizeof *header);
	/* [ pos + no ... +\infty ) entries were shifted by ( no *
	   sizeof *header + data_size ) bytes */
	for (i = pos + no; i < entries; ++i)
		adj_offset(coord, i, no * sizeof *header + data_size);
	return 0;
}
Esempio n. 8
0
void ValueMap::print() {
  tty->print_cr("(size %d, entries %d, nesting %d)", size(), entry_count(), nesting());

  int entries = 0;
  for (int i = 0; i < size(); i++) {
    if (entry_at(i) != NULL) {
      tty->print("  %2d: ", i);
      for (ValueMapEntry* entry = entry_at(i); entry != NULL; entry = entry->next()) {
        Value value = entry->value();
        tty->print("%s %c%d (%s%d) -> ", value->name(), value->type()->tchar(), value->id(), is_killed(value) ? "x" : "", entry->nesting());
        entries++;
      }
      tty->print_cr("NULL");
    }
  }

  _killed_values.print();
  assert(entry_count() == entries, "entry_count incorrect");
}
Esempio n. 9
0
Value ValueMap::find_insert(Value x) {
  const intx hash = x->hash();
  if (hash != 0) {
    // 0 hash means: exclude from value numbering
    NOT_PRODUCT(_number_of_finds++);

    for (ValueMapEntry* entry = entry_at(entry_index(hash, size())); entry != NULL; entry = entry->next()) {
      if (entry->hash() == hash) {
        Value f = entry->value();

        if (!is_killed(f) && f->is_equal(x)) {
          NOT_PRODUCT(_number_of_hits++);
          TRACE_VALUE_NUMBERING(tty->print_cr("Value Numbering: %s %c%d equal to %c%d  (size %d, entries %d, nesting-diff %d)", x->name(), x->type()->tchar(), x->id(), f->type()->tchar(), f->id(), size(), entry_count(), nesting() - entry->nesting()));

          if (entry->nesting() != nesting() && f->as_Constant() == NULL) {
            // non-constant values of of another block must be pinned,
            // otherwise it is possible that they are not evaluated
            f->pin(Instruction::PinGlobalValueNumbering);
          }
          assert(x->type()->tag() == f->type()->tag(), "should have same type");

          return f;

        }
      }
    }

    // x not found, so insert it
    if (entry_count() >= size_threshold()) {
      increase_table_size();
    }
    int idx = entry_index(hash, size());
    _entries.at_put(idx, new ValueMapEntry(hash, x, nesting(), entry_at(idx)));
    _entry_count++;

    TRACE_VALUE_NUMBERING(tty->print_cr("Value Numbering: insert %s %c%d  (size %d, entries %d, nesting %d)", x->name(), x->type()->tchar(), x->id(), size(), entry_count(), nesting()));
  }

  return x;
}
Esempio n. 10
0
/* cde_check ->check() method for compressed directory items

   used for debugging, every item should have here the most complete
   possible check of the consistency of the item that the inventor can
   construct
*/
int reiser4_check_cde(const coord_t * coord /* coord of item to check */,
		      const char **error /* where to store error message */)
{
	int i;
	int result;
	char *item_start;
	char *item_end;
	reiser4_key key;

	coord_t c;

	assert("nikita-1357", coord != NULL);
	assert("nikita-1358", error != NULL);

	if (!ergo(coord->item_pos != 0,
		  is_dot_key(item_key_by_coord(coord, &key)))) {
		*error = "CDE doesn't start with dot";
		return -1;
	}
	item_start = item_body_by_coord(coord);
	item_end = item_start + item_length_by_coord(coord);

	coord_dup(&c, coord);
	result = 0;
	for (i = 0; i < units(coord); ++i) {
		directory_entry_format *entry;

		if ((char *)(header_at(coord, i) + 1) >
		    item_end - units(coord) * sizeof *entry) {
			*error = "CDE header is out of bounds";
			result = -1;
			break;
		}
		entry = entry_at(coord, i);
		if ((char *)entry < item_start + sizeof(cde_item_format)) {
			*error = "CDE header is too low";
			result = -1;
			break;
		}
		if ((char *)(entry + 1) > item_end) {
			*error = "CDE header is too high";
			result = -1;
			break;
		}
	}

	return result;
}
Esempio n. 11
0
void ValueMap::increase_table_size() {
  int old_size = size();
  int new_size = old_size * 2 + 1;

  ValueMapEntryList worklist(8);
  ValueMapEntryArray new_entries(new_size, NULL);
  int new_entry_count = 0;

  TRACE_VALUE_NUMBERING(tty->print_cr("increasing table size from %d to %d", old_size, new_size));

  for (int i = old_size - 1; i >= 0; i--) {
    ValueMapEntry* entry;
    for (entry = entry_at(i); entry != NULL; entry = entry->next()) {
      if (!is_killed(entry->value())) {
        worklist.push(entry);
      }
    }

    while (!worklist.is_empty()) {
      entry = worklist.pop();
      int new_index = entry_index(entry->hash(), new_size);

      if (entry->nesting() != nesting() && new_entries.at(new_index) != entry->next()) {
        // changing entries with a lower nesting than the current nesting of the table
        // is not allowed because then the same entry is contained in multiple value maps.
        // clone entry when next-pointer must be changed
        entry = new ValueMapEntry(entry->hash(), entry->value(), entry->nesting(), NULL);
      }
      entry->set_next(new_entries.at(new_index));
      new_entries.at_put(new_index, entry);
      new_entry_count++;
    }
  }

  _entries = new_entries;
  _entry_count = new_entry_count;
}
Esempio n. 12
0
File: menu.c Progetto: Cougar/pwm
void menu_button(WThing *thing, XButtonEvent *ev,
				 WFunction *func, WFuncArg arg)
{
	WMenu *menu;
	int x, y, entry;
	
	if(!WTHING_IS(thing, WTHING_MENU))
		return;
	
	menu=(WMenu*)thing;
	x=ev->x_root-menu->x;
	y=ev->y_root-menu->y;
	entry=entry_at(menu, x, y);
	
	if(ev->type==ButtonPress){
		/* press */
		if(entry==menu->selected){
			menu_set_selected(menu, NO_ENTRY);
		}else{
			menu_set_selected(menu, entry);
			show_selected_submenu(menu);
		}
		return;
	}
	
	end_scroll();
	
	/* release */
	if(entry>=0){
		if(menu->selected==entry)
			menu_execute_selected(menu);
	}else if(entry!=ENTRY_TITLE && !(menu->flags&WMENU_KEEP)){
		finish_menu(menu, FALSE);
	}
	
	destroy_contextual_menus();
}
Esempio n. 13
0
File: menu.c Progetto: Cougar/pwm
bool menu_select_at(WMenu *menu, int rx, int ry)
{
	int x, y;
	int entry;
	
	x=rx-menu->x;
	y=ry-menu->y;
	
	entry=entry_at(menu, x, y);
	
	if(entry==NO_ENTRY){
		if(MENU_SUBMENU(menu)==NULL)
			menu_set_selected(menu, NO_ENTRY);
		
		return FALSE;
	}
	
	if(entry!=menu->selected){
		menu_set_selected(menu, entry);
		show_selected_submenu(menu);
	}

	return TRUE;
}
Esempio n. 14
0
void constantPoolCacheOopDesc::initialize(intArray& inverse_index_map) {
  assert(inverse_index_map.length() == length(), "inverse index map must have same length as cache");
  for (int i = 0; i < length(); i++) entry_at(i)->set_initial_state(inverse_index_map[i]);
}
Esempio n. 15
0
void IntervalTimer::do_async_tasks() {
  for ( fint i = 0;  i < registered;  ++i)
    entry_at(i)->do_procs_if_needed();
}