Clean up profiler.c using new JIT API
parent
e45790a802
commit
d5b51df7e7
|
@ -1,32 +1,16 @@
|
||||||
#include "master.h"
|
#include "master.h"
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
F_CODE_BLOCK *compile_profiling_stub(F_WORD *word)
|
static F_CODE_BLOCK *compile_profiling_stub(CELL word)
|
||||||
{
|
{
|
||||||
CELL literals = allot_array_2(tag_object(word),tag_object(word));
|
REGISTER_ROOT(word);
|
||||||
REGISTER_ROOT(literals);
|
F_JIT jit;
|
||||||
|
jit_init(&jit,WORD_TYPE,word);
|
||||||
F_ARRAY *quadruple = untag_object(userenv[JIT_PROFILING]);
|
jit_emit_with(&jit,userenv[JIT_PROFILING],word);
|
||||||
|
F_CODE_BLOCK *block = jit_make_code_block(&jit);
|
||||||
CELL code = array_nth(quadruple,0);
|
jit_dispose(&jit);
|
||||||
REGISTER_ROOT(code);
|
UNREGISTER_ROOT(word);
|
||||||
|
return block;
|
||||||
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(F_REL));
|
|
||||||
memcpy(relocation + 1,&rel,sizeof(F_REL));
|
|
||||||
|
|
||||||
UNREGISTER_ROOT(code);
|
|
||||||
UNREGISTER_ROOT(literals);
|
|
||||||
|
|
||||||
return add_code_block(
|
|
||||||
WORD_TYPE,
|
|
||||||
untag_object(code),
|
|
||||||
NULL, /* no labels */
|
|
||||||
tag_object(relocation),
|
|
||||||
literals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
|
@ -37,7 +21,7 @@ void update_word_xt(F_WORD *word)
|
||||||
if(!word->profiling)
|
if(!word->profiling)
|
||||||
{
|
{
|
||||||
REGISTER_UNTAGGED(word);
|
REGISTER_UNTAGGED(word);
|
||||||
F_CODE_BLOCK *profiling = compile_profiling_stub(word);
|
F_CODE_BLOCK *profiling = compile_profiling_stub(tag_object(word));
|
||||||
UNREGISTER_UNTAGGED(word);
|
UNREGISTER_UNTAGGED(word);
|
||||||
word->profiling = profiling;
|
word->profiling = profiling;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
bool profiling_p;
|
bool profiling_p;
|
||||||
void primitive_profiling(void);
|
void primitive_profiling(void);
|
||||||
F_CODE_BLOCK *compile_profiling_stub(F_WORD *word);
|
|
||||||
void update_word_xt(F_WORD *word);
|
void update_word_xt(F_WORD *word);
|
||||||
|
|
Loading…
Reference in New Issue