]> gitweb.factorcode.org Git - factor.git/blob - vm/jit.hpp
Put brackets around ipv6 addresses in `inet6 present`
[factor.git] / vm / jit.hpp
1 namespace factor {
2
3 struct jit {
4   data_root<object> owner;
5   growable_byte_array code;
6   growable_byte_array relocation;
7   growable_array parameters;
8   growable_array literals;
9   bool computing_offset_p;
10   fixnum position;
11   cell offset;
12   factor_vm* parent;
13
14   jit(cell owner, factor_vm* parent);
15   ~jit();
16
17   void compute_position(cell offset);
18
19   void emit_relocation(cell relocation_template);
20   void emit(cell code_template);
21
22   // Allocates memory
23   void parameter(cell parameter) { parameters.add(parameter); }
24   // Allocates memory
25   void emit_with_parameter(cell code_template_, cell parameter_);
26
27   // Allocates memory
28   void literal(cell literal) { literals.add(literal); }
29   // Allocates memory
30   void emit_with_literal(cell code_template_, cell literal_);
31
32   // Allocates memory
33   void push(cell literal) {
34     emit_with_literal(parent->special_objects[JIT_PUSH_LITERAL], literal);
35   }
36
37   bool emit_subprimitive(cell word_, bool tail_call_p, bool stack_frame_p);
38
39   fixnum get_position() {
40     if (computing_offset_p) {
41       // If this is still on, emit() didn't clear it,
42       // so the offset was out of bounds
43       return -1;
44     }
45     return position;
46   }
47
48   void set_position(fixnum position_) {
49     if (computing_offset_p)
50       position = position_;
51   }
52
53   code_block* to_code_block(code_block_type type, cell frame_size);
54
55 private:
56   jit(const jit&);
57   void operator=(const jit&);
58 };
59
60 }