From 2a7848053fe2591c3f511a03ac7abfcd84dcbbf0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 19 Mar 2009 23:21:32 -0500 Subject: [PATCH] Fix 64-bit build issue; relocation entries are 32-bit on all platforms --- vm/code_block.c | 10 +++++----- vm/code_block.h | 3 ++- vm/profiler.c | 6 +++--- vm/quotations.c | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/vm/code_block.c b/vm/code_block.c index 7cfadbbefb..a9b5277c84 100644 --- a/vm/code_block.c +++ b/vm/code_block.c @@ -13,8 +13,8 @@ void iterate_relocations(F_CODE_BLOCK *compiled, RELOCATION_ITERATOR iter) CELL index = 1; - CELL *rel = (CELL *)(relocation + 1); - CELL *rel_end = (CELL *)((char *)rel + byte_array_capacity(relocation)); + F_REL *rel = (F_REL *)(relocation + 1); + F_REL *rel_end = (F_REL *)((char *)rel + byte_array_capacity(relocation)); while(rel < rel_end) { @@ -107,7 +107,7 @@ void store_address_in_code_block(CELL class, CELL offset, F_FIXNUM absolute_valu } } -void update_literal_references_step(CELL rel, CELL index, F_CODE_BLOCK *compiled) +void update_literal_references_step(F_REL rel, CELL index, F_CODE_BLOCK *compiled) { if(REL_TYPE(rel) == RT_IMMEDIATE) { @@ -158,7 +158,7 @@ CELL object_xt(CELL obj) return (CELL)untag_quotation(obj)->xt; } -void update_word_references_step(CELL rel, CELL index, F_CODE_BLOCK *compiled) +void update_word_references_step(F_REL rel, CELL index, F_CODE_BLOCK *compiled) { if(REL_TYPE(rel) == RT_XT) { @@ -286,7 +286,7 @@ void *get_rel_symbol(F_ARRAY *literals, CELL index) } /* Compute an address to store at a relocation */ -void relocate_code_block_step(CELL rel, CELL index, F_CODE_BLOCK *compiled) +void relocate_code_block_step(F_REL rel, CELL index, F_CODE_BLOCK *compiled) { CELL offset = REL_OFFSET(rel) + (CELL)(compiled + 1); F_ARRAY *literals = untag_object(compiled->literals); diff --git a/vm/code_block.h b/vm/code_block.h index e3668108da..b00e4be8b6 100644 --- a/vm/code_block.h +++ b/vm/code_block.h @@ -44,13 +44,14 @@ typedef enum { #define REL_RELATIVE_ARM_3_MASK 0xffffff /* code relocation table consists of a table of entries for each fixup */ +typedef u32 F_REL; #define REL_TYPE(r) (((r) & 0xf0000000) >> 28) #define REL_CLASS(r) (((r) & 0x0f000000) >> 24) #define REL_OFFSET(r) ((r) & 0x00ffffff) void flush_icache_for(F_CODE_BLOCK *compiled); -typedef void (*RELOCATION_ITERATOR)(CELL rel, CELL index, F_CODE_BLOCK *compiled); +typedef void (*RELOCATION_ITERATOR)(F_REL rel, CELL index, F_CODE_BLOCK *compiled); void iterate_relocations(F_CODE_BLOCK *compiled, RELOCATION_ITERATOR iter); diff --git a/vm/profiler.c b/vm/profiler.c index b87a241f7d..acafecdff5 100755 --- a/vm/profiler.c +++ b/vm/profiler.c @@ -11,12 +11,12 @@ F_CODE_BLOCK *compile_profiling_stub(F_WORD *word) CELL code = array_nth(quadruple,0); REGISTER_ROOT(code); - CELL rel = (to_fixnum(array_nth(quadruple,1)) << 24) + F_REL rel = (to_fixnum(array_nth(quadruple,1)) << 24) | (to_fixnum(array_nth(quadruple,2)) << 28) | (to_fixnum(array_nth(quadruple,3)) * compiled_code_format()); - F_BYTE_ARRAY *relocation = allot_byte_array(sizeof(CELL)); - memcpy(relocation + 1,&rel,sizeof(CELL)); + F_BYTE_ARRAY *relocation = allot_byte_array(sizeof(F_REL)); + memcpy(relocation + 1,&rel,sizeof(F_REL)); UNREGISTER_ROOT(code); UNREGISTER_ROOT(literals); diff --git a/vm/quotations.c b/vm/quotations.c index b65f8de27c..86e47745b7 100755 --- a/vm/quotations.c +++ b/vm/quotations.c @@ -94,7 +94,7 @@ F_ARRAY *code_to_emit(CELL code) return untag_object(array_nth(untag_object(code),0)); } -CELL rel_to_emit(CELL code, CELL code_format, CELL code_length, bool *rel_p) +F_REL rel_to_emit(CELL code, CELL code_format, CELL code_length, bool *rel_p) { F_ARRAY *quadruple = untag_object(code); CELL rel_class = array_nth(quadruple,1); @@ -117,8 +117,8 @@ CELL rel_to_emit(CELL code, CELL code_format, CELL code_length, bool *rel_p) #define EMIT(name) { \ bool rel_p; \ - CELL rel = rel_to_emit(name,code_format,code_count,&rel_p); \ - if(rel_p) GROWABLE_BYTE_ARRAY_APPEND(relocation,&rel,sizeof(CELL)); \ + F_REL rel = rel_to_emit(name,code_format,code_count,&rel_p); \ + if(rel_p) GROWABLE_BYTE_ARRAY_APPEND(relocation,&rel,sizeof(F_REL)); \ GROWABLE_ARRAY_APPEND(code,code_to_emit(name)); \ }