Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/amsss.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int main(int argc, char *argv[])
mps_message_type_enable(arena, mps_message_type_gc_start());
mps_message_type_enable(arena, mps_message_type_gc());
die(mps_thread_reg(&thread, arena), "thread_reg");
die(mps_fmt_create_A(&format, arena, dylan_fmt_A()), "fmt_create");
die(dylan_fmt(&format, arena), "fmt_create");
die(mps_chain_create(&chain, arena, 1, testChain), "chain_create");

for (i = 0; i < 8; i++) {
Expand Down
6 changes: 2 additions & 4 deletions code/awlut.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,8 @@ static void setup(struct guff_s *guff)

die(mps_root_create_thread(&stack, arena, thr, guff),
"Root Create\n");
die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
"Format Create\n");
die(mps_fmt_create_A(&dylanweakfmt, arena, dylan_fmt_A_weak()),
"Format Create (weak)\n");
die(dylan_fmt(&dylanfmt, arena), "Format Create");
die(dylan_fmt_weak(&dylanweakfmt, arena), "Format Create (weak)");
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, dylanfmt);
die(mps_pool_create_k(&leafpool, arena, mps_class_lo(), args),
Expand Down
6 changes: 2 additions & 4 deletions code/awlutth.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,8 @@ static void setup(struct guff_s *guff)

die(mps_root_create_thread(&stack, arena, thr, guff),
"Root Create\n");
die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
"Format Create\n");
die(mps_fmt_create_A(&dylanweakfmt, arena, dylan_fmt_A_weak()),
"Format Create (weak)\n");
die(dylan_fmt(&dylanfmt, arena), "Format Create");
die(dylan_fmt_weak(&dylanweakfmt, arena), "Format Create (weak)");
die(mps_pool_create(&leafpool, arena, mps_class_lo(), dylanfmt),
"Leaf Pool Create\n");
die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt,
Expand Down
6 changes: 3 additions & 3 deletions code/comm.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ MV2 = poolmv2.c
MVFF = poolmvff.c
TESTLIB = testlib.c
TESTTHR = testthrix.c
FMTDY = fmtdy.c fmtno.c
FMTDYTST = fmtdy.c fmtno.c fmtdytst.c
FMTHETST = fmthe.c fmtdy.c fmtno.c fmtdytst.c
FMTDY = fmtdy.c
FMTDYTST = fmtdy.c fmtdytst.c
FMTHETST = fmthe.c fmtdy.c fmtdytst.c
FMTSCM = fmtscheme.c
PLINTH = mpsliban.c mpsioan.c
MPMCOMMON = \
Expand Down
4 changes: 2 additions & 2 deletions code/commpre.nmk
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ LO = [poollo]
MVFF = [poolmvff]
POOLN = [pooln]
SNC = [poolsnc]
FMTDY = [fmtdy] [fmtno]
FMTTEST = [fmthe] [fmtdy] [fmtno] [fmtdytst]
FMTDY = [fmtdy]
FMTTEST = [fmthe] [fmtdy] [fmtdytst]
FMTSCHEME = [fmtscheme]
TESTLIB = [testlib] [getoptl]
TESTTHR = [testthrw3]
Expand Down
2 changes: 1 addition & 1 deletion code/finalcv.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void test(mps_arena_t arena, mps_pool_class_t pool_class)

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

die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
die(dylan_fmt(&fmt, arena), "fmt_create");
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);
Expand Down
2 changes: 1 addition & 1 deletion code/finaltest.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void test_pool(int mode, mps_arena_t arena, mps_chain_t chain,
mps_pool_t pool;
mps_root_t mps_root;

die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
die(dylan_fmt(&fmt, arena), "fmt_create");
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_FORMAT, fmt);
if (mode == ModePOLL) {
Expand Down
140 changes: 24 additions & 116 deletions code/fmtdy.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@


#include "fmtdy.h"
#include "fmtno.h"
#include "mps.h"
#include <assert.h>
#include <string.h>
Expand Down Expand Up @@ -516,8 +515,7 @@ mps_res_t dylan_scan1(mps_ss_t mps_ss, mps_addr_t *object_io)
return MPS_RES_OK;
}

