26 "JiT management. This is an abstract class"
28 jitted_block_delete_cb =
None
29 jitted_block_max_size = 10000
32 """Initialise a JitCore instance.
33 @ir_arch: ir instance for current architecture
60 "Set options relative to the backend"
62 self.options.update(kwargs)
65 """The disassembly engine will stop on address in args if they
66 are not at the block beginning"""
67 self.split_dis.update(set(args))
70 """The disassembly engine will no longer stop on address in args"""
71 self.split_dis.difference_update(set(args))
73 def load(self, arch, attrib):
74 "Initialise the Jitter according to arch and attrib"
76 raise NotImplementedError(
"Abstract class")
79 "Update cur_bloc to set min/max address"
82 cur_bloc.ad_min = cur_bloc.lines[0].offset
83 cur_bloc.ad_max = cur_bloc.lines[-1].offset + cur_bloc.lines[-1].l
86 "Update vm to include bloc addresses in its memory range"
90 vm.reset_code_bloc_pool()
92 vm.add_code_bloc(a, b + 1)
95 """JiT a group of irblocs.
96 @label: the label of the irblocs
97 @irblocs: a gorup of irblocs
100 raise NotImplementedError(
"Abstract class")
103 """Add a bloc to JiT and JiT it.
107 irblocs = self.ir_arch.add_bloc(b, gen_pc_updt =
True)
112 "Disassemble a new bloc and JiT it"
115 if isinstance(addr, asmbloc.asm_label):
118 l = self.ir_arch.symbol_pool.getby_offset_create(addr)
119 cur_bloc = asmbloc.asm_bloc(l)
123 asmbloc.dis_bloc(self.ir_arch.arch, self.
bs, cur_bloc, addr,
124 set(), self.ir_arch.symbol_pool, [],
125 follow_call=
False, dontdis_retcall=
False,
126 lines_wd=self.
options[
"jit_maxline"],
128 attrib=self.ir_arch.attrib,
141 if not cur_bloc.lines:
142 raise ValueError(
"Cannot JIT a block without any assembly line")
156 def jit_call(self, label, cpu, _vmmngr, breakpoints):
157 """Call the function label with cpu and vmmngr states
158 @label: function's label
159 @cpu: JitCpu instance
160 @breakpoints: Dict instance of used breakpoints
162 return self.exec_wrapper(label, cpu, self.lbl2jitbloc.data, breakpoints)
165 """Run the bloc starting at lbl.
166 @cpu: JitCpu instance
172 lbl = cpu.get_gpreg()[self.ir_arch.pc.name]
179 ret = self.
jit_call(lbl, cpu, vm, breakpoints)
184 """Return an interval instance standing for blocs addresses
185 @blocs: list of asm_bloc instances
191 mem_range +=
interval([(b.ad_min, b.ad_max - 1)])
196 """Rebuild the VM blocs address memory range
201 vm.reset_code_bloc_pool()
205 vm.add_code_bloc(a, b + 1)
208 """Find and remove jitted bloc in range [ad1, ad2].
209 Return the list of bloc removed.
215 modified_blocs = set()
216 for b
in self.lbl2bloc.values():
219 if b.ad_max <= ad1
or b.ad_min >= ad2:
224 modified_blocs.add(b)
233 for b
in modified_blocs:
235 for irbloc
in b.irblocs:
241 except AttributeError:
249 return modified_blocs
252 """Remove code jitted in range self.addr_mod
255 for addr_start, addr_stop
in self.
addr_mod:
int jitted_block_max_size
def add_bloc_to_mem_interval
def __updt_jitcode_mem_range
def remove_disassembly_splits
def add_disassembly_splits