@Before public void setUp() { dexBuilder = VMTester.getDexBuilder(); }
/** * Create a new {@link VirtualMachine} for testing. Since this is heavily used, it tries to avoid the main cost of creating a {@link * VirtualMachine} by reusing the same {@link ClassManager} by default. If {@code reloadClasses} is true, a new {@link ClassManager} is created * and all classes are loaded again. This is necessary if method implementations are modified. For example, Simplify optimization strategy tests * modify method implementation and in order for each test to have the true method implementations, many of those tests set {@code reloadClasses} * to {@code true}. * * @param reloadClasses if true, rebuild {@link ClassManager}, otherwise reuse existing * @return {@link VirtualMachine} for tests */ public static VirtualMachine spawnVM(boolean reloadClasses) { if ((null == classManager) || reloadClasses) { try { classManager = new ClassManagerFactory().build(TEST_CLASS_PATH, getDexBuilder()); } catch (IOException e) { throw new RuntimeException("Exception building class manager for " + TEST_CLASS_PATH, e); } } return new VirtualMachineFactory().build(classManager); }
public static ExecutionGraphManipulator getGraphManipulator(VirtualMachine vm, String className, String methodDescriptor, VMState initial) { ExecutionGraph graph = VMTester.execute(vm, className, methodDescriptor, initial); String methodSignature = className + "->" + methodDescriptor; VirtualMethod method = vm.getClassManager().getMethod(methodSignature); DexBuilder dexBuilder = VMTester.getDexBuilder(); return new ExecutionGraphManipulator(graph, method, vm, dexBuilder); }