diff options
| author | Nick Barnes | 2001-11-23 13:52:41 +0000 |
|---|---|---|
| committer | Nick Barnes | 2001-11-23 13:52:41 +0000 |
| commit | 04fe0477bb432d4f76f6f4d4b244286e19105978 (patch) | |
| tree | 698ae38e1814e8e572facccd10d75b95f885ff69 /mps/code | |
| parent | f198709e44763c6e61a474b8fb66df1f299810fc (diff) | |
| parent | ab1124eed09590d8904c98e8624d67f6b5433898 (diff) | |
| download | emacs-04fe0477bb432d4f76f6f4d4b244286e19105978.tar.gz emacs-04fe0477bb432d4f76f6f4d4b244286e19105978.zip | |
Format_auto_header test needs to cope with larger header sizes (not just 8!)
Copied from Perforce
Change: 24156
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/amcsshe.c | 2 | ||||
| -rw-r--r-- | mps/code/fmthe.c | 62 | ||||
| -rw-r--r-- | mps/code/fmthe.h | 11 |
3 files changed, 33 insertions, 42 deletions
diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c index 778ce7c1710..5c5c5edff0f 100644 --- a/mps/code/amcsshe.c +++ b/mps/code/amcsshe.c | |||
| @@ -153,7 +153,7 @@ static mps_addr_t make(void) | |||
| 153 | res = init(userP, size, exactRoots, exactRootsCOUNT); | 153 | res = init(userP, size, exactRoots, exactRootsCOUNT); |
| 154 | if (res) | 154 | if (res) |
| 155 | die(res, "dylan_init"); | 155 | die(res, "dylan_init"); |
| 156 | ((int*)p)[0] = realTYPE; | 156 | ((int*)p)[0] = realHeader; |
| 157 | ((int*)p)[1] = 0xED0ED; | 157 | ((int*)p)[1] = 0xED0ED; |
| 158 | } while(!mps_commit(ap, p, size + headerSIZE)); | 158 | } while(!mps_commit(ap, p, size + headerSIZE)); |
| 159 | 159 | ||
diff --git a/mps/code/fmthe.c b/mps/code/fmthe.c index 148c37d5c10..3455b30cc80 100644 --- a/mps/code/fmthe.c +++ b/mps/code/fmthe.c | |||
| @@ -288,21 +288,23 @@ static mps_res_t dylan_scan1(mps_ss_t mps_ss, mps_addr_t *object_io) | |||
| 288 | unsigned es; /* variable part element size (log2 of bits) */ | 288 | unsigned es; /* variable part element size (log2 of bits) */ |
| 289 | mps_word_t vt; /* total vector length */ | 289 | mps_word_t vt; /* total vector length */ |
| 290 | mps_res_t res; | 290 | mps_res_t res; |
| 291 | int* header; | 291 | int header; |
| 292 | 292 | ||
| 293 | assert(object_io != NULL); | 293 | assert(object_io != NULL); |
| 294 | 294 | ||
| 295 | p = (mps_addr_t *)*object_io; | 295 | p = (mps_addr_t *)*object_io; |
| 296 | assert(p != NULL); | 296 | assert(p != NULL); |
| 297 | 297 | ||
| 298 | header = (int*)((char*)p - headerSIZE); | 298 | header = *(int*)((char*)p - headerSIZE); |
| 299 | if (*header != realTYPE) { | 299 | switch(headerType(header)) { |
| 300 | switch (*header) { | 300 | case realTYPE: |
| 301 | case pad1TYPE: *object_io = (mps_addr_t)((char*)p + 4); break; | 301 | break; |
| 302 | case pad2TYPE: *object_io = (mps_addr_t)((char*)p + 8); break; | 302 | case padTYPE: |
| 303 | default: notreached(); break; | 303 | *object_io = (mps_addr_t)((char*)p + headerPadSize(header)); |
| 304 | } | 304 | return MPS_RES_OK; |
| 305 | return MPS_RES_OK; | 305 | default: |
| 306 | notreached(); | ||
| 307 | break; | ||
| 306 | } | 308 | } |
| 307 | 309 | ||
| 308 | h = (mps_word_t)p[0]; /* load the header word */ | 310 | h = (mps_word_t)p[0]; /* load the header word */ |
| @@ -458,18 +460,20 @@ static mps_addr_t dylan_skip(mps_addr_t object) | |||
| 458 | mps_word_t vt; /* total vector length */ | 460 | mps_word_t vt; /* total vector length */ |
| 459 | unsigned vb; /* vector bias */ | 461 | unsigned vb; /* vector bias */ |
| 460 | unsigned es; /* variable part element size (log2 of bits) */ | 462 | unsigned es; /* variable part element size (log2 of bits) */ |
| 461 | int* header; | 463 | int header; |
| 462 | 464 | ||
| 463 | p = (mps_addr_t *)object; | 465 | p = (mps_addr_t *)object; |
| 464 | assert(p != NULL); | 466 | assert(p != NULL); |
| 465 | 467 | ||
| 466 | header = (int*)((char*)object - headerSIZE); | 468 | header = *(int*)((char*)object - headerSIZE); |
| 467 | if (*header != realTYPE) { | 469 | switch(headerType(header)) { |
| 468 | switch (*header) { | 470 | case realTYPE: |
| 469 | case pad1TYPE: return (mps_addr_t)((char*)object + 4); break; | 471 | break; |
| 470 | case pad2TYPE: return (mps_addr_t)((char*)object + 8); break; | 472 | case padTYPE: |
| 471 | default: assert(0 == 1); break; | 473 | return (mps_addr_t)((char*)object + headerPadSize(header)); |
| 472 | } | 474 | default: |
| 475 | notreached(); | ||
| 476 | break; | ||
| 473 | } | 477 | } |
| 474 | 478 | ||
| 475 | h = (mps_word_t)p[0]; /* load the header word */ | 479 | h = (mps_word_t)p[0]; /* load the header word */ |
| @@ -519,12 +523,11 @@ static mps_addr_t dylan_skip(mps_addr_t object) | |||
| 519 | static mps_addr_t dylan_isfwd(mps_addr_t object) | 523 | static mps_addr_t dylan_isfwd(mps_addr_t object) |
| 520 | { | 524 | { |
| 521 | mps_word_t h, tag; | 525 | mps_word_t h, tag; |
| 522 | int *header; | 526 | int header; |
| 523 | 527 | ||
| 524 | header = (int*)((char*)object - headerSIZE); | 528 | header = *(int*)((char*)object - headerSIZE); |
| 525 | if (*header != realTYPE) { | 529 | if (headerType(header) != realTYPE) |
| 526 | return NULL; | 530 | return NULL; |
| 527 | } | ||
| 528 | 531 | ||
| 529 | h = *(mps_word_t *)object; | 532 | h = *(mps_word_t *)object; |
| 530 | tag = h & 3; | 533 | tag = h & 3; |
| @@ -556,22 +559,7 @@ static void dylan_fwd(mps_addr_t old, mps_addr_t new) | |||
| 556 | 559 | ||
| 557 | static void dylan_pad(mps_addr_t addr, size_t fullSize) | 560 | static void dylan_pad(mps_addr_t addr, size_t fullSize) |
| 558 | { | 561 | { |
| 559 | mps_word_t *p; | 562 | *(int*)addr = padHeader(fullSize); |
| 560 | size_t size; | ||
| 561 | |||
| 562 | p = (mps_word_t *)AddHeader(addr); | ||
| 563 | size = fullSize - headerSIZE; | ||
| 564 | if (fullSize <= headerSIZE) { | ||
| 565 | *(int*)addr = (fullSize == 4) ? pad1TYPE : pad2TYPE; | ||
| 566 | } else { | ||
| 567 | *(int*)addr = realTYPE; | ||
| 568 | if(size == sizeof(mps_word_t)) /* single-word object? */ | ||
| 569 | p[0] = 1; | ||
| 570 | else { | ||
| 571 | p[0] = 2; | ||
| 572 | p[1] = (mps_word_t)AddHeader((char *)addr + fullSize); | ||
| 573 | } | ||
| 574 | } | ||
| 575 | } | 563 | } |
| 576 | 564 | ||
| 577 | 565 | ||
diff --git a/mps/code/fmthe.h b/mps/code/fmthe.h index 58bbe03f7b8..174ab24c5a8 100644 --- a/mps/code/fmthe.h +++ b/mps/code/fmthe.h | |||
| @@ -29,10 +29,13 @@ extern mps_res_t HeaderFormatCheck(mps_addr_t addr); | |||
| 29 | #define ALIGN sizeof(mps_word_t) /* alignment for Dylan format */ | 29 | #define ALIGN sizeof(mps_word_t) /* alignment for Dylan format */ |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | #define headerSIZE (8) | 32 | #define headerSIZE (32) |
| 33 | #define headerTypeBits 1 | ||
| 33 | #define realTYPE 0 | 34 | #define realTYPE 0 |
| 34 | #define pad1TYPE 1 | 35 | #define realHeader realTYPE |
| 35 | #define pad2TYPE 2 | 36 | #define padTYPE 1 |
| 36 | 37 | #define headerType(header) ((header) & ((1 << headerTypeBits) - 1)) | |
| 38 | #define headerPadSize(header) ((header) >> headerTypeBits) | ||
| 39 | #define padHeader(size) ((size << headerTypeBits) | padTYPE) | ||
| 37 | 40 | ||
| 38 | #endif /* fmthe_h */ | 41 | #endif /* fmthe_h */ |