/***********************************************************************/ /* */ /* Objective Caml */ /* */ /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */ /* */ /* Copyright 1996 Institut National de Recherche en Informatique et */ /* en Automatique. All rights reserved. This file is distributed */ /* under the terms of the GNU Library General Public License. */ /* */ /***********************************************************************/ /***--------------------------------------------------------------------- Modified and adapted for the Lazy Virtual Machine by Daan Leijen. Modifications copyright 2001, Daan Leijen. This (modified) file is distributed under the terms of the GNU Library General Public License. ---------------------------------------------------------------------***/ /* $Id$ */ /* 1. Allocation functions doing the same work as the macros in the case where [Setup_for_gc] and [Restore_after_gc] are no-ops. 2. Convenience functions related to allocation. */ #include #include #include "mlvalues.h" #include "heapfast.h" #include "custom.h" #define Setup_for_gc #define Restore_after_gc value alloc (mlsize_t wosize, tag_t tag) { value result; mlsize_t i; Assert (tag < 256); if (wosize == 0){ result = Atom (tag); } else if (wosize <= Max_young_wosize){ Alloc_small (result, wosize, tag); if (tag < No_scan_tag){ for (i = 0; i < wosize; i++) Field (result, i) = 0; } }else{ result = alloc_shr (wosize, tag); if (tag < No_scan_tag) memset (Bp_val (result), 0, Bsize_wsize (wosize)); result = check_urgent_gc (result); } return result; } value alloc_major(mlsize_t wosize, tag_t tag) { value result; Assert (tag < 256); if (wosize == 0){ result = Atom (tag); } else{ result = alloc_shr (wosize, tag); if (tag < No_scan_tag) memset (Bp_val (result), 0, Bsize_wsize (wosize)); result = check_urgent_gc (result); } return result; } value alloc_small (mlsize_t wosize, tag_t tag) { value result; mlsize_t i; Assert (wosize > 0); Assert (wosize <= Max_young_wosize); Assert (tag < 256); Alloc_small (result, wosize, tag); for(i=0;i