Skip to content

Commit 54afc12

Browse files
committed
Replace deprecated format structures and functions in test cases.
The object format variant structures (mps_fmt_A_s, mps_fmt_B_s, mps_fmt_auto_header_s) and the functions taking them as arguments (mps_fmt_create_A, mps_fmt_create_B, mps_fmt_create_auto_header) were deprecated in release 1.112.0. Using the recommended interface mps_fmt_create_k in test cases improves the coverage of that interfaces, makes it easy to remove the deprecated interfaces if needed, and prepares the test cases for the addition of more format methods if needed. Additionally, remove copy methods and associated code for counting the number of copies, as copy methods are not called and so this code is unreachable or ineffective.
1 parent 73cc748 commit 54afc12

215 files changed

Lines changed: 445 additions & 1522 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code/amsss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
213213
mps_message_type_enable(arena, mps_message_type_gc_start());
214214
mps_message_type_enable(arena, mps_message_type_gc());
215215
die(mps_thread_reg(&thread, arena), "thread_reg");
216-
die(mps_fmt_create_A(&format, arena, dylan_fmt_A()), "fmt_create");
216+
die(dylan_fmt(&format, arena), "fmt_create");
217217
die(mps_chain_create(&chain, arena, 1, testChain), "chain_create");
218218

219219
for (i = 0; i < 8; i++) {

code/awlut.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,8 @@ static void setup(struct guff_s *guff)
305305

306306
die(mps_root_create_thread(&stack, arena, thr, guff),
307307
"Root Create\n");
308-
die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
309-
"Format Create\n");
310-
die(mps_fmt_create_A(&dylanweakfmt, arena, dylan_fmt_A_weak()),
311-
"Format Create (weak)\n");
308+
die(dylan_fmt(&dylanfmt, arena), "Format Create");
309+
die(dylan_fmt_weak(&dylanweakfmt, arena), "Format Create (weak)");
312310
MPS_ARGS_BEGIN(args) {
313311
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, dylanfmt);
314312
die(mps_pool_create_k(&leafpool, arena, mps_class_lo(), args),

code/awlutth.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,8 @@ static void setup(struct guff_s *guff)
254254

255255
die(mps_root_create_thread(&stack, arena, thr, guff),
256256
"Root Create\n");
257-
die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
258-
"Format Create\n");
259-
die(mps_fmt_create_A(&dylanweakfmt, arena, dylan_fmt_A_weak()),
260-
"Format Create (weak)\n");
257+
die(dylan_fmt(&dylanfmt, arena), "Format Create");
258+
die(dylan_fmt_weak(&dylanweakfmt, arena), "Format Create (weak)");
261259
die(mps_pool_create(&leafpool, arena, mps_class_lo(), dylanfmt),
262260
"Leaf Pool Create\n");
263261
die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt,

code/comm.gmk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ MV2 = poolmv2.c
162162
MVFF = poolmvff.c
163163
TESTLIB = testlib.c
164164
TESTTHR = testthrix.c
165-
FMTDY = fmtdy.c fmtno.c
166-
FMTDYTST = fmtdy.c fmtno.c fmtdytst.c
167-
FMTHETST = fmthe.c fmtdy.c fmtno.c fmtdytst.c
165+
FMTDY = fmtdy.c
166+
FMTDYTST = fmtdy.c fmtdytst.c
167+
FMTHETST = fmthe.c fmtdy.c fmtdytst.c
168168
FMTSCM = fmtscheme.c
169169
PLINTH = mpsliban.c mpsioan.c
170170
MPMCOMMON = \

code/commpre.nmk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ LO = [poollo]
181181
MVFF = [poolmvff]
182182
POOLN = [pooln]
183183
SNC = [poolsnc]
184-
FMTDY = [fmtdy] [fmtno]
185-
FMTTEST = [fmthe] [fmtdy] [fmtno] [fmtdytst]
184+
FMTDY = [fmtdy]
185+
FMTTEST = [fmthe] [fmtdy] [fmtdytst]
186186
FMTSCHEME = [fmtscheme]
187187
TESTLIB = [testlib] [getoptl]
188188
TESTTHR = [testthrw3]

code/finalcv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void test(mps_arena_t arena, mps_pool_class_t pool_class)
116116

117117
printf("---- finalcv: pool class %s ----\n", ClassName(pool_class));
118118

