diff options
author | Mark Shinwell <mshinwell@janestreet.com> | 2014-05-01 13:07:48 +0000 |
---|---|---|
committer | Mark Shinwell <mshinwell@janestreet.com> | 2014-05-01 13:07:48 +0000 |
commit | 05100e597e4296a2e79e6c2d9cd75b7e1cc595c9 (patch) | |
tree | 6238ef4ffb4cfc18f8a8a87b8d001884c70753d4 | |
parent | 521ac0213a11a22ca9e7dd588d7274072eb8e094 (diff) |
initialize blocks with Val_unit, not zero
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14720 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | byterun/alloc.c | 6 | ||||
-rw-r--r-- | byterun/memory.h | 12 |
3 files changed, 12 insertions, 8 deletions
@@ -65,6 +65,8 @@ Toplevel interactive system: - PR#5377: New "#show_*" directives Runtime system: +- Blocks initialized by [CAMLlocal*] and [caml_alloc] are now filled with + [Val_unit] rather than zero. - Fixed a major performance problem on large heaps (~1GB) by making heap increments proportional to heap size - PR#4765: Structural equality should treat exception specifically diff --git a/byterun/alloc.c b/byterun/alloc.c index a1fd2f03e..1fc33b55a 100644 --- a/byterun/alloc.c +++ b/byterun/alloc.c @@ -39,11 +39,13 @@ CAMLexport value caml_alloc (mlsize_t wosize, tag_t 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; + for (i = 0; i < wosize; i++) Field (result, i) = Val_unit; } }else{ result = caml_alloc_shr (wosize, tag); - if (tag < No_scan_tag) memset (Bp_val (result), 0, Bsize_wsize (wosize)); + if (tag < No_scan_tag){ + for (i = 0; i < wosize; i++) Field (result, i) = Val_unit; + } result = caml_check_urgent_gc (result); } return result; diff --git a/byterun/memory.h b/byterun/memory.h index 076107017..2d1479620 100644 --- a/byterun/memory.h +++ b/byterun/memory.h @@ -266,27 +266,27 @@ CAMLextern struct caml__roots_block *caml_local_roots; /* defined in roots.c */ 0) #define CAMLlocal1(x) \ - value x = 0; \ + value x = Val_unit; \ CAMLxparam1 (x) #define CAMLlocal2(x, y) \ - value x = 0, y = 0; \ + value x = Val_unit, y = Val_unit; \ CAMLxparam2 (x, y) #define CAMLlocal3(x, y, z) \ - value x = 0, y = 0, z = 0; \ + value x = Val_unit, y = Val_unit, z = Val_unit; \ CAMLxparam3 (x, y, z) #define CAMLlocal4(x, y, z, t) \ - value x = 0, y = 0, z = 0, t = 0; \ + value x = Val_unit, y = Val_unit, z = Val_unit, t = Val_unit; \ CAMLxparam4 (x, y, z, t) #define CAMLlocal5(x, y, z, t, u) \ - value x = 0, y = 0, z = 0, t = 0, u = 0; \ + value x = Val_unit, y = Val_unit, z = Val_unit, t = Val_unit, u = Val_unit; \ CAMLxparam5 (x, y, z, t, u) #define CAMLlocalN(x, size) \ - value x [(size)] = { 0, /* 0, 0, ... */ }; \ + value x [(size)] = { Val_unit, /* Val_unit, Val_unit, ... */ }; \ CAMLxparamN (x, (size)) |