}
struct inline_cache_jit : public jit {
- inline_cache_jit(cell generic_word, factor_vm* vm)
- : jit(code_block_pic, generic_word, vm) {}
+ inline_cache_jit(cell generic_word, factor_vm* vm) : jit(generic_word, vm) {}
void emit_check_and_jump(cell ic_type, cell i, cell klass, cell method);
void emit_inline_cache(fixnum index, cell generic_word_, cell methods_,
cell ic_type = determine_inline_cache_type(cache_entries.untagged());
parent->update_pic_count(ic_type);
- // Generate machine code to determine the object's class.
+ // Put the tag of the object, or class of the tuple in a register.
emit_with_literal(parent->special_objects[PIC_LOAD],
tag_fixnum(-index * sizeof(cell)));
- // Put the tag of the object, or class of the tuple in a register.
+ // Generate machine code to determine the object's class.
emit(parent->special_objects[ic_type]);
// Generate machine code to check, in turn, if the class is one of the cached
true); // stack_frame_p
}
-// Allocates memory
-code_block* factor_vm::compile_inline_cache(fixnum index, cell generic_word_,
- cell methods_, cell cache_entries_,
- bool tail_call_p) {
- data_root<word> generic_word(generic_word_, this);
- data_root<array> methods(methods_, this);
- data_root<array> cache_entries(cache_entries_, this);
-
- inline_cache_jit jit(generic_word.value(), this);
- jit.emit_inline_cache(index, generic_word.value(), methods.value(),
- cache_entries.value(), tail_call_p);
- code_block* code = jit.to_code_block(JIT_FRAME_SIZE);
- initialize_code_block(code);
- return code;
-}
-
// Allocates memory
cell factor_vm::add_inline_cache_entry(cell cache_entries_, cell klass_,
cell method_) {
update_pic_transitions(pic_size);
- cell xt;
-
- if (pic_size >= max_pic_size)
- xt = generic_word->entry_point;
- else {
+ cell xt = generic_word->entry_point;
+ if (pic_size < max_pic_size) {
cell klass = object_class(object.value());
cell method = lookup_method(object.value(), methods.value());
data_root<array> new_cache_entries(
add_inline_cache_entry(cache_entries.value(), klass, method), this);
- xt = compile_inline_cache(index, generic_word.value(), methods.value(),
- new_cache_entries.value(), tail_call_site)
- ->entry_point();
+ inline_cache_jit jit(generic_word.value(), this);
+ jit.emit_inline_cache(index, generic_word.value(), methods.value(),
+ new_cache_entries.value(), tail_call_site);
+ code_block* code = jit.to_code_block(CODE_BLOCK_PIC, JIT_FRAME_SIZE);
+ initialize_code_block(code);
+ xt = code->entry_point();
}
// Install the new stub.