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