@Override public void execute(ExecutionNode node, MethodState mState) { MethodState parent = mState.getParent(); int targetRegister = parent.getRegistersAssigned()[0]; // Peek rather than read. This pseudo-instruction shouldn't count as an actual usage for the optimizer. HeapItem arrayItem = mState.peekRegister(targetRegister); if (!arrayItem.isUnknown()) { Object array = arrayItem.getValue(); Class<?> expectedClass = array.getClass().getComponentType(); for (int i = 0; i < arrayElements.size(); i++) { Number number = arrayElements.get(i); Object value = getProperValue(number, expectedClass); Array.set(array, i, value); } // Poke rather than assign for the optimizer. mState.pokeRegister(targetRegister, arrayItem); } MethodLocation returnLocation = mState.getParent().getPseudoInstructionReturnInstruction(); node.setChildLocations(returnLocation); }
@Override public void execute(ExecutionNode node, MethodState mState) { // Pseudo points to instruction *after* switch op. MethodLocation returnLocation = mState.getPseudoInstructionReturnInstruction(); int branchFromAddress = returnLocation.getCodeAddress() - SWITCH_OP_CODE_UNITS; HeapItem targetItem = mState.readResultRegister(); if (targetItem.isUnknown()) { List<MethodLocation> childList = getTargets(branchFromAddress, targetKeyToOffset); childList.add(returnLocation); MethodLocation[] children = childList.toArray(new MethodLocation[childList.size()]); node.setChildLocations(children); return; } int targetKey = Utils.getIntegerValue(targetItem.getValue()); if (targetKeyToOffset.containsKey(targetKey)) { int targetOffset = branchFromAddress + targetKeyToOffset.get(targetKey); MethodLocation child = addressToLocation.get(targetOffset); node.setChildLocations(child); return; } // Branch target is unspecified. Continue to next op. node.setChildLocations(returnLocation); }