VM: moving a few methods arounds
word_call, word_jump and emit_mega_cache_lookup are only used in quotations.cpp so they should be defined there too.locals-and-roots
parent
8f2738cd82
commit
1fddf79724
|
@ -119,30 +119,4 @@ void factor_vm::primitive_dispatch_stats() {
|
||||||
ctx->push(tag<byte_array>(byte_array_from_value(&dispatch_stats)));
|
ctx->push(tag<byte_array>(byte_array_from_value(&dispatch_stats)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates memory */
|
|
||||||
void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index,
|
|
||||||
cell cache_) {
|
|
||||||
data_root<array> methods(methods_, parent);
|
|
||||||
data_root<array> cache(cache_, parent);
|
|
||||||
|
|
||||||
/* The object must be on the top of the datastack at this point. */
|
|
||||||
|
|
||||||
/* Do a cache lookup. */
|
|
||||||
emit_with_literal(parent->special_objects[MEGA_LOOKUP], cache.value());
|
|
||||||
|
|
||||||
/* If we end up here, the cache missed. */
|
|
||||||
emit(parent->special_objects[JIT_PROLOG]);
|
|
||||||
|
|
||||||
/* Push index, method table and cache on the stack. */
|
|
||||||
push(methods.value());
|
|
||||||
push(tag_fixnum(index));
|
|
||||||
push(cache.value());
|
|
||||||
word_call(parent->special_objects[MEGA_MISS_WORD]);
|
|
||||||
|
|
||||||
/* Now the new method has been stored into the cache, and its on
|
|
||||||
the stack. */
|
|
||||||
emit(parent->special_objects[JIT_EPILOG]);
|
|
||||||
emit(parent->special_objects[JIT_EXECUTE]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
17
vm/jit.hpp
17
vm/jit.hpp
|
@ -35,21 +35,6 @@ struct jit {
|
||||||
emit_with_literal(parent->special_objects[JIT_PUSH_IMMEDIATE], literal);
|
emit_with_literal(parent->special_objects[JIT_PUSH_IMMEDIATE], literal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates memory (literal(), emit())*/
|
|
||||||
void word_jump(cell word_) {
|
|
||||||
data_root<word> word(word_, parent);
|
|
||||||
#ifndef FACTOR_AMD64
|
|
||||||
literal(tag_fixnum(xt_tail_pic_offset));
|
|
||||||
#endif
|
|
||||||
literal(word.value());
|
|
||||||
emit(parent->special_objects[JIT_WORD_JUMP]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocates memory */
|
|
||||||
void word_call(cell word) {
|
|
||||||
emit_with_literal(parent->special_objects[JIT_WORD_CALL], word);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p);
|
bool emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p);
|
||||||
|
|
||||||
fixnum get_position() {
|
fixnum get_position() {
|
||||||
|
@ -57,7 +42,7 @@ struct jit {
|
||||||
/* If this is still on, emit() didn't clear it,
|
/* If this is still on, emit() didn't clear it,
|
||||||
so the offset was out of bounds */
|
so the offset was out of bounds */
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
}
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,32 @@ cell quotation_jit::word_stack_frame_size(cell obj) {
|
||||||
return JIT_FRAME_SIZE;
|
return JIT_FRAME_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocates memory */
|
||||||
|
void quotation_jit::emit_mega_cache_lookup(cell methods_, fixnum index,
|
||||||
|
cell cache_) {
|
||||||
|
data_root<array> methods(methods_, parent);
|
||||||
|
data_root<array> cache(cache_, parent);
|
||||||
|
|
||||||
|
/* The object must be on the top of the datastack at this point. */
|
||||||
|
|
||||||
|
/* Do a cache lookup. */
|
||||||
|
emit_with_literal(parent->special_objects[MEGA_LOOKUP], cache.value());
|
||||||
|
|
||||||
|
/* If we end up here, the cache missed. */
|
||||||
|
emit(parent->special_objects[JIT_PROLOG]);
|
||||||
|
|
||||||
|
/* Push index, method table and cache on the stack. */
|
||||||
|
push(methods.value());
|
||||||
|
push(tag_fixnum(index));
|
||||||
|
push(cache.value());
|
||||||
|
word_call(parent->special_objects[MEGA_MISS_WORD]);
|
||||||
|
|
||||||
|
/* Now the new method has been stored into the cache, and its on
|
||||||
|
the stack. */
|
||||||
|
emit(parent->special_objects[JIT_EPILOG]);
|
||||||
|
emit(parent->special_objects[JIT_EXECUTE]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
code_block* factor_vm::jit_compile_quotation(cell owner_, cell quot_,
|
code_block* factor_vm::jit_compile_quotation(cell owner_, cell quot_,
|
||||||
bool relocating) {
|
bool relocating) {
|
||||||
|
|
|
@ -28,6 +28,21 @@ struct quotation_jit : public jit {
|
||||||
bool word_safepoint_p(cell obj);
|
bool word_safepoint_p(cell obj);
|
||||||
bool no_non_safepoint_words_p();
|
bool no_non_safepoint_words_p();
|
||||||
void iterate_quotation();
|
void iterate_quotation();
|
||||||
|
|
||||||
|
/* Allocates memory */
|
||||||
|
void word_call(cell word) {
|
||||||
|
emit_with_literal(parent->special_objects[JIT_WORD_CALL], word);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocates memory (literal(), emit())*/
|
||||||
|
void word_jump(cell word_) {
|
||||||
|
data_root<word> word(word_, parent);
|
||||||
|
#ifndef FACTOR_AMD64
|
||||||
|
literal(tag_fixnum(xt_tail_pic_offset));
|
||||||
|
#endif
|
||||||
|
literal(word.value());
|
||||||
|
emit(parent->special_objects[JIT_WORD_JUMP]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
VM_C_API cell lazy_jit_compile(cell quot, factor_vm* parent);
|
VM_C_API cell lazy_jit_compile(cell quot, factor_vm* parent);
|
||||||
|
|
Loading…
Reference in New Issue