MCPcopy Create free account
hub / github.com/dynjs/dynjs / prepareIPCs

Method prepareIPCs

src/main/java/org/dynjs/ir/Scope.java:254–282  ·  view source on GitHub ↗
(List<BasicBlock> list, CFG cfg)

Source from the content-addressed store, hash-verified

252 }
253
254 private Instruction[] prepareIPCs(List<BasicBlock> list, CFG cfg) {
255 // Set up IPCs
256 List<Instruction> newInstrs = new ArrayList<Instruction>();
257 HashMap<Label, Integer> labelIPCMap = new HashMap<Label, Integer>();
258 int ipc = 0;
259 for (BasicBlock basicBlock: list) {
260 Label label = basicBlock.getLabel();
261 labelIPCMap.put(label, ipc);
262 // This assumes if multiple equal/same labels exist which are scattered around the scope
263 // must be the same Java instance or only this one will get a targetPC set.
264 label.setTargetIPC(ipc);
265 List<Instruction> bbInstrs = basicBlock.getInstructions();
266 int bbInstrsLength = bbInstrs.size();
267 for (int i = 0; i < bbInstrsLength; i++) {
268 Instruction instr = bbInstrs.get(i);
269
270 newInstrs.add(instr);
271 instr.setIPC(ipc);
272 ipc++;
273 }
274 }
275
276 cfg.getExitBB().getLabel().setTargetIPC(ipc + 1); // Exit BasicBlock IPC
277
278
279 setupRescueMap(list, cfg); // Set up the rescue map
280
281 return newInstrs.toArray(new Instruction[newInstrs.size()]);
282 }
283
284 public void setupRescueMap(List<BasicBlock> list, CFG cfg) {
285 rescueMap = new HashMap<Integer, Integer>();

Callers 1

prepareForInterpretMethod · 0.95

Calls 11

setTargetIPCMethod · 0.95
setIPCMethod · 0.95
setupRescueMapMethod · 0.95
getExitBBMethod · 0.80
toArrayMethod · 0.80
putMethod · 0.65
getMethod · 0.65
getLabelMethod · 0.45
getInstructionsMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected