summaryrefslogtreecommitdiffstats
path: root/byterun/intern.c
diff options
context:
space:
mode:
Diffstat (limited to 'byterun/intern.c')
-rw-r--r--byterun/intern.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/byterun/intern.c b/byterun/intern.c
index 9fa403ad6..35d293b60 100644
--- a/byterun/intern.c
+++ b/byterun/intern.c
@@ -19,6 +19,7 @@
#include <string.h>
#include "alloc.h"
+#include "callback.h"
#include "custom.h"
#include "fail.h"
#include "gc.h"
@@ -63,6 +64,10 @@ static value intern_block;
/* Point to the heap block allocated as destination block.
Meaningful only if intern_extra_block is NULL. */
+static value * camlinternaloo_last_id = NULL;
+/* Pointer to a reference holding the last object id.
+ -1 means not available (CamlinternalOO not loaded). */
+
#define Sign_extend_shift ((sizeof(intnat) - 1) * 8)
#define Sign_extend(x) (((intnat)(x) << Sign_extend_shift) >> Sign_extend_shift)
@@ -139,6 +144,22 @@ static void intern_rec(value *dest)
dest = (value *) (intern_dest + 1);
*intern_dest = Make_header(size, tag, intern_color);
intern_dest += 1 + size;
+ /* For objects, we need to freshen the oid */
+ if (tag == Object_tag && camlinternaloo_last_id != (value*)-1) {
+ intern_rec(dest++);
+ intern_rec(dest++);
+ if (camlinternaloo_last_id == NULL)
+ camlinternaloo_last_id = caml_named_value("CamlinternalOO.last_id");
+ if (camlinternaloo_last_id == NULL)
+ camlinternaloo_last_id = (value*)-1;
+ else {
+ value id = Field(*camlinternaloo_last_id,0);
+ Field(dest,-1) = id;
+ Field(*camlinternaloo_last_id,0) = id + 2;
+ }
+ size -= 2;
+ if (size == 0) return;
+ }
for(/*nothing*/; size > 1; size--, dest++)
intern_rec(dest);
goto tailcall;
@@ -328,6 +349,8 @@ static void intern_alloc(mlsize_t whsize, mlsize_t num_objects)
{
mlsize_t wosize;
+ if (camlinternaloo_last_id == (value*)-1)
+ camlinternaloo_last_id = NULL; /* Reset ignore flag */
if (whsize == 0) {
intern_obj_table = NULL;
intern_extra_block = NULL;