static mps_res_t dylan_scan(mps_ss_t mps_ss,
mps_addr_t base, mps_addr_t limit)
mps_res_t dylan_scan(mps_ss_t mps_ss, mps_addr_t base, mps_addr_t limit)
{
mps_res_t res;
mps_addr_t prev = base;
Expand All @@ -534,21 +532,6 @@ static mps_res_t dylan_scan(mps_ss_t mps_ss,
return MPS_RES_OK;
}

/* dylan_class -- return pointer indicating class of object
*
* Return wrapper pointer, except for broken hearts or padding
*/

static mps_addr_t dylan_class(mps_addr_t obj)
{
mps_word_t first_word = ((mps_word_t *)obj)[0];

if((first_word & 3) != 0) /* broken heart or padding */
return NULL;
else
return (mps_addr_t)first_word;
}

mps_res_t dylan_scan1_weak(mps_ss_t mps_ss, mps_addr_t *object_io)
{
mps_addr_t *assoc;
Expand Down Expand Up @@ -695,20 +678,7 @@ mps_addr_t dylan_skip(mps_addr_t object)
return (mps_addr_t)p;
}

static void dylan_copy(mps_addr_t old, mps_addr_t new)
{
char *base = (char *)old;
char *limit = (char *)dylan_skip(old);
size_t length;
assert(base < limit);
length = (size_t)(limit - base);
assert(dylan_wrapper_check(*(mps_word_t **)old));
/* .improve.memcpy: Can do better here as we know that new and old
will be aligned (to MPS_PF_ALIGN) */
(void)memcpy(new, old, length);
}

static mps_addr_t dylan_isfwd(mps_addr_t object)
mps_addr_t dylan_isfwd(mps_addr_t object)
{
mps_word_t h, tag;

Expand All @@ -720,7 +690,7 @@ static mps_addr_t dylan_isfwd(mps_addr_t object)
return NULL;
}

static void dylan_fwd(mps_addr_t old, mps_addr_t new)
void dylan_fwd(mps_addr_t old, mps_addr_t new)
{
mps_word_t *p;
mps_addr_t limit;
Expand Down Expand Up @@ -761,101 +731,39 @@ mps_bool_t dylan_ispad(mps_addr_t addr)
}


/* The dylan format structures */

static struct mps_fmt_A_s dylan_fmt_A_s =
{
ALIGN,
dylan_scan,
dylan_skip,
dylan_copy,
dylan_fwd,
dylan_isfwd,
dylan_pad
};

static struct mps_fmt_B_s dylan_fmt_B_s =
{
ALIGN,
dylan_scan,
dylan_skip,
dylan_copy,
dylan_fwd,
dylan_isfwd,
dylan_pad,
dylan_class
};

/* Functions returning the dylan format structures */

mps_fmt_A_s *dylan_fmt_A(void)
{
return &dylan_fmt_A_s;
}

mps_fmt_B_s *dylan_fmt_B(void)
{
return &dylan_fmt_B_s;
}

/* Format variety-independent version that picks the right format
* variety and creates it. */
/* Create Dylan object format. */

mps_res_t dylan_fmt(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
{
return mps_fmt_create_B(mps_fmt_o, arena, dylan_fmt_B());
}

/* The weak format structures */

static struct mps_fmt_A_s dylan_fmt_A_weak_s =
{
ALIGN,
dylan_scan_weak,
dylan_skip,
no_copy,
no_fwd,
no_isfwd,
no_pad
};

static struct mps_fmt_B_s dylan_fmt_B_weak_s =
{
ALIGN,
dylan_scan_weak,
dylan_skip,
no_copy,
no_fwd,
no_isfwd,
no_pad,
dylan_class
};

/* Functions returning the weak format structures */

mps_fmt_A_s *dylan_fmt_A_weak(void)
{
return &dylan_fmt_A_weak_s;
}


mps_fmt_B_s *dylan_fmt_B_weak(void)
{
return &dylan_fmt_B_weak_s;
mps_res_t res;
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_scan);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_skip);
MPS_ARGS_ADD(args, MPS_KEY_FMT_FWD, dylan_fwd);
MPS_ARGS_ADD(args, MPS_KEY_FMT_ISFWD, dylan_isfwd);
MPS_ARGS_ADD(args, MPS_KEY_FMT_PAD, dylan_pad);
res = mps_fmt_create_k(mps_fmt_o, arena, args);
} MPS_ARGS_END(args);
return res;
}


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

mps_res_t dylan_fmt_weak(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
{
return mps_fmt_create_B(mps_fmt_o, arena, dylan_fmt_B_weak());
mps_res_t res;
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_scan_weak);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_skip);
res = mps_fmt_create_k(mps_fmt_o, arena, args);
} MPS_ARGS_END(args);
return res;
}




/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2020 Ravenbrook Limited <https://www.ravenbrook.com/>.
Expand Down
6 changes: 3 additions & 3 deletions code/fmtdy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ extern mps_res_t dylan_scan1_weak(mps_ss_t, mps_addr_t *);