119-
die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
119+
die(dylan_fmt(&fmt, arena), "fmt_create");
120120
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
121121
MPS_ARGS_BEGIN(args) {
122122
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);

code/finaltest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static void test_pool(int mode, mps_arena_t arena, mps_chain_t chain,
239239
mps_pool_t pool;
240240
mps_root_t mps_root;
241241

242-
die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
242+
die(dylan_fmt(&fmt, arena), "fmt_create");
243243
MPS_ARGS_BEGIN(args) {
244244
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
245245
if (mode == ModePOLL) {

code/fmtdy.c

Lines changed: 24 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353

5454
#include "fmtdy.h"
55-
#include "fmtno.h"
5655
#include "mps.h"
5756
#include <assert.h>
5857
#include <string.h>
@@ -516,8 +515,7 @@ mps_res_t dylan_scan1(mps_ss_t mps_ss, mps_addr_t *object_io)
516515
return MPS_RES_OK;
517516
}
518517

519-
static mps_res_t dylan_scan(mps_ss_t mps_ss,
520-
mps_addr_t base, mps_addr_t limit)
518+
mps_res_t dylan_scan(mps_ss_t mps_ss, mps_addr_t base, mps_addr_t limit)
521519
{
522520
mps_res_t res;
523521
mps_addr_t prev = base;
@@ -534,21 +532,6 @@ static mps_res_t dylan_scan(mps_ss_t mps_ss,
534532
return MPS_RES_OK;
535533
}
536534

537-
/* dylan_class -- return pointer indicating class of object
538-
*
539-
* Return wrapper pointer, except for broken hearts or padding
540-
*/
541-
542-
static mps_addr_t dylan_class(mps_addr_t obj)
543-
{
544-
mps_word_t first_word = ((mps_word_t *)obj)[0];
545-
546-
if((first_word & 3) != 0) /* broken heart or padding */
547-
return NULL;
548-
else
549-
return (mps_addr_t)first_word;
550-
}
551-
552535
mps_res_t dylan_scan1_weak(mps_ss_t mps_ss, mps_addr_t *object_io)
553536
{
554537
mps_addr_t *assoc;
@@ -695,20 +678,7 @@ mps_addr_t dylan_skip(mps_addr_t object)
695678
return (mps_addr_t)p;
696679
}
697680

698-
static void dylan_copy(mps_addr_t old, mps_addr_t new)
699-
{
700-
char *base = (char *)old;
701-
char *limit = (char *)dylan_skip(old);
702-
size_t length;
703-
assert(base < limit);
704-
length = (size_t)(limit - base);
705-
assert(dylan_wrapper_check(*(mps_word_t **)old));
706-
/* .improve.memcpy: Can do better here as we know that new and old
707-
will be aligned (to MPS_PF_ALIGN) */
708-
(void)memcpy(new, old, length);
709-
}
710-
711-
static mps_addr_t dylan_isfwd(mps_addr_t object)
681+
mps_addr_t dylan_isfwd(mps_addr_t object)
712682
{
713683
mps_word_t h, tag;
714684

@@ -720,7 +690,7 @@ static mps_addr_t dylan_isfwd(mps_addr_t object)
720690
return NULL;
721691
}
722692

723-
static void dylan_fwd(mps_addr_t old, mps_addr_t new)
693+
void dylan_fwd(mps_addr_t old, mps_addr_t new)
724694
{
725695
mps_word_t *p;
726696
mps_addr_t limit;
@@ -761,101 +731,39 @@ mps_bool_t dylan_ispad(mps_addr_t addr)
761731
}
762732

763733

764-
/* The dylan format structures */
765-
766-
static struct mps_fmt_A_s dylan_fmt_A_s =
767-
{
768-
ALIGN,
769-
dylan_scan,
770-
dylan_skip,
771-
dylan_copy,
772-
dylan_fwd,
773-
dylan_isfwd,
774-
dylan_pad
775-
};
776-
777-
static struct mps_fmt_B_s dylan_fmt_B_s =
778-
{
779-
ALIGN,
780-
dylan_scan,
781-
dylan_skip,
782-
dylan_copy,
783-
dylan_fwd,
784-
dylan_isfwd,
785-
dylan_pad,
786-
dylan_class
787-
};
788-
789-
/* Functions returning the dylan format structures */
790-
791-
mps_fmt_A_s *dylan_fmt_A(void)
792-
{
793-
return &dylan_fmt_A_s;
794-
}
795-
796-
mps_fmt_B_s *dylan_fmt_B(void)
797-
{
798-
return &dylan_fmt_B_s;
799-
}
800-
801-
/* Format variety-independent version that picks the right format
802-
* variety and creates it. */
734+
/* Create Dylan object format. */
803735

804736
mps_res_t dylan_fmt(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
805737
{
806-
return mps_fmt_create_B(mps_fmt_o, arena, dylan_fmt_B());
807-
}
808-
809-
/* The weak format structures */
810-
811-
static struct mps_fmt_A_s dylan_fmt_A_weak_s =
812-
{
813-
ALIGN,
814-
dylan_scan_weak,
815-
dylan_skip,
816-
no_copy,
817-
no_fwd,
818-
no_isfwd,
819-
no_pad
820-
};
821-
822-
static struct mps_fmt_B_s dylan_fmt_B_weak_s =
823-
{
824-
ALIGN,
825-
dylan_scan_weak,
826-
dylan_skip,
827-
no_copy,
828-
no_fwd,
829-
no_isfwd,
830-
no_pad,
831-
dylan_class
832-
};
833-
834-
/* Functions returning the weak format structures */
835-
836-
mps_fmt_A_s *dylan_fmt_A_weak(void)
837-
{
838-
return &dylan_fmt_A_weak_s;
839-
}
840-
841-
842-
mps_fmt_B_s *dylan_fmt_B_weak(void)
843-
{
844-
return &dylan_fmt_B_weak_s;
738+
mps_res_t res;
739+
MPS_ARGS_BEGIN(args) {
740+
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
741+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_scan);
742+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_skip);
743+
MPS_ARGS_ADD(args, MPS_KEY_FMT_FWD, dylan_fwd);
744+
MPS_ARGS_ADD(args, MPS_KEY_FMT_ISFWD, dylan_isfwd);
745+
MPS_ARGS_ADD(args, MPS_KEY_FMT_PAD, dylan_pad);
746+
res = mps_fmt_create_k(mps_fmt_o, arena, args);
747+
} MPS_ARGS_END(args);
748+
return res;
845749
}
846750

847751

848-
/* Format variety-independent version that picks the right format
849-
* variety and creates it. */
752+
/* Create Dylan weak object format. */
850753

851754
mps_res_t dylan_fmt_weak(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
852755
{
853-
return mps_fmt_create_B(mps_fmt_o, arena, dylan_fmt_B_weak());
756+
mps_res_t res;
757+
MPS_ARGS_BEGIN(args) {
758+
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
759+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_scan_weak);
760+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_skip);
761+
res = mps_fmt_create_k(mps_fmt_o, arena, args);
762+
} MPS_ARGS_END(args);
763+
return res;
854764
}
855765

856766

857-
858-
859767
/* C. COPYRIGHT AND LICENSE
860768
*
861769
* Copyright (C) 2001-2020 Ravenbrook Limited <https://www.ravenbrook.com/>.

code/fmtdy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ extern mps_res_t dylan_scan1_weak(mps_ss_t, mps_addr_t *);
1616

1717
/* Format */
1818
extern mps_fmt_A_s *dylan_fmt_A(void);
19-
extern mps_fmt_A_s *dylan_fmt_A_weak(void);
20-
extern mps_fmt_B_s *dylan_fmt_B(void);
21-
extern mps_fmt_B_s *dylan_fmt_B_weak(void);
2219
extern mps_res_t dylan_fmt(mps_fmt_t *, mps_arena_t);
2320
extern mps_res_t dylan_fmt_weak(mps_fmt_t *, mps_arena_t);
2421

2522
extern mps_addr_t dylan_weak_dependent(mps_addr_t);
2623

24+
extern mps_res_t dylan_scan(mps_ss_t mps_ss, mps_addr_t base, mps_addr_t limit);
2725
extern mps_addr_t dylan_skip(mps_addr_t);
26+
extern void dylan_fwd(mps_addr_t old, mps_addr_t new);
27+
extern mps_addr_t dylan_isfwd(mps_addr_t object);
2828
extern void dylan_pad(mps_addr_t, size_t);
2929
extern mps_bool_t dylan_ispad(mps_addr_t);
3030
extern int dylan_wrapper_check(mps_word_t *);

code/fmthe.c

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
#include "fmtdy.h"
12-
#include "fmtno.h"
1312
#include "fmthe.h"
1413
#include "mps.h"
1514

@@ -24,8 +23,6 @@
2423

2524
#define AddHeader(p) ((mps_addr_t)((char*)(p) + headerSIZE))
2625

27-
static mps_fmt_A_s *dylan_format;
28-
2926
static mps_res_t dylan_header_scan(mps_ss_t mps_ss,
3027
mps_addr_t base, mps_addr_t limit)
3128
{
@@ -103,7 +100,7 @@ static mps_addr_t dylan_header_skip(mps_addr_t object)
103100
break;
104101
}
105102

106-
p = dylan_format->skip(object);
103+
p = dylan_skip(object);
107104
p = AddHeader(p);
108105
return p;
109106
}
@@ -119,7 +116,7 @@ static mps_addr_t dylan_header_isfwd(mps_addr_t object)
119116

