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