void CachedResource::setDecodedSize(unsigned size)
{
    if (size == m_decodedSize)
        return;

    int delta = size - m_decodedSize;

    // The object must now be moved to a different queue, since its size has been changed.
    // We have to remove explicitly before updating m_decodedSize, so that we find the correct previous
    // queue.
    if (inCache())
        cache()->removeFromLRUList(this);
    
    m_decodedSize = size;
   
    if (inCache()) { 
        // Now insert into the new LRU list.
        cache()->insertInLRUList(this);
        
        // Insert into or remove from the live decoded list if necessary.
        if (m_decodedSize && !m_inLiveDecodedResourcesList && referenced())
            cache()->insertInLiveDecodedResourcesList(this);
        else if (!m_decodedSize && m_inLiveDecodedResourcesList)
            cache()->removeFromLiveDecodedResourcesList(this);

        // Update the cache's size totals.
        cache()->adjustSize(referenced(), delta);
    }
}
//#####################################################################
// Function Destroy_Unreferenced_Geometry
//#####################################################################
template<class TV> void RIGID_GEOMETRY_COLLECTION<TV>::
Destroy_Unreferenced_Geometry() 
{
    ARRAY<bool> referenced(structure_list.Number_Of_Active_Elements());
    for(int i=1;i<=particles.array_collection->Size();i++) for(int j=1;j<=particles.structure_ids(i).m;j++) if(particles.structure_ids(i)(j))
        referenced(structure_list.Element_Index(particles.structure_ids(i)(j)))=true;
    for(int i=structure_list.Number_Of_Active_Elements();i>=1;i--) if(!referenced(i)) structure_list.Remove_Element(structure_list.Active_Element_Id(i));
}
void CachedResource::setEncodedSize(unsigned size)
{
    if (size == m_encodedSize)
        return;

    // The size cannot ever shrink (unless it is being nulled out because of an error).  If it ever does, assert.
    ASSERT(size == 0 || size >= m_encodedSize);
    
    int delta = size - m_encodedSize;

    // The object must now be moved to a different queue, since its size has been changed.
    // We have to remove explicitly before updating m_encodedSize, so that we find the correct previous
    // queue.
    if (inCache())
        cache()->removeFromLRUList(this);
    
    m_encodedSize = size;
   
    if (inCache()) { 
        // Now insert into the new LRU list.
        cache()->insertInLRUList(this);
        
        // Update the cache's size totals.
        cache()->adjustSize(referenced(), delta);
    }
}
Esempio n. 4
0
/*
 * Add this AST_Enum node (an enum declaration) to this scope
 */
