From 097f47afb8feb8a80b3b03391da28d60d087df21 Mon Sep 17 00:00:00 2001 From: Pekka Pirinen Date: Thu, 23 Jul 1998 17:04:44 +0100 Subject: [PATCH] Dylan_write to write integers half the time Copied from Perforce Change: 19808 ServerID: perforce.ravenbrook.com --- mps/src/fmtdytst.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mps/src/fmtdytst.c b/mps/src/fmtdytst.c index f64b13ee795..c39ee3ce8b3 100644 --- a/mps/src/fmtdytst.c +++ b/mps/src/fmtdytst.c @@ -1,6 +1,6 @@ /* impl.c.fmtdytst: DYLAN FORMAT TEST CODE * - * $HopeName: MMsrc!fmtdytst.c(trunk.4) $ + * $HopeName: MMsrc!fmtdytst.c(trunk.5) $ * Copyright (C) 1998 Harlequin Group. All rights reserved. * * .readership: MPS developers, Dylan developers. @@ -110,13 +110,17 @@ mps_res_t dylan_init(mps_addr_t addr, size_t size, void dylan_write(mps_addr_t addr, mps_addr_t *refs, size_t nr_refs) { mps_word_t *p = (mps_word_t *)addr; + mps_word_t t = p[1] >> 2; /* If the object is a vector, update a random entry. */ - if(p[0] == (mps_word_t)tvw) { - mps_word_t t = p[1] >> 2; - if(t > 0) - p[2 + (rnd() % t)] = - (mps_word_t)refs[rnd() % nr_refs]; + if(p[0] == (mps_word_t)tvw && t > 0) { + mps_word_t r = rnd(); + size_t i = 2 + (rnd() % t); + + if(r & 1) + p[i] = ((r & ~(mps_word_t)3) | 1); /* random int */ + else + p[i] = (mps_word_t)refs[(r >> 1) % nr_refs]; /* random ptr */ } }