/* Format */
extern mps_fmt_A_s *dylan_fmt_A(void);
extern mps_fmt_A_s *dylan_fmt_A_weak(void);
extern mps_fmt_B_s *dylan_fmt_B(void);
extern mps_fmt_B_s *dylan_fmt_B_weak(void);
extern mps_res_t dylan_fmt(mps_fmt_t *, mps_arena_t);
extern mps_res_t dylan_fmt_weak(mps_fmt_t *, mps_arena_t);

extern mps_addr_t dylan_weak_dependent(mps_addr_t);

extern mps_res_t dylan_scan(mps_ss_t mps_ss, mps_addr_t base, mps_addr_t limit);
extern mps_addr_t dylan_skip(mps_addr_t);
extern void dylan_fwd(mps_addr_t old, mps_addr_t new);
extern mps_addr_t dylan_isfwd(mps_addr_t object);
extern void dylan_pad(mps_addr_t, size_t);
extern mps_bool_t dylan_ispad(mps_addr_t);
extern int dylan_wrapper_check(mps_word_t *);
Expand Down
64 changes: 26 additions & 38 deletions code/fmthe.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

#include "fmtdy.h"
#include "fmtno.h"
#include "fmthe.h"
#include "mps.h"

Expand All @@ -24,8 +23,6 @@

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

static mps_fmt_A_s *dylan_format;

static mps_res_t dylan_header_scan(mps_ss_t mps_ss,
mps_addr_t base, mps_addr_t limit)
{
Expand Down Expand Up @@ -103,7 +100,7 @@ static mps_addr_t dylan_header_skip(mps_addr_t object)
break;
}

p = dylan_format->skip(object);
p = dylan_skip(object);
p = AddHeader(p);
return p;
}
Expand All @@ -119,7 +116,7 @@ static mps_addr_t dylan_header_isfwd(mps_addr_t object)

assert(header == realHeader);

return dylan_format->isfwd(object);
return dylan_isfwd(object);
}


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


/* HeaderFormat -- format descriptor for this format */

static struct mps_fmt_auto_header_s HeaderFormat =
{
ALIGN,
dylan_header_scan,
dylan_header_skip,
NULL, /* later overwritten by dylan format forward method */
dylan_header_isfwd,
dylan_header_pad,
(size_t)headerSIZE
};


/* HeaderWeakFormat -- format descriptor for this format */

static struct mps_fmt_auto_header_s HeaderWeakFormat =
{
ALIGN,
dylan_header_scan_weak,
dylan_header_skip,
no_fwd,
no_isfwd,
no_pad,
(size_t)headerSIZE
};


/* EnsureHeaderFormat -- create a format object for this format */

mps_res_t EnsureHeaderFormat(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
{
dylan_format = dylan_fmt_A();
HeaderFormat.fwd = dylan_format->fwd;
return mps_fmt_create_auto_header(mps_fmt_o, arena, &HeaderFormat);
mps_res_t res;
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
MPS_ARGS_ADD(args, MPS_KEY_FMT_HEADER_SIZE, headerSIZE);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_header_scan);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_header_skip);
MPS_ARGS_ADD(args, MPS_KEY_FMT_FWD, dylan_fwd);
MPS_ARGS_ADD(args, MPS_KEY_FMT_ISFWD, dylan_header_isfwd);
MPS_ARGS_ADD(args, MPS_KEY_FMT_PAD, dylan_header_pad);
res = mps_fmt_create_k(mps_fmt_o, arena, args);
} MPS_ARGS_END(args);
return res;
}


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

mps_res_t EnsureHeaderWeakFormat(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
{
dylan_format = dylan_fmt_A();
return mps_fmt_create_auto_header(mps_fmt_o, arena, &HeaderWeakFormat);
mps_res_t res;
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_ALIGN, ALIGN);
MPS_ARGS_ADD(args, MPS_KEY_FMT_HEADER_SIZE, headerSIZE);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SCAN, dylan_header_scan_weak);
MPS_ARGS_ADD(args, MPS_KEY_FMT_SKIP, dylan_header_skip);
MPS_ARGS_ADD(args, MPS_KEY_FMT_FWD, dylan_fwd);
MPS_ARGS_ADD(args, MPS_KEY_FMT_ISFWD, dylan_header_isfwd);
MPS_ARGS_ADD(args, MPS_KEY_FMT_PAD, dylan_header_pad);
res = mps_fmt_create_k(mps_fmt_o, arena, args);
} MPS_ARGS_END(args);
return res;
}


Expand Down
Loading