AST_Enum *AST_Module::fe_add_enum(AST_Enum *t)
{
   AST_Decl *d;

   /*
    * Already defined and cannot be redefined? Or already used?
    */

   if ((d = lookup_for_add (t)) != NULL)
   {
      if (!can_be_redefined (d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d);
         return NULL;
      }

      if (referenced (d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(t);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(t, false);

   return t;
}
Esempio n. 5
0
// Add a node to set of nodes referenced in this scope
void
UTL_Scope::add_to_referenced(AST_Decl *e, idl_bool recursive)
{
   UTL_Scope *s;
   AST_Decl **tmp;
   AST_Interface *itf;
   long oreferenced_allocated;
   long i;

   if (e == NULL)
      return ;

   // Special cases for forward declared interfaces and valuetypes in
   // the scope in which they're defined. Cannot add before full
   // definition is seen
   if ((e->node_type() == AST_Decl::NT_interface)
       || (e->node_type() == AST_Decl::NT_value))
   {
      itf = AST_Interface::narrow_from_decl(e);

      if (itf != NULL && itf->defined_in() == this && !itf->is_defined())
         return ;
   }

   // Only insert if it is not there already
   if (referenced(e))
      return ;

   // Make sure there's space for one more
   if (pd_referenced_allocated == pd_referenced_used)
   {

      oreferenced_allocated = pd_referenced_allocated;
      pd_referenced_allocated += INCREMENT;
      tmp = new AST_Decl * [pd_referenced_allocated];

      for (i = 0; i < oreferenced_allocated; i++)
         tmp[i] = pd_referenced[i];

      delete [] pd_referenced;

      pd_referenced = tmp;
   }

   // Insert new reference
   pd_referenced[pd_referenced_used++] = e;

   // Now, if recursive is specified and "this" is not a common ancestor
   // of the referencing scope and the scope of definition of "e" then
   // add "e" to the set of referenced nodes in the parent of "this"
   if (recursive && !(e->has_ancestor(ScopeAsDecl(this))))
   {
      s = e->defined_in();

      if (s != NULL)
         s->add_to_referenced(e, recursive);
   }
}
Esempio n. 6
0
void map(mmu *m, int index, int phy, int instnnd){
  PRINT_INST(instnnd, "MAP", index, phy);
  present(&(m->pageT[index]));
  referenced(&(m->pageT[index]));
  pagedin(&(m->pageT[index]),phy); 
  m->frames[phy] = index;
  m->frameN += 1;  
  m->maps_N += 1;
  return;
}
Esempio n. 7
0
/*
 * Add this AST_InterfaceFwd node (a forward declaration of an IDL
 * interface) to this scope
 */
AST_InterfaceFwd * AST_Module::fe_add_interface_fwd (AST_InterfaceFwd * i)
{
   AST_Decl * d = lookup_for_add (i);
   AST_Interface * itf;

   /*
    * Already defined and cannot be redefined? Or already used?
    */
   if (d)
   {
      if (d->node_type() == AST_Decl::NT_interface && d->defined_in() == this)
      {
         itf = AST_Interface::narrow_from_decl (d);

         if (itf == 0)
         {
            return 0;
         }

         i->set_full_definition (itf);
         return i;
      }

      if (!can_be_redefined (d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, i, this, d);
         return NULL;
      }

      if (referenced (d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, i, this, d);
         return NULL;
      }

      if (i->has_ancestor (d))
      {
         idl_global->err()->redefinition_in_scope(i, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope (i);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced (i, false);

   return i;
}
Esempio n. 8
0
AST_ValueFwd *AST_Module::fe_add_valuetype_fwd(AST_ValueFwd *v)
{
   AST_Decl *d;
   AST_Value *val;

   /*
    * Already defined and cannot be redefined? Or already used?
    */
   if ((d = lookup_for_add (v)) != NULL)
   {
      if (d->node_type() == AST_Decl::NT_value && d->defined_in() == this)
      {
         val = AST_Value::narrow_from_decl(d);

         if (val == NULL)
            return NULL;

         v->set_full_definition(val);

         return v;
      }

      if (!can_be_redefined(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, v, this, d);
         return NULL;
      }

      if (referenced(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, d);
         return NULL;
      }

      if (v->has_ancestor(d))
      {
         idl_global->err()->redefinition_in_scope(v, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(v);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(v, I_FALSE);

   return v;
}
void CachedResource::deref(CachedResourceClient *c)
{
    ASSERT(m_clients.contains(c));
    m_clients.remove(c);
    if (canDelete() && !inCache())
        delete this;
    else if (!referenced() && inCache()) {
        cache()->removeFromLiveResourcesSize(this);
        cache()->removeFromLiveDecodedResourcesList(this);
        allReferencesRemoved();
        cache()->prune();
    }
}
Esempio n. 10
0
AST_StateMember *AST_Value::fe_add_state_member(AST_StateMember *t)
{
   AST_Decl *d;

   /*
    * Can't add to interface which was not yet defined
    */

   if (!is_defined())
   {
      idl_global->err()->error2(UTL_Error::EIDL_DECL_NOT_DEFINED, this, t);
      return NULL;
   }

   /*
    * Already defined and cannot be redefined? Or already used?
    */
   if ((d = lookup_for_add (t)) != NULL)
   {
      if (!can_be_redefined(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d);
         return NULL;
      }

      if (referenced(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d);
         return NULL;
      }

      if (t->has_ancestor(d))
      {
         idl_global->err()->redefinition_in_scope(t, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(t);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(t, I_FALSE);

   return t;
}
Esempio n. 11
0
void simulate(mmu *m){
  inst *elt, *tmp;
    
  while (instList != NULL){
    tmp = instList;
    elt = popInst(tmp);
    if (elt == NULL){ continue; } //invalid instruction

    m->insts_N +=1;
    
    int rw = elt->rw;
    int page = elt->page;
    int instN = elt->instN;
    free(elt); elt =NULL; tmp = NULL;

    if (algo==3){
      m->mmucounter +=1;
      m->cT64[page] =  m->mmucounter; 
      //printf("==> %llu %lu\n", m->cT64[page],m->mmucounter);
    }

    if (isPresent(m->pageT[page])){
      if (rw ==1){ 
	modified(&(m->pageT[page])); 
      }
      referenced(&(m->pageT[page]));
      continue; 
    } //page present 
   

    int victim, nextFID;
    if (m->frameN < numFrames){
      victim = page;
      nextFID = m->frameN;
    }
    else {
      updateMMU(m, page);
      victim = nextFrame(m);
      nextFID = unmap(m,victim,instN); 
    }

    pageIn(m, page, rw, instN, nextFID); 
    
    map(m, page, nextFID, instN); /* MAP */
    
  } //while instList NOT NULL
  
  return;
}
Esempio n. 12
0
/*
 * Add this AST_EnumVal (enumerator declaration) to the current scope.
 * This is done to conform to the C++ scoping rules which declare
 * enumerators in the enclosing scope (in addition to declaring them
 * in the enum itself)
 */
AST_EnumVal *AST_Exception::fe_add_enum_val(AST_EnumVal *t)
{
   AST_Decl *d;

   /*
    * Already defined and cannot be redefined? Or already used?
    */

   if ((d = lookup_for_add (t)) != NULL)
   {
      if (!can_be_redefined(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d);
         return NULL;
      }

      if (referenced(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d);
         return NULL;
      }

      if (t->has_ancestor(d))
      {
         idl_global->err()->redefinition_in_scope(t, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(t);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(t, I_FALSE);

   return t;
}
Esempio n. 13
0
AST_Opaque*
AST_Module::fe_add_opaque(AST_Opaque* o)
{

   AST_Decl *d;
   /*
    * Already defined and cannot be redefined? Or already used?
    */

   if ((d = lookup_for_add (o)) != NULL)
   {
      if (!can_be_redefined(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, o, this, d);
         return NULL;
      }

      if (referenced(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, o, this, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(o);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(o, I_FALSE);

   return o;
}
void CachedResource::ref(CachedResourceClient *c)
{
    if (!referenced() && inCache())
        cache()->addToLiveResourcesSize(this);
    m_clients.add(c);
}
Esempio n. 15
0
/*
 * Add this AST_Value node (a value type declaration) to this scope
 */
AST_BoxedValue *AST_Module::fe_add_boxed_valuetype(AST_BoxedValue *v)
{
   AST_Decl *predef;
   AST_Interface *fwd;

   /*
    * Already defined?
    */

   if ((predef = lookup_for_add (v)) != NULL)
   {
      /*
       * Treat fwd declared interfaces specially
       */

      if (predef->node_type() == AST_Decl::NT_value)
      {
         fwd = AST_Value::narrow_from_decl(predef);

         if (fwd == NULL)
            return NULL;

         if (!fwd->is_defined())
         { /* Forward declared and not defined yet */

            if (fwd->defined_in() != this)
            {
               idl_global->err()
               ->error3(UTL_Error::EIDL_SCOPE_CONFLICT, fwd, v, this);
               return NULL;
            }
         }

         /*
          * OK, not illegal redef of forward declaration. Now check whether
          * it has been referenced already
          */
         else if (referenced(predef))
         {
            idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, predef);
            return NULL;
         }
      }
      else if (!can_be_redefined(predef))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, v, this, predef);
         return NULL;
      }
      else if (referenced(predef))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, predef);
         return NULL;
      }
      else if (v->has_ancestor(predef))
      {
         idl_global->err()->redefinition_in_scope(v, predef);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(v);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(v, I_FALSE);

   return v;
}
Esempio n. 16
0
DECL *
UTL_Scope::fe_add_full_intf_decl (DECL *t)
{
  if (t->redef_clash ())
    {
      return 0;
    }

  AST_Decl *predef = 0;
  DECL *fwd = 0;

  // Already defined?
  if ((predef = this->lookup_for_add (t)) != 0)
    {
      // Treat fwd declared interfaces specially
      if (predef->node_type () == DECL::NT)
        {
          fwd = DECL::narrow_from_decl (predef);

          if (fwd == 0)
            {
              return 0;
            }

          // Forward declared and not defined yet.
          if (!fwd->is_defined ())
            {
              if (fwd->defined_in () != this)
                {
                  idl_global->err ()->error3 (UTL_Error::EIDL_SCOPE_CONFLICT,
                                              fwd,
                                              t,
                                              ScopeAsDecl (this));

                  return 0;
                }
            }
          // OK, not illegal redef of forward declaration. Now check whether.
          // it has been referenced already.
          else if (this->referenced (predef, t->local_name ()))
            {
              idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE,
                                          t,
                                          ScopeAsDecl (this),
                                          predef);

              return 0;
            }

        }
      else if (!FE_Utils::can_be_redefined (predef, t))
        {
          idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
                                      t,
                                      ScopeAsDecl (this),
                                      predef);

          return 0;
        }
      else if (referenced (predef, t->local_name ()) && !t->is_defined ())
        {
          idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE,
                                      t,
                                      ScopeAsDecl (this),
                                      predef);

          return 0;
        }
      else if (t->has_ancestor (predef))
        {
          idl_global->err ()->redefinition_in_scope (t, predef);

          return 0;
        }
    }

  // Add it to scope
  this->add_to_scope (t);

  // We do this for interfaces, valuetypes and components in
  // a different place than we do for structs and unions,
  // since fwd declared structs and unions must be defined in
  // the same translation unit.
  AST_InterfaceFwd *fd = t->fwd_decl ();

  if (0 != fd)
    {
      fd->set_as_defined ();
    }

  // Add it to set of locally referenced symbols
  this->add_to_referenced (t,
                           false,
                           t->local_name ());
  return t;
}