]> gitweb.factorcode.org Git - factor.git/blob - vm/jit.hpp
VM: Remove unnecessary explicit keywords
[factor.git] / vm / jit.hpp
1 namespace factor {
2
3 struct jit {
4   code_block_type type;
5   data_root<object> owner;
6   growable_byte_array code;
7   growable_byte_array relocation;
8   growable_array parameters;
9   growable_array literals;
10   bool computing_offset_p;
11   fixnum position;
12   cell offset;
13   factor_vm* parent;
14
15   jit(code_block_type type, cell owner, factor_vm* parent);
16   ~jit();
17
18   void compute_position(cell offset);
19
20   void emit_relocation(cell relocation_template);
21   void emit(cell code_template);
22
23   void parameter(cell parameter) { parameters.add(parameter); }
24   void emit_with_parameter(cell code_template_, cell parameter_);
25
26   void literal(cell literal) { literals.add(literal); }
27   void emit_with_literal(cell code_template_, cell literal_);
28
29   void push(cell literal) {
30     emit_with_literal(parent->special_objects[JIT_PUSH_IMMEDIATE], literal);
31   }
32
33   void word_jump(cell word_) {
34     data_root<word> word(word_, parent);
35 #ifndef FACTOR_AMD64
36     literal(tag_fixnum(xt_tail_pic_offset));
37 #endif
38     literal(word.value());
39     emit(parent->special_objects[JIT_WORD_JUMP]);
40   }
41
42   void word_call(cell word) {
43     emit_with_literal(parent->special_objects[JIT_WORD_CALL], word);
44   }
45
46   bool emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p);
47
48   fixnum get_position() {
49     if (computing_offset_p) {
50       /* If this is still on, emit() didn't clear it,
51          so the offset was out of bounds */
52       return -1;
53     } else
54       return position;
55   }
56
57   void set_position(fixnum position_) {
58     if (computing_offset_p)
59       position = position_;
60   }
61
62   code_block* to_code_block(cell frame_size);
63
64 private:
65   jit(const jit&);
66   void operator=(const jit&);
67 };
68
69 }