Merge branch 'master' of git://factorcode.org/git/factor
commit
32ef3aa40a
20
vm/alien.cpp
20
vm/alien.cpp
|
@ -10,10 +10,12 @@ char *pinned_alien_offset(cell obj)
|
|||
switch(tagged<object>(obj).type())
|
||||
{
|
||||
case ALIEN_TYPE:
|
||||
alien *ptr = untag<alien>(obj);
|
||||
if(ptr->expired != F)
|
||||
general_error(ERROR_EXPIRED,obj,F,NULL);
|
||||
return pinned_alien_offset(ptr->alien) + ptr->displacement;
|
||||
{
|
||||
alien *ptr = untag<alien>(obj);
|
||||
if(ptr->expired != F)
|
||||
general_error(ERROR_EXPIRED,obj,F,NULL);
|
||||
return pinned_alien_offset(ptr->alien) + ptr->displacement;
|
||||
}
|
||||
case F_TYPE:
|
||||
return NULL;
|
||||
default:
|
||||
|
@ -165,10 +167,12 @@ VM_C_API char *alien_offset(cell obj)
|
|||
case BYTE_ARRAY_TYPE:
|
||||
return untag<byte_array>(obj)->data<char>();
|
||||
case ALIEN_TYPE:
|
||||
alien *ptr = untag<alien>(obj);
|
||||
if(ptr->expired != F)
|
||||
general_error(ERROR_EXPIRED,obj,F,NULL);
|
||||
return alien_offset(ptr->alien) + ptr->displacement;
|
||||
{
|
||||
alien *ptr = untag<alien>(obj);
|
||||
if(ptr->expired != F)
|
||||
general_error(ERROR_EXPIRED,obj,F,NULL);
|
||||
return alien_offset(ptr->alien) + ptr->displacement;
|
||||
}
|
||||
case F_TYPE:
|
||||
return NULL;
|
||||
default:
|
||||
|
|
|
@ -279,21 +279,27 @@ void mark_object_code_block(object *object)
|
|||
switch(object->h.hi_tag())
|
||||
{
|
||||
case WORD_TYPE:
|
||||
word *w = (word *)object;
|
||||
if(w->code)
|
||||
mark_code_block(w->code);
|
||||
if(w->profiling)
|
||||
mark_code_block(w->profiling);
|
||||
break;
|
||||
{
|
||||
word *w = (word *)object;
|
||||
if(w->code)
|
||||
mark_code_block(w->code);
|
||||
if(w->profiling)
|
||||
mark_code_block(w->profiling);
|
||||
break;
|
||||
}
|
||||
case QUOTATION_TYPE:
|
||||
quotation *q = (quotation *)object;
|
||||
if(q->compiledp != F)
|
||||
mark_code_block(q->code);
|
||||
break;
|
||||
{
|
||||
quotation *q = (quotation *)object;
|
||||
if(q->compiledp != F)
|
||||
mark_code_block(q->code);
|
||||
break;
|
||||
}
|
||||
case CALLSTACK_TYPE:
|
||||
callstack *stack = (callstack *)object;
|
||||
iterate_callstack_object(stack,mark_stack_frame_step);
|
||||
break;
|
||||
{
|
||||
callstack *stack = (callstack *)object;
|
||||
iterate_callstack_object(stack,mark_stack_frame_step);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,28 +324,32 @@ void *get_rel_symbol(array *literals, cell index)
|
|||
switch(tagged<object>(symbol).type())
|
||||
{
|
||||
case BYTE_ARRAY_TYPE:
|
||||
symbol_char *name = alien_offset(symbol);
|
||||
void *sym = ffi_dlsym(d,name);
|
||||
|
||||
if(sym)
|
||||
return sym;
|
||||
else
|
||||
{
|
||||
printf("%s\n",name);
|
||||
return (void *)undefined_symbol;
|
||||
}
|
||||
case ARRAY_TYPE:
|
||||
cell i;
|
||||
array *names = untag<array>(symbol);
|
||||
for(i = 0; i < array_capacity(names); i++)
|
||||
{
|
||||
symbol_char *name = alien_offset(array_nth(names,i));
|
||||
symbol_char *name = alien_offset(symbol);
|
||||
void *sym = ffi_dlsym(d,name);
|
||||
|
||||
if(sym)
|
||||
return sym;
|
||||
else
|
||||
{
|
||||
printf("%s\n",name);
|
||||
return (void *)undefined_symbol;
|
||||
}
|
||||
}
|
||||
case ARRAY_TYPE:
|
||||
{
|
||||
cell i;
|
||||
array *names = untag<array>(symbol);
|
||||
for(i = 0; i < array_capacity(names); i++)
|
||||
{
|
||||
symbol_char *name = alien_offset(array_nth(names,i));
|
||||
void *sym = ffi_dlsym(d,name);
|
||||
|
||||
if(sym)
|
||||
return sym;
|
||||
}
|
||||
return (void *)undefined_symbol;
|
||||
}
|
||||
return (void *)undefined_symbol;
|
||||
default:
|
||||
critical_error("Bad symbol specifier",symbol);
|
||||
return (void *)undefined_symbol;
|
||||
|
|
|
@ -80,20 +80,22 @@ PRIMITIVE(modify_code_heap)
|
|||
jit_compile_word(word.value(),data.value(),false);
|
||||
break;
|
||||
case ARRAY_TYPE:
|
||||
array *compiled_data = data.as<array>().untagged();
|
||||
cell literals = array_nth(compiled_data,0);
|
||||
cell relocation = array_nth(compiled_data,1);
|
||||
cell labels = array_nth(compiled_data,2);
|
||||
cell code = array_nth(compiled_data,3);
|
||||
{
|
||||
array *compiled_data = data.as<array>().untagged();
|
||||
cell literals = array_nth(compiled_data,0);
|
||||
cell relocation = array_nth(compiled_data,1);
|
||||
cell labels = array_nth(compiled_data,2);
|
||||
cell code = array_nth(compiled_data,3);
|
||||
|
||||
code_block *compiled = add_code_block(
|
||||
WORD_TYPE,
|
||||
code,
|
||||
labels,
|
||||
relocation,
|
||||
literals);
|
||||
code_block *compiled = add_code_block(
|
||||
WORD_TYPE,
|
||||
code,
|
||||
labels,
|
||||
relocation,
|
||||
literals);
|
||||
|
||||
word->code = compiled;
|
||||
word->code = compiled;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
critical_error("Expected a quotation or an array",data.value());
|
||||
|
@ -141,25 +143,28 @@ void forward_object_xts(void)
|
|||
switch(tagged<object>(obj).type())
|
||||
{
|
||||
case WORD_TYPE:
|
||||
word *w = untag<word>(obj);
|
||||
{
|
||||
word *w = untag<word>(obj);
|
||||
|
||||
if(w->code)
|
||||
w->code = forward_xt(w->code);
|
||||
if(w->profiling)
|
||||
w->profiling = forward_xt(w->profiling);
|
||||
|
||||
if(w->code)
|
||||
w->code = forward_xt(w->code);
|
||||
if(w->profiling)
|
||||
w->profiling = forward_xt(w->profiling);
|
||||
}
|
||||
break;
|
||||
case QUOTATION_TYPE:
|
||||
quotation *quot = untag<quotation>(obj);
|
||||
{
|
||||
quotation *quot = untag<quotation>(obj);
|
||||
|
||||
if(quot->compiledp != F)
|
||||
quot->code = forward_xt(quot->code);
|
||||
|
||||
if(quot->compiledp != F)
|
||||
quot->code = forward_xt(quot->code);
|
||||
}
|
||||
break;
|
||||
case CALLSTACK_TYPE:
|
||||
callstack *stack = untag<callstack>(obj);
|
||||
iterate_callstack_object(stack,forward_frame_xt);
|
||||
|
||||
{
|
||||
callstack *stack = untag<callstack>(obj);
|
||||
iterate_callstack_object(stack,forward_frame_xt);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -185,10 +190,12 @@ void fixup_object_xts(void)
|
|||
update_word_xt(obj);
|
||||
break;
|
||||
case QUOTATION_TYPE:
|
||||
quotation *quot = untag<quotation>(obj);
|
||||
if(quot->compiledp != F)
|
||||
set_quot_xt(quot,quot->code);
|
||||
break;
|
||||
{
|
||||
quotation *quot = untag<quotation>(obj);
|
||||
if(quot->compiledp != F)
|
||||
set_quot_xt(quot,quot->code);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ void clear_gc_stats(void)
|
|||
{
|
||||
int i;
|
||||
for(i = 0; i < MAX_GEN_COUNT; i++)
|
||||
memset(&stats[i],0,sizeof(stats));
|
||||
memset(&stats[i],0,sizeof(gc_stats));
|
||||
|
||||
cards_scanned = 0;
|
||||
decks_scanned = 0;
|
||||
|
|
|
@ -293,7 +293,7 @@ void dump_code_heap(void)
|
|||
|
||||
while(scan)
|
||||
{
|
||||
char *status;
|
||||
const char *status;
|
||||
switch(scan->status)
|
||||
{
|
||||
case B_FREE:
|
||||
|
|
|
@ -16,14 +16,14 @@ void out_of_memory(void)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
void fatal_error(char* msg, cell tagged)
|
||||
void fatal_error(const char* msg, cell tagged)
|
||||
{
|
||||
print_string("fatal_error: "); print_string(msg);
|
||||
print_string(": "); print_cell_hex(tagged); nl();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void critical_error(char* msg, cell tagged)
|
||||
void critical_error(const char* msg, cell tagged)
|
||||
{
|
||||
print_string("You have triggered a bug in Factor. Please report.\n");
|
||||
print_string("critical_error: "); print_string(msg);
|
||||
|
|
|
@ -23,8 +23,8 @@ enum vm_error_type
|
|||
};
|
||||
|
||||
void out_of_memory(void);
|
||||
void fatal_error(char* msg, cell tagged);
|
||||
void critical_error(char* msg, cell tagged);
|
||||
void fatal_error(const char* msg, cell tagged);
|
||||
void critical_error(const char* msg, cell tagged);
|
||||
|
||||
PRIMITIVE(die);
|
||||
|
||||
|
|
|
@ -49,9 +49,11 @@ static cell determine_inline_cache_type(array *cache_entries)
|
|||
switch(TAG(klass))
|
||||
{
|
||||
case FIXNUM_TYPE:
|
||||
fixnum type = untag_fixnum(klass);
|
||||
if(type >= HEADER_TYPE)
|
||||
seen_hi_tag = true;
|
||||
{
|
||||
fixnum type = untag_fixnum(klass);
|
||||
if(type >= HEADER_TYPE)
|
||||
seen_hi_tag = true;
|
||||
}
|
||||
break;
|
||||
case ARRAY_TYPE:
|
||||
seen_tuple = true;
|
||||
|
|
|
@ -31,7 +31,7 @@ const char *default_image_path(void)
|
|||
const char *iter = path;
|
||||
while(*iter) { len++; iter++; }
|
||||
|
||||
char *new_path = safe_malloc(PATH_MAX + SUFFIX_LEN + 1);
|
||||
char *new_path = (char *)safe_malloc(PATH_MAX + SUFFIX_LEN + 1);
|
||||
memcpy(new_path,path,len + 1);
|
||||
memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1);
|
||||
return new_path;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace factor
|
|||
/* Snarfed from SBCL linux-so.c. You must free() this yourself. */
|
||||
const char *vm_executable_path(void)
|
||||
{
|
||||
char *path = safe_malloc(PATH_MAX + 1);
|
||||
char *path = (char *)safe_malloc(PATH_MAX + 1);
|
||||
|
||||
int size = readlink("/proc/self/exe", path, PATH_MAX);
|
||||
if (size < 0)
|
||||
|
|
Loading…
Reference in New Issue