MPS issue job003316

TitleUser guide doesn't explain how to choose object format alignment
Assigned userRichard Brooksby
DescriptionThe user guide "Garbage collecting a language with the MPS" [1] explains how to create an object format, and one of the components of the object format is its alignment. The Scheme example [2] just says:


The user guide needs to explain how to choose this alignment, and why "sizeof(mps_word_t)" is the right choice.
AnalysisGDR writes: I struggled to explain this choice of alignment.

I had thought that it might be possible to deduce the alignment in C by writing code like:

#define ALIGNMENT offsetof(struct {char c; obj_s obj}, obj)

But I believe this is not reliable: compilers do various kinds of structure-packing that defeat this. (For example, the -fpack-struct option to GCC.) So I don't think that it would be a good idea to use this approach.

So "sizeof(mps_word_t)" is probably fine, but you need to help me write the explanation.

GDR 2012-10-18: I made my best attempt to explain it, so I've closed this job.
How foundinspection
Evidence[1] <>
[2] <>
Observed in1.110.0
Created byGareth Rees
Created on2012-10-17 17:15:16
Last modified byGareth Rees
Last modified on2012-10-18 13:12:06
History2012-10-17 GDR Created.


Change Effect Date User Description
179935 closed 2012-10-18 13:10:41 Gareth Rees Move user-facing material from RHSK's wiki to the manual:
New glossary entry "foreign code"
Explain how to find the alignment for your object format.
Document symbols: mps_class_mv, mps_arena_start_collect, mps_arena_step, mps_chain_create, mps_chain_destroy, mps_chain_t, mps_gen_param_s.