120117
assert(header == realHeader);
121118

122-
return dylan_format->isfwd(object);
119+
return dylan_isfwd(object);
123120
}
124121

125122

@@ -129,50 +126,41 @@ static void dylan_header_pad(mps_addr_t addr, size_t fullSize)
129126
}
130127

131128

132-
/* HeaderFormat -- format descriptor for this format */
133-
134-
static struct mps_fmt_auto_header_s HeaderFormat =
135-
{
136-
ALIGN,
137-
dylan_header_scan,
138-
dylan_header_skip,
139-
NULL, /* later overwritten by dylan format forward method */
140-
dylan_header_isfwd,
141-
dylan_header_pad,
142-
(size_t)headerSIZE
143-
};
144-
145-
146-
/* HeaderWeakFormat -- format descriptor for this format */
147-
148-
static struct mps_fmt_auto_header_s HeaderWeakFormat =
149-
{
150-
ALIGN,
151-
dylan_header_scan_weak,
152-
dylan_header_skip,
153-
no_fwd,
154-
no_isfwd,
155-
no_pad,
156-
(size_t)headerSIZE
157-
};
158-
159-
160129
/* EnsureHeaderFormat -- create a format object for this format */
161130

162131
mps_res_t EnsureHeaderFormat(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
163132
{
164-
dylan_format = dylan_fmt_A();
165-
HeaderFormat.fwd = dylan_format->fwd;
166-
return mps_fmt_create_auto_header(mps_fmt_o, arena, &HeaderFormat);
133+
mps_res_t res;
134+
MPS_ARGS_BEGIN(args) {
135+
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
136+
MPS_ARGS_ADD(args, MPS_KEY_FMT_HEADER_SIZE, headerSIZE);
137+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_header_scan);
138+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_header_skip);
139+
MPS_ARGS_ADD(args, MPS_KEY_FMT_FWD, dylan_fwd);
140+
MPS_ARGS_ADD(args, MPS_KEY_FMT_ISFWD, dylan_header_isfwd);
141+
MPS_ARGS_ADD(args, MPS_KEY_FMT_PAD, dylan_header_pad);
142+
res = mps_fmt_create_k(mps_fmt_o, arena, args);
143+
} MPS_ARGS_END(args);
144+
return res;
167145
}
168146

169147

170148
/* EnsureHeaderWeakFormat -- create a format object for the weak format */
171149

172150
mps_res_t EnsureHeaderWeakFormat(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
173151
{
174-
dylan_format = dylan_fmt_A();
175-
return mps_fmt_create_auto_header(mps_fmt_o, arena, &HeaderWeakFormat);
152+
mps_res_t res;
153+
MPS_ARGS_BEGIN(args) {
154+
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
155+
MPS_ARGS_ADD(args, MPS_KEY_FMT_HEADER_SIZE, headerSIZE);
156+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_header_scan_weak);
157+
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_header_skip);
158+
MPS_ARGS_ADD(args, MPS_KEY_FMT_FWD, dylan_fwd);
159+
MPS_ARGS_ADD(args, MPS_KEY_FMT_ISFWD, dylan_header_isfwd);
160+
MPS_ARGS_ADD(args, MPS_KEY_FMT_PAD, dylan_header_pad);
161+
res = mps_fmt_create_k(mps_fmt_o, arena, args);
162+
} MPS_ARGS_END(args);
163+
return res;
176164
}
177165

178166

0 commit comments

Comments
 (0)