VirtualBox

Changeset 1862 in kBuild for trunk/src/kmk/incdep.c


Ignore:
Timestamp:
Oct 14, 2008 1:04:03 AM (16 years ago)
Author:
bird
Message:

kmk: some preliminary allocation caching. seems dep, variables, variable sets and files would be good candidates for generic alloc caches.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/incdep.c

    r1854 r1862  
    150150  const char *err_msg;
    151151
     152  struct dep *dep_start;            /* start of the current dep block. */
     153  struct dep *dep_end;              /* end of the current dep block. */
     154
    152155  struct incdep_variable_in_set *recorded_variables_in_set_head;
    153156  struct incdep_variable_in_set *recorded_variables_in_set_tail;
     
    233236   For working around multithreaded performance problems found on Darwin,
    234237   Linux (glibc), and possibly other systems. */
    235 static void *incdep_xmalloc (struct incdep *cur, size_t size)
     238static void *
     239incdep_xmalloc (struct incdep *cur, size_t size)
    236240{
    237241  void *ptr;
     
    255259
    256260/* memset(malloc(sz),'\0',sz) wrapper. */
    257 static void *incdep_xcalloc (struct incdep *cur, size_t size)
     261static void *
     262incdep_xcalloc (struct incdep *cur, size_t size)
    258263{
    259264  void *ptr;
     
    275280
    276281/* free wrapper */
    277 static void incdep_xfree (struct incdep *cur, void *ptr)
     282static void
     283incdep_xfree (struct incdep *cur, void *ptr)
    278284{
    279285  /* free() *must* work for the allocation hacks above because
     
    283289}
    284290
     291/* alloc a dep structure. These are allocated in bunches to save time. */
     292struct dep *
     293incdep_alloc_dep (struct incdep *cur)
     294{
     295  if (cur->dep_start != cur->dep_end)
     296    return cur->dep_start++;
     297
     298  cur->dep_start = (struct dep *)incdep_xcalloc (cur, sizeof(struct dep) * 256);
     299  cur->dep_end = cur->dep_start + 256;
     300  return cur->dep_start++;
     301}
    285302
    286303
     
    457474incdep_worker (void)
    458475{
     476#ifdef PARSE_IN_WORKER
     477  struct dep *dep_start = NULL;
     478  struct dep *dep_end = NULL;
     479#endif
     480
    459481  incdep_lock ();
    460482
     
    480502      cur->is_worker = 1;
    481503      incdep_read_file (cur, NILF);
     504
    482505#ifdef PARSE_IN_WORKER
     506      cur->dep_start = dep_start;
     507      cur->dep_end = dep_end;
     508
    483509      eval_include_dep_file (cur, NILF);
    484 #endif
     510
     511      dep_start = cur->dep_start;
     512      cur->dep_start = NULL;
     513      dep_end = cur->dep_end;
     514      cur->dep_end = NULL;
     515#endif
     516
    485517      cur->is_worker = 0;
    486518      incdep_lock ();
     
    13371369
    13381370                  /* add it to the list. */
    1339                   *nextdep = dep = incdep_xcalloc (curdep, sizeof (*dep));
     1371                  *nextdep = dep = incdep_alloc_dep (curdep);
    13401372                  dep->name = incdep_record_strcache (curdep, cur, endp - cur);
    13411373                  dep->includedep = 1;
     
    14411473       cur->err_line_no = 0;
    14421474       cur->err_msg = NULL;
     1475       cur->dep_start = NULL;
     1476       cur->dep_end = NULL;
    14431477       cur->recorded_variables_in_set_head = NULL;
    14441478       cur->recorded_variables_in_set_tail = NULL;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette