Skip to content

Commit

Permalink
initialize blocks with Val_unit, not zero
Browse files Browse the repository at this point in the history
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14720 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
mshinwell committed May 1, 2014
1 parent 521ac02 commit 05100e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions byterun/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions byterun/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down

0 comments on commit 05100e5

Please sign in